SteamWar/BauSystem2.0
Archiviert
12
0

Fix TestblockCommand
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2023-07-28 22:16:55 +02:00
Ursprung 8a01394092
Commit ad55b25cf0

Datei anzeigen

@ -59,12 +59,13 @@ public class TestblockCommand extends SWCommand {
} }
@Register @Register
public void schematicTestblockCommand(@Validator Player p,@OptionalValue("") @Mapper("withPublic") @AllowNull SchematicNode node,TestblockParameter... testblockParameters) { public void schematicTestblockCommand(@Validator Player p, @OptionalValue("") @Mapper("withPublic") @AllowNull SchematicNode node, TestblockParameterType... testblockParameterTypes) {
boolean isExtension = Arrays.stream(testblockParameters).anyMatch(testblockParameter -> testblockParameter.extension); Set<TestblockParameterType> testblockParameterTypesSet = new HashSet<>(Arrays.asList(testblockParameterTypes));
boolean isIgnoreAir = Arrays.stream(testblockParameters).anyMatch(testblockParameter -> testblockParameter.ignoreAir); boolean isExtension = testblockParameterTypesSet.contains(TestblockParameterType.EXTENSION);
boolean isOnlyColor = Arrays.stream(testblockParameters).anyMatch(testblockParameter -> testblockParameter.onlyColor); boolean isIgnoreAir = testblockParameterTypesSet.contains(TestblockParameterType.IGNORE_AIR);
boolean replaceTNT = Arrays.stream(testblockParameters).anyMatch(testblockParameter -> testblockParameter.tnt); boolean isOnlyColor = testblockParameterTypesSet.contains(TestblockParameterType.ONLY_COLOR);
boolean replaceWater = Arrays.stream(testblockParameters).anyMatch(testblockParameter -> testblockParameter.water); boolean replaceTNT = testblockParameterTypesSet.contains(TestblockParameterType.TNT);
boolean replaceWater = testblockParameterTypesSet.contains(TestblockParameterType.WATER);
resetRegion(p, node, isExtension ? RegionExtensionType.EXTENSION : RegionExtensionType.NORMAL, isIgnoreAir, isOnlyColor, replaceTNT, replaceWater); resetRegion(p, node, isExtension ? RegionExtensionType.EXTENSION : RegionExtensionType.NORMAL, isIgnoreAir, isOnlyColor, replaceTNT, replaceWater);
} }
@ -98,7 +99,7 @@ public class TestblockCommand extends SWCommand {
} }
@ClassMapper(value = TestblockParameterType.class, local = true) @ClassMapper(value = TestblockParameterType.class, local = true)
private TypeMapper<TestblockParameterType> testblockParameterTypeMapper() { public TypeMapper<TestblockParameterType> testblockParameterTypeMapper() {
Map<TestblockParameterType, List<String>> testblockParameterTypeListMap = new EnumMap<>(TestblockParameterType.class); Map<TestblockParameterType, List<String>> testblockParameterTypeListMap = new EnumMap<>(TestblockParameterType.class);
for (TestblockParameterType value : TestblockParameterType.values()) { for (TestblockParameterType value : TestblockParameterType.values()) {
testblockParameterTypeListMap.put(value, value.getTabCompletes()); testblockParameterTypeListMap.put(value, value.getTabCompletes());
@ -117,7 +118,7 @@ public class TestblockCommand extends SWCommand {
public List<String> tabCompletes(CommandSender commandSender, PreviousArguments previousArguments, String s) { public List<String> tabCompletes(CommandSender commandSender, PreviousArguments previousArguments, String s) {
Set<TestblockParameterType> testblockParameterTypeSet = new HashSet<>(); Set<TestblockParameterType> testblockParameterTypeSet = new HashSet<>();
previousArguments.getAll(TestblockParameterType.class).forEach(showModeType -> { previousArguments.getAll(TestblockParameterType.class).forEach(showModeType -> {
testblockParameterTypeSet.addAll(Arrays.asList(showModeType.removed.get())); testblockParameterTypeSet.addAll(Arrays.asList(showModeType.getRemoved().get()));
}); });
Arrays.stream(previousArguments.userArgs).map(testblockParameterTypesMap::get).forEach(testblockParameterTypeSet::add); Arrays.stream(previousArguments.userArgs).map(testblockParameterTypesMap::get).forEach(testblockParameterTypeSet::add);
testblockParameterTypeSet.remove(null); testblockParameterTypeSet.remove(null);
@ -175,7 +176,36 @@ public class TestblockCommand extends SWCommand {
}; };
} }
private enum TestblockParameterType { public static class TestblockParameter {
private boolean water = false;
private boolean tnt = false;
private boolean extension = false;
private boolean onlyColor = false;
private boolean ignoreAir = false;
public void enableWater() {
this.water = true;
}
public void enableTNT() {
this.tnt = true;
}
public void enableExtension() {
this.extension = true;
}
public void enableOnlyColor() {
this.onlyColor = true;
}
public void enableIgnoreAir() {
this.ignoreAir = true;
}
}
public enum TestblockParameterType {
EXTENSION(TestblockParameter::enableExtension, Arrays.asList("-e", "-extension")), EXTENSION(TestblockParameter::enableExtension, Arrays.asList("-e", "-extension")),
TNT(TestblockParameter::enableTNT, Arrays.asList("-t", "-tnt")), TNT(TestblockParameter::enableTNT, Arrays.asList("-t", "-tnt")),
WATER(TestblockParameter::enableWater, Arrays.asList("-w", "-water")), WATER(TestblockParameter::enableWater, Arrays.asList("-w", "-water")),
@ -208,29 +238,4 @@ public class TestblockCommand extends SWCommand {
}; };
} }
} }
public static class TestblockParameter {
private boolean water = false;
private boolean tnt = false;
private boolean extension = false;
private boolean onlyColor = false;
private boolean ignoreAir = false;
public void enableWater() {
this.water = true;
}
public void enableTNT() {
this.tnt = true;
}
public void enableExtension() {
this.extension = true;
}
public void enableOnlyColor() { this.onlyColor = true; }
public void enableIgnoreAir() { this.ignoreAir = true; }
}
} }