mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-25 09:59:20 +00:00
更新命名
This commit is contained in:
@@ -83,7 +83,7 @@ public class BukkitExistingBlock implements ExistingBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key type() {
|
||||
public Key id() {
|
||||
Object blockState = BlockStateUtils.getBlockState(this.block);
|
||||
Optional<ImmutableBlockState> optionalCustomBlockState = BlockStateUtils.getOptionalCustomBlockState(blockState);
|
||||
if (optionalCustomBlockState.isPresent()) {
|
||||
|
||||
@@ -10,8 +10,8 @@ public final class CommonConditions {
|
||||
public static final Key ANY_OF = Key.of("craftengine:any_of");
|
||||
public static final Key INVERTED = Key.of("craftengine:inverted");
|
||||
public static final Key MATCH_ITEM = Key.of("craftengine:match_item");
|
||||
public static final Key MATCH_ENTITY_TYPE = Key.of("craftengine:match_entity_type");
|
||||
public static final Key MATCH_BLOCK_TYPE = Key.of("craftengine:match_block_type");
|
||||
public static final Key MATCH_ENTITY = Key.of("craftengine:match_entity");
|
||||
public static final Key MATCH_BLOCK = Key.of("craftengine:match_block");
|
||||
public static final Key MATCH_BLOCK_PROPERTY = Key.from("craftengine:match_block_property");
|
||||
public static final Key TABLE_BONUS = Key.from("craftengine:table_bonus");
|
||||
public static final Key SURVIVES_EXPLOSION = Key.from("craftengine:survives_explosion");
|
||||
|
||||
@@ -11,24 +11,24 @@ import net.momirealms.craftengine.core.world.ExistingBlock;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class MatchBlockTypeCondition<CTX extends Context> implements Condition<CTX> {
|
||||
public class MatchBlockCondition<CTX extends Context> implements Condition<CTX> {
|
||||
private final Set<String> ids;
|
||||
private final boolean regexMatch;
|
||||
|
||||
public MatchBlockTypeCondition(Collection<String> ids, boolean regexMatch) {
|
||||
public MatchBlockCondition(Collection<String> ids, boolean regexMatch) {
|
||||
this.ids = new HashSet<>(ids);
|
||||
this.regexMatch = regexMatch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key type() {
|
||||
return CommonConditions.MATCH_BLOCK_TYPE;
|
||||
return CommonConditions.MATCH_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(CTX ctx) {
|
||||
Optional<ExistingBlock> block = ctx.getOptionalParameter(DirectContextParameters.BLOCK);
|
||||
return block.filter(blockInWorld -> MiscUtils.matchRegex(blockInWorld.type().asString(), this.ids, this.regexMatch)).isPresent();
|
||||
return block.filter(blockInWorld -> MiscUtils.matchRegex(blockInWorld.id().asString(), this.ids, this.regexMatch)).isPresent();
|
||||
}
|
||||
|
||||
public static class FactoryImpl<CTX extends Context> implements ConditionFactory<CTX> {
|
||||
@@ -40,7 +40,7 @@ public class MatchBlockTypeCondition<CTX extends Context> implements Condition<C
|
||||
throw new LocalizedResourceConfigException("warning.config.condition.match_block_type.missing_id");
|
||||
}
|
||||
boolean regex = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("regex", false), "regex");
|
||||
return new MatchBlockTypeCondition<>(ids, regex);
|
||||
return new MatchBlockCondition<>(ids, regex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,18 +11,18 @@ import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class MatchEntityTypeCondition<CTX extends Context> implements Condition<CTX> {
|
||||
public class MatchEntityCondition<CTX extends Context> implements Condition<CTX> {
|
||||
private final Set<String> ids;
|
||||
private final boolean regexMatch;
|
||||
|
||||
public MatchEntityTypeCondition(Collection<String> ids, boolean regexMatch) {
|
||||
public MatchEntityCondition(Collection<String> ids, boolean regexMatch) {
|
||||
this.ids = new HashSet<>(ids);
|
||||
this.regexMatch = regexMatch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key type() {
|
||||
return CommonConditions.MATCH_ENTITY_TYPE;
|
||||
return CommonConditions.MATCH_ENTITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,7 +40,7 @@ public class MatchEntityTypeCondition<CTX extends Context> implements Condition<
|
||||
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);
|
||||
return new MatchEntityCondition<>(ids, regex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,8 @@ public class EventConditions {
|
||||
|
||||
static {
|
||||
register(CommonConditions.MATCH_ITEM, new MatchItemCondition.FactoryImpl<>());
|
||||
register(CommonConditions.MATCH_ENTITY_TYPE, new MatchEntityTypeCondition.FactoryImpl<>());
|
||||
register(CommonConditions.MATCH_BLOCK_TYPE, new MatchBlockTypeCondition.FactoryImpl<>());
|
||||
register(CommonConditions.MATCH_ENTITY, new MatchEntityCondition.FactoryImpl<>());
|
||||
register(CommonConditions.MATCH_BLOCK, new MatchBlockCondition.FactoryImpl<>());
|
||||
register(CommonConditions.MATCH_BLOCK_PROPERTY, new MatchBlockPropertyCondition.FactoryImpl<>());
|
||||
register(CommonConditions.TABLE_BONUS, new TableBonusCondition.FactoryImpl<>());
|
||||
register(CommonConditions.SURVIVES_EXPLOSION, new SurvivesExplosionCondition.FactoryImpl<>());
|
||||
|
||||
@@ -39,7 +39,7 @@ public interface ExistingBlock {
|
||||
|
||||
World world();
|
||||
|
||||
Key type();
|
||||
Key id();
|
||||
|
||||
int x();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user