Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
8a01394092
Commit
ad55b25cf0
@ -59,22 +59,23 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetRegion(Player p,SchematicNode node, RegionExtensionType regionExtensionType,boolean ignoreAir,boolean onlyColors, boolean removeTNT, boolean removeWater) {
|
private void resetRegion(Player p, SchematicNode node, RegionExtensionType regionExtensionType, boolean ignoreAir, boolean onlyColors, boolean removeTNT, boolean removeWater) {
|
||||||
Region region = regionCheck(p);
|
Region region = regionCheck(p);
|
||||||
if (region == null) return;
|
if (region == null) return;
|
||||||
|
|
||||||
if(node != null) {
|
if (node != null) {
|
||||||
if(node.isDir()) {
|
if (node.isDir()) {
|
||||||
BauSystem.MESSAGE.send("ONLY_SCHEMS", p);
|
BauSystem.MESSAGE.send("ONLY_SCHEMS", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -89,7 +90,7 @@ public class TestblockCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
region.reset(node,RegionType.TESTBLOCK, regionExtensionType,ignoreAir,onlyColors,removeTNT,removeWater);
|
region.reset(node, RegionType.TESTBLOCK, regionExtensionType, ignoreAir, onlyColors, removeTNT, removeWater);
|
||||||
RegionUtils.message(region, "REGION_TB_DONE");
|
RegionUtils.message(region, "REGION_TB_DONE");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
BauSystem.MESSAGE.send("REGION_TB_ERROR", p);
|
BauSystem.MESSAGE.send("REGION_TB_ERROR", p);
|
||||||
@ -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);
|
||||||
@ -167,7 +168,7 @@ public class TestblockCommand extends SWCommand {
|
|||||||
@Override
|
@Override
|
||||||
public SchematicNode map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
public SchematicNode map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
||||||
SchematicNode node = SchematicNode.getNodeFromPath(SteamwarUser.get(((Player) commandSender).getUniqueId()), s);
|
SchematicNode node = SchematicNode.getNodeFromPath(SteamwarUser.get(((Player) commandSender).getUniqueId()), s);
|
||||||
if(node == null) {
|
if (node == null) {
|
||||||
node = SchematicNode.getNodeFromPath(SteamwarUser.get(0), s);
|
node = SchematicNode.getNodeFromPath(SteamwarUser.get(0), s);
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
@ -175,12 +176,41 @@ 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")),
|
||||||
IGNORE_AIR(TestblockParameter::enableIgnoreAir, Arrays.asList("-ig", "-ignore_air")),
|
IGNORE_AIR(TestblockParameter::enableIgnoreAir, Arrays.asList("-ig", "-ignore_air")),
|
||||||
ONLY_COLOR(TestblockParameter::enableOnlyColor, Arrays.asList("-o","-color","-only_color"));
|
ONLY_COLOR(TestblockParameter::enableOnlyColor, Arrays.asList("-o", "-color", "-only_color"));
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Consumer<TestblockParameter> testblockParameterConsumer;
|
private final Consumer<TestblockParameter> testblockParameterConsumer;
|
||||||
@ -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; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren