diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/util/InteractUtils.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/util/InteractUtils.java index d16537def..dee6874b7 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/util/InteractUtils.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/util/InteractUtils.java @@ -169,6 +169,7 @@ public final class InteractUtils { registerInteraction(BlockKeys.DAMAGED_ANVIL, (player, item, blockState, result) -> true); registerInteraction(BlockKeys.FURNACE, (player, item, blockState, result) -> true); registerInteraction(BlockKeys.CRAFTING_TABLE, (player, item, blockState, result) -> true); + registerInteraction(BlockKeys.CARTOGRAPHY_TABLE, (player, item, blockState, result) -> true); registerInteraction(BlockKeys.STONECUTTER, (player, item, blockState, result) -> true); registerInteraction(BlockKeys.SMITHING_TABLE, (player, item, blockState, result) -> true); registerInteraction(BlockKeys.LOOM, (player, item, blockState, result) -> true); diff --git a/core/src/main/java/net/momirealms/craftengine/core/block/BlockKeys.java b/core/src/main/java/net/momirealms/craftengine/core/block/BlockKeys.java index 6f5daecc9..c6b9cd591 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/block/BlockKeys.java +++ b/core/src/main/java/net/momirealms/craftengine/core/block/BlockKeys.java @@ -8,6 +8,7 @@ public final class BlockKeys { public static final Key NOTE_BLOCK = Key.of("minecraft:note_block"); public static final Key TRIPWIRE = Key.of("minecraft:tripwire"); public static final Key CRAFTING_TABLE = Key.of("minecraft:crafting_table"); + public static final Key CARTOGRAPHY_TABLE = Key.of("minecraft:cartography_table"); public static final Key STONECUTTER = Key.of("minecraft:stonecutter"); public static final Key BELL = Key.of("minecraft:bell"); public static final Key SMITHING_TABLE = Key.of("minecraft:smithing_table"); @@ -176,8 +177,6 @@ public final class BlockKeys { public static final Key WAXED_OXIDIZED_COPPER_TRAPDOOR = Key.of("minecraft:waxed_oxidized_copper_trapdoor"); public static final Key WAXED_WEATHERED_COPPER_TRAPDOOR = Key.of("minecraft:waxed_weathered_copper_trapdoor"); - - public static final Key OAK_FENCE_GATE = Key.of("minecraft:oak_fence_gate"); public static final Key SPRUCE_FENCE_GATE = Key.of("minecraft:spruce_fence_gate"); public static final Key BIRCH_FENCE_GATE = Key.of("minecraft:birch_fence_gate"); 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 515166d68..7a08fd238 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 @@ -22,7 +22,7 @@ public class MatchBlockTypeCondition implements Condition implements Condition { - private final Set ids; - private final boolean regexMatch; +public class MatchEntityTypeCondition implements Condition { + private final Set ids; + private final boolean regexMatch; - public MatchEntityTypeCondition(Collection ids, boolean regexMatch) { - this.ids = new HashSet<>(ids); - this.regexMatch = regexMatch; - } + public MatchEntityTypeCondition(Collection ids, boolean regexMatch) { + this.ids = new HashSet<>(ids); + this.regexMatch = regexMatch; + } + + @Override + public Key type() { + return CommonConditions.MATCH_ENTITY_TYPE; + } + + @Override + public boolean test(CTX ctx) { + Optional entity = ctx.getOptionalParameter(DirectContextParameters.ENTITY); + return entity.filter(value -> MiscUtils.matchRegex(value.type().asString(), this.ids, this.regexMatch)).isPresent(); + } + + public static class FactoryImpl implements ConditionFactory { @Override - public Key type() { - return CommonConditions.MATCH_ENTITY_TYPE; - } - - @Override - public boolean test(CTX ctx) { - Optional entity = ctx.getOptionalParameter(DirectContextParameters.ENTITY); - return entity.filter(value -> MiscUtils.matchRegex(value.type().asString(), this.ids, this.regexMatch)).isPresent(); - } - - public static class FactoryImpl implements ConditionFactory { - - @Override - public Condition create(Map arguments) { - List ids = MiscUtils.getAsStringList(arguments.get("id")); - if (ids.isEmpty()) { - throw new LocalizedResourceConfigException("warning.config.condition.match_entity_type.missing_id"); - } - boolean regex = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("regex", false), "regex"); - return new MatchEntityTypeCondition<>(ids, regex); + public Condition create(Map arguments) { + List ids = MiscUtils.getAsStringList(arguments.get("id")); + if (ids.isEmpty()) { + throw new LocalizedResourceConfigException("warning.config.condition.match_entity_type.missing_id"); } + boolean regex = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("regex", false), "regex"); + return new MatchEntityTypeCondition<>(ids, regex); } } +}