9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-25 09:59:20 +00:00

修正一些问题

This commit is contained in:
XiaoMoMi
2025-08-23 18:28:07 +08:00
parent 05e3dd545f
commit c8a6b3b8d5
11 changed files with 22 additions and 20 deletions

View File

@@ -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() {

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)));
}

View File

@@ -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;
}

View File

@@ -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> {

View File

@@ -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> {

View File

@@ -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> {

View File

@@ -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;

View File

@@ -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)) {