From 5b8f7b10df88d00d4653e100502b9861f83e3d01 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Sat, 3 Apr 2021 14:34:52 +0200 Subject: [PATCH 01/25] added getMinPoint and getMaxPoint to region --- BauSystem_12/pom.xml | 1 + BauSystem_15/pom.xml | 1 + BauSystem_API/pom.xml | 1 + BauSystem_Main/pom.xml | 7 ++ .../de/steamwar/bausystem/world/Region.java | 92 ++++++++++++++----- pom.xml | 1 + 6 files changed, 82 insertions(+), 21 deletions(-) diff --git a/BauSystem_12/pom.xml b/BauSystem_12/pom.xml index 84b59ee..c146055 100644 --- a/BauSystem_12/pom.xml +++ b/BauSystem_12/pom.xml @@ -18,6 +18,7 @@ 1.0 + clean verify -U src diff --git a/BauSystem_15/pom.xml b/BauSystem_15/pom.xml index bcebe1e..c646b3b 100644 --- a/BauSystem_15/pom.xml +++ b/BauSystem_15/pom.xml @@ -18,6 +18,7 @@ 1.0 + clean verify -U src diff --git a/BauSystem_API/pom.xml b/BauSystem_API/pom.xml index f84e8ff..942f5d2 100644 --- a/BauSystem_API/pom.xml +++ b/BauSystem_API/pom.xml @@ -18,6 +18,7 @@ 1.0 + clean verify -U src diff --git a/BauSystem_Main/pom.xml b/BauSystem_Main/pom.xml index 3aa54e7..4d46542 100644 --- a/BauSystem_Main/pom.xml +++ b/BauSystem_Main/pom.xml @@ -18,6 +18,7 @@ 1.0 + clean verify -U src @@ -79,5 +80,11 @@ system ${main.basedir}/lib/WorldEdit-1.15.jar + + org.projectlombok + lombok + 1.18.10 + provided + diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java index 13b99d1..02caaf8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java @@ -21,10 +21,13 @@ package de.steamwar.bausystem.world; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.math.BlockVector3; import de.steamwar.bausystem.commands.CommandTNT.TNTMode; import de.steamwar.core.VersionedCallable; import de.steamwar.sql.NoClipboardException; import de.steamwar.sql.Schematic; +import java.awt.*; +import java.util.List; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.configuration.ConfigurationSection; @@ -80,9 +83,7 @@ public class Region { } private final String name; - private final int minX; - private final int minY; - private final int minZ; + private final Point minPoint; private final Prototype prototype; private final String optionsLinkedWith; // nullable private Region linkedRegion = null; // nullable @@ -95,9 +96,7 @@ public class Region { private Region(ConfigurationSection config) { name = config.getName(); - minX = config.getInt("minX"); - minY = config.getInt("minY"); - minZ = config.getInt("minZ"); + minPoint = new Point(config.getInt("minX"), config.getInt("minY"), config.getInt("minZ")); prototype = Prototype.prototypes.get(config.getString("prototype")); optionsLinkedWith = config.getString("optionsLinkedWith", null); if (!hasTestblock()) tntMode = TNTMode.OFF; @@ -106,9 +105,7 @@ public class Region { public Region(String name) { this.name = name; - this.minX = 0; - this.minY = 0; - this.minZ = 0; + this.minPoint = new Point(0, 0, 0); this.prototype = null; this.optionsLinkedWith = null; tntMode = TNTMode.OFF; @@ -158,6 +155,14 @@ public class Region { setLinkedRegion(region -> region.fire = fire); } + public Point getMinPoint() { + return prototype.getMinPoint(this); + } + + public Point getMaxPoint() { + return prototype.getMaxPoint(this); + } + public boolean inRegion(Location l) { return prototype.inRegion(this, l); } @@ -356,22 +361,38 @@ public class Region { prototypes.put(config.getName(), this); } + public Point getMinPoint(Region region) { + return new Point( + region.minPoint.getX() + offsetX, + region.minPoint.getY() + offsetY, + region.minPoint.getZ() + offsetZ + ); + } + + public Point getMaxPoint(Region region) { + return new Point( + region.minPoint.getX() + offsetX + sizeX, + region.minPoint.getY() + offsetY + sizeY, + region.minPoint.getZ() + offsetZ + sizeZ + ); + } + 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); + return inRange(l.getX(), region.minPoint.getX() + offsetX, sizeX) && + inRange(l.getY(), region.minPoint.getY() + offsetY, sizeY) && + inRange(l.getZ(), region.minPoint.getZ() + offsetZ, sizeZ); } public boolean inRegionExtension(Region region, Location l) { - 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); + return inRange(l.getX(), region.minPoint.getX() + offsetX - extensionAxisX, sizeX + extensionAxisX * 2) && + inRange(l.getY(), region.minPoint.getY() + offsetY, sizeY + extensionPositiveY) && + inRange(l.getZ(), region.minPoint.getZ() + offsetZ - extensionNegativeZ, sizeZ + extensionNegativeZ + extensionPositiveZ); } public EditSession reset(Region region, Schematic schem) throws IOException, NoClipboardException { - int x = region.minX + offsetX + sizeX / 2; - int y = region.minY + offsetY; - int z = region.minZ + offsetZ + sizeZ / 2; + int x = region.minPoint.getX() + offsetX + sizeX / 2; + int y = region.minPoint.getY() + offsetY; + int z = region.minPoint.getZ() + offsetZ + sizeZ / 2; if (schem == null) return paste(new File(schematic), x, y, z, rotate); else @@ -383,9 +404,9 @@ public class Region { } public EditSession protect(Region region, Schematic schem) throws IOException, NoClipboardException { - int x = region.minX + offsetX + sizeX / 2; - int y = region.minY + testblock.offsetY - 1; - int z = region.minZ + offsetZ + sizeZ / 2; + int x = region.minPoint.getX() + offsetX + sizeX / 2; + int y = region.minPoint.getY() + testblock.offsetY - 1; + int z = region.minPoint.getZ() + offsetZ + sizeZ / 2; if (schem == null) return paste(new File(protectSchematic), x, y, z, rotate); else @@ -414,4 +435,33 @@ public class Region { new VersionedCallable(() -> Region_15.paste(clipboard, x, y, z, rotate), 15)); } } + + public static class Point { + + final int x; + final int y; + final int z; + + public Point(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } + + public BlockVector3 toBlockVector3() { + return BlockVector3.at(this.x, this.y, this.z); + } + + public int getX() { + return this.x; + } + + public int getY() { + return this.y; + } + + public int getZ() { + return this.z; + } + } } diff --git a/pom.xml b/pom.xml index 4076eca..a57b450 100644 --- a/pom.xml +++ b/pom.xml @@ -15,6 +15,7 @@ + clean verify -U org.apache.maven.plugins -- 2.39.5 From a08c31c8b42a835c44d81a8dd66560559c38a4f7 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 3 Apr 2021 17:13:51 +0200 Subject: [PATCH 02/25] Add Region.Prototype.waterLevel --- .../de/steamwar/bausystem/world/Region.java | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java index 02caaf8..a256e53 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java @@ -28,6 +28,9 @@ import de.steamwar.sql.NoClipboardException; import de.steamwar.sql.Schematic; import java.awt.*; import java.util.List; + +import lombok.AllArgsConstructor; +import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.configuration.ConfigurationSection; @@ -320,6 +323,8 @@ public class Region { private final int extensionAxisX; private final boolean extensionPrototypeArea; + private final int waterLevel; + private final String schematic; private final boolean rotate; @@ -344,6 +349,7 @@ public class Region { extensionArea = true; } extensionPrototypeArea = extensionNegativeZ != 0 || extensionPositiveZ != 0 || extensionPositiveY != 0 || extensionAxisX != 0; + waterLevel = config.getInt("waterLevel", 0); rotate = config.getBoolean("rotate", false); ConfigurationSection testblockSection = config.getConfigurationSection("testblock"); @@ -436,32 +442,16 @@ public class Region { } } + @Getter + @AllArgsConstructor public static class Point { final int x; final int y; final int z; - public Point(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } - public BlockVector3 toBlockVector3() { return BlockVector3.at(this.x, this.y, this.z); } - - public int getX() { - return this.x; - } - - public int getY() { - return this.y; - } - - public int getZ() { - return this.z; - } } } -- 2.39.5 From 979ebb8ad03c2fdd7f6fbdcfedd88237ee19e6d4 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 3 Apr 2021 18:30:41 +0200 Subject: [PATCH 03/25] Add Region.getMinBuildAreaPoint Add Region.getMaxBuildAreaPoint --- .../src/de/steamwar/bausystem/world/Region.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java index a256e53..2b1265c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java @@ -166,6 +166,14 @@ public class Region { return prototype.getMaxPoint(this); } + public Point getMinBuildAreaPoint() { + return prototype.buildArea.getMinPoint(this); + } + + public Point getMaxBuildAreaPoint() { + return prototype.buildArea.getMaxPoint(this); + } + public boolean inRegion(Location l) { return prototype.inRegion(this, l); } -- 2.39.5 From fb7fe3fb2e493b2ba69f4228910e0e61758ad0b8 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Sat, 3 Apr 2021 19:08:04 +0200 Subject: [PATCH 04/25] added -a to trace show as tab complete and map --- BauSystem_Main/src/de/steamwar/bausystem/Mapper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/Mapper.java b/BauSystem_Main/src/de/steamwar/bausystem/Mapper.java index 8dee240..591fdd0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/Mapper.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/Mapper.java @@ -67,6 +67,7 @@ public class Mapper { showModeParameterTypesMap.put("-xz", ShowModeParameterType.INTERPOLATE_XZ); showModeParameterTypesMap.put("-advanced", ShowModeParameterType.ADVANCED); + showModeParameterTypesMap.put("-a", ShowModeParameterType.ADVANCED); showModeParameterTypesMap.put("advanced", ShowModeParameterType.ADVANCED); showModeParameterTypesMap.put("a", ShowModeParameterType.ADVANCED); -- 2.39.5 From 373f74122f8dea11448fc1e56349c7a2642040c4 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Sat, 3 Apr 2021 19:13:53 +0200 Subject: [PATCH 05/25] added getMinPointExtension and getMaxPointExtension --- .../de/steamwar/bausystem/world/Region.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java index 2b1265c..c9d746a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java @@ -166,11 +166,19 @@ public class Region { return prototype.getMaxPoint(this); } - public Point getMinBuildAreaPoint() { + public Point getMinPointExtension() { + return prototype.getMinPointExtension(this); + } + + public Point getMaxPointExtension() { + return prototype.getMaxPointExtension(this); + } + + public Point getMinPointBuildArea() { return prototype.buildArea.getMinPoint(this); } - public Point getMaxBuildAreaPoint() { + public Point getMaxPointBuildArea() { return prototype.buildArea.getMaxPoint(this); } @@ -391,6 +399,23 @@ public class Region { ); } + + public Point getMinPointExtension(Region region) { + return new Point( + region.minPoint.getX() + offsetX - extensionAxisX, + region.minPoint.getY() + offsetY, + region.minPoint.getZ() + offsetZ - extensionNegativeZ + ); + } + + public Point getMaxPointExtension(Region region) { + return new Point( + region.minPoint.getX() + offsetX - extensionAxisX + (sizeX + extensionAxisX * 2), + region.minPoint.getY() + offsetY + sizeY + extensionPositiveY, + region.minPoint.getZ() + offsetZ - extensionNegativeZ + (sizeZ + extensionNegativeZ + extensionPositiveZ) + ); + } + public boolean inRegion(Region region, Location l) { return inRange(l.getX(), region.minPoint.getX() + offsetX, sizeX) && inRange(l.getY(), region.minPoint.getY() + offsetY, sizeY) && -- 2.39.5 From e75da0d8f4b9221c740a69f7ea69fae9d453e45b Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 3 Apr 2021 19:35:37 +0200 Subject: [PATCH 06/25] Add Region.RegionExtensionType Add Region.RegionType --- .../bausystem/commands/CommandTNT.java | 4 +- .../bausystem/commands/RegionUtils.java | 2 +- .../de/steamwar/bausystem/world/Region.java | 163 ++++++++++-------- 3 files changed, 95 insertions(+), 74 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java index c839afe..18553db 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java @@ -157,11 +157,11 @@ public class CommandTNT extends SWCommand implements Listener { event.blockList().removeIf(block -> { Region region = Region.getRegion(block.getLocation()); if (region.getTntMode() == TNTMode.ON) return false; - if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation())) { + if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation(), Region.RegionExtensionType.NORMAL)) { RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Baubereich zerstört"); return true; } - if (region.hasBuildRegion() && region.inBuildRegionExtension(block.getLocation())) { + if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation(), Region.RegionExtensionType.EXTENSION)) { RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Ausfahrbereich zerstört"); return true; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java index 24dcedd..49901e0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java @@ -30,7 +30,7 @@ public class RegionUtils { if (Region.GlobalRegion.isGlobalRegion(region)) { Bukkit.getOnlinePlayers().stream().filter(player -> Region.getRegion(player.getLocation()) == null).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s))); } else { - Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation())).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s))); + Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), Region.RegionExtensionType.NORMAL)).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s))); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java index c9d746a..53bb16a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java @@ -26,9 +26,6 @@ import de.steamwar.bausystem.commands.CommandTNT.TNTMode; import de.steamwar.core.VersionedCallable; import de.steamwar.sql.NoClipboardException; import de.steamwar.sql.Schematic; -import java.awt.*; -import java.util.List; - import lombok.AllArgsConstructor; import lombok.Getter; import org.bukkit.Bukkit; @@ -80,7 +77,7 @@ public class Region { public static Region getRegion(Location location) { for (Region region : regions) { - if (region.inRegion(location)) return region; + if (region.inRegion(location, RegionExtensionType.NORMAL)) return region; } return GlobalRegion.getInstance(); } @@ -158,44 +155,52 @@ public class Region { setLinkedRegion(region -> region.fire = fire); } - public Point getMinPoint() { - return prototype.getMinPoint(this); + public Point getMinPoint(RegionType regionType, RegionExtensionType regionExtensionType) { + switch (regionType) { + case BUILD_AREA: + return prototype.buildArea.getMinPoint(this, regionExtensionType); + case TESTBLOCK: + return prototype.testblock.getMinPoint(this, regionExtensionType); + default: + case NORMAL: + return prototype.getMinPoint(this, regionExtensionType); + } } - public Point getMaxPoint() { - return prototype.getMaxPoint(this); + public Point getMaxPoint(RegionType regionType, RegionExtensionType regionExtensionType) { + switch (regionType) { + case BUILD_AREA: + return prototype.buildArea.getMaxPoint(this, regionExtensionType); + case TESTBLOCK: + return prototype.testblock.getMaxPoint(this, regionExtensionType); + default: + case NORMAL: + return prototype.getMaxPoint(this, regionExtensionType); + } } - public Point getMinPointExtension() { - return prototype.getMinPointExtension(this); + public boolean inRegion(Location l, RegionType regionType, RegionExtensionType regionExtensionType) { + switch (regionType) { + case BUILD_AREA: + return prototype.buildArea.inRegion(this, l, regionExtensionType); + case TESTBLOCK: + return prototype.testblock.inRegion(this, l, regionExtensionType); + default: + case NORMAL: + return prototype.inRegion(this, l, regionExtensionType); + } } - public Point getMaxPointExtension() { - return prototype.getMaxPointExtension(this); - } - - public Point getMinPointBuildArea() { - return prototype.buildArea.getMinPoint(this); - } - - public Point getMaxPointBuildArea() { - return prototype.buildArea.getMaxPoint(this); - } - - public boolean inRegion(Location l) { - return prototype.inRegion(this, l); + public boolean inRegion(Location l, RegionExtensionType regionExtensionType) { + return prototype.inRegion(this, l, regionExtensionType); } public boolean hasBuildRegion() { return prototype.buildArea != null; } - public boolean inBuildRegion(Location l) { - return prototype.buildArea.inRegion(this, l); - } - - public boolean inBuildRegionExtension(Location l) { - return prototype.buildArea.inRegionExtension(this, l); + public boolean inBuildRegion(Location l, RegionExtensionType regionExtensionType) { + return prototype.buildArea.inRegion(this, l, regionExtensionType); } public void reset() throws IOException { @@ -292,7 +297,7 @@ public class Region { } @Override - public boolean inRegion(Location l) { + public boolean inRegion(Location l, RegionExtensionType regionExtensionType) { return true; } @@ -382,50 +387,55 @@ public class Region { if (!config.getName().equals("testblock") && !config.getName().equals("buildArea")) prototypes.put(config.getName(), this); } - - public Point getMinPoint(Region region) { - return new Point( - region.minPoint.getX() + offsetX, - region.minPoint.getY() + offsetY, - region.minPoint.getZ() + offsetZ - ); + + public Point getMinPoint(Region region, RegionExtensionType regionExtensionType) { + switch (regionExtensionType) { + case EXTENSION: + return new Point( + region.minPoint.getX() + offsetX - extensionAxisX, + region.minPoint.getY() + offsetY, + region.minPoint.getZ() + offsetZ - extensionNegativeZ + ); + default: + case NORMAL: + return new Point( + region.minPoint.getX() + offsetX, + region.minPoint.getY() + offsetY, + region.minPoint.getZ() + offsetZ + ); + } } - public Point getMaxPoint(Region region) { - return new Point( - region.minPoint.getX() + offsetX + sizeX, - region.minPoint.getY() + offsetY + sizeY, - region.minPoint.getZ() + offsetZ + sizeZ - ); + public Point getMaxPoint(Region region, RegionExtensionType regionExtensionType) { + switch (regionExtensionType) { + case EXTENSION: + return new Point( + region.minPoint.getX() + offsetX - extensionAxisX + (sizeX + extensionAxisX * 2), + region.minPoint.getY() + offsetY + sizeY + extensionPositiveY, + region.minPoint.getZ() + offsetZ - extensionNegativeZ + (sizeZ + extensionNegativeZ + extensionPositiveZ) + ); + default: + case NORMAL: + return new Point( + region.minPoint.getX() + offsetX + sizeX, + region.minPoint.getY() + offsetY + sizeY, + region.minPoint.getZ() + offsetZ + sizeZ + ); + } } - - public Point getMinPointExtension(Region region) { - return new Point( - region.minPoint.getX() + offsetX - extensionAxisX, - region.minPoint.getY() + offsetY, - region.minPoint.getZ() + offsetZ - extensionNegativeZ - ); - } - - public Point getMaxPointExtension(Region region) { - return new Point( - region.minPoint.getX() + offsetX - extensionAxisX + (sizeX + extensionAxisX * 2), - region.minPoint.getY() + offsetY + sizeY + extensionPositiveY, - region.minPoint.getZ() + offsetZ - extensionNegativeZ + (sizeZ + extensionNegativeZ + extensionPositiveZ) - ); - } - - public boolean inRegion(Region region, Location l) { - return inRange(l.getX(), region.minPoint.getX() + offsetX, sizeX) && - inRange(l.getY(), region.minPoint.getY() + offsetY, sizeY) && - inRange(l.getZ(), region.minPoint.getZ() + offsetZ, sizeZ); - } - - public boolean inRegionExtension(Region region, Location l) { - return inRange(l.getX(), region.minPoint.getX() + offsetX - extensionAxisX, sizeX + extensionAxisX * 2) && - inRange(l.getY(), region.minPoint.getY() + offsetY, sizeY + extensionPositiveY) && - inRange(l.getZ(), region.minPoint.getZ() + offsetZ - extensionNegativeZ, sizeZ + extensionNegativeZ + extensionPositiveZ); + public boolean inRegion(Region region, Location l, RegionExtensionType regionExtensionType) { + switch (regionExtensionType) { + case EXTENSION: + return inRange(l.getX(), region.minPoint.getX() + offsetX - extensionAxisX, sizeX + extensionAxisX * 2) && + inRange(l.getY(), region.minPoint.getY() + offsetY, sizeY + extensionPositiveY) && + inRange(l.getZ(), region.minPoint.getZ() + offsetZ - extensionNegativeZ, sizeZ + extensionNegativeZ + extensionPositiveZ); + default: + case NORMAL: + return inRange(l.getX(), region.minPoint.getX() + offsetX, sizeX) && + inRange(l.getY(), region.minPoint.getY() + offsetY, sizeY) && + inRange(l.getZ(), region.minPoint.getZ() + offsetZ, sizeZ); + } } public EditSession reset(Region region, Schematic schem) throws IOException, NoClipboardException { @@ -475,6 +485,17 @@ public class Region { } } + public enum RegionType { + NORMAL, + BUILD_AREA, + TESTBLOCK + } + + public enum RegionExtensionType { + NORMAL, + EXTENSION + } + @Getter @AllArgsConstructor public static class Point { -- 2.39.5 From 255c7e83558c80f1316edad6a74e8d85b0124745 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 3 Apr 2021 19:40:47 +0200 Subject: [PATCH 07/25] Update Region to new Region.RegionType and Region.RegionExtensionType --- .../de/steamwar/bausystem/commands/CommandTNT.java | 4 ++-- .../de/steamwar/bausystem/commands/RegionUtils.java | 4 +++- .../src/de/steamwar/bausystem/world/Region.java | 12 ++---------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java index 18553db..b57d083 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java @@ -157,11 +157,11 @@ public class CommandTNT extends SWCommand implements Listener { event.blockList().removeIf(block -> { Region region = Region.getRegion(block.getLocation()); if (region.getTntMode() == TNTMode.ON) return false; - if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation(), Region.RegionExtensionType.NORMAL)) { + if (region.hasBuildRegion() && region.inRegion(block.getLocation(), Region.RegionType.BUILD_AREA, Region.RegionExtensionType.NORMAL)) { RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Baubereich zerstört"); return true; } - if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation(), Region.RegionExtensionType.EXTENSION)) { + if (region.hasBuildRegion() && region.inRegion(block.getLocation(), Region.RegionType.BUILD_AREA, Region.RegionExtensionType.EXTENSION)) { RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Ausfahrbereich zerstört"); return true; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java index 49901e0..7c2cc3a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java @@ -20,17 +20,19 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.world.Region; +import lombok.experimental.UtilityClass; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; +@UtilityClass public class RegionUtils { public static void actionBar(Region region, String s) { if (Region.GlobalRegion.isGlobalRegion(region)) { Bukkit.getOnlinePlayers().stream().filter(player -> Region.getRegion(player.getLocation()) == null).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s))); } else { - Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), Region.RegionExtensionType.NORMAL)).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s))); + Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), Region.RegionType.NORMAL, Region.RegionExtensionType.NORMAL)).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s))); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java index 53bb16a..5363d9d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java @@ -77,7 +77,7 @@ public class Region { public static Region getRegion(Location location) { for (Region region : regions) { - if (region.inRegion(location, RegionExtensionType.NORMAL)) return region; + if (region.inRegion(location, RegionType.NORMAL, RegionExtensionType.NORMAL)) return region; } return GlobalRegion.getInstance(); } @@ -191,18 +191,10 @@ public class Region { } } - public boolean inRegion(Location l, RegionExtensionType regionExtensionType) { - return prototype.inRegion(this, l, regionExtensionType); - } - public boolean hasBuildRegion() { return prototype.buildArea != null; } - public boolean inBuildRegion(Location l, RegionExtensionType regionExtensionType) { - return prototype.buildArea.inRegion(this, l, regionExtensionType); - } - public void reset() throws IOException { initSessions(); undosessions.push(prototype.reset(this, null)); @@ -297,7 +289,7 @@ public class Region { } @Override - public boolean inRegion(Location l, RegionExtensionType regionExtensionType) { + public boolean inRegion(Location l, RegionType regionType, RegionExtensionType regionExtensionType) { return true; } -- 2.39.5 From bdc9e44e2a564f9b30aa5fbe39bc05374bfe18f4 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 3 Apr 2021 19:49:36 +0200 Subject: [PATCH 08/25] Make Region System more readable by splitting a long class file --- .../world/{ => regions}/Region_12.java | 38 +- .../world/{ => regions}/Region_15.java | 38 +- .../bausystem/commands/CommandFire.java | 2 +- .../bausystem/commands/CommandFreeze.java | 2 +- .../bausystem/commands/CommandGUI.java | 4 +- .../bausystem/commands/CommandInfo.java | 2 +- .../bausystem/commands/CommandProtect.java | 2 +- .../bausystem/commands/CommandRegion.java | 5 +- .../bausystem/commands/CommandReset.java | 5 +- .../bausystem/commands/CommandTNT.java | 8 +- .../bausystem/commands/CommandTestblock.java | 2 +- .../bausystem/commands/RegionUtils.java | 9 +- .../bausystem/world/BauScoreboard.java | 1 + .../de/steamwar/bausystem/world/Region.java | 503 ------------------ .../bausystem/world/ScriptListener.java | 1 + .../bausystem/world/regions/GlobalRegion.java | 69 +++ .../bausystem/world/regions/Point.java | 37 ++ .../bausystem/world/regions/Prototype.java | 191 +++++++ .../bausystem/world/regions/Region.java | 273 ++++++++++ .../world/regions/RegionExtensionType.java | 25 + .../bausystem/world/regions/RegionType.java | 26 + 21 files changed, 686 insertions(+), 557 deletions(-) rename BauSystem_12/src/de/steamwar/bausystem/world/{ => regions}/Region_12.java (73%) rename BauSystem_15/src/de/steamwar/bausystem/world/{ => regions}/Region_15.java (74%) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/world/Region.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/world/regions/GlobalRegion.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/world/regions/Point.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/world/regions/RegionExtensionType.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/world/regions/RegionType.java diff --git a/BauSystem_12/src/de/steamwar/bausystem/world/Region_12.java b/BauSystem_12/src/de/steamwar/bausystem/world/regions/Region_12.java similarity index 73% rename from BauSystem_12/src/de/steamwar/bausystem/world/Region_12.java rename to BauSystem_12/src/de/steamwar/bausystem/world/regions/Region_12.java index d95b106..db8cb37 100644 --- a/BauSystem_12/src/de/steamwar/bausystem/world/Region_12.java +++ b/BauSystem_12/src/de/steamwar/bausystem/world/regions/Region_12.java @@ -1,23 +1,23 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.world; +package de.steamwar.bausystem.world.regions; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.Vector; diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/Region_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java similarity index 74% rename from BauSystem_15/src/de/steamwar/bausystem/world/Region_15.java rename to BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java index 76da59d..9e735cb 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/Region_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java @@ -1,23 +1,23 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.world; +package de.steamwar.bausystem.world.regions; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEdit; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java index 0c9d5c2..8295088 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java @@ -21,7 +21,7 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.Region; +import de.steamwar.bausystem.world.regions.Region; import de.steamwar.bausystem.world.Welt; import de.steamwar.command.SWCommand; import org.bukkit.Bukkit; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java index 2baeb2a..2531ccd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java @@ -21,7 +21,7 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.Region; +import de.steamwar.bausystem.world.regions.Region; import de.steamwar.bausystem.world.Welt; import de.steamwar.command.SWCommand; import de.steamwar.core.Core; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java index b2fa3db..69a51fc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java @@ -25,6 +25,8 @@ import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.tracer.record.RecordStateMachine; import de.steamwar.bausystem.tracer.show.TraceShowManager; import de.steamwar.bausystem.world.*; +import de.steamwar.bausystem.world.regions.GlobalRegion; +import de.steamwar.bausystem.world.regions.Region; import de.steamwar.command.SWCommand; import de.steamwar.core.Core; import de.steamwar.inventory.SWAnvilInv; @@ -190,7 +192,7 @@ public class CommandGUI extends SWCommand implements Listener { anvilInv.open(); }); - if (Region.GlobalRegion.isGlobalRegion(region)) { + if (GlobalRegion.isGlobalRegion(region)) { inv.setItem(9, Material.BARRIER, "§eKeine Region", clickType -> { }); inv.setItem(18, Material.BARRIER, "§eKeine Region", clickType -> { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java index 93873dc..0eb78c1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java @@ -20,7 +20,7 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.world.Region; +import de.steamwar.bausystem.world.regions.Region; import de.steamwar.bausystem.world.TPSUtils; import de.steamwar.command.SWCommand; import de.steamwar.core.TPSWatcher; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java index fed21f5..65c602f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java @@ -21,7 +21,7 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.Region; +import de.steamwar.bausystem.world.regions.Region; import de.steamwar.bausystem.world.Welt; import de.steamwar.command.SWCommand; import de.steamwar.sql.Schematic; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java index 7ed72ff..bb28fc8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java @@ -2,7 +2,8 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.Region; +import de.steamwar.bausystem.world.regions.GlobalRegion; +import de.steamwar.bausystem.world.regions.Region; import de.steamwar.bausystem.world.Welt; import de.steamwar.command.SWCommand; import org.bukkit.entity.Player; @@ -51,7 +52,7 @@ public class CommandRegion extends SWCommand { } static boolean checkGlobalRegion(Region region, Player p) { - if(Region.GlobalRegion.isGlobalRegion(region)) { + if(GlobalRegion.isGlobalRegion(region)) { p.sendMessage(BauSystem.PREFIX + "§cDu bist in keiner Region"); return true; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java index 05d3988..0847c11 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java @@ -21,7 +21,8 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.Region; +import de.steamwar.bausystem.world.regions.GlobalRegion; +import de.steamwar.bausystem.world.regions.Region; import de.steamwar.bausystem.world.Welt; import de.steamwar.command.SWCommand; import de.steamwar.sql.Schematic; @@ -86,7 +87,7 @@ public class CommandReset extends SWCommand { private Region regionCheck(Player player) { Region region = Region.getRegion(player.getLocation()); - if (region == Region.GlobalRegion.getInstance()) { + if (region == GlobalRegion.getInstance()) { player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region"); return null; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java index b57d083..0e510cf 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java @@ -21,8 +21,10 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.Region; +import de.steamwar.bausystem.world.regions.Region; import de.steamwar.bausystem.world.Welt; +import de.steamwar.bausystem.world.regions.RegionExtensionType; +import de.steamwar.bausystem.world.regions.RegionType; import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; @@ -157,11 +159,11 @@ public class CommandTNT extends SWCommand implements Listener { event.blockList().removeIf(block -> { Region region = Region.getRegion(block.getLocation()); if (region.getTntMode() == TNTMode.ON) return false; - if (region.hasBuildRegion() && region.inRegion(block.getLocation(), Region.RegionType.BUILD_AREA, Region.RegionExtensionType.NORMAL)) { + if (region.hasBuildRegion() && region.inRegion(block.getLocation(), RegionType.BUILD_AREA, RegionExtensionType.NORMAL)) { RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Baubereich zerstört"); return true; } - if (region.hasBuildRegion() && region.inRegion(block.getLocation(), Region.RegionType.BUILD_AREA, Region.RegionExtensionType.EXTENSION)) { + if (region.hasBuildRegion() && region.inRegion(block.getLocation(), RegionType.BUILD_AREA, RegionExtensionType.EXTENSION)) { RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Ausfahrbereich zerstört"); return true; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java index f90e8cb..bcc9a00 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java @@ -21,7 +21,7 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.Region; +import de.steamwar.bausystem.world.regions.Region; import de.steamwar.bausystem.world.Welt; import de.steamwar.command.SWCommand; import de.steamwar.sql.Schematic; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java index 7c2cc3a..1d9dc60 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java @@ -19,7 +19,10 @@ package de.steamwar.bausystem.commands; -import de.steamwar.bausystem.world.Region; +import de.steamwar.bausystem.world.regions.GlobalRegion; +import de.steamwar.bausystem.world.regions.Region; +import de.steamwar.bausystem.world.regions.RegionExtensionType; +import de.steamwar.bausystem.world.regions.RegionType; import lombok.experimental.UtilityClass; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; @@ -29,10 +32,10 @@ import org.bukkit.Bukkit; public class RegionUtils { public static void actionBar(Region region, String s) { - if (Region.GlobalRegion.isGlobalRegion(region)) { + if (GlobalRegion.isGlobalRegion(region)) { Bukkit.getOnlinePlayers().stream().filter(player -> Region.getRegion(player.getLocation()) == null).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s))); } else { - Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), Region.RegionType.NORMAL, Region.RegionExtensionType.NORMAL)).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s))); + Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s))); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java b/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java index ccdc312..5ba1eb3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.world; import de.steamwar.bausystem.commands.CommandTPSLimiter; import de.steamwar.bausystem.tracer.record.RecordStateMachine; +import de.steamwar.bausystem.world.regions.Region; import de.steamwar.core.TPSWatcher; import de.steamwar.scoreboard.SWScoreboard; import de.steamwar.scoreboard.ScoreboardCallback; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java deleted file mode 100644 index 5363d9d..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java +++ /dev/null @@ -1,503 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.world; - -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.math.BlockVector3; -import de.steamwar.bausystem.commands.CommandTNT.TNTMode; -import de.steamwar.core.VersionedCallable; -import de.steamwar.sql.NoClipboardException; -import de.steamwar.sql.Schematic; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.YamlConfiguration; - -import java.io.File; -import java.io.IOException; -import java.util.*; -import java.util.function.Consumer; -import java.util.logging.Level; - -public class Region { - - private static final List regions = new ArrayList<>(); - private static boolean buildArea = false; - private static boolean extensionArea = false; - - static { - YamlConfiguration config = new YamlConfiguration(); - try { - config.load(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections.yml")); - } catch (InvalidConfigurationException | IOException e) { - Bukkit.getLogger().log(Level.SEVERE, "Failed to load sections.yml", e); - } - - ConfigurationSection prototypes = config.getConfigurationSection("prototypes"); - assert prototypes != null; - 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)) { - new Region(Objects.requireNonNull(regions.getConfigurationSection(region))); - } - } - - public static boolean buildAreaEnabled() { - return buildArea; - } - - public static boolean extensionAreaEnabled() { - return extensionArea; - } - - public static Region getRegion(Location location) { - for (Region region : regions) { - if (region.inRegion(location, RegionType.NORMAL, RegionExtensionType.NORMAL)) return region; - } - return GlobalRegion.getInstance(); - } - - private final String name; - private final Point minPoint; - private final Prototype prototype; - private final String optionsLinkedWith; // nullable - private Region linkedRegion = null; // nullable - private SizedStack undosessions; - private SizedStack redosessions; - - private TNTMode tntMode = Region.buildAreaEnabled() ? TNTMode.ONLY_TB : TNTMode.OFF; - private boolean freeze = false; - private boolean fire = false; - - private Region(ConfigurationSection config) { - name = config.getName(); - minPoint = new Point(config.getInt("minX"), config.getInt("minY"), config.getInt("minZ")); - prototype = Prototype.prototypes.get(config.getString("prototype")); - optionsLinkedWith = config.getString("optionsLinkedWith", null); - if (!hasTestblock()) tntMode = TNTMode.OFF; - regions.add(this); - } - - public Region(String name) { - this.name = name; - this.minPoint = new Point(0, 0, 0); - this.prototype = null; - this.optionsLinkedWith = null; - tntMode = TNTMode.OFF; - } - - private void setLinkedRegion(Consumer regionConsumer) { - if (optionsLinkedWith == null) { - return; - } - if (linkedRegion != null) { - regionConsumer.accept(linkedRegion); - return; - } - for (Region region : regions) { - if (region.name.equals(name)) { - linkedRegion = region; - regionConsumer.accept(linkedRegion); - return; - } - } - } - - public TNTMode getTntMode() { - return tntMode; - } - - public void setTntMode(TNTMode tntMode) { - this.tntMode = tntMode; - setLinkedRegion(region -> region.tntMode = tntMode); - } - - public boolean isFreeze() { - return freeze; - } - - public void setFreeze(boolean freeze) { - this.freeze = freeze; - setLinkedRegion(region -> region.freeze = freeze); - } - - public boolean isFire() { - return fire; - } - - public void setFire(boolean fire) { - this.fire = fire; - setLinkedRegion(region -> region.fire = fire); - } - - public Point getMinPoint(RegionType regionType, RegionExtensionType regionExtensionType) { - switch (regionType) { - case BUILD_AREA: - return prototype.buildArea.getMinPoint(this, regionExtensionType); - case TESTBLOCK: - return prototype.testblock.getMinPoint(this, regionExtensionType); - default: - case NORMAL: - return prototype.getMinPoint(this, regionExtensionType); - } - } - - public Point getMaxPoint(RegionType regionType, RegionExtensionType regionExtensionType) { - switch (regionType) { - case BUILD_AREA: - return prototype.buildArea.getMaxPoint(this, regionExtensionType); - case TESTBLOCK: - return prototype.testblock.getMaxPoint(this, regionExtensionType); - default: - case NORMAL: - return prototype.getMaxPoint(this, regionExtensionType); - } - } - - public boolean inRegion(Location l, RegionType regionType, RegionExtensionType regionExtensionType) { - switch (regionType) { - case BUILD_AREA: - return prototype.buildArea.inRegion(this, l, regionExtensionType); - case TESTBLOCK: - return prototype.testblock.inRegion(this, l, regionExtensionType); - default: - case NORMAL: - return prototype.inRegion(this, l, regionExtensionType); - } - } - - public boolean hasBuildRegion() { - return prototype.buildArea != null; - } - - public void reset() throws IOException { - initSessions(); - undosessions.push(prototype.reset(this, null)); - } - - public void reset(Schematic schem) throws IOException, NoClipboardException { - initSessions(); - undosessions.push(prototype.reset(this, schem)); - } - - public boolean hasTestblock() { - return prototype.hasTestblock(); - } - - public void resetTestblock(Schematic schem) throws IOException, NoClipboardException { - initSessions(); - undosessions.push(prototype.resetTestblock(this, schem)); - } - - public boolean hasProtection() { - return prototype.hasProtection(); - } - - public void protect(Schematic schem) throws IOException, NoClipboardException { - initSessions(); - undosessions.push(prototype.protect(this, schem)); - } - - public boolean hasExtensionAreaRegistered() { - return prototype.extensionPrototypeArea; - } - - public boolean hasTestblockExtensionAreaRegistered() { - return prototype.testblock.extensionPrototypeArea; - } - - private void initSessions() { - if(undosessions == null) { - undosessions = new SizedStack<>(20); - redosessions = new SizedStack<>(20); - } - } - - public boolean undo() { - initSessions(); - EditSession session = null; - try { - session = undosessions.pop(); - if(session == null) - return false; - session.undo(session); - redosessions.push(session); - return true; - } finally { - if (session != null) { - session.flushSession(); - } - } - } - - public boolean redo() { - initSessions(); - EditSession session = null; - try { - session = redosessions.pop(); - if(session == null) - return false; - session.redo(session); - undosessions.push(session); - return true; - } finally { - if (session != null) { - session.flushSession(); - } - } - } - - public static class GlobalRegion extends Region { - - private static final GlobalRegion GLOBAL_REGION = new GlobalRegion(); - - public static GlobalRegion getInstance() { - return GLOBAL_REGION; - } - - public static boolean isGlobalRegion(Region region) { - return region == GLOBAL_REGION; - } - - public GlobalRegion() { - super("Global"); - } - - @Override - public boolean inRegion(Location l, RegionType regionType, RegionExtensionType regionExtensionType) { - return true; - } - - @Override - public boolean hasBuildRegion() { - return false; - } - - @Override - public boolean hasTestblock() { - return false; - } - - @Override - public boolean hasProtection() { - return false; - } - - @Override - public boolean hasExtensionAreaRegistered() { - return false; - } - - @Override - public boolean hasTestblockExtensionAreaRegistered() { - return false; - } - } - - public static class Prototype { - private static final Map prototypes = new HashMap<>(); - - private final int sizeX; - private final int sizeY; - private final int sizeZ; - - private final int offsetX; - private final int offsetY; - private final int offsetZ; - - private final int extensionPositiveZ; - private final int extensionNegativeZ; - private final int extensionPositiveY; - private final int extensionAxisX; - private final boolean extensionPrototypeArea; - - private final int waterLevel; - - private final String schematic; - private final boolean rotate; - - private final Prototype testblock; //nullable - private final Prototype buildArea; //nullable - - private final String protectSchematic; //nullable - - private Prototype(ConfigurationSection config) { - sizeX = config.getInt("sizeX"); - sizeY = config.getInt("sizeY"); - sizeZ = config.getInt("sizeZ"); - schematic = config.getString("schematic"); - offsetX = config.getInt("offsetX", 0); - offsetY = config.getInt("offsetY", 0); - offsetZ = config.getInt("offsetZ", 0); - extensionPositiveZ = config.getInt("extensionPositiveZ", 0); - extensionNegativeZ = config.getInt("extensionNegativeZ", 0); - extensionPositiveY = config.getInt("extensionPositiveY", 0); - extensionAxisX = config.getInt("extensionAxisX", 0); - if (config.contains("extensionPositiveZ") || config.contains("extensionNegativeZ") || config.contains("extensionPositiveY") || config.contains("extensionAxisX")) { - extensionArea = true; - } - extensionPrototypeArea = extensionNegativeZ != 0 || extensionPositiveZ != 0 || extensionPositiveY != 0 || extensionAxisX != 0; - waterLevel = config.getInt("waterLevel", 0); - rotate = config.getBoolean("rotate", false); - - ConfigurationSection testblockSection = config.getConfigurationSection("testblock"); - testblock = testblockSection != null ? new Prototype(testblockSection) : null; - - ConfigurationSection buildAreaSection = config.getConfigurationSection("buildArea"); - buildArea = buildAreaSection != null ? new Prototype(buildAreaSection) : null; - if (buildArea != null) { - Region.buildArea = true; - } - - protectSchematic = config.getString("protection", null); - - if (!config.getName().equals("testblock") && !config.getName().equals("buildArea")) - prototypes.put(config.getName(), this); - } - - public Point getMinPoint(Region region, RegionExtensionType regionExtensionType) { - switch (regionExtensionType) { - case EXTENSION: - return new Point( - region.minPoint.getX() + offsetX - extensionAxisX, - region.minPoint.getY() + offsetY, - region.minPoint.getZ() + offsetZ - extensionNegativeZ - ); - default: - case NORMAL: - return new Point( - region.minPoint.getX() + offsetX, - region.minPoint.getY() + offsetY, - region.minPoint.getZ() + offsetZ - ); - } - } - - public Point getMaxPoint(Region region, RegionExtensionType regionExtensionType) { - switch (regionExtensionType) { - case EXTENSION: - return new Point( - region.minPoint.getX() + offsetX - extensionAxisX + (sizeX + extensionAxisX * 2), - region.minPoint.getY() + offsetY + sizeY + extensionPositiveY, - region.minPoint.getZ() + offsetZ - extensionNegativeZ + (sizeZ + extensionNegativeZ + extensionPositiveZ) - ); - default: - case NORMAL: - return new Point( - region.minPoint.getX() + offsetX + sizeX, - region.minPoint.getY() + offsetY + sizeY, - region.minPoint.getZ() + offsetZ + sizeZ - ); - } - } - - public boolean inRegion(Region region, Location l, RegionExtensionType regionExtensionType) { - switch (regionExtensionType) { - case EXTENSION: - return inRange(l.getX(), region.minPoint.getX() + offsetX - extensionAxisX, sizeX + extensionAxisX * 2) && - inRange(l.getY(), region.minPoint.getY() + offsetY, sizeY + extensionPositiveY) && - inRange(l.getZ(), region.minPoint.getZ() + offsetZ - extensionNegativeZ, sizeZ + extensionNegativeZ + extensionPositiveZ); - default: - case NORMAL: - return inRange(l.getX(), region.minPoint.getX() + offsetX, sizeX) && - inRange(l.getY(), region.minPoint.getY() + offsetY, sizeY) && - inRange(l.getZ(), region.minPoint.getZ() + offsetZ, sizeZ); - } - } - - public EditSession reset(Region region, Schematic schem) throws IOException, NoClipboardException { - int x = region.minPoint.getX() + offsetX + sizeX / 2; - int y = region.minPoint.getY() + offsetY; - int z = region.minPoint.getZ() + offsetZ + sizeZ / 2; - if (schem == null) - return paste(new File(schematic), x, y, z, rotate); - else - return paste(schem.load(), x, y, z, rotate); - } - - public boolean hasProtection() { - return protectSchematic != null; - } - - public EditSession protect(Region region, Schematic schem) throws IOException, NoClipboardException { - int x = region.minPoint.getX() + offsetX + sizeX / 2; - int y = region.minPoint.getY() + testblock.offsetY - 1; - int z = region.minPoint.getZ() + offsetZ + sizeZ / 2; - if (schem == null) - return paste(new File(protectSchematic), x, y, z, rotate); - else - return paste(schem.load(), x, y, z, rotate); - } - - public boolean hasTestblock() { - return testblock != null; - } - - public EditSession resetTestblock(Region region, Schematic schem) throws IOException, NoClipboardException { - return testblock.reset(region, schem); - } - - private static boolean inRange(double l, int min, int size) { - return min <= l && l < min + size; - } - - private static EditSession paste(File file, int x, int y, int z, boolean rotate) { //Type of protect - return (EditSession) VersionedCallable.call(new VersionedCallable(() -> Region_12.paste(file, x, y, z, rotate), 8), - new VersionedCallable(() -> Region_15.paste(file, x, y, z, rotate), 15)); - } - - private static EditSession paste(Clipboard clipboard, int x, int y, int z, boolean rotate) { - return (EditSession) VersionedCallable.call(new VersionedCallable(() -> Region_12.paste(clipboard, x, y, z, rotate), 8), - new VersionedCallable(() -> Region_15.paste(clipboard, x, y, z, rotate), 15)); - } - } - - public enum RegionType { - NORMAL, - BUILD_AREA, - TESTBLOCK - } - - public enum RegionExtensionType { - NORMAL, - EXTENSION - } - - @Getter - @AllArgsConstructor - public static class Point { - - final int x; - final int y; - final int z; - - public BlockVector3 toBlockVector3() { - return BlockVector3.at(this.x, this.y, this.z); - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java index cf084e2..542f134 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java @@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.commands.CommandScript; import de.steamwar.bausystem.commands.CommandTNT; import de.steamwar.bausystem.tracer.record.RecordStateMachine; +import de.steamwar.bausystem.world.regions.Region; import de.steamwar.core.VersionedCallable; import de.steamwar.inventory.SWAnvilInv; import org.bukkit.Bukkit; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/GlobalRegion.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/GlobalRegion.java new file mode 100644 index 0000000..e16d048 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/GlobalRegion.java @@ -0,0 +1,69 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.world.regions; + +import org.bukkit.Location; + +public class GlobalRegion extends Region { + + private static final GlobalRegion GLOBAL_REGION = new GlobalRegion(); + + public static GlobalRegion getInstance() { + return GLOBAL_REGION; + } + + public static boolean isGlobalRegion(Region region) { + return region == GLOBAL_REGION; + } + + public GlobalRegion() { + super("Global"); + } + + @Override + public boolean inRegion(Location l, RegionType regionType, RegionExtensionType regionExtensionType) { + return true; + } + + @Override + public boolean hasBuildRegion() { + return false; + } + + @Override + public boolean hasTestblock() { + return false; + } + + @Override + public boolean hasProtection() { + return false; + } + + @Override + public boolean hasBuildAreaExtensionAreaRegistered() { + return false; + } + + @Override + public boolean hasTestblockExtensionAreaRegistered() { + return false; + } +} \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Point.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Point.java new file mode 100644 index 0000000..b3f7f07 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Point.java @@ -0,0 +1,37 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.world.regions; + +import com.sk89q.worldedit.math.BlockVector3; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class Point { + + final int x; + final int y; + final int z; + + public BlockVector3 toBlockVector3() { + return BlockVector3.at(this.x, this.y, this.z); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java new file mode 100644 index 0000000..0c8a658 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java @@ -0,0 +1,191 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.world.regions; + +import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.extent.clipboard.Clipboard; +import de.steamwar.core.VersionedCallable; +import de.steamwar.sql.NoClipboardException; +import de.steamwar.sql.Schematic; +import org.bukkit.Location; +import org.bukkit.configuration.ConfigurationSection; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public class Prototype { + static final Map prototypes = new HashMap<>(); + + private final int sizeX; + private final int sizeY; + private final int sizeZ; + + private final int offsetX; + private final int offsetY; + private final int offsetZ; + + private final int extensionPositiveZ; + private final int extensionNegativeZ; + private final int extensionPositiveY; + private final int extensionAxisX; + final boolean extensionPrototypeArea; + + private final int waterLevel; + + private final String schematic; + private final boolean rotate; + + final Prototype testblock; //nullable + final Prototype buildArea; //nullable + + private final String protectSchematic; //nullable + + Prototype(ConfigurationSection config) { + sizeX = config.getInt("sizeX"); + sizeY = config.getInt("sizeY"); + sizeZ = config.getInt("sizeZ"); + schematic = config.getString("schematic"); + offsetX = config.getInt("offsetX", 0); + offsetY = config.getInt("offsetY", 0); + offsetZ = config.getInt("offsetZ", 0); + extensionPositiveZ = config.getInt("extensionPositiveZ", 0); + extensionNegativeZ = config.getInt("extensionNegativeZ", 0); + extensionPositiveY = config.getInt("extensionPositiveY", 0); + extensionAxisX = config.getInt("extensionAxisX", 0); + if (config.contains("extensionPositiveZ") || config.contains("extensionNegativeZ") || config.contains("extensionPositiveY") || config.contains("extensionAxisX")) { + Region.extensionArea = true; + } + extensionPrototypeArea = extensionNegativeZ != 0 || extensionPositiveZ != 0 || extensionPositiveY != 0 || extensionAxisX != 0; + waterLevel = config.getInt("waterLevel", 0); + rotate = config.getBoolean("rotate", false); + + ConfigurationSection testblockSection = config.getConfigurationSection("testblock"); + testblock = testblockSection != null ? new Prototype(testblockSection) : null; + + ConfigurationSection buildAreaSection = config.getConfigurationSection("buildArea"); + buildArea = buildAreaSection != null ? new Prototype(buildAreaSection) : null; + if (buildArea != null) { + Region.buildArea = true; + } + + protectSchematic = config.getString("protection", null); + + if (!config.getName().equals("testblock") && !config.getName().equals("buildArea")) + prototypes.put(config.getName(), this); + } + + public Point getMinPoint(Region region, RegionExtensionType regionExtensionType) { + switch (regionExtensionType) { + case EXTENSION: + return new Point( + region.minPoint.getX() + offsetX - extensionAxisX, + region.minPoint.getY() + offsetY, + region.minPoint.getZ() + offsetZ - extensionNegativeZ + ); + default: + case NORMAL: + return new Point( + region.minPoint.getX() + offsetX, + region.minPoint.getY() + offsetY, + region.minPoint.getZ() + offsetZ + ); + } + } + + public Point getMaxPoint(Region region, RegionExtensionType regionExtensionType) { + switch (regionExtensionType) { + case EXTENSION: + return new Point( + region.minPoint.getX() + offsetX - extensionAxisX + (sizeX + extensionAxisX * 2), + region.minPoint.getY() + offsetY + sizeY + extensionPositiveY, + region.minPoint.getZ() + offsetZ - extensionNegativeZ + (sizeZ + extensionNegativeZ + extensionPositiveZ) + ); + default: + case NORMAL: + return new Point( + region.minPoint.getX() + offsetX + sizeX, + region.minPoint.getY() + offsetY + sizeY, + region.minPoint.getZ() + offsetZ + sizeZ + ); + } + } + + public boolean inRegion(Region region, Location l, RegionExtensionType regionExtensionType) { + switch (regionExtensionType) { + case EXTENSION: + return inRange(l.getX(), region.minPoint.getX() + offsetX - extensionAxisX, sizeX + extensionAxisX * 2) && + inRange(l.getY(), region.minPoint.getY() + offsetY, sizeY + extensionPositiveY) && + inRange(l.getZ(), region.minPoint.getZ() + offsetZ - extensionNegativeZ, sizeZ + extensionNegativeZ + extensionPositiveZ); + default: + case NORMAL: + return inRange(l.getX(), region.minPoint.getX() + offsetX, sizeX) && + inRange(l.getY(), region.minPoint.getY() + offsetY, sizeY) && + inRange(l.getZ(), region.minPoint.getZ() + offsetZ, sizeZ); + } + } + + public EditSession reset(Region region, Schematic schem) throws IOException, NoClipboardException { + int x = region.minPoint.getX() + offsetX + sizeX / 2; + int y = region.minPoint.getY() + offsetY; + int z = region.minPoint.getZ() + offsetZ + sizeZ / 2; + if (schem == null) + return paste(new File(schematic), x, y, z, rotate); + else + return paste(schem.load(), x, y, z, rotate); + } + + public boolean hasProtection() { + return protectSchematic != null; + } + + public EditSession protect(Region region, Schematic schem) throws IOException, NoClipboardException { + int x = region.minPoint.getX() + offsetX + sizeX / 2; + int y = region.minPoint.getY() + testblock.offsetY - 1; + int z = region.minPoint.getZ() + offsetZ + sizeZ / 2; + if (schem == null) + return paste(new File(protectSchematic), x, y, z, rotate); + else + return paste(schem.load(), x, y, z, rotate); + } + + public boolean hasTestblock() { + return testblock != null; + } + + public EditSession resetTestblock(Region region, Schematic schem) throws IOException, NoClipboardException { + return testblock.reset(region, schem); + } + + private static boolean inRange(double l, int min, int size) { + return min <= l && l < min + size; + } + + private static EditSession paste(File file, int x, int y, int z, boolean rotate) { //Type of protect + return (EditSession) VersionedCallable.call(new VersionedCallable(() -> Region_12.paste(file, x, y, z, rotate), 8), + new VersionedCallable(() -> Region_15.paste(file, x, y, z, rotate), 15)); + } + + private static EditSession paste(Clipboard clipboard, int x, int y, int z, boolean rotate) { + return (EditSession) VersionedCallable.call(new VersionedCallable(() -> Region_12.paste(clipboard, x, y, z, rotate), 8), + new VersionedCallable(() -> Region_15.paste(clipboard, x, y, z, rotate), 15)); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java new file mode 100644 index 0000000..3959bc5 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java @@ -0,0 +1,273 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.world.regions; + +import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.extent.clipboard.Clipboard; +import de.steamwar.bausystem.commands.CommandTNT.TNTMode; +import de.steamwar.bausystem.world.SizedStack; +import de.steamwar.core.VersionedCallable; +import de.steamwar.sql.NoClipboardException; +import de.steamwar.sql.Schematic; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.InvalidConfigurationException; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.io.IOException; +import java.util.*; +import java.util.function.Consumer; +import java.util.logging.Level; + +public class Region { + + private static final List regions = new ArrayList<>(); + static boolean buildArea = false; + static boolean extensionArea = false; + + static { + YamlConfiguration config = new YamlConfiguration(); + try { + config.load(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections.yml")); + } catch (InvalidConfigurationException | IOException e) { + Bukkit.getLogger().log(Level.SEVERE, "Failed to load sections.yml", e); + } + + ConfigurationSection prototypes = config.getConfigurationSection("prototypes"); + assert prototypes != null; + 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)) { + new Region(Objects.requireNonNull(regions.getConfigurationSection(region))); + } + } + + public static boolean buildAreaEnabled() { + return buildArea; + } + + public static boolean extensionAreaEnabled() { + return extensionArea; + } + + public static Region getRegion(Location location) { + for (Region region : regions) { + if (region.inRegion(location, RegionType.NORMAL, RegionExtensionType.NORMAL)) return region; + } + return GlobalRegion.getInstance(); + } + + private final String name; + final Point minPoint; + private final Prototype prototype; + private final String optionsLinkedWith; // nullable + private Region linkedRegion = null; // nullable + private SizedStack undosessions; + private SizedStack redosessions; + + private TNTMode tntMode = Region.buildAreaEnabled() ? TNTMode.ONLY_TB : TNTMode.OFF; + private boolean freeze = false; + private boolean fire = false; + + private Region(ConfigurationSection config) { + name = config.getName(); + minPoint = new Point(config.getInt("minX"), config.getInt("minY"), config.getInt("minZ")); + prototype = Prototype.prototypes.get(config.getString("prototype")); + optionsLinkedWith = config.getString("optionsLinkedWith", null); + if (!hasTestblock()) tntMode = TNTMode.OFF; + regions.add(this); + } + + public Region(String name) { + this.name = name; + this.minPoint = new Point(0, 0, 0); + this.prototype = null; + this.optionsLinkedWith = null; + tntMode = TNTMode.OFF; + } + + private void setLinkedRegion(Consumer regionConsumer) { + if (optionsLinkedWith == null) { + return; + } + if (linkedRegion != null) { + regionConsumer.accept(linkedRegion); + return; + } + for (Region region : regions) { + if (region.name.equals(name)) { + linkedRegion = region; + regionConsumer.accept(linkedRegion); + return; + } + } + } + + public TNTMode getTntMode() { + return tntMode; + } + + public void setTntMode(TNTMode tntMode) { + this.tntMode = tntMode; + setLinkedRegion(region -> region.tntMode = tntMode); + } + + public boolean isFreeze() { + return freeze; + } + + public void setFreeze(boolean freeze) { + this.freeze = freeze; + setLinkedRegion(region -> region.freeze = freeze); + } + + public boolean isFire() { + return fire; + } + + public void setFire(boolean fire) { + this.fire = fire; + setLinkedRegion(region -> region.fire = fire); + } + + public Point getMinPoint(RegionType regionType, RegionExtensionType regionExtensionType) { + switch (regionType) { + case BUILD_AREA: + return prototype.buildArea.getMinPoint(this, regionExtensionType); + case TESTBLOCK: + return prototype.testblock.getMinPoint(this, regionExtensionType); + default: + case NORMAL: + return prototype.getMinPoint(this, regionExtensionType); + } + } + + public Point getMaxPoint(RegionType regionType, RegionExtensionType regionExtensionType) { + switch (regionType) { + case BUILD_AREA: + return prototype.buildArea.getMaxPoint(this, regionExtensionType); + case TESTBLOCK: + return prototype.testblock.getMaxPoint(this, regionExtensionType); + default: + case NORMAL: + return prototype.getMaxPoint(this, regionExtensionType); + } + } + + public boolean inRegion(Location l, RegionType regionType, RegionExtensionType regionExtensionType) { + switch (regionType) { + case BUILD_AREA: + return prototype.buildArea.inRegion(this, l, regionExtensionType); + case TESTBLOCK: + return prototype.testblock.inRegion(this, l, regionExtensionType); + default: + case NORMAL: + return prototype.inRegion(this, l, regionExtensionType); + } + } + + public boolean hasBuildRegion() { + return prototype.buildArea != null; + } + + public void reset() throws IOException { + initSessions(); + undosessions.push(prototype.reset(this, null)); + } + + public void reset(Schematic schem) throws IOException, NoClipboardException { + initSessions(); + undosessions.push(prototype.reset(this, schem)); + } + + public boolean hasTestblock() { + return prototype.hasTestblock(); + } + + public void resetTestblock(Schematic schem) throws IOException, NoClipboardException { + initSessions(); + undosessions.push(prototype.resetTestblock(this, schem)); + } + + public boolean hasProtection() { + return prototype.hasProtection(); + } + + public void protect(Schematic schem) throws IOException, NoClipboardException { + initSessions(); + undosessions.push(prototype.protect(this, schem)); + } + + public boolean hasBuildAreaExtensionAreaRegistered() { + return prototype.buildArea.extensionPrototypeArea; + } + + public boolean hasTestblockExtensionAreaRegistered() { + return prototype.testblock.extensionPrototypeArea; + } + + private void initSessions() { + if(undosessions == null) { + undosessions = new SizedStack<>(20); + redosessions = new SizedStack<>(20); + } + } + + public boolean undo() { + initSessions(); + EditSession session = null; + try { + session = undosessions.pop(); + if(session == null) + return false; + session.undo(session); + redosessions.push(session); + return true; + } finally { + if (session != null) { + session.flushSession(); + } + } + } + + public boolean redo() { + initSessions(); + EditSession session = null; + try { + session = redosessions.pop(); + if(session == null) + return false; + session.redo(session); + undosessions.push(session); + return true; + } finally { + if (session != null) { + session.flushSession(); + } + } + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/RegionExtensionType.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/RegionExtensionType.java new file mode 100644 index 0000000..b2194e0 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/RegionExtensionType.java @@ -0,0 +1,25 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.world.regions; + +public enum RegionExtensionType { + NORMAL, + EXTENSION +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/RegionType.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/RegionType.java new file mode 100644 index 0000000..2b9fbaf --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/RegionType.java @@ -0,0 +1,26 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.world.regions; + +public enum RegionType { + NORMAL, + BUILD_AREA, + TESTBLOCK +} -- 2.39.5 From e90dda786b3e582707ae7e36f16a446805528001 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 3 Apr 2021 20:28:29 +0200 Subject: [PATCH 09/25] Update to new Code style --- .../bausystem/world/regions/Prototype.java | 10 ++++++---- .../bausystem/world/regions/Region.java | 20 +++++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java index 0c8a658..0ce643b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java @@ -147,10 +147,11 @@ public class Prototype { int x = region.minPoint.getX() + offsetX + sizeX / 2; int y = region.minPoint.getY() + offsetY; int z = region.minPoint.getZ() + offsetZ + sizeZ / 2; - if (schem == null) + if (schem == null) { return paste(new File(schematic), x, y, z, rotate); - else + } else { return paste(schem.load(), x, y, z, rotate); + } } public boolean hasProtection() { @@ -161,10 +162,11 @@ public class Prototype { int x = region.minPoint.getX() + offsetX + sizeX / 2; int y = region.minPoint.getY() + testblock.offsetY - 1; int z = region.minPoint.getZ() + offsetZ + sizeZ / 2; - if (schem == null) + if (schem == null) { return paste(new File(protectSchematic), x, y, z, rotate); - else + } else { return paste(schem.load(), x, y, z, rotate); + } } public boolean hasTestblock() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java index 3959bc5..e9aed03 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java @@ -20,10 +20,8 @@ package de.steamwar.bausystem.world.regions; import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.bausystem.commands.CommandTNT.TNTMode; import de.steamwar.bausystem.world.SizedStack; -import de.steamwar.core.VersionedCallable; import de.steamwar.sql.NoClipboardException; import de.steamwar.sql.Schematic; import org.bukkit.Bukkit; @@ -34,7 +32,9 @@ import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; import java.util.function.Consumer; import java.util.logging.Level; @@ -75,7 +75,9 @@ public class Region { public static Region getRegion(Location location) { for (Region region : regions) { - if (region.inRegion(location, RegionType.NORMAL, RegionExtensionType.NORMAL)) return region; + if (region.inRegion(location, RegionType.NORMAL, RegionExtensionType.NORMAL)) { + return region; + } } return GlobalRegion.getInstance(); } @@ -103,7 +105,7 @@ public class Region { public Region(String name) { this.name = name; - this.minPoint = new Point(0, 0, 0); + this.minPoint = new Point(0, 0, 0); this.prototype = null; this.optionsLinkedWith = null; tntMode = TNTMode.OFF; @@ -230,7 +232,7 @@ public class Region { } private void initSessions() { - if(undosessions == null) { + if (undosessions == null) { undosessions = new SizedStack<>(20); redosessions = new SizedStack<>(20); } @@ -241,8 +243,9 @@ public class Region { EditSession session = null; try { session = undosessions.pop(); - if(session == null) + if (session == null) { return false; + } session.undo(session); redosessions.push(session); return true; @@ -258,8 +261,9 @@ public class Region { EditSession session = null; try { session = redosessions.pop(); - if(session == null) + if (session == null) { return false; + } session.redo(session); undosessions.push(session); return true; -- 2.39.5 From d5f194656b7a17befaf5fdde5112fe81981452a9 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 3 Apr 2021 21:28:34 +0200 Subject: [PATCH 10/25] Fix RegionType.BUILD --- .../src/de/steamwar/bausystem/commands/CommandTNT.java | 4 ++-- .../src/de/steamwar/bausystem/world/regions/Region.java | 6 +++--- .../src/de/steamwar/bausystem/world/regions/RegionType.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java index 0e510cf..10c7d7e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java @@ -159,11 +159,11 @@ public class CommandTNT extends SWCommand implements Listener { event.blockList().removeIf(block -> { Region region = Region.getRegion(block.getLocation()); if (region.getTntMode() == TNTMode.ON) return false; - if (region.hasBuildRegion() && region.inRegion(block.getLocation(), RegionType.BUILD_AREA, RegionExtensionType.NORMAL)) { + if (region.hasBuildRegion() && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.NORMAL)) { RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Baubereich zerstört"); return true; } - if (region.hasBuildRegion() && region.inRegion(block.getLocation(), RegionType.BUILD_AREA, RegionExtensionType.EXTENSION)) { + if (region.hasBuildRegion() && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)) { RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Ausfahrbereich zerstört"); return true; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java index e9aed03..22e904d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java @@ -157,7 +157,7 @@ public class Region { public Point getMinPoint(RegionType regionType, RegionExtensionType regionExtensionType) { switch (regionType) { - case BUILD_AREA: + case BUILD: return prototype.buildArea.getMinPoint(this, regionExtensionType); case TESTBLOCK: return prototype.testblock.getMinPoint(this, regionExtensionType); @@ -169,7 +169,7 @@ public class Region { public Point getMaxPoint(RegionType regionType, RegionExtensionType regionExtensionType) { switch (regionType) { - case BUILD_AREA: + case BUILD: return prototype.buildArea.getMaxPoint(this, regionExtensionType); case TESTBLOCK: return prototype.testblock.getMaxPoint(this, regionExtensionType); @@ -181,7 +181,7 @@ public class Region { public boolean inRegion(Location l, RegionType regionType, RegionExtensionType regionExtensionType) { switch (regionType) { - case BUILD_AREA: + case BUILD: return prototype.buildArea.inRegion(this, l, regionExtensionType); case TESTBLOCK: return prototype.testblock.inRegion(this, l, regionExtensionType); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/RegionType.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/RegionType.java index 2b9fbaf..ac47eb9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/RegionType.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/RegionType.java @@ -21,6 +21,6 @@ package de.steamwar.bausystem.world.regions; public enum RegionType { NORMAL, - BUILD_AREA, + BUILD, TESTBLOCK } -- 2.39.5 From 61c7a5c7a66c45e48825bf5ff4a1771fafeebb7f Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 3 Apr 2021 22:16:09 +0200 Subject: [PATCH 11/25] Fix Region.hasExtensionArea --- .../bausystem/world/regions/GlobalRegion.java | 7 +------ .../steamwar/bausystem/world/regions/Region.java | 16 ++++++++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/GlobalRegion.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/GlobalRegion.java index e16d048..363284c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/GlobalRegion.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/GlobalRegion.java @@ -58,12 +58,7 @@ public class GlobalRegion extends Region { } @Override - public boolean hasBuildAreaExtensionAreaRegistered() { - return false; - } - - @Override - public boolean hasTestblockExtensionAreaRegistered() { + public boolean hasExtensionArea(RegionType regionType) { return false; } } \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java index 22e904d..fbd113a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java @@ -223,12 +223,16 @@ public class Region { undosessions.push(prototype.protect(this, schem)); } - public boolean hasBuildAreaExtensionAreaRegistered() { - return prototype.buildArea.extensionPrototypeArea; - } - - public boolean hasTestblockExtensionAreaRegistered() { - return prototype.testblock.extensionPrototypeArea; + public boolean hasExtensionArea(RegionType regionType) { + switch (regionType) { + case BUILD: + return prototype.buildArea.extensionPrototypeArea; + case TESTBLOCK: + return prototype.testblock.extensionPrototypeArea; + default: + case NORMAL: + return prototype.extensionPrototypeArea; + } } private void initSessions() { -- 2.39.5 From db3e3a7cbc8288bdd4a1c7b13c6f8bc27869d722 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Sat, 3 Apr 2021 22:16:19 +0200 Subject: [PATCH 12/25] converted enums to upper case added CommandSelect --- .../src/de/steamwar/bausystem/Permission.java | 8 +- .../bausystem/commands/CommandClear.java | 2 +- .../bausystem/commands/CommandDebugStick.java | 2 +- .../bausystem/commands/CommandDetonator.java | 2 +- .../bausystem/commands/CommandFire.java | 2 +- .../bausystem/commands/CommandFreeze.java | 2 +- .../bausystem/commands/CommandGUI.java | 70 +++++------ .../bausystem/commands/CommandLoader.java | 2 +- .../commands/CommandRedstoneTester.java | 2 +- .../bausystem/commands/CommandReset.java | 2 +- .../bausystem/commands/CommandSelect.java | 110 ++++++++++++++++++ .../bausystem/commands/CommandSimulator.java | 2 +- .../bausystem/commands/CommandTNT.java | 2 +- .../bausystem/commands/CommandTPSLimiter.java | 2 +- .../bausystem/commands/CommandTime.java | 4 +- .../bausystem/commands/CommandTrace.java | 2 +- .../bausystem/world/DetonatorListener.java | 2 +- .../bausystem/world/RedstoneListener.java | 2 +- .../bausystem/world/RegionListener.java | 6 +- .../bausystem/world/TNTSimulatorListener.java | 2 +- .../src/de/steamwar/bausystem/world/Welt.java | 6 +- 21 files changed, 172 insertions(+), 62 deletions(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java index c776150..3bacfea 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java @@ -20,8 +20,8 @@ package de.steamwar.bausystem; public enum Permission { - world, - worldedit, - build, - member + WORLD, + WORLDEDIT, + BUILD, + MEMBER } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java index 81225a8..d1c60e4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java @@ -54,7 +54,7 @@ public class CommandClear extends SWCommand { } private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + "$cDu darfst hier keine fremden Inventare leeren."); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java index 604122f..c6da6b5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java @@ -39,7 +39,7 @@ public class CommandDebugStick extends SWCommand { @Register public void genericCommand(Player p) { - if (Welt.noPermission(p, Permission.build)) { + if (Welt.noPermission(p, Permission.BUILD)) { p.sendMessage(BauSystem.PREFIX + "§cKein Debugstick für dich hier."); } else { VersionedRunnable.call(new VersionedRunnable(() -> p.sendMessage(BauSystem.PREFIX + "§cDen Debugstick gibt es nicht in der 1.12."), 8), diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java index 226e498..28b91c0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDetonator.java @@ -105,7 +105,7 @@ public class CommandDetonator extends SWCommand { } private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Detonator nutzen"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java index 8295088..56b4862 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFire.java @@ -72,7 +72,7 @@ public class CommandFire extends SWCommand implements Listener { } private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + getNoPermMessage()); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java index 2531ccd..a3460ed 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java @@ -77,7 +77,7 @@ public class CommandFreeze extends SWCommand implements Listener { } private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + getNoPermMessage()); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java index 69a51fc..f73270a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java @@ -97,45 +97,45 @@ public class CommandGUI extends SWCommand implements Listener { player.performCommand("gui item"); }); - ItemStack dtWand = wand(player, Detonator.WAND, "§8/§7dt wand", Permission.world, "§cDu hast keine Worldrechte"); + ItemStack dtWand = wand(player, Detonator.WAND, "§8/§7dt wand", Permission.WORLD, "§cDu hast keine Worldrechte"); inv.setItem(39, dtWand, clickType -> { - if (Welt.noPermission(player, Permission.world)) + if (Welt.noPermission(player, Permission.WORLD)) return; player.closeInventory(); player.performCommand("dt wand"); }); - ItemStack simWand = wand(player, TNTSimulator.WAND, "§8/§7sim wand", Permission.world, "§cDu hast keine Worldrechte"); + ItemStack simWand = wand(player, TNTSimulator.WAND, "§8/§7sim wand", Permission.WORLD, "§cDu hast keine Worldrechte"); inv.setItem(38, simWand, clickType -> { - if (Welt.noPermission(player, Permission.world)) + if (Welt.noPermission(player, Permission.WORLD)) return; player.closeInventory(); player.performCommand("sim wand"); }); - ItemStack redstoneWand = wand(player, RedstoneListener.WAND, "§8/§7redstonetester", Permission.build, "Du hast keine Buildrechte"); + ItemStack redstoneWand = wand(player, RedstoneListener.WAND, "§8/§7redstonetester", Permission.BUILD, "Du hast keine Buildrechte"); inv.setItem(37, redstoneWand, clickType -> { - if (Welt.noPermission(player, Permission.build)) + if (Welt.noPermission(player, Permission.BUILD)) return; player.closeInventory(); player.performCommand("redstonetester"); }); inv.setItem(40, getMaterial("WOODEN_AXE", "WOOD_AXE"), "§eWorldedit Axt", getNoPermsLore(Arrays.asList("§8//§7wand"), player, "§cDu hast keine Worldeditrechte", Permission.worldedit), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + if (Welt.noPermission(player, Permission.WORLD)) return; player.closeInventory(); player.performCommand("/wand"); }); - inv.setItem(41, getMaterial("DEBUG_STICK", "STICK"), "§eDebugstick", getNoPermsLore(Arrays.asList("§8/§7debugstick"), player, "§cDu hast keine Worldrechte", Permission.world), Core.getVersion() < 13, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(41, getMaterial("DEBUG_STICK", "STICK"), "§eDebugstick", getNoPermsLore(Arrays.asList("§8/§7debugstick"), player, "§cDu hast keine Worldrechte", Permission.WORLD), Core.getVersion() < 13, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.closeInventory(); player.performCommand("debugstick"); }); - inv.setItem(20, Material.COMPASS, "§7TPS Limitieren", getNoPermsLore(Arrays.asList("§7Aktuell: §e" + CommandTPSLimiter.getCurrentTPSLimit(), "§8/§7tpslimit §8[§e0,5 - " + (TPSUtils.isWarpAllowed() ? 40 : 20) + "§8]"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(20, Material.COMPASS, "§7TPS Limitieren", getNoPermsLore(Arrays.asList("§7Aktuell: §e" + CommandTPSLimiter.getCurrentTPSLimit(), "§8/§7tpslimit §8[§e0,5 - " + (TPSUtils.isWarpAllowed() ? 40 : 20) + "§8]"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; SWAnvilInv anvilInv = new SWAnvilInv(player, "TPS Limitieren"); anvilInv.setItem(Material.COMPASS); @@ -170,16 +170,16 @@ public class CommandGUI extends SWCommand implements Listener { scriptBooksGUI(player); }); - inv.setItem(21, Material.OBSERVER, "§7Tracer", getNoPermsLore(Arrays.asList("§7Status: §e" + RecordStateMachine.getRecordStatus().getName()), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(21, Material.OBSERVER, "§7Tracer", getNoPermsLore(Arrays.asList("§7Status: §e" + RecordStateMachine.getRecordStatus().getName()), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.closeInventory(); OPEN_TRACER_INVS.add(player); traceGUI(player); }); - inv.setItem(22, Material.DISPENSER, "§7Auto-Loader", getNoPermsLore(Arrays.asList("§7Status: " + (AutoLoader.hasLoader(player) ? "§aan" : "§caus")), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(22, Material.DISPENSER, "§7Auto-Loader", getNoPermsLore(Arrays.asList("§7Status: " + (AutoLoader.hasLoader(player) ? "§aan" : "§caus")), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.closeInventory(); autoLoaderGUI(player); @@ -200,15 +200,15 @@ public class CommandGUI extends SWCommand implements Listener { inv.setItem(27, Material.BARRIER, "§eKeine Region", clickType -> { }); } else { - inv.setItem(27, getMaterial("HEAVY_WEIGHTED_PRESSURE_PLATE", "IRON_PLATE"), "§eRegion Reseten", getNoPermsLore(Arrays.asList("§8/§7reset"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(27, getMaterial("HEAVY_WEIGHTED_PRESSURE_PLATE", "IRON_PLATE"), "§eRegion Reseten", getNoPermsLore(Arrays.asList("§8/§7reset"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; confirmationInventory(player, "Region Reseten?", () -> player.performCommand("reset"), () -> openBauGui(player)); }); if (region.hasProtection()) { - inv.setItem(18, Material.OBSIDIAN, "§eRegion Protecten", getNoPermsLore(Arrays.asList("§8/§7protect"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(18, Material.OBSIDIAN, "§eRegion Protecten", getNoPermsLore(Arrays.asList("§8/§7protect"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; confirmationInventory(player, "Region Protecten", () -> player.performCommand("protect"), () -> openBauGui(player)); }); @@ -218,8 +218,8 @@ public class CommandGUI extends SWCommand implements Listener { } if (region.hasTestblock()) { - inv.setItem(9, getMaterial("END_STONE", "ENDER_STONE"), "§eTestblock erneuern", getNoPermsLore(Arrays.asList("§8/§7testblock"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(9, getMaterial("END_STONE", "ENDER_STONE"), "§eTestblock erneuern", getNoPermsLore(Arrays.asList("§8/§7testblock"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; confirmationInventory(player, "Testblock erneuern", () -> player.performCommand("testblock"), () -> openBauGui(player)); }); @@ -254,11 +254,11 @@ public class CommandGUI extends SWCommand implements Listener { } boolean isBuildArea = region.hasBuildRegion(); - List tntLore = getNoPermsLore(Arrays.asList("§8/§7tnt §8[" + (isBuildArea ? "§eTB§7, " : "") + "§eOff §7oder §eOn§7]"), player, "§cDu hast keine Worldrechte", Permission.world); + List tntLore = getNoPermsLore(Arrays.asList("§8/§7tnt §8[" + (isBuildArea ? "§eTB§7, " : "") + "§eOff §7oder §eOn§7]"), player, "§cDu hast keine Worldrechte", Permission.WORLD); switch (region.getTntMode()) { case OFF: inv.setItem(23, Material.MINECART, "§7TNT: §eAusgeschaltet", tntLore, false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("tnt " + (isBuildArea ? "tb" : "on")); updateInventories(); @@ -266,7 +266,7 @@ public class CommandGUI extends SWCommand implements Listener { break; case ONLY_TB: inv.setItem(23, getMaterial("TNT_MINECART", "EXPLOSIVE_MINECART"), "§7TNT: §enur Testblock", tntLore, false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("tnt on"); updateInventories(); @@ -274,7 +274,7 @@ public class CommandGUI extends SWCommand implements Listener { break; default: inv.setItem(23, Material.TNT, "§7TNT: §eEingeschaltet", tntLore, false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("tnt off"); updateInventories(); @@ -282,15 +282,15 @@ public class CommandGUI extends SWCommand implements Listener { } if (region.isFreeze()) { - inv.setItem(24, getMaterial("GUNPOWDER", "SULPHUR"), "§7Freeze: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(24, getMaterial("GUNPOWDER", "SULPHUR"), "§7Freeze: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("freeze"); updateInventories(); }); } else { - inv.setItem(24, Material.REDSTONE, "§7Freeze: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(24, Material.REDSTONE, "§7Freeze: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("freeze"); updateInventories(); @@ -298,23 +298,23 @@ public class CommandGUI extends SWCommand implements Listener { } if (region.isFire()) { - inv.setItem(3, getMaterial("FIREWORK_STAR", "FIREWORK_CHARGE"), "§7Fire: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(3, getMaterial("FIREWORK_STAR", "FIREWORK_CHARGE"), "§7Fire: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("fire"); updateInventories(); }); } else { - inv.setItem(3, getMaterial("FIRE_CHARGE", "FIREBALL"), "§7Fire: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(3, getMaterial("FIRE_CHARGE", "FIREBALL"), "§7Fire: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("fire"); updateInventories(); }); } - inv.setItem(2, Material.ENDER_PEARL, "§7Teleporter", getNoPermsLore(Arrays.asList("§8/§7tp §8[§eSpieler§8]"), player, "§cDu hast keine Buildrechte", Permission.build), false, clickType -> { - if (Welt.noPermission(player, Permission.build)) + inv.setItem(2, Material.ENDER_PEARL, "§7Teleporter", getNoPermsLore(Arrays.asList("§8/§7tp §8[§eSpieler§8]"), player, "§cDu hast keine Buildrechte", Permission.BUILD), false, clickType -> { + if (Welt.noPermission(player, Permission.BUILD)) return; List> playerSWListEntry = new ArrayList<>(); Bukkit.getOnlinePlayers().forEach(player1 -> { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java index fb3f5d6..da8dcdf 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandLoader.java @@ -80,7 +80,7 @@ public class CommandLoader extends SWCommand { } private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.build)) { + if (Welt.noPermission(player, Permission.BUILD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den AutoLader verwenden"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java index 3038690..c22df9b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRedstoneTester.java @@ -52,7 +52,7 @@ public class CommandRedstoneTester extends SWCommand { private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.build)) { + if (Welt.noPermission(player, Permission.BUILD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Redstonetester nutzen"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java index 0847c11..cc61dd3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java @@ -78,7 +78,7 @@ public class CommandReset extends SWCommand { } private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Region zurücksetzen"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java new file mode 100644 index 0000000..f10761f --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java @@ -0,0 +1,110 @@ +package de.steamwar.bausystem.commands; + +import com.sk89q.worldedit.bukkit.BukkitWorld; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; +import com.sk89q.worldedit.world.World; +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.world.Welt; +import de.steamwar.bausystem.world.regions.*; +import de.steamwar.command.SWCommand; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + + +public class CommandSelect extends SWCommand { + + + public static final WorldEditPlugin WORLDEDIT_PLUGIN = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")); + public static final World BUKKITWORLD = new BukkitWorld(Bukkit.getWorlds().get(0)); + + public CommandSelect() { + super("select"); + } + + + @Register + public void baurahmenCommand(Player p, RegionType regionType) { + if (!permissionCheck(p)) { + return; + } + + Region region = Region.getRegion(p.getLocation()); + + if (GlobalRegion.isGlobalRegion(region)) { + //TODO + return; + } + + if (regionType == RegionType.TESTBLOCK) { + if (!region.hasTestblock()) { + //TODO motz den user an + return; + } + setSelection(regionType, RegionExtensionType.NORMAL, region, p); + return; + } + + if (regionType == RegionType.BUILD) { + if (!region.hasBuildRegion()) { + //TODO motz den user an + return; + } + setSelection(regionType, RegionExtensionType.NORMAL, region, p); + return; + } + + setSelection(regionType, RegionExtensionType.NORMAL, region, p); + } + + @Register + public void baurahmenCommand(Player p, RegionType regionType, RegionExtensionType regionExtensionType) { + if (!permissionCheck(p)) { + return; + } + + Region region = Region.getRegion(p.getLocation()); + + if (GlobalRegion.isGlobalRegion(region)) { + //TODO + return; + } + + if (regionType == RegionType.TESTBLOCK) { + if (!region.hasTestblock() || !region.hasTestblockExtensionAreaRegistered()) { + //TODO motz den user an + return; + } + setSelection(regionType, regionExtensionType, region, p); + return; + } + + if (regionType == RegionType.BUILD) { + if (!region.hasBuildRegion() || !region.hasBuildAreaExtensionAreaRegistered()) { + //TODO motz den user an + return; + } + setSelection(regionType, regionExtensionType, region, p); + return; + } + + setSelection(regionType, regionExtensionType, region, p); + } + + + private boolean permissionCheck(Player player) { + if (Welt.noPermission(player, Permission.WORLDEDIT)) { + player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den AutoLader verwenden"); + return false; + } + return true; + } + + private void setSelection(RegionType regionType, RegionExtensionType regionExtensionType, Region region, Player p) { + Point minPoint = region.getMinPoint(regionType, regionExtensionType); + Point maxPoint = region.getMaxPoint(regionType, regionExtensionType); + + WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, minPoint.toBlockVector3(), maxPoint.toBlockVector3())); + } +} \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulator.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulator.java index 10e603d..17947a5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSimulator.java @@ -67,7 +67,7 @@ public class CommandSimulator extends SWCommand { } private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Simulator nutzen"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java index 10c7d7e..a96daf3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java @@ -96,7 +96,7 @@ public class CommandTNT extends SWCommand implements Listener { } private boolean permissionCheck(Player p) { - if (Welt.noPermission(p, Permission.world)) { + if (Welt.noPermission(p, Permission.WORLD)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht TNT-Schaden (de-)aktivieren"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index 35101f5..9f4e904 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -105,7 +105,7 @@ public class CommandTPSLimiter extends SWCommand { } private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TPS-Limiter nutzen"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java index ce07c8a..8a23105 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTime.java @@ -45,7 +45,7 @@ public class CommandTime extends SWCommand { @Register public void genericCommand(Player p, int time) { - if (Welt.noPermission(p, Permission.world)) { + if (Welt.noPermission(p, Permission.WORLD)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern"); return; } @@ -58,7 +58,7 @@ public class CommandTime extends SWCommand { @Register public void genericCommand(Player p, Time time) { - if (Welt.noPermission(p, Permission.world)) { + if (Welt.noPermission(p, Permission.WORLD)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern"); return; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java index beb45b8..d1c9e2f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java @@ -123,7 +123,7 @@ public class CommandTrace extends SWCommand { private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/DetonatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/DetonatorListener.java index dced125..c044144 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/DetonatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/DetonatorListener.java @@ -21,7 +21,7 @@ public class DetonatorListener implements Listener { if (VersionedCallable.call(new VersionedCallable<>(() -> event.getItem().isSimilar(Detonator.WAND), 12), new VersionedCallable<>(() -> event.getItem().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE), 15))) { Player player = event.getPlayer(); - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Detonator nutzen"); return; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java index 1fd82b3..5454ed2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java @@ -49,7 +49,7 @@ public class RedstoneListener implements Listener { private static Map playerMap = new HashMap<>(); private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.build)) { + if (Welt.noPermission(player, Permission.BUILD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Redstonetester nutzen"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java index b562a9f..1b05bdc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java @@ -63,7 +63,7 @@ public class RegionListener implements Listener { public void onBlockBreak(BlockBreakEvent e) { Player p = e.getPlayer(); - if (Welt.noPermission(p, Permission.build)) { + if (Welt.noPermission(p, Permission.BUILD)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke abbauen"); e.setCancelled(true); } @@ -75,7 +75,7 @@ public class RegionListener implements Listener { Player p = e.getPlayer(); try { - if (Welt.noPermission(p, Permission.build)) { + if (Welt.noPermission(p, Permission.BUILD)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren"); e.setBuildable(false); } @@ -90,7 +90,7 @@ public class RegionListener implements Listener { Player p = e.getPlayer(); try { - if (Welt.noPermission(p, Permission.build)) { + if (Welt.noPermission(p, Permission.BUILD)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren"); e.setCancelled(true); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulatorListener.java index e0af211..0a722ce 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulatorListener.java @@ -37,7 +37,7 @@ public class TNTSimulatorListener implements Listener { private static final Vector HALF = new Vector(0.5, 0, 0.5); private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.world)) { + if (Welt.noPermission(player, Permission.WORLD)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Simulator nutzen"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java index 7b733ba..e9e40ec 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java @@ -40,13 +40,13 @@ public class Welt { return true; switch (perm) { - case build: + case BUILD: return !member1.isBuild(); case worldedit: return !member1.isWorldEdit(); - case world: + case WORLD: return !member1.isWorld(); - case member: + case MEMBER: return false; default: return true; -- 2.39.5 From 00b350be63212b68f80293a6a41e71977e7167bd Mon Sep 17 00:00:00 2001 From: Zeanon Date: Sat, 3 Apr 2021 22:17:42 +0200 Subject: [PATCH 13/25] updated because Yoyo renamed methods --- .../src/de/steamwar/bausystem/commands/CommandSelect.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java index f10761f..7f00202 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java @@ -72,7 +72,7 @@ public class CommandSelect extends SWCommand { } if (regionType == RegionType.TESTBLOCK) { - if (!region.hasTestblock() || !region.hasTestblockExtensionAreaRegistered()) { + if (!region.hasTestblock() || !region.hasExtensionArea(regionType)) { //TODO motz den user an return; } @@ -81,7 +81,7 @@ public class CommandSelect extends SWCommand { } if (regionType == RegionType.BUILD) { - if (!region.hasBuildRegion() || !region.hasBuildAreaExtensionAreaRegistered()) { + if (!region.hasBuildRegion() || !region.hasExtensionArea(regionType)) { //TODO motz den user an return; } -- 2.39.5 From b23c112a7d9528034c8424ffea3311fd413edd1e Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 3 Apr 2021 22:25:57 +0200 Subject: [PATCH 14/25] Finish CommandSelect --- .../src/de/steamwar/bausystem/BauSystem.java | 1 + .../bausystem/commands/CommandGUI.java | 2 +- .../bausystem/commands/CommandProtect.java | 2 +- .../bausystem/commands/CommandRegion.java | 2 +- .../bausystem/commands/CommandSelect.java | 33 +++++++++++++------ .../bausystem/commands/CommandTestblock.java | 2 +- .../bausystem/world/RegionListener.java | 2 +- .../src/de/steamwar/bausystem/world/Welt.java | 2 +- 8 files changed, 30 insertions(+), 16 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 337ea4a..ca34723 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -93,6 +93,7 @@ public class BauSystem extends JavaPlugin implements Listener { new CommandGUI(); new CommandWorldSpawn(); new CommandRegion(); + new CommandSelect(); Bukkit.getPluginManager().registerEvents(this, this); Bukkit.getPluginManager().registerEvents(new RegionListener(), this); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java index f73270a..a562cf0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java @@ -121,7 +121,7 @@ public class CommandGUI extends SWCommand implements Listener { player.performCommand("redstonetester"); }); - inv.setItem(40, getMaterial("WOODEN_AXE", "WOOD_AXE"), "§eWorldedit Axt", getNoPermsLore(Arrays.asList("§8//§7wand"), player, "§cDu hast keine Worldeditrechte", Permission.worldedit), false, clickType -> { + inv.setItem(40, getMaterial("WOODEN_AXE", "WOOD_AXE"), "§eWorldedit Axt", getNoPermsLore(Arrays.asList("§8//§7wand"), player, "§cDu hast keine Worldeditrechte", Permission.WORLDEDIT), false, clickType -> { if (Welt.noPermission(player, Permission.WORLD)) return; player.closeInventory(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java index 65c602f..2de12c4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java @@ -77,7 +77,7 @@ public class CommandProtect extends SWCommand { } private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.worldedit)) { + if (Welt.noPermission(player, Permission.WORLDEDIT)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Boden schützen"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java index bb28fc8..adbd242 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java @@ -60,7 +60,7 @@ public class CommandRegion extends SWCommand { } private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.worldedit)) { + if (Welt.noPermission(player, Permission.WORLDEDIT)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Region verändern"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java index 7f00202..007bdf0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java @@ -15,7 +15,6 @@ import org.bukkit.entity.Player; public class CommandSelect extends SWCommand { - public static final WorldEditPlugin WORLDEDIT_PLUGIN = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")); public static final World BUKKITWORLD = new BukkitWorld(Bukkit.getWorlds().get(0)); @@ -23,6 +22,11 @@ public class CommandSelect extends SWCommand { super("select"); } + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage("§8/§eselect §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp aus"); + p.sendMessage("§8/§eselect §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Wähle einen RegionsTyp aus mit oder ohne Extension"); + } @Register public void baurahmenCommand(Player p, RegionType regionType) { @@ -33,13 +37,13 @@ public class CommandSelect extends SWCommand { Region region = Region.getRegion(p.getLocation()); if (GlobalRegion.isGlobalRegion(region)) { - //TODO + p.sendMessage(BauSystem.PREFIX + "§cDie globale Region kannst du nicht auswählen"); return; } if (regionType == RegionType.TESTBLOCK) { if (!region.hasTestblock()) { - //TODO motz den user an + p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen Testblock"); return; } setSelection(regionType, RegionExtensionType.NORMAL, region, p); @@ -48,7 +52,7 @@ public class CommandSelect extends SWCommand { if (regionType == RegionType.BUILD) { if (!region.hasBuildRegion()) { - //TODO motz den user an + p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen BuildArea"); return; } setSelection(regionType, RegionExtensionType.NORMAL, region, p); @@ -67,13 +71,17 @@ public class CommandSelect extends SWCommand { Region region = Region.getRegion(p.getLocation()); if (GlobalRegion.isGlobalRegion(region)) { - //TODO + p.sendMessage(BauSystem.PREFIX + "§cDie globale Region kannst du nicht auswählen"); return; } if (regionType == RegionType.TESTBLOCK) { - if (!region.hasTestblock() || !region.hasExtensionArea(regionType)) { - //TODO motz den user an + if (!region.hasTestblock()) { + p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen Testblock"); + return; + } + if (regionExtensionType == RegionExtensionType.EXTENSION && !region.hasExtensionArea(regionType)) { + p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keine Ausfahrmaße"); return; } setSelection(regionType, regionExtensionType, region, p); @@ -81,8 +89,12 @@ public class CommandSelect extends SWCommand { } if (regionType == RegionType.BUILD) { - if (!region.hasBuildRegion() || !region.hasExtensionArea(regionType)) { - //TODO motz den user an + if (!region.hasBuildRegion()) { + p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen BuildArea"); + return; + } + if (regionExtensionType == RegionExtensionType.EXTENSION && !region.hasExtensionArea(regionType)) { + p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keine Ausfahrmaße"); return; } setSelection(regionType, regionExtensionType, region, p); @@ -95,7 +107,7 @@ public class CommandSelect extends SWCommand { private boolean permissionCheck(Player player) { if (Welt.noPermission(player, Permission.WORLDEDIT)) { - player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den AutoLader verwenden"); + player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Select verwenden"); return false; } return true; @@ -106,5 +118,6 @@ public class CommandSelect extends SWCommand { Point maxPoint = region.getMaxPoint(regionType, regionExtensionType); WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, minPoint.toBlockVector3(), maxPoint.toBlockVector3())); + p.sendMessage(BauSystem.PREFIX + "WorldEdit auswahl auf von " + minPoint.getX() + ", " + minPoint.getY() + ", " + minPoint.getZ() + " bis " + maxPoint.getX() + ", " + maxPoint.getY() + ", " + maxPoint.getZ() + " gesetzt"); } } \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java index bcc9a00..45cc490 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java @@ -77,7 +77,7 @@ public class CommandTestblock extends SWCommand { } private boolean permissionCheck(Player player) { - if (Welt.noPermission(player, Permission.worldedit)) { + if (Welt.noPermission(player, Permission.WORLDEDIT)) { player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Testblock zurücksetzen"); return false; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java index 1b05bdc..5ac6b2f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java @@ -53,7 +53,7 @@ public class RegionListener implements Listener { Player p = e.getPlayer(); - if (Welt.noPermission(p, Permission.worldedit)) { + if (Welt.noPermission(p, Permission.WORLDEDIT)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier kein WorldEdit benutzen"); e.setCancelled(true); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java index e9e40ec..4ffdbaa 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java @@ -42,7 +42,7 @@ public class Welt { switch (perm) { case BUILD: return !member1.isBuild(); - case worldedit: + case WORLDEDIT: return !member1.isWorldEdit(); case WORLD: return !member1.isWorld(); -- 2.39.5 From 840016ec44e0a25f18a8f67818c7a647adaff793 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 3 Apr 2021 22:33:38 +0200 Subject: [PATCH 15/25] Add CommandSelect.instance --- .../src/de/steamwar/bausystem/commands/CommandSelect.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java index 007bdf0..7771b20 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java @@ -9,12 +9,16 @@ import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.Welt; import de.steamwar.bausystem.world.regions.*; import de.steamwar.command.SWCommand; +import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.entity.Player; public class CommandSelect extends SWCommand { + @Getter + private static CommandSelect instance = null; + public static final WorldEditPlugin WORLDEDIT_PLUGIN = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")); public static final World BUKKITWORLD = new BukkitWorld(Bukkit.getWorlds().get(0)); @@ -22,6 +26,10 @@ public class CommandSelect extends SWCommand { super("select"); } + { + instance = this; + } + @Register(help = true) public void genericHelp(Player p, String... args) { p.sendMessage("§8/§eselect §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp aus"); -- 2.39.5 From ab7471a028580b983545e4a18e5a8d5d2c18e5b1 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 3 Apr 2021 22:36:23 +0200 Subject: [PATCH 16/25] Update Formatting --- .../steamwar/bausystem/commands/CommandRegion.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java index adbd242..2f221f6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java @@ -2,9 +2,9 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.world.Welt; import de.steamwar.bausystem.world.regions.GlobalRegion; import de.steamwar.bausystem.world.regions.Region; -import de.steamwar.bausystem.world.Welt; import de.steamwar.command.SWCommand; import org.bukkit.entity.Player; @@ -27,20 +27,20 @@ public class CommandRegion extends SWCommand { @Register public void undoCommand(Player p, Action action) { - if(!permissionCheck(p)) return; + if (!permissionCheck(p)) return; Region region = Region.getRegion(p.getLocation()); - if(checkGlobalRegion(region, p)) return; + if (checkGlobalRegion(region, p)) return; switch (action) { case UNDO: - if(region.undo()) { + if (region.undo()) { p.sendMessage(BauSystem.PREFIX + "Letzte Aktion rückgangig gemacht"); } else { p.sendMessage(BauSystem.PREFIX + "§cNichts zum rückgängig machen"); } break; case REDO: - if(region.redo()) { + if (region.redo()) { p.sendMessage(BauSystem.PREFIX + "Letzte Aktion wiederhohlt"); } else { p.sendMessage(BauSystem.PREFIX + "§cNichts zum wiederhohlen"); @@ -52,7 +52,7 @@ public class CommandRegion extends SWCommand { } static boolean checkGlobalRegion(Region region, Player p) { - if(GlobalRegion.isGlobalRegion(region)) { + if (GlobalRegion.isGlobalRegion(region)) { p.sendMessage(BauSystem.PREFIX + "§cDu bist in keiner Region"); return true; } -- 2.39.5 From 0a821936c66dc3b212cc1e0f00984b34e7ada07c Mon Sep 17 00:00:00 2001 From: Zeanon Date: Sat, 3 Apr 2021 22:39:49 +0200 Subject: [PATCH 17/25] updated because Yoyo renamed methods --- .../bausystem/commands/CommandRegion.java | 67 ++++++++++++------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java index 2f221f6..cfbd865 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java @@ -5,9 +5,12 @@ import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.Welt; import de.steamwar.bausystem.world.regions.GlobalRegion; import de.steamwar.bausystem.world.regions.Region; +import de.steamwar.bausystem.world.regions.RegionExtensionType; +import de.steamwar.bausystem.world.regions.RegionType; import de.steamwar.command.SWCommand; import org.bukkit.entity.Player; + public class CommandRegion extends SWCommand { public CommandRegion() { @@ -25,30 +28,48 @@ public class CommandRegion extends SWCommand { player.sendMessage(BauSystem.PREFIX + "§8/§7region redo §8- §7Wiederhohle die letzten 10 §8/§7rg undo"); } - @Register - public void undoCommand(Player p, Action action) { - if (!permissionCheck(p)) return; - Region region = Region.getRegion(p.getLocation()); - if (checkGlobalRegion(region, p)) return; - - switch (action) { - case UNDO: - if (region.undo()) { - p.sendMessage(BauSystem.PREFIX + "Letzte Aktion rückgangig gemacht"); - } else { - p.sendMessage(BauSystem.PREFIX + "§cNichts zum rückgängig machen"); - } - break; - case REDO: - if (region.redo()) { - p.sendMessage(BauSystem.PREFIX + "Letzte Aktion wiederhohlt"); - } else { - p.sendMessage(BauSystem.PREFIX + "§cNichts zum wiederhohlen"); - } - break; - default: - genericHelp(p); + @Register("undo") + public void undoCommand(Player p) { + if (!permissionCheck(p)) { + return; } + Region region = Region.getRegion(p.getLocation()); + if (checkGlobalRegion(region, p)) { + return; + } + + if (region.undo()) { + p.sendMessage(BauSystem.PREFIX + "Letzte Aktion rückgangig gemacht"); + } else { + p.sendMessage(BauSystem.PREFIX + "§cNichts zum rückgängig machen"); + } + } + + @Register("redo") + public void redoCommand(Player p) { + if (!permissionCheck(p)) { + return; + } + Region region = Region.getRegion(p.getLocation()); + if (checkGlobalRegion(region, p)) { + return; + } + + if (region.redo()) { + p.sendMessage(BauSystem.PREFIX + "Letzte Aktion wiederhohlt"); + } else { + p.sendMessage(BauSystem.PREFIX + "§cNichts zum wiederhohlen"); + } + } + + @Register + public void baurahmenCommand(Player p, RegionType regionType) { + CommandSelect.getInstance().baurahmenCommand(p, regionType, RegionExtensionType.NORMAL); + } + + @Register + public void baurahmenCommand(Player p, RegionType regionType, RegionExtensionType regionExtensionType) { + CommandSelect.getInstance().baurahmenCommand(p, regionType, regionExtensionType); } static boolean checkGlobalRegion(Region region, Player p) { -- 2.39.5 From d2824852556006a96c19d53528d6dddd5c97edc7 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 3 Apr 2021 22:40:24 +0200 Subject: [PATCH 18/25] Change Success message --- .../src/de/steamwar/bausystem/commands/CommandSelect.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java index 7771b20..1cb693c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java @@ -126,6 +126,6 @@ public class CommandSelect extends SWCommand { Point maxPoint = region.getMaxPoint(regionType, regionExtensionType); WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, minPoint.toBlockVector3(), maxPoint.toBlockVector3())); - p.sendMessage(BauSystem.PREFIX + "WorldEdit auswahl auf von " + minPoint.getX() + ", " + minPoint.getY() + ", " + minPoint.getZ() + " bis " + maxPoint.getX() + ", " + maxPoint.getY() + ", " + maxPoint.getZ() + " gesetzt"); + p.sendMessage(BauSystem.PREFIX + "WorldEdit auswahl auf " + minPoint.getX() + ", " + minPoint.getY() + ", " + minPoint.getZ() + " und " + maxPoint.getX() + ", " + maxPoint.getY() + ", " + maxPoint.getZ() + " gesetzt"); } } \ No newline at end of file -- 2.39.5 From a55499d0310decc54bd249d197f4ebe1c4ce6d80 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Sat, 3 Apr 2021 22:50:14 +0200 Subject: [PATCH 19/25] hopefully fixed region points --- .../steamwar/bausystem/world/regions/Prototype.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java index 0ce643b..3c34230 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java @@ -115,16 +115,16 @@ public class Prototype { switch (regionExtensionType) { case EXTENSION: return new Point( - region.minPoint.getX() + offsetX - extensionAxisX + (sizeX + extensionAxisX * 2), - region.minPoint.getY() + offsetY + sizeY + extensionPositiveY, - region.minPoint.getZ() + offsetZ - extensionNegativeZ + (sizeZ + extensionNegativeZ + extensionPositiveZ) + region.minPoint.getX() + offsetX - extensionAxisX + (sizeX + extensionAxisX * 2) - 1, + region.minPoint.getY() + offsetY + sizeY + extensionPositiveY - 1, + region.minPoint.getZ() + offsetZ - extensionNegativeZ + (sizeZ + extensionNegativeZ + extensionPositiveZ) - 1 ); default: case NORMAL: return new Point( - region.minPoint.getX() + offsetX + sizeX, - region.minPoint.getY() + offsetY + sizeY, - region.minPoint.getZ() + offsetZ + sizeZ + region.minPoint.getX() + offsetX + sizeX - 1, + region.minPoint.getY() + offsetY + sizeY - 1, + region.minPoint.getZ() + offsetZ + sizeZ - 1 ); } } -- 2.39.5 From 7e9f7139fd11f7f99045ba395be85c1f3d56ea5f Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 4 Apr 2021 18:59:02 +0200 Subject: [PATCH 20/25] Remove Permission.build --- .../src/de/steamwar/bausystem/Permission.java | 6 +- .../bausystem/commands/CommandGUI.java | 68 ++++++++++--------- .../bausystem/world/RegionListener.java | 3 +- .../src/de/steamwar/bausystem/world/Welt.java | 6 +- 4 files changed, 42 insertions(+), 41 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java index dc92701..f3e5085 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java @@ -20,7 +20,7 @@ package de.steamwar.bausystem; public enum Permission { - world, - worldedit, - member + WORLD, + WORLDEDIT, + MEMBER } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java index 7cdccfa..b403982 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandGUI.java @@ -25,6 +25,8 @@ import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.tracer.record.RecordStateMachine; import de.steamwar.bausystem.tracer.show.TraceShowManager; import de.steamwar.bausystem.world.*; +import de.steamwar.bausystem.world.regions.GlobalRegion; +import de.steamwar.bausystem.world.regions.Region; import de.steamwar.command.SWCommand; import de.steamwar.core.Core; import de.steamwar.inventory.SWAnvilInv; @@ -95,17 +97,17 @@ public class CommandGUI extends SWCommand implements Listener { player.performCommand("gui item"); }); - ItemStack dtWand = wand(player, Detonator.WAND, "§8/§7dt wand", Permission.world, "§cDu hast keine Worldrechte"); + ItemStack dtWand = wand(player, Detonator.WAND, "§8/§7dt wand", Permission.WORLD, "§cDu hast keine Worldrechte"); inv.setItem(39, dtWand, clickType -> { - if (Welt.noPermission(player, Permission.world)) + if (Welt.noPermission(player, Permission.WORLD)) return; player.closeInventory(); player.performCommand("dt wand"); }); - ItemStack simWand = wand(player, TNTSimulator.WAND, "§8/§7sim wand", Permission.world, "§cDu hast keine Worldrechte"); + ItemStack simWand = wand(player, TNTSimulator.WAND, "§8/§7sim wand", Permission.WORLD, "§cDu hast keine Worldrechte"); inv.setItem(38, simWand, clickType -> { - if (Welt.noPermission(player, Permission.world)) + if (Welt.noPermission(player, Permission.WORLD)) return; player.closeInventory(); player.performCommand("sim wand"); @@ -117,21 +119,21 @@ public class CommandGUI extends SWCommand implements Listener { player.performCommand("redstonetester"); }); - inv.setItem(40, getMaterial("WOODEN_AXE", "WOOD_AXE"), "§eWorldedit Axt", getNoPermsLore(Arrays.asList("§8//§7wand"), player, "§cDu hast keine Worldeditrechte", Permission.worldedit), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(40, getMaterial("WOODEN_AXE", "WOOD_AXE"), "§eWorldedit Axt", getNoPermsLore(Arrays.asList("§8//§7wand"), player, "§cDu hast keine Worldeditrechte", Permission.WORLDEDIT), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.closeInventory(); player.performCommand("/wand"); }); - inv.setItem(41, getMaterial("DEBUG_STICK", "STICK"), "§eDebugstick", getNoPermsLore(Arrays.asList("§8/§7debugstick"), player, "§cDu hast keine Worldrechte", Permission.world), Core.getVersion() < 13, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(41, getMaterial("DEBUG_STICK", "STICK"), "§eDebugstick", getNoPermsLore(Arrays.asList("§8/§7debugstick"), player, "§cDu hast keine Worldrechte", Permission.WORLD), Core.getVersion() < 13, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.closeInventory(); player.performCommand("debugstick"); }); - inv.setItem(20, Material.COMPASS, "§7TPS Limitieren", getNoPermsLore(Arrays.asList("§7Aktuell: §e" + CommandTPSLimiter.getCurrentTPSLimit(), "§8/§7tpslimit §8[§e0,5 - " + (TPSUtils.isWarpAllowed() ? 40 : 20) + "§8]"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(20, Material.COMPASS, "§7TPS Limitieren", getNoPermsLore(Arrays.asList("§7Aktuell: §e" + CommandTPSLimiter.getCurrentTPSLimit(), "§8/§7tpslimit §8[§e0,5 - " + (TPSUtils.isWarpAllowed() ? 40 : 20) + "§8]"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; SWAnvilInv anvilInv = new SWAnvilInv(player, "TPS Limitieren"); anvilInv.setItem(Material.COMPASS); @@ -166,16 +168,16 @@ public class CommandGUI extends SWCommand implements Listener { scriptBooksGUI(player); }); - inv.setItem(21, Material.OBSERVER, "§7Tracer", getNoPermsLore(Arrays.asList("§7Status: §e" + RecordStateMachine.getRecordStatus().getName()), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(21, Material.OBSERVER, "§7Tracer", getNoPermsLore(Arrays.asList("§7Status: §e" + RecordStateMachine.getRecordStatus().getName()), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.closeInventory(); OPEN_TRACER_INVS.add(player); traceGUI(player); }); - inv.setItem(22, Material.DISPENSER, "§7Auto-Loader", getNoPermsLore(Arrays.asList("§7Status: " + (AutoLoader.hasLoader(player) ? "§aan" : "§caus")), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(22, Material.DISPENSER, "§7Auto-Loader", getNoPermsLore(Arrays.asList("§7Status: " + (AutoLoader.hasLoader(player) ? "§aan" : "§caus")), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.closeInventory(); autoLoaderGUI(player); @@ -188,7 +190,7 @@ public class CommandGUI extends SWCommand implements Listener { anvilInv.open(); }); - if (Region.GlobalRegion.isGlobalRegion(region)) { + if (GlobalRegion.isGlobalRegion(region)) { inv.setItem(9, Material.BARRIER, "§eKeine Region", clickType -> { }); inv.setItem(18, Material.BARRIER, "§eKeine Region", clickType -> { @@ -196,15 +198,15 @@ public class CommandGUI extends SWCommand implements Listener { inv.setItem(27, Material.BARRIER, "§eKeine Region", clickType -> { }); } else { - inv.setItem(27, getMaterial("HEAVY_WEIGHTED_PRESSURE_PLATE", "IRON_PLATE"), "§eRegion Reseten", getNoPermsLore(Arrays.asList("§8/§7reset"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(27, getMaterial("HEAVY_WEIGHTED_PRESSURE_PLATE", "IRON_PLATE"), "§eRegion Reseten", getNoPermsLore(Arrays.asList("§8/§7reset"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; confirmationInventory(player, "Region Reseten?", () -> player.performCommand("reset"), () -> openBauGui(player)); }); if (region.hasProtection()) { - inv.setItem(18, Material.OBSIDIAN, "§eRegion Protecten", getNoPermsLore(Arrays.asList("§8/§7protect"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(18, Material.OBSIDIAN, "§eRegion Protecten", getNoPermsLore(Arrays.asList("§8/§7protect"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; confirmationInventory(player, "Region Protecten", () -> player.performCommand("protect"), () -> openBauGui(player)); }); @@ -214,8 +216,8 @@ public class CommandGUI extends SWCommand implements Listener { } if (region.hasTestblock()) { - inv.setItem(9, getMaterial("END_STONE", "ENDER_STONE"), "§eTestblock erneuern", getNoPermsLore(Arrays.asList("§8/§7testblock"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(9, getMaterial("END_STONE", "ENDER_STONE"), "§eTestblock erneuern", getNoPermsLore(Arrays.asList("§8/§7testblock"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; confirmationInventory(player, "Testblock erneuern", () -> player.performCommand("testblock"), () -> openBauGui(player)); }); @@ -250,11 +252,11 @@ public class CommandGUI extends SWCommand implements Listener { } boolean isBuildArea = region.hasBuildRegion(); - List tntLore = getNoPermsLore(Arrays.asList("§8/§7tnt §8[" + (isBuildArea ? "§eTB§7, " : "") + "§eOff §7oder §eOn§7]"), player, "§cDu hast keine Worldrechte", Permission.world); + List tntLore = getNoPermsLore(Arrays.asList("§8/§7tnt §8[" + (isBuildArea ? "§eTB§7, " : "") + "§eOff §7oder §eOn§7]"), player, "§cDu hast keine Worldrechte", Permission.WORLD); switch (region.getTntMode()) { case OFF: inv.setItem(23, Material.MINECART, "§7TNT: §eAusgeschaltet", tntLore, false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("tnt " + (isBuildArea ? "tb" : "on")); updateInventories(); @@ -262,7 +264,7 @@ public class CommandGUI extends SWCommand implements Listener { break; case ONLY_TB: inv.setItem(23, getMaterial("TNT_MINECART", "EXPLOSIVE_MINECART"), "§7TNT: §enur Testblock", tntLore, false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("tnt on"); updateInventories(); @@ -270,7 +272,7 @@ public class CommandGUI extends SWCommand implements Listener { break; default: inv.setItem(23, Material.TNT, "§7TNT: §eEingeschaltet", tntLore, false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("tnt off"); updateInventories(); @@ -278,15 +280,15 @@ public class CommandGUI extends SWCommand implements Listener { } if (region.isFreeze()) { - inv.setItem(24, getMaterial("GUNPOWDER", "SULPHUR"), "§7Freeze: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(24, getMaterial("GUNPOWDER", "SULPHUR"), "§7Freeze: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("freeze"); updateInventories(); }); } else { - inv.setItem(24, Material.REDSTONE, "§7Freeze: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(24, Material.REDSTONE, "§7Freeze: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("freeze"); updateInventories(); @@ -294,15 +296,15 @@ public class CommandGUI extends SWCommand implements Listener { } if (region.isFire()) { - inv.setItem(3, getMaterial("FIREWORK_STAR", "FIREWORK_CHARGE"), "§7Fire: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(3, getMaterial("FIREWORK_STAR", "FIREWORK_CHARGE"), "§7Fire: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("fire"); updateInventories(); }); } else { - inv.setItem(3, getMaterial("FIRE_CHARGE", "FIREBALL"), "§7Fire: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { - if (Welt.noPermission(player, Permission.world)) + inv.setItem(3, getMaterial("FIRE_CHARGE", "FIREBALL"), "§7Fire: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> { + if (Welt.noPermission(player, Permission.WORLD)) return; player.performCommand("fire"); updateInventories(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java index ead9a3c..b32d6e9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java @@ -28,7 +28,6 @@ import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.wrappers.BlockPosition; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.core.Core; import de.steamwar.core.VersionedCallable; import de.steamwar.core.VersionedRunnable; import org.bukkit.Bukkit; @@ -53,7 +52,7 @@ public class RegionListener implements Listener { Player p = e.getPlayer(); - if (Welt.noPermission(p, Permission.worldedit)) { + if (Welt.noPermission(p, Permission.WORLDEDIT)) { p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier kein WorldEdit benutzen"); e.setCancelled(true); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java index c5c411c..ee68461 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Welt.java @@ -40,11 +40,11 @@ public class Welt { return true; switch (perm) { - case worldedit: + case WORLDEDIT: return !member1.isWorldEdit(); - case world: + case WORLD: return !member1.isWorld(); - case member: + case MEMBER: return false; default: return true; -- 2.39.5 From cf9ebaa253bc705dcb93792b59b2d868610e0e6a Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 4 Apr 2021 21:51:19 +0200 Subject: [PATCH 21/25] Fixup CommandRegion '/rg restore' --- .../bausystem/commands/CommandProtect.java | 6 ++--- .../bausystem/commands/CommandRegion.java | 11 +++++---- .../bausystem/commands/CommandReset.java | 6 ++--- .../bausystem/world/regions/Prototype.java | 24 +++++++++---------- .../bausystem/world/regions/Region.java | 9 ++----- 5 files changed, 27 insertions(+), 29 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java index 2de12c4..9329daf 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandProtect.java @@ -21,8 +21,8 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.world.regions.Region; import de.steamwar.bausystem.world.Welt; +import de.steamwar.bausystem.world.regions.Region; import de.steamwar.command.SWCommand; import de.steamwar.sql.Schematic; import org.bukkit.Bukkit; @@ -44,7 +44,7 @@ public class CommandProtect extends SWCommand { } @Register - public void genericTestblockCommand(Player p) { + public void genericProtectCommand(Player p) { if (!permissionCheck(p)) return; Region region = regionCheck(p); if (region == null) return; @@ -58,7 +58,7 @@ public class CommandProtect extends SWCommand { } @Register - public void schematicTestblockCommand(Player p, String s) { + public void schematicProtectCommand(Player p, String s) { if (!permissionCheck(p)) return; Region region = regionCheck(p); if (region == null) return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java index 423d41d..75aacc6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java @@ -28,12 +28,15 @@ public class CommandRegion extends SWCommand { @Register(help = true) public void genericHelp(Player player, String... args) { - player.sendMessage(BauSystem.PREFIX + "§8/§7region undo §8- §7Mache die letzten 10 /testblock oder /reset rückgängig"); - player.sendMessage(BauSystem.PREFIX + "§8/§7region redo §8- §7Wiederhohle die letzten 10 §8/§7rg undo"); + player.sendMessage("§8/§eregion undo §8- §7Mache die letzten 20 /testblock oder /reset rückgängig"); + player.sendMessage("§8/§eregion redo §8- §7Wiederhohle die letzten 20 §8/§7rg undo"); + player.sendMessage("§8/§eregion restore §8- §7Setzte die Region zurück, ohne das Gebaute zu löschen"); + player.sendMessage("§8/§ereset select §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp aus"); + player.sendMessage("§8/§ereset select §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Wähle einen RegionsTyp aus mit oder ohne Extension"); } - @Register - public void undoCommand(Player p, Action action) { + @Register("undo") + public void undoCommand(Player p) { if(!permissionCheck(p)) return; Region region = Region.getRegion(p.getLocation()); if(checkGlobalRegion(region, p)) return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java index cc61dd3..fdc540a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java @@ -21,9 +21,9 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.world.Welt; import de.steamwar.bausystem.world.regions.GlobalRegion; import de.steamwar.bausystem.world.regions.Region; -import de.steamwar.bausystem.world.Welt; import de.steamwar.command.SWCommand; import de.steamwar.sql.Schematic; import org.bukkit.Bukkit; @@ -50,7 +50,7 @@ public class CommandReset extends SWCommand { Region region = regionCheck(p); if (region == null) return; try { - region.reset(null); + region.reset(null, false); p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt"); } catch (IOException e) { p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region"); @@ -69,7 +69,7 @@ public class CommandReset extends SWCommand { return; } try { - region.reset(schem); + region.reset(schem, false); p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt"); } catch (IOException e) { p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region"); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java index 3c34230..455f9de 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java @@ -143,14 +143,14 @@ public class Prototype { } } - public EditSession reset(Region region, Schematic schem) throws IOException, NoClipboardException { + public EditSession reset(Region region, Schematic schem, boolean ignoreAir) throws IOException, NoClipboardException { int x = region.minPoint.getX() + offsetX + sizeX / 2; int y = region.minPoint.getY() + offsetY; int z = region.minPoint.getZ() + offsetZ + sizeZ / 2; if (schem == null) { - return paste(new File(schematic), x, y, z, rotate); + return paste(new File(schematic), x, y, z, rotate, ignoreAir); } else { - return paste(schem.load(), x, y, z, rotate); + return paste(schem.load(), x, y, z, rotate, ignoreAir); } } @@ -163,9 +163,9 @@ public class Prototype { int y = region.minPoint.getY() + testblock.offsetY - 1; int z = region.minPoint.getZ() + offsetZ + sizeZ / 2; if (schem == null) { - return paste(new File(protectSchematic), x, y, z, rotate); + return paste(new File(protectSchematic), x, y, z, rotate, false); } else { - return paste(schem.load(), x, y, z, rotate); + return paste(schem.load(), x, y, z, rotate, false); } } @@ -174,20 +174,20 @@ public class Prototype { } public EditSession resetTestblock(Region region, Schematic schem) throws IOException, NoClipboardException { - return testblock.reset(region, schem); + return testblock.reset(region, schem, false); } private static boolean inRange(double l, int min, int size) { return min <= l && l < min + size; } - private static EditSession paste(File file, int x, int y, int z, boolean rotate) { //Type of protect - return (EditSession) VersionedCallable.call(new VersionedCallable(() -> Region_12.paste(file, x, y, z, rotate), 8), - new VersionedCallable(() -> Region_15.paste(file, x, y, z, rotate), 15)); + private static EditSession paste(File file, int x, int y, int z, boolean rotate, boolean ignoreAir) { //Type of protect + return (EditSession) VersionedCallable.call(new VersionedCallable(() -> Region_12.paste(file, x, y, z, rotate, ignoreAir), 8), + new VersionedCallable(() -> Region_15.paste(file, x, y, z, rotate, ignoreAir), 15)); } - private static EditSession paste(Clipboard clipboard, int x, int y, int z, boolean rotate) { - return (EditSession) VersionedCallable.call(new VersionedCallable(() -> Region_12.paste(clipboard, x, y, z, rotate), 8), - new VersionedCallable(() -> Region_15.paste(clipboard, x, y, z, rotate), 15)); + private static EditSession paste(Clipboard clipboard, int x, int y, int z, boolean rotate, boolean ignoreAir) { + return (EditSession) VersionedCallable.call(new VersionedCallable(() -> Region_12.paste(clipboard, x, y, z, rotate, ignoreAir), 8), + new VersionedCallable(() -> Region_15.paste(clipboard, x, y, z, rotate, ignoreAir), 15)); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java index fbd113a..c35be73 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java @@ -195,14 +195,9 @@ public class Region { return prototype.buildArea != null; } - public void reset() throws IOException { + public void reset(Schematic schem, boolean ignoreAir) throws IOException, NoClipboardException { initSessions(); - undosessions.push(prototype.reset(this, null)); - } - - public void reset(Schematic schem) throws IOException, NoClipboardException { - initSessions(); - undosessions.push(prototype.reset(this, schem)); + undosessions.push(prototype.reset(this, schem, ignoreAir)); } public boolean hasTestblock() { -- 2.39.5 From 485efedcfcbd06e804360863b5f789f5477864a0 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 5 Apr 2021 13:21:57 +0200 Subject: [PATCH 22/25] Fix CommandColor --- .../bausystem/world/regions/Region_15.java | 2 + .../src/de/steamwar/bausystem/BauSystem.java | 1 + .../bausystem/commands/CommandColor.java | 7 +- .../bausystem/world/regions/Prototype.java | 23 ++--- .../bausystem/world/regions/Region.java | 92 ++++++++++++++++++- 5 files changed, 111 insertions(+), 14 deletions(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java index 1a228ce..7f888d2 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java @@ -36,6 +36,8 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Objects; + +import de.steamwar.bausystem.world.Color; import org.bukkit.Bukkit; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 1d09ff1..829132c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem; import de.steamwar.bausystem.commands.*; import de.steamwar.bausystem.world.*; +import de.steamwar.bausystem.world.regions.Region; import de.steamwar.core.Core; import de.steamwar.core.VersionedRunnable; import de.steamwar.scoreboard.SWScoreboard; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandColor.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandColor.java index 09b25d7..0e77ef3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandColor.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandColor.java @@ -2,7 +2,8 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.world.Color; -import de.steamwar.bausystem.world.Region; +import de.steamwar.bausystem.world.regions.GlobalRegion; +import de.steamwar.bausystem.world.regions.Region; import de.steamwar.command.SWCommand; import org.bukkit.entity.Player; @@ -35,6 +36,10 @@ public class CommandColor extends SWCommand { return; } Region region = Region.getRegion(p.getLocation()); + if (GlobalRegion.isGlobalRegion(region)) { + p.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region"); + return; + } region.setColor(color); p.sendMessage(BauSystem.PREFIX + "Regions farben auf §e" + color.name().toLowerCase() + "§7 gesetzt"); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java index 455f9de..5866b2e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.world.regions; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.extent.clipboard.Clipboard; +import de.steamwar.bausystem.world.Color; import de.steamwar.core.VersionedCallable; import de.steamwar.sql.NoClipboardException; import de.steamwar.sql.Schematic; @@ -143,14 +144,14 @@ public class Prototype { } } - public EditSession reset(Region region, Schematic schem, boolean ignoreAir) throws IOException, NoClipboardException { + public EditSession reset(Region region, Schematic schem, boolean ignoreAir, Color color) throws IOException, NoClipboardException { int x = region.minPoint.getX() + offsetX + sizeX / 2; int y = region.minPoint.getY() + offsetY; int z = region.minPoint.getZ() + offsetZ + sizeZ / 2; if (schem == null) { - return paste(new File(schematic), x, y, z, rotate, ignoreAir); + return paste(new File(schematic), x, y, z, rotate, ignoreAir, color); } else { - return paste(schem.load(), x, y, z, rotate, ignoreAir); + return paste(schem.load(), x, y, z, rotate, ignoreAir, color); } } @@ -163,9 +164,9 @@ public class Prototype { int y = region.minPoint.getY() + testblock.offsetY - 1; int z = region.minPoint.getZ() + offsetZ + sizeZ / 2; if (schem == null) { - return paste(new File(protectSchematic), x, y, z, rotate, false); + return paste(new File(protectSchematic), x, y, z, rotate, false, Color.YELLOW); } else { - return paste(schem.load(), x, y, z, rotate, false); + return paste(schem.load(), x, y, z, rotate, false, Color.YELLOW); } } @@ -173,21 +174,21 @@ public class Prototype { return testblock != null; } - public EditSession resetTestblock(Region region, Schematic schem) throws IOException, NoClipboardException { - return testblock.reset(region, schem, false); + public EditSession resetTestblock(Region region, Schematic schem, Color color) throws IOException, NoClipboardException { + return testblock.reset(region, schem, false, color); } private static boolean inRange(double l, int min, int size) { return min <= l && l < min + size; } - private static EditSession paste(File file, int x, int y, int z, boolean rotate, boolean ignoreAir) { //Type of protect + private static EditSession paste(File file, int x, int y, int z, boolean rotate, boolean ignoreAir, Color color) { //Type of protect return (EditSession) VersionedCallable.call(new VersionedCallable(() -> Region_12.paste(file, x, y, z, rotate, ignoreAir), 8), - new VersionedCallable(() -> Region_15.paste(file, x, y, z, rotate, ignoreAir), 15)); + new VersionedCallable(() -> Region_15.paste(file, x, y, z, rotate, ignoreAir, color), 15)); } - private static EditSession paste(Clipboard clipboard, int x, int y, int z, boolean rotate, boolean ignoreAir) { + private static EditSession paste(Clipboard clipboard, int x, int y, int z, boolean rotate, boolean ignoreAir, Color color) { return (EditSession) VersionedCallable.call(new VersionedCallable(() -> Region_12.paste(clipboard, x, y, z, rotate, ignoreAir), 8), - new VersionedCallable(() -> Region_15.paste(clipboard, x, y, z, rotate, ignoreAir), 15)); + new VersionedCallable(() -> Region_15.paste(clipboard, x, y, z, rotate, ignoreAir, color), 15)); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java index c35be73..bdc95de 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java @@ -19,8 +19,13 @@ package de.steamwar.bausystem.world.regions; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSyntaxException; import com.sk89q.worldedit.EditSession; import de.steamwar.bausystem.commands.CommandTNT.TNTMode; +import de.steamwar.bausystem.world.Color; import de.steamwar.bausystem.world.SizedStack; import de.steamwar.sql.NoClipboardException; import de.steamwar.sql.Schematic; @@ -31,6 +36,8 @@ import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; +import java.io.FileOutputStream; +import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -43,8 +50,18 @@ public class Region { private static final List regions = new ArrayList<>(); static boolean buildArea = false; static boolean extensionArea = false; + private static JsonObject regionsObject = new JsonObject(); static { + File regionsFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "regions.json"); + if (regionsFile.exists()) { + try { + regionsObject = new JsonParser().parse(new FileReader(regionsFile)).getAsJsonObject(); + } catch (JsonSyntaxException | IOException e) { + Bukkit.getLogger().log(Level.WARNING, "Item JSON error"); + } + } + YamlConfiguration config = new YamlConfiguration(); try { config.load(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections.yml")); @@ -82,6 +99,30 @@ public class Region { return GlobalRegion.getInstance(); } + public static void setGlobalColor(Color color) { + for (Region region : regions) { + region.setColor(color); + } + } + + public static void save() { + File colorsFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "regions.json"); + if (!colorsFile.exists()) { + try { + colorsFile.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + return; + } + } + try (FileOutputStream fileOutputStream = new FileOutputStream(colorsFile)) { + fileOutputStream.write(regionsObject.toString().getBytes()); + } catch (IOException e) { + e.printStackTrace(); + // Ignored + } + } + private final String name; final Point minPoint; private final Prototype prototype; @@ -90,12 +131,47 @@ public class Region { private SizedStack undosessions; private SizedStack redosessions; + private JsonObject regionOptions = new JsonObject(); + private TNTMode tntMode = Region.buildAreaEnabled() ? TNTMode.ONLY_TB : TNTMode.OFF; private boolean freeze = false; private boolean fire = false; + private Color color = Color.YELLOW; + private Region(ConfigurationSection config) { name = config.getName(); + if (regionsObject.has(name)) { + regionOptions = regionsObject.getAsJsonObject(name); + if (regionOptions.has("tnt")) { + String tntName = regionsObject.getAsJsonObject(name).getAsJsonPrimitive("tnt").getAsString(); + try { + tntMode = TNTMode.valueOf(tntName); + } catch (Exception e) { + // Ignored + } + } + + if (regionOptions.has("fire")) { + fire = regionOptions.getAsJsonPrimitive("fire").getAsBoolean(); + } + + if (regionOptions.has("freeze")) { + freeze = regionOptions.getAsJsonPrimitive("freeze").getAsBoolean(); + } + + if (regionOptions.has("color")) { + String colorName = regionOptions.getAsJsonPrimitive("color").getAsString(); + try { + color = Color.valueOf(colorName); + } catch (Exception e) { + // Ignored + } + } + } else { + regionsObject.add(name, regionOptions); + } + minPoint = new Point(config.getInt("minX"), config.getInt("minY"), config.getInt("minZ")); prototype = Prototype.prototypes.get(config.getString("prototype")); optionsLinkedWith = config.getString("optionsLinkedWith", null); @@ -111,6 +187,15 @@ public class Region { tntMode = TNTMode.OFF; } + public Color getColor() { + return color; + } + + public void setColor(Color color) { + this.color = color; + regionOptions.add("color", new JsonPrimitive(color.name())); + } + private void setLinkedRegion(Consumer regionConsumer) { if (optionsLinkedWith == null) { return; @@ -135,6 +220,7 @@ public class Region { public void setTntMode(TNTMode tntMode) { this.tntMode = tntMode; setLinkedRegion(region -> region.tntMode = tntMode); + regionOptions.add("tnt", new JsonPrimitive(tntMode.name())); } public boolean isFreeze() { @@ -144,6 +230,7 @@ public class Region { public void setFreeze(boolean freeze) { this.freeze = freeze; setLinkedRegion(region -> region.freeze = freeze); + regionOptions.add("freeze", new JsonPrimitive(freeze)); } public boolean isFire() { @@ -153,6 +240,7 @@ public class Region { public void setFire(boolean fire) { this.fire = fire; setLinkedRegion(region -> region.fire = fire); + regionOptions.add("fire", new JsonPrimitive(fire)); } public Point getMinPoint(RegionType regionType, RegionExtensionType regionExtensionType) { @@ -197,7 +285,7 @@ public class Region { public void reset(Schematic schem, boolean ignoreAir) throws IOException, NoClipboardException { initSessions(); - undosessions.push(prototype.reset(this, schem, ignoreAir)); + undosessions.push(prototype.reset(this, schem, ignoreAir, color)); } public boolean hasTestblock() { @@ -206,7 +294,7 @@ public class Region { public void resetTestblock(Schematic schem) throws IOException, NoClipboardException { initSessions(); - undosessions.push(prototype.resetTestblock(this, schem)); + undosessions.push(prototype.resetTestblock(this, schem, color)); } public boolean hasProtection() { -- 2.39.5 From 5bf771c1ceaaafa5d37ca3e9438536dd5163adc2 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 5 Apr 2021 14:31:47 +0200 Subject: [PATCH 23/25] Add save/load GlobalRegion options --- .../bausystem/world/regions/Region.java | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java index bdc95de..a02edfb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java @@ -141,6 +141,24 @@ public class Region { private Region(ConfigurationSection config) { name = config.getName(); + minPoint = new Point(config.getInt("minX"), config.getInt("minY"), config.getInt("minZ")); + prototype = Prototype.prototypes.get(config.getString("prototype")); + optionsLinkedWith = config.getString("optionsLinkedWith", null); + if (!hasTestblock()) tntMode = TNTMode.OFF; + regions.add(this); + load(); + } + + public Region(String name) { + this.name = name; + this.minPoint = new Point(0, 0, 0); + this.prototype = null; + this.optionsLinkedWith = null; + tntMode = TNTMode.OFF; + load(); + } + + private void load() { if (regionsObject.has(name)) { regionOptions = regionsObject.getAsJsonObject(name); if (regionOptions.has("tnt")) { @@ -171,20 +189,6 @@ public class Region { } else { regionsObject.add(name, regionOptions); } - - minPoint = new Point(config.getInt("minX"), config.getInt("minY"), config.getInt("minZ")); - prototype = Prototype.prototypes.get(config.getString("prototype")); - optionsLinkedWith = config.getString("optionsLinkedWith", null); - if (!hasTestblock()) tntMode = TNTMode.OFF; - regions.add(this); - } - - public Region(String name) { - this.name = name; - this.minPoint = new Point(0, 0, 0); - this.prototype = null; - this.optionsLinkedWith = null; - tntMode = TNTMode.OFF; } public Color getColor() { -- 2.39.5 From 8aecdf71a54e5aacb5568413402052a4800d7888 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 5 Apr 2021 15:34:22 +0200 Subject: [PATCH 24/25] Fix help mnessage CommandRegion --- .../src/de/steamwar/bausystem/commands/CommandRegion.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java index 1596b61..05e4059 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java @@ -32,8 +32,9 @@ public class CommandRegion extends SWCommand { player.sendMessage("§8/§eregion undo §8- §7Mache die letzten 20 /testblock oder /reset rückgängig"); player.sendMessage("§8/§eregion redo §8- §7Wiederhohle die letzten 20 §8/§7rg undo"); player.sendMessage("§8/§eregion restore §8- §7Setzte die Region zurück, ohne das Gebaute zu löschen"); - player.sendMessage("§8/§ereset select §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp aus"); - player.sendMessage("§8/§ereset select §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Wähle einen RegionsTyp aus mit oder ohne Extension"); + player.sendMessage("§8/§eregion select §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp aus"); + player.sendMessage("§8/§eregion select §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Wähle einen RegionsTyp aus mit oder ohne Extension"); + player.sendMessage("§8/§eregion color §8[§7Color§8] §8- §7Ändere die Regions Farbe"); } @Register("undo") -- 2.39.5 From 41e0eacd580e8483751c062b88fef8343ac3917d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 5 Apr 2021 16:40:05 +0200 Subject: [PATCH 25/25] Fix one ofs in Region_15 --- .../src/de/steamwar/bausystem/world/regions/Region_15.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java index 7f888d2..b4d47c2 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java @@ -67,9 +67,9 @@ class Region_15 { BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); if (rotate) { ch.setTransform(new AffineTransform().rotateY(180)); - v = v.add(dimensions.getX() / 2 + dimensions.getX() % 2, 0, dimensions.getZ() / 2 + dimensions.getZ() % 2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1); + v = v.add(dimensions.getX() / 2, 0, dimensions.getZ() / 2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1); } else { - v = v.subtract(dimensions.getX() / 2 - dimensions.getX() % 2, 0, dimensions.getZ() / 2 - dimensions.getZ() % 2).subtract(offset); + v = v.subtract(dimensions.getX() / 2, 0, dimensions.getZ() / 2).subtract(offset); } Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(ignoreAir).build()); -- 2.39.5