RegionFix #240
@ -18,6 +18,7 @@
|
||||
<version>1.0</version>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean verify -U</defaultGoal>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
|
@ -1,23 +1,23 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.world;
|
||||
package de.steamwar.bausystem.world.regions;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
@ -18,6 +18,7 @@
|
||||
<version>1.0</version>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean verify -U</defaultGoal>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
|
@ -1,23 +1,23 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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());
|
@ -18,6 +18,7 @@
|
||||
<version>1.0</version>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean verify -U</defaultGoal>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
|
@ -18,6 +18,7 @@
|
||||
<version>1.0</version>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean verify -U</defaultGoal>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
@ -79,5 +80,11 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${main.basedir}/lib/WorldEdit-1.15.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.10</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -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()) {
|
||||
|
@ -20,7 +20,7 @@
|
||||
package de.steamwar.bausystem;
|
||||
|
||||
public enum Permission {
|
||||
world,
|
||||
worldedit,
|
||||
member
|
||||
WORLD,
|
||||
WORLDEDIT,
|
||||
MEMBER
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<String> tntLore = getNoPermsLore(Arrays.asList("§8/§7tnt §8[" + (isBuildArea ? "§eTB§7, " : "") + "§eOff §7oder §eOn§7]"), player, "§cDu hast keine Worldrechte", Permission.world);
|
||||
List<String> 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();
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
131
BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java
Normale Datei
131
BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java
Normale Datei
@ -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");
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
37
BauSystem_Main/src/de/steamwar/bausystem/world/regions/Point.java
Normale Datei
37
BauSystem_Main/src/de/steamwar/bausystem/world/regions/Point.java
Normale Datei
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
194
BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java
Normale Datei
194
BauSystem_Main/src/de/steamwar/bausystem/world/regions/Prototype.java
Normale Datei
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<String, Prototype> 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));
|
||||
}
|
||||
}
|
@ -1,32 +1,32 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<Region> 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();
|
||||
}
|
||||
@ -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<String, Prototype> 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));
|
||||
}
|
||||
}
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.world.regions;
|
||||
|
||||
public enum RegionExtensionType {
|
||||
NORMAL,
|
||||
EXTENSION
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.world.regions;
|
||||
|
||||
public enum RegionType {
|
||||
NORMAL,
|
||||
BUILD,
|
||||
TESTBLOCK
|
||||
}
|
1
pom.xml
1
pom.xml
@ -15,6 +15,7 @@
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean verify -U</defaultGoal>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren