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_12/src/de/steamwar/bausystem/world/Region_12.java b/BauSystem_12/src/de/steamwar/bausystem/world/regions/Region_12.java
similarity index 74%
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 f9ca671..d743f3b 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/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_15/src/de/steamwar/bausystem/world/Region_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/regions/Region_15.java
similarity index 85%
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 8751c47..b4d47c2 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;
@@ -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;
@@ -65,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());
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/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java
index 85430f9..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;
@@ -93,6 +94,7 @@ public class BauSystem extends JavaPlugin implements Listener {
new CommandGUI();
new CommandWorldSpawn();
new CommandRegion();
+ new CommandSelect();
VersionedRunnable.call(new VersionedRunnable(() -> {
if (Region.buildAreaEnabled()) {
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/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/CommandColor.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandColor.java
index 342866e..ddd04fe 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;
@@ -42,7 +43,7 @@ public class CommandColor extends SWCommand {
return;
}
Region region = Region.getRegion(p.getLocation());
- if (Region.GlobalRegion.isGlobalRegion(region)) {
+ if (GlobalRegion.isGlobalRegion(region)) {
p.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
return;
}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java
index 8e4cfc7..d9dec58 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java
@@ -20,8 +20,6 @@
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
-import de.steamwar.bausystem.Permission;
-import de.steamwar.bausystem.world.Welt;
import de.steamwar.command.SWCommand;
import de.steamwar.core.VersionedRunnable;
import org.bukkit.entity.Player;
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 0c9d5c2..56b4862 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;
@@ -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 2baeb2a..a3460ed 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;
@@ -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 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/commands/CommandInfo.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java
index 20e0f5d..c6b245d 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..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.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;
@@ -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 c39918b..05e4059 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java
@@ -3,8 +3,11 @@ package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.Color;
-import de.steamwar.bausystem.world.Region;
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 de.steamwar.sql.Schematic;
import org.bukkit.Bukkit;
@@ -26,36 +29,54 @@ 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/§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
- 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;
- 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);
+ 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);
+ }
+
@Register("restore")
public void genericRestoreCommand(Player p) {
if (!permissionCheck(p)) return;
@@ -99,7 +120,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;
}
@@ -107,15 +128,10 @@ 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;
}
return true;
}
-
- enum Action {
- UNDO,
- REDO
- }
}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java
index 05d3988..fdc540a 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandReset.java
@@ -21,8 +21,9 @@ 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.Welt;
+import de.steamwar.bausystem.world.regions.GlobalRegion;
+import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.command.SWCommand;
import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit;
@@ -49,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");
@@ -68,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");
@@ -77,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;
}
@@ -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/CommandSelect.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java
new file mode 100644
index 0000000..1cb693c
--- /dev/null
+++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java
@@ -0,0 +1,131 @@
+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 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));
+
+ public CommandSelect() {
+ 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");
+ 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) {
+ if (!permissionCheck(p)) {
+ return;
+ }
+
+ Region region = Region.getRegion(p.getLocation());
+
+ if (GlobalRegion.isGlobalRegion(region)) {
+ p.sendMessage(BauSystem.PREFIX + "§cDie globale Region kannst du nicht auswählen");
+ return;
+ }
+
+ if (regionType == RegionType.TESTBLOCK) {
+ if (!region.hasTestblock()) {
+ p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen Testblock");
+ return;
+ }
+ setSelection(regionType, RegionExtensionType.NORMAL, region, p);
+ return;
+ }
+
+ if (regionType == RegionType.BUILD) {
+ if (!region.hasBuildRegion()) {
+ p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen BuildArea");
+ 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)) {
+ p.sendMessage(BauSystem.PREFIX + "§cDie globale Region kannst du nicht auswählen");
+ return;
+ }
+
+ if (regionType == RegionType.TESTBLOCK) {
+ 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);
+ return;
+ }
+
+ if (regionType == RegionType.BUILD) {
+ 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);
+ 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 Select 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()));
+ 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
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 c839afe..a96daf3 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;
@@ -94,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;
}
@@ -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.inBuildRegion(block.getLocation())) {
+ 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.inBuildRegionExtension(block.getLocation())) {
+ 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/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java
index 1e2e01b..6a5a8cc 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java
@@ -107,7 +107,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/CommandTestblock.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTestblock.java
index f90e8cb..45cc490 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;
@@ -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/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/commands/RegionUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java
index 24dcedd..1d9dc60 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java
@@ -19,18 +19,23 @@
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;
import org.bukkit.Bukkit;
+@UtilityClass
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())).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/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/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/ScriptListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java
index 425ff41..240540a 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/TNTSimulatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulatorListener.java
index 0c53f1a..2a11d53 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulatorListener.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulatorListener.java
@@ -38,7 +38,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 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;
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..363284c
--- /dev/null
+++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/GlobalRegion.java
@@ -0,0 +1,64 @@
+/*
+ * 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 hasExtensionArea(RegionType regionType) {
+ 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..5866b2e
--- /dev/null
+++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java
@@ -0,0 +1,194 @@
+/*
+ * 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.world.Color;
+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) - 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 - 1,
+ region.minPoint.getY() + offsetY + sizeY - 1,
+ region.minPoint.getZ() + offsetZ + sizeZ - 1
+ );
+ }
+ }
+
+ 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, 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, color);
+ } else {
+ return paste(schem.load(), x, y, z, rotate, ignoreAir, color);
+ }
+ }
+
+ 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, false, Color.YELLOW);
+ } else {
+ return paste(schem.load(), x, y, z, rotate, false, Color.YELLOW);
+ }
+ }
+
+ public boolean hasTestblock() {
+ return testblock != null;
+ }
+
+ 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, 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, color), 15));
+ }
+
+ 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, color), 15));
+ }
+}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java
similarity index 50%
rename from BauSystem_Main/src/de/steamwar/bausystem/world/Region.java
rename to BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java
index 76ee3da..a02edfb 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Region.java
@@ -1,32 +1,32 @@
-/*
- 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.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSyntaxException;
import com.sk89q.worldedit.EditSession;
-import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.bausystem.commands.CommandTNT.TNTMode;
-import de.steamwar.core.VersionedCallable;
+import de.steamwar.bausystem.world.Color;
+import de.steamwar.bausystem.world.SizedStack;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit;
@@ -39,15 +39,17 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
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;
public class Region {
private static final List regions = new ArrayList<>();
- private static boolean buildArea = false;
- private static boolean extensionArea = false;
+ static boolean buildArea = false;
+ static boolean extensionArea = false;
private static JsonObject regionsObject = new JsonObject();
static {
@@ -90,7 +92,9 @@ public class Region {
public static Region getRegion(Location location) {
for (Region region : regions) {
- if (region.inRegion(location)) return region;
+ if (region.inRegion(location, RegionType.NORMAL, RegionExtensionType.NORMAL)) {
+ return region;
+ }
}
return GlobalRegion.getInstance();
}
@@ -100,7 +104,7 @@ public class Region {
region.setColor(color);
}
}
-
+
public static void save() {
File colorsFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "regions.json");
if (!colorsFile.exists()) {
@@ -120,9 +124,7 @@ public class Region {
}
private final String name;
- private final int minX;
- private final int minY;
- private final int minZ;
+ final Point minPoint;
private final Prototype prototype;
private final String optionsLinkedWith; // nullable
private Region linkedRegion = null; // nullable
@@ -139,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")) {
@@ -169,24 +189,6 @@ public class Region {
} else {
regionsObject.add(name, regionOptions);
}
-
- minX = config.getInt("minX");
- minY = config.getInt("minY");
- minZ = 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.minX = 0;
- this.minY = 0;
- this.minZ = 0;
- this.prototype = null;
- this.optionsLinkedWith = null;
- tntMode = TNTMode.OFF;
}
public Color getColor() {
@@ -245,26 +247,46 @@ public class Region {
regionOptions.add("fire", new JsonPrimitive(fire));
}
- public boolean inRegion(Location l) {
- return prototype.inRegion(this, l);
+ public Point getMinPoint(RegionType regionType, RegionExtensionType regionExtensionType) {
+ switch (regionType) {
+ case BUILD:
+ 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:
+ 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:
+ 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 boolean inBuildRegion(Location l) {
- return prototype.buildArea.inRegion(this, l);
- }
-
- public boolean inBuildRegionExtension(Location l) {
- return prototype.buildArea.inRegionExtension(this, l);
- }
-
- public void reset(Schematic schem) throws IOException, NoClipboardException {
- reset(schem, false);
- }
-
public void reset(Schematic schem, boolean ignoreAir) throws IOException, NoClipboardException {
initSessions();
undosessions.push(prototype.reset(this, schem, ignoreAir, color));
@@ -288,16 +310,20 @@ public class Region {
undosessions.push(prototype.protect(this, schem));
}
- public boolean hasExtensionAreaRegistered() {
- return prototype.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() {
- if(undosessions == null) {
+ if (undosessions == null) {
undosessions = new SizedStack<>(20);
redosessions = new SizedStack<>(20);
}
@@ -308,8 +334,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;
@@ -325,8 +352,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;
@@ -337,167 +365,4 @@ public class Region {
}
}
- 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) {
- 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 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;
- 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 boolean inRegion(Region region, Location l) {
- return inRange(l.getX(), region.minX + offsetX, sizeX) &&
- inRange(l.getY(), region.minY + offsetY, sizeY) &&
- inRange(l.getZ(), region.minZ + offsetZ, sizeZ);
- }
-
- public boolean inRegionExtension(Region region, Location l) {
- return inRange(l.getX(), region.minX + offsetX - extensionAxisX, sizeX + extensionAxisX * 2) &&
- inRange(l.getY(), region.minY + offsetY, sizeY + extensionPositiveY) &&
- inRange(l.getZ(), region.minZ + offsetZ - extensionNegativeZ, sizeZ + extensionNegativeZ + extensionPositiveZ);
- }
-
- public EditSession reset(Region region, Schematic schem, boolean ignoreAir, Color color) throws IOException, NoClipboardException {
- int x = region.minX + offsetX + sizeX / 2;
- int y = region.minY + offsetY;
- int z = region.minZ + offsetZ + sizeZ / 2;
- if (schem == null)
- return paste(new File(schematic), x, y, z, rotate, ignoreAir, color);
- else
- return paste(schem.load(), x, y, z, rotate, ignoreAir, color);
- }
-
- public boolean hasProtection() {
- return protectSchematic != null;
- }
-
- 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;
- if (schem == null)
- return paste(new File(protectSchematic), x, y, z, rotate, false, Color.YELLOW);
- else
- return paste(schem.load(), x, y, z, rotate, false, Color.YELLOW);
- }
-
- public boolean hasTestblock() {
- return testblock != null;
- }
-
- 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, 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, color), 15));
- }
-
- 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, color), 15));
- }
- }
}
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..ac47eb9
--- /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,
+ TESTBLOCK
+}
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