From 06d3393c44e045ef6e33b9edf4dc3916cd21c2fe Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 20 Mar 2021 12:47:36 +0100 Subject: [PATCH] Fix Region --- .../de/steamwar/bausystem/world/Region.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java index 168d97c..8c6d43b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java @@ -42,7 +42,7 @@ public class Region { private static boolean buildArea = false; private static boolean extensionArea = false; - static{ + static { YamlConfiguration config = new YamlConfiguration(); try { config.load(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections.yml")); @@ -52,13 +52,13 @@ public class Region { ConfigurationSection prototypes = config.getConfigurationSection("prototypes"); assert prototypes != null; - for(String prototype : prototypes.getKeys(false)){ + for (String prototype : prototypes.getKeys(false)) { new Prototype(Objects.requireNonNull(prototypes.getConfigurationSection(prototype))); } ConfigurationSection regions = config.getConfigurationSection("regions"); assert regions != null; - for(String region : regions.getKeys(false)){ + for (String region : regions.getKeys(false)) { new Region(Objects.requireNonNull(regions.getConfigurationSection(region))); } } @@ -90,7 +90,7 @@ public class Region { private boolean freeze = false; private boolean fire = false; - private Region(ConfigurationSection config){ + private Region(ConfigurationSection config) { name = config.getName(); minX = config.getInt("minX"); minY = config.getInt("minY"); @@ -155,7 +155,7 @@ public class Region { setLinkedRegion(region -> region.fire = fire); } - public boolean inRegion(Location l){ + public boolean inRegion(Location l) { return prototype.inRegion(this, l); } @@ -171,7 +171,7 @@ public class Region { return prototype.buildArea.inRegionExtension(this, l); } - public void fastreset(){ + public void fastreset() { prototype.fastreset(this); } @@ -183,11 +183,11 @@ public class Region { return prototype.hasTestblock(); } - public void resetTestblock(Schematic schem) throws IOException, NoClipboardException{ + public void resetTestblock(Schematic schem) throws IOException, NoClipboardException { prototype.resetTestblock(this, schem); } - public boolean hasProtection(){ + public boolean hasProtection() { return prototype.hasProtection(); } @@ -250,7 +250,7 @@ public class Region { } } - public static class Prototype{ + public static class Prototype { private static final Map prototypes = new HashMap<>(); private final int sizeX; @@ -275,7 +275,7 @@ public class Region { private final String protectSchematic; //nullable - private Prototype(ConfigurationSection config){ + private Prototype(ConfigurationSection config) { sizeX = config.getInt("sizeX"); sizeY = config.getInt("sizeY"); sizeZ = config.getInt("sizeZ"); @@ -304,27 +304,27 @@ public class Region { protectSchematic = config.getString("protection", null); - if(!config.getName().equals("testblock") && !config.getName().equals("buildArea")) + if (!config.getName().equals("testblock") && !config.getName().equals("buildArea")) prototypes.put(config.getName(), this); } - public boolean inRegion(Region region, Location l){ - return inRange(l.getX(), region.minX + offsetX, sizeX) && + public boolean inRegion(Region region, Location l) { + return inRange(l.getX(), region.minX + offsetX, sizeX) && inRange(l.getY(), region.minY + offsetY, sizeY) && inRange(l.getZ(), region.minZ + offsetZ, sizeZ); } public boolean inRegionExtension(Region region, Location l) { - return inRange(l.getX(), region.minX + offsetX - extensionAxisX, sizeX + extensionAxisX * 2) && + return inRange(l.getX(), region.minX + offsetX - extensionAxisX, sizeX + extensionAxisX * 2) && inRange(l.getY(), region.minY + offsetY, sizeY + extensionPositiveY) && inRange(l.getZ(), region.minZ + offsetZ - extensionNegativeZ, sizeZ + extensionNegativeZ + extensionPositiveZ); } - public void fastreset(Region region){ + public void fastreset(Region region) { File file = new File(schematic); - int x = region.minX + offsetX + sizeX/2; + int x = region.minX + offsetX + sizeX / 2; int y = region.minY + offsetY; - int z = region.minZ + offsetZ + sizeZ/2; + int z = region.minZ + offsetZ + sizeZ / 2; VersionedRunnable.call(new VersionedRunnable(() -> Region_12.paste(file, x, y, z, rotate), 8), new VersionedRunnable(() -> Region_15.fastpaste(file, x, y, z, rotate), 15)); } @@ -333,7 +333,7 @@ public class Region { int x = region.minX + offsetX + sizeX / 2; int y = region.minY + offsetY; int z = region.minZ + offsetZ + sizeZ / 2; - if(schem == null) + if (schem == null) paste(new File(schematic), x, y, z, rotate); else paste(schem.load(), x, y, z, rotate); @@ -347,7 +347,7 @@ public class Region { int x = region.minX + offsetX + sizeX / 2; int y = region.minY + testblock.offsetY - 1; int z = region.minZ + offsetZ + sizeZ / 2; - if(schem == null) + if (schem == null) paste(new File(protectSchematic), x, y, z, rotate); else paste(schem.load(), x, y, z, rotate); @@ -361,16 +361,16 @@ public class Region { testblock.reset(region, schem); } - private static boolean inRange(double l, int min, int size){ + private static boolean inRange(double l, int min, int size) { return min <= l && l < min + size; } - private static void paste(File file, int x, int y, int z, boolean rotate){ //Type of protect + private static void paste(File file, int x, int y, int z, boolean rotate) { //Type of protect VersionedRunnable.call(new VersionedRunnable(() -> Region_12.paste(file, x, y, z, rotate), 8), new VersionedRunnable(() -> Region_15.paste(file, x, y, z, rotate), 15)); } - private static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate){ + private static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate) { VersionedRunnable.call(new VersionedRunnable(() -> Region_12.paste(clipboard, x, y, z, rotate), 8), new VersionedRunnable(() -> Region_15.paste(clipboard, x, y, z, rotate), 15)); }