mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-25 09:59:20 +00:00
修正一些问题
This commit is contained in:
@@ -8,9 +8,17 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class CraftEngineReloadEvent extends Event {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
private final BukkitCraftEngine plugin;
|
||||
private static boolean firstFlag = true;
|
||||
private final boolean isFirstReload;
|
||||
|
||||
public CraftEngineReloadEvent(BukkitCraftEngine plugin) {
|
||||
this.plugin = plugin;
|
||||
this.isFirstReload = firstFlag;
|
||||
firstFlag = false;
|
||||
}
|
||||
|
||||
public boolean isFirstReload() {
|
||||
return this.isFirstReload;
|
||||
}
|
||||
|
||||
public BukkitCraftEngine plugin() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.momirealms.craftengine.bukkit.entity;
|
||||
|
||||
import net.momirealms.craftengine.bukkit.util.KeyUtils;
|
||||
import net.momirealms.craftengine.bukkit.util.EntityUtils;
|
||||
import net.momirealms.craftengine.bukkit.world.BukkitWorld;
|
||||
import net.momirealms.craftengine.core.entity.AbstractEntity;
|
||||
import net.momirealms.craftengine.core.util.Direction;
|
||||
@@ -68,7 +68,7 @@ public class BukkitEntity extends AbstractEntity {
|
||||
|
||||
@Override
|
||||
public Key type() {
|
||||
return KeyUtils.namespacedKey2Key(literalObject().getType().getKey());
|
||||
return EntityUtils.getEntityType(literalObject());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,7 +6,6 @@ import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflect
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MBlocks;
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MFluids;
|
||||
import net.momirealms.craftengine.bukkit.util.BlockStateUtils;
|
||||
import net.momirealms.craftengine.bukkit.util.KeyUtils;
|
||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||
@@ -63,7 +62,11 @@ public class BukkitBlockInWorld implements BlockInWorld {
|
||||
|
||||
@Override
|
||||
public Key type() {
|
||||
return KeyUtils.namespacedKey2Key(this.block.getType().getKey());
|
||||
CustomBlock customBlock = customBlock();
|
||||
if (customBlock == null) {
|
||||
return BlockStateUtils.getBlockOwnerIdFromData(this.block.getBlockData());
|
||||
}
|
||||
return customBlock.id();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -377,7 +377,7 @@ chunk-system:
|
||||
# Settings for injection
|
||||
injection:
|
||||
# Requires a restart to apply.
|
||||
# SECTION: Inject the LevelChunkSection
|
||||
# SECTION: Inject the LevelChunkSection (Use this if you have installed both FastAsyncWorldEdit and Axiom)
|
||||
# PALETTE: Inject the PalettedContainer
|
||||
target: PALETTE
|
||||
# Enables faster injection method
|
||||
|
||||
@@ -125,6 +125,7 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
|
||||
loadInternalList("textures", "", VANILLA_TEXTURES::add);
|
||||
VANILLA_MODELS.add(Key.of("minecraft", "builtin/entity"));
|
||||
VANILLA_MODELS.add(Key.of("minecraft", "item/player_head"));
|
||||
for (int i = 0; i < 256; i++) {
|
||||
VANILLA_TEXTURES.add(Key.of("minecraft", "font/unicode_page_" + String.format("%02x", i)));
|
||||
}
|
||||
|
||||
@@ -420,7 +420,6 @@ public class Config {
|
||||
emoji$contexts$sign = config.getBoolean("emoji.contexts.sign", true);
|
||||
emoji$max_emojis_per_parse = config.getInt("emoji.max-emojis-per-parse", 32);
|
||||
|
||||
|
||||
firstTime = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.momirealms.craftengine.core.plugin.context.condition;
|
||||
|
||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||
import net.momirealms.craftengine.core.plugin.context.Condition;
|
||||
import net.momirealms.craftengine.core.plugin.context.Context;
|
||||
import net.momirealms.craftengine.core.plugin.context.parameter.DirectContextParameters;
|
||||
@@ -29,10 +28,7 @@ public class MatchBlockTypeCondition<CTX extends Context> implements Condition<C
|
||||
@Override
|
||||
public boolean test(CTX ctx) {
|
||||
Optional<BlockInWorld> block = ctx.getOptionalParameter(DirectContextParameters.BLOCK);
|
||||
if (block.isEmpty()) return false;
|
||||
Optional<ImmutableBlockState> customBlock = ctx.getOptionalParameter(DirectContextParameters.CUSTOM_BLOCK_STATE);
|
||||
Key key = customBlock.isPresent() ? customBlock.get().owner().value().id() : block.get().type();
|
||||
return MiscUtils.matchObject(key, this.regexMatch, this.ids);
|
||||
return block.filter(blockInWorld -> MiscUtils.matchRegex(blockInWorld.type().asString(), this.ids, this.regexMatch)).isPresent();
|
||||
}
|
||||
|
||||
public static class FactoryImpl<CTX extends Context> implements ConditionFactory<CTX> {
|
||||
|
||||
@@ -28,9 +28,7 @@
|
||||
@Override
|
||||
public boolean test(CTX ctx) {
|
||||
Optional<Entity> entity = ctx.getOptionalParameter(DirectContextParameters.ENTITY);
|
||||
if (entity.isEmpty()) return false;
|
||||
Key key = entity.get().type();
|
||||
return MiscUtils.matchObject(key, this.regexMatch, this.ids);
|
||||
return entity.filter(value -> MiscUtils.matchRegex(value.type().asString(), this.ids, this.regexMatch)).isPresent();
|
||||
}
|
||||
|
||||
public static class FactoryImpl<CTX extends Context> implements ConditionFactory<CTX> {
|
||||
|
||||
@@ -28,9 +28,7 @@ public class MatchItemCondition<CTX extends Context> implements Condition<CTX> {
|
||||
@Override
|
||||
public boolean test(CTX ctx) {
|
||||
Optional<Item<?>> item = ctx.getOptionalParameter(DirectContextParameters.ITEM_IN_HAND);
|
||||
if (item.isEmpty()) return false;
|
||||
Key key = item.get().id();
|
||||
return MiscUtils.matchObject(key, this.regexMatch, this.ids);
|
||||
return item.filter(value -> MiscUtils.matchRegex(value.id().asString(), this.ids, this.regexMatch)).isPresent();
|
||||
}
|
||||
|
||||
public static class FactoryImpl<CTX extends Context> implements ConditionFactory<CTX> {
|
||||
|
||||
@@ -9,7 +9,7 @@ public enum Debugger {
|
||||
COMMON(Config::debugCommon),
|
||||
PACKET(Config::debugPacket),
|
||||
FURNITURE(Config::debugFurniture),
|
||||
RESOURCE_PACK(Config::debugFurniture),
|
||||
RESOURCE_PACK(Config::debugResourcePack),
|
||||
ITEM(Config::debugItem);
|
||||
|
||||
private final Supplier<Boolean> condition;
|
||||
|
||||
@@ -151,8 +151,7 @@ public class MiscUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean matchObject(Key key, boolean regexMatch, Set<String> ids) {
|
||||
String id = key.toString();
|
||||
public static boolean matchRegex(String id, Set<String> ids, boolean regexMatch) {
|
||||
if (regexMatch) {
|
||||
for (String regex : ids) {
|
||||
if (id.matches(regex)) {
|
||||
|
||||
Reference in New Issue
Block a user