From c8a6b3b8d5f9acd5866cb7a825c93701127de18e Mon Sep 17 00:00:00 2001 From: XiaoMoMi Date: Sat, 23 Aug 2025 18:28:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=80=E4=BA=9B=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukkit/api/event/CraftEngineReloadEvent.java | 8 ++++++++ .../craftengine/bukkit/entity/BukkitEntity.java | 4 ++-- .../craftengine/bukkit/world/BukkitBlockInWorld.java | 7 +++++-- common-files/src/main/resources/config.yml | 2 +- .../craftengine/core/pack/AbstractPackManager.java | 1 + .../momirealms/craftengine/core/plugin/config/Config.java | 1 - .../plugin/context/condition/MatchBlockTypeCondition.java | 6 +----- .../context/condition/MatchEntityTypeCondition.java | 4 +--- .../core/plugin/context/condition/MatchItemCondition.java | 4 +--- .../craftengine/core/plugin/logger/Debugger.java | 2 +- .../net/momirealms/craftengine/core/util/MiscUtils.java | 3 +-- 11 files changed, 22 insertions(+), 20 deletions(-) diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/api/event/CraftEngineReloadEvent.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/api/event/CraftEngineReloadEvent.java index 58d5dea02..949299b48 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/api/event/CraftEngineReloadEvent.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/api/event/CraftEngineReloadEvent.java @@ -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() { diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/entity/BukkitEntity.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/entity/BukkitEntity.java index 2193b86f9..caf677a3a 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/entity/BukkitEntity.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/entity/BukkitEntity.java @@ -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 diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/world/BukkitBlockInWorld.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/world/BukkitBlockInWorld.java index 2be28902a..49ec901f2 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/world/BukkitBlockInWorld.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/world/BukkitBlockInWorld.java @@ -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 diff --git a/common-files/src/main/resources/config.yml b/common-files/src/main/resources/config.yml index 6a8a03355..cc87f1c59 100644 --- a/common-files/src/main/resources/config.yml +++ b/common-files/src/main/resources/config.yml @@ -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 diff --git a/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java b/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java index c8c09139c..99313220e 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java +++ b/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java @@ -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))); } diff --git a/core/src/main/java/net/momirealms/craftengine/core/plugin/config/Config.java b/core/src/main/java/net/momirealms/craftengine/core/plugin/config/Config.java index 18e0bf089..d1268aca1 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/plugin/config/Config.java +++ b/core/src/main/java/net/momirealms/craftengine/core/plugin/config/Config.java @@ -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; } diff --git a/core/src/main/java/net/momirealms/craftengine/core/plugin/context/condition/MatchBlockTypeCondition.java b/core/src/main/java/net/momirealms/craftengine/core/plugin/context/condition/MatchBlockTypeCondition.java index b8d825437..515166d68 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/plugin/context/condition/MatchBlockTypeCondition.java +++ b/core/src/main/java/net/momirealms/craftengine/core/plugin/context/condition/MatchBlockTypeCondition.java @@ -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 implements Condition block = ctx.getOptionalParameter(DirectContextParameters.BLOCK); - if (block.isEmpty()) return false; - Optional 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 implements ConditionFactory { diff --git a/core/src/main/java/net/momirealms/craftengine/core/plugin/context/condition/MatchEntityTypeCondition.java b/core/src/main/java/net/momirealms/craftengine/core/plugin/context/condition/MatchEntityTypeCondition.java index 5f51872ab..2ec39b86e 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/plugin/context/condition/MatchEntityTypeCondition.java +++ b/core/src/main/java/net/momirealms/craftengine/core/plugin/context/condition/MatchEntityTypeCondition.java @@ -28,9 +28,7 @@ @Override public boolean test(CTX ctx) { Optional 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 implements ConditionFactory { diff --git a/core/src/main/java/net/momirealms/craftengine/core/plugin/context/condition/MatchItemCondition.java b/core/src/main/java/net/momirealms/craftengine/core/plugin/context/condition/MatchItemCondition.java index 4ba82709f..f6c7f78a8 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/plugin/context/condition/MatchItemCondition.java +++ b/core/src/main/java/net/momirealms/craftengine/core/plugin/context/condition/MatchItemCondition.java @@ -28,9 +28,7 @@ public class MatchItemCondition implements Condition { @Override public boolean test(CTX ctx) { Optional> 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 implements ConditionFactory { diff --git a/core/src/main/java/net/momirealms/craftengine/core/plugin/logger/Debugger.java b/core/src/main/java/net/momirealms/craftengine/core/plugin/logger/Debugger.java index 4ca696c84..fba7f7fa9 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/plugin/logger/Debugger.java +++ b/core/src/main/java/net/momirealms/craftengine/core/plugin/logger/Debugger.java @@ -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 condition; diff --git a/core/src/main/java/net/momirealms/craftengine/core/util/MiscUtils.java b/core/src/main/java/net/momirealms/craftengine/core/util/MiscUtils.java index 77853bb18..ed0c90d9c 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/util/MiscUtils.java +++ b/core/src/main/java/net/momirealms/craftengine/core/util/MiscUtils.java @@ -151,8 +151,7 @@ public class MiscUtils { } } - public static boolean matchObject(Key key, boolean regexMatch, Set ids) { - String id = key.toString(); + public static boolean matchRegex(String id, Set ids, boolean regexMatch) { if (regexMatch) { for (String regex : ids) { if (id.matches(regex)) {