SteamWar/BauSystem
Archiviert
13
0

Add initial Region.protect

Dieser Commit ist enthalten in:
yoyosource 2021-04-09 16:24:47 +02:00
Ursprung f1e6006c51
Commit 2353fb17e7

Datei anzeigen

@ -29,6 +29,7 @@ import de.steamwar.bausystem.world.Color;
import de.steamwar.bausystem.world.SizedStack;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
@ -133,10 +134,19 @@ public class Region {
private JsonObject regionOptions = new JsonObject();
@Getter
private TNTMode tntMode = Region.buildAreaEnabled() ? TNTMode.ONLY_TB : TNTMode.OFF;
@Getter
private boolean freeze = false;
@Getter
private boolean fire = false;
@Getter
private boolean protect = false;
@Getter
private Color color = Color.YELLOW;
private Region(ConfigurationSection config) {
@ -178,6 +188,10 @@ public class Region {
freeze = regionOptions.getAsJsonPrimitive("freeze").getAsBoolean();
}
if (regionOptions.has("protect")) {
protect = regionOptions.getAsJsonPrimitive("protect").getAsBoolean();
}
if (regionOptions.has("color")) {
String colorName = regionOptions.getAsJsonPrimitive("color").getAsString();
try {
@ -191,10 +205,6 @@ public class Region {
}
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
regionOptions.add("color", new JsonPrimitive(color.name()));
@ -217,36 +227,42 @@ public class Region {
}
}
public TNTMode getTntMode() {
return tntMode;
}
public void setTntMode(TNTMode tntMode) {
this.tntMode = tntMode;
setLinkedRegion(region -> region.tntMode = tntMode);
setLinkedRegion(region -> {
region.tntMode = tntMode;
region.regionOptions.add("tnt", new JsonPrimitive(tntMode.name()));
});
regionOptions.add("tnt", new JsonPrimitive(tntMode.name()));
}
public boolean isFreeze() {
return freeze;
}
public void setFreeze(boolean freeze) {
this.freeze = freeze;
setLinkedRegion(region -> region.freeze = freeze);
setLinkedRegion(region -> {
region.freeze = freeze;
region.regionOptions.add("freeze", new JsonPrimitive(freeze));
});
regionOptions.add("freeze", new JsonPrimitive(freeze));
}
public boolean isFire() {
return fire;
}
public void setFire(boolean fire) {
this.fire = fire;
setLinkedRegion(region -> region.fire = fire);
setLinkedRegion(region -> {
region.fire = fire;
region.regionOptions.add("fire", new JsonPrimitive(fire));
});
regionOptions.add("fire", new JsonPrimitive(fire));
}
public void setProtect(boolean protect) {
this.protect = protect;
setLinkedRegion(region -> {
region.protect = protect;
region.regionOptions.add("protect", new JsonPrimitive(protect));
});
regionOptions.add("protect", new JsonPrimitive(protect));
}
public Point getMinPoint(RegionType regionType, RegionExtensionType regionExtensionType) {
switch (regionType) {
case BUILD: