SteamWar/BauSystem
Archiviert
13
0

Simplify Region

Dieser Commit ist enthalten in:
jojo 2021-02-06 15:15:52 +01:00
Ursprung 863f06673f
Commit 9d07f192a7

Datei anzeigen

@ -231,10 +231,25 @@ public class Region {
public enum ExtensionDirection {
PositiveZ(),
NegativeZ(),
PositiveX(),
NegativeX()
PositiveZ("positivez", "z+"),
NegativeZ("negativez", "z-"),
PositiveX("positivex", "x+"),
NegativeX("negativex", "x-");
private Set<String> values;
ExtensionDirection(String... values) {
this.values = new HashSet<>(Arrays.asList(values));
}
public static ExtensionDirection getByString(String value) {
if (value == null) return null;
value = value.toLowerCase();
for (ExtensionDirection extensionDirection : values()) {
if (extensionDirection.values.contains(value)) return extensionDirection;
}
return null;
}
}
@ -271,28 +286,7 @@ public class Region {
offsetX = config.getInt("offsetX", 0);
offsetY = config.getInt("offsetY", 0);
offsetZ = config.getInt("offsetZ", 0);
String extDir = config.getString("extensionFrontDirection", null);
if (extDir == null) extensionFrontDirection = null;
else {
ExtensionDirection extDirection = null;
switch (extDir.toLowerCase()) {
case "positivex":
extDirection = ExtensionDirection.PositiveX;
break;
case "negativex":
extDirection = ExtensionDirection.NegativeX;
break;
case "positivez":
extDirection = ExtensionDirection.PositiveZ;
break;
case "negativez":
extDirection = ExtensionDirection.NegativeZ;
break;
default:
break;
}
extensionFrontDirection = extDirection;
}
extensionFrontDirection = ExtensionDirection.getByString(config.getString("extensionFrontDirection", null));
extensionFront = config.getInt("extensionFront", 0);
extensionBack = config.getInt("extensionBack", 0);
extensionUp = config.getInt("extensionUp", 0);