From fe458d185caab3a06c1aedc14f3daa1b1df19184 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 5 Apr 2021 17:19:58 +0200 Subject: [PATCH] Hotfix CommandSelect for 1.12 --- BauSystem_12/pom.xml | 6 +++ .../bausystem/commands/CommandSelect_12.java | 44 +++++++++++++++++++ BauSystem_15/pom.xml | 6 +++ .../bausystem/commands/CommandSelect_15.java | 44 +++++++++++++++++++ BauSystem_API/pom.xml | 6 +++ .../bausystem/world/regions/Point.java | 6 --- .../bausystem/commands/CommandSelect.java | 12 ++--- 7 files changed, 109 insertions(+), 15 deletions(-) create mode 100644 BauSystem_12/src/de/steamwar/bausystem/commands/CommandSelect_12.java create mode 100644 BauSystem_15/src/de/steamwar/bausystem/commands/CommandSelect_15.java rename {BauSystem_Main => BauSystem_API}/src/de/steamwar/bausystem/world/regions/Point.java (86%) diff --git a/BauSystem_12/pom.xml b/BauSystem_12/pom.xml index c146055..b9417a9 100644 --- a/BauSystem_12/pom.xml +++ b/BauSystem_12/pom.xml @@ -52,5 +52,11 @@ 1.0 compile + + org.projectlombok + lombok + 1.18.10 + provided + diff --git a/BauSystem_12/src/de/steamwar/bausystem/commands/CommandSelect_12.java b/BauSystem_12/src/de/steamwar/bausystem/commands/CommandSelect_12.java new file mode 100644 index 0000000..144714e --- /dev/null +++ b/BauSystem_12/src/de/steamwar/bausystem/commands/CommandSelect_12.java @@ -0,0 +1,44 @@ +/* + * 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.commands; + +import com.sk89q.worldedit.Vector; +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.world.regions.Point; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +class CommandSelect_12 { + + static final WorldEditPlugin WORLDEDIT_PLUGIN = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")); + static final World BUKKITWORLD = new BukkitWorld(Bukkit.getWorlds().get(0)); + + static void setSelection(Player p, Point minPoint, Point maxPoint) { + WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, toVector(minPoint), toVector(maxPoint))); + } + + private static Vector toVector(Point point) { + return Vector.toBlockPoint(point.getX(), point.getY(), point.getZ()); + } + +} diff --git a/BauSystem_15/pom.xml b/BauSystem_15/pom.xml index c646b3b..225e0ef 100644 --- a/BauSystem_15/pom.xml +++ b/BauSystem_15/pom.xml @@ -58,5 +58,11 @@ system ${main.basedir}/lib/ProtocolLib.jar + + org.projectlombok + lombok + 1.18.10 + provided + diff --git a/BauSystem_15/src/de/steamwar/bausystem/commands/CommandSelect_15.java b/BauSystem_15/src/de/steamwar/bausystem/commands/CommandSelect_15.java new file mode 100644 index 0000000..f69008a --- /dev/null +++ b/BauSystem_15/src/de/steamwar/bausystem/commands/CommandSelect_15.java @@ -0,0 +1,44 @@ +/* + * 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.commands; + +import com.sk89q.worldedit.bukkit.BukkitWorld; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; +import com.sk89q.worldedit.world.World; +import de.steamwar.bausystem.world.regions.Point; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +class CommandSelect_15 { + + static final WorldEditPlugin WORLDEDIT_PLUGIN = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")); + static final World BUKKITWORLD = new BukkitWorld(Bukkit.getWorlds().get(0)); + + static void setSelection(Player p, Point minPoint, Point maxPoint) { + WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, toBlockVector3(minPoint), toBlockVector3(maxPoint))); + } + + private static BlockVector3 toBlockVector3(Point point) { + return BlockVector3.at(point.getX(), point.getY(), point.getZ()); + } + +} diff --git a/BauSystem_API/pom.xml b/BauSystem_API/pom.xml index 942f5d2..a9698bd 100644 --- a/BauSystem_API/pom.xml +++ b/BauSystem_API/pom.xml @@ -39,5 +39,11 @@ system ${main.basedir}/lib/Spigot-1.12.jar + + org.projectlombok + lombok + 1.18.10 + provided + diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Point.java b/BauSystem_API/src/de/steamwar/bausystem/world/regions/Point.java similarity index 86% rename from BauSystem_Main/src/de/steamwar/bausystem/world/regions/Point.java rename to BauSystem_API/src/de/steamwar/bausystem/world/regions/Point.java index b3f7f07..b7bdf43 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/regions/Point.java +++ b/BauSystem_API/src/de/steamwar/bausystem/world/regions/Point.java @@ -19,19 +19,13 @@ 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/commands/CommandSelect.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java index 1cb693c..93b1538 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandSelect.java @@ -1,16 +1,12 @@ 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 de.steamwar.core.VersionedRunnable; import lombok.Getter; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -19,9 +15,6 @@ 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"); } @@ -125,7 +118,8 @@ public class CommandSelect extends SWCommand { 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())); + VersionedRunnable.call(new VersionedRunnable(() -> CommandSelect_12.setSelection(p, minPoint, maxPoint), 12), + new VersionedRunnable(() -> CommandSelect_15.setSelection(p, minPoint, maxPoint), 15)); 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