From de2f4a1c53a0fd221e86c99c1004bbc800c54ff2 Mon Sep 17 00:00:00 2001 From: jojo Date: Mon, 8 Feb 2021 20:56:18 +0100 Subject: [PATCH 1/5] Add VersionedRunnable to CommandDebugStick --- .../bausystem/commands/CommandDebugStick.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java index 0e5feb1..74e9f66 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandDebugStick.java @@ -22,7 +22,7 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.Welt; -import de.steamwar.core.Core; +import de.steamwar.core.VersionedRunnable; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -42,14 +42,8 @@ public class CommandDebugStick implements CommandExecutor { return false; } - switch(Core.getVersion()){ - case 15: - CommandDebugStick_15.giveStick(player); - break; - case 12: - default: - player.sendMessage(BauSystem.PREFIX + "§cDen Debugstick gibt es nicht in der 1.12."); - } + VersionedRunnable.call(new VersionedRunnable(() -> player.sendMessage(BauSystem.PREFIX + "§cDen Debugstick gibt es nicht in der 1.12."), 8), + new VersionedRunnable(() -> CommandDebugStick_15.giveStick(player), 15)); return false; } } -- 2.39.5 From 461e6d17a0a3574a8eb878ef06552180ce46b0b7 Mon Sep 17 00:00:00 2001 From: jojo Date: Mon, 8 Feb 2021 21:02:19 +0100 Subject: [PATCH 2/5] Add VersionedRunnable to AutoLoader --- .../de/steamwar/bausystem/world/AutoLoader.java | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java b/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java index 6763ac7..1b83664 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java @@ -20,7 +20,6 @@ package de.steamwar.bausystem.world; import de.steamwar.bausystem.BauSystem; -import de.steamwar.core.Core; import de.steamwar.core.VersionedCallable; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -225,12 +224,8 @@ public class AutoLoader extends IAutoLoader implements Listener { @Override boolean setRedstone(Location location, boolean active){ - switch(Core.getVersion()){ - case 15: - return AutoLoader_15.setRedstone(location, active); - default: - return AutoLoader_12.setRedstone(location, active); - } + return VersionedCallable.call(new VersionedCallable<>(() -> AutoLoader_12.setRedstone(location, active), 8), + new VersionedCallable<>(() -> AutoLoader_15.setRedstone(location, active), 15)); } @Override @@ -256,12 +251,8 @@ public class AutoLoader extends IAutoLoader implements Listener { @Override public boolean perform() { - switch(Core.getVersion()){ - case 15: - return AutoLoader_15.tntPlaceActionPerform(location); - default: - return AutoLoader_12.tntPlaceActionPerform(location); - } + return VersionedCallable.call(new VersionedCallable<>(() -> AutoLoader_12.tntPlaceActionPerform(location), 8), + new VersionedCallable<>(() -> AutoLoader_15.tntPlaceActionPerform(location), 15)); } @Override -- 2.39.5 From 9dc5c535f5f3b659fa40e63f9d5465cb35ee5380 Mon Sep 17 00:00:00 2001 From: jojo Date: Mon, 8 Feb 2021 21:02:31 +0100 Subject: [PATCH 3/5] Add VersionedRunnable to Region --- .../de/steamwar/bausystem/world/Region.java | 32 ++++--------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java index 0f3d682..e7a6007 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java @@ -21,7 +21,7 @@ package de.steamwar.bausystem.world; import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.bausystem.commands.CommandTNT.TNTMode; -import de.steamwar.core.Core; +import de.steamwar.core.VersionedRunnable; import de.steamwar.sql.NoClipboardException; import de.steamwar.sql.Schematic; import org.bukkit.Bukkit; @@ -298,14 +298,8 @@ public class Region { int x = region.minX + offsetX + sizeX/2; int y = region.minY + offsetY; int z = region.minZ + offsetZ + sizeZ/2; - switch(Core.getVersion()){ - case 12: - Region_12.paste(file, x, y, z, rotate); - break; - case 15: - default: - Region_15.fastpaste(file, x, y, z, rotate); - } + VersionedRunnable.call(new VersionedRunnable(() -> Region_12.paste(file, x, y, z, rotate), 8), + new VersionedRunnable(() -> Region_15.fastpaste(file, x, y, z, rotate), 15)); } public void reset(Region region, Schematic schem) throws IOException, NoClipboardException { @@ -345,25 +339,13 @@ public class Region { } private static void paste(File file, int x, int y, int z, boolean rotate){ //Type of protect - switch(Core.getVersion()){ - case 12: - Region_12.paste(file, x, y, z, rotate); - break; - case 15: - default: - Region_15.paste(file, x, y, z, rotate); - } + VersionedRunnable.call(new VersionedRunnable(() -> Region_12.paste(file, x, y, z, rotate), 8), + new VersionedRunnable(() -> Region_15.paste(file, x, y, z, rotate), 15)); } private static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate){ - switch(Core.getVersion()){ - case 12: - Region_12.paste(clipboard, x, y, z, rotate); - break; - case 15: - default: - Region_15.paste(clipboard, x, y, z, rotate); - } + VersionedRunnable.call(new VersionedRunnable(() -> Region_12.paste(clipboard, x, y, z, rotate), 8), + new VersionedRunnable(() -> Region_15.paste(clipboard, x, y, z, rotate), 15)); } } } -- 2.39.5 From d45c39c528b6119584a9c584a46c6290dd38781d Mon Sep 17 00:00:00 2001 From: jojo Date: Mon, 8 Feb 2021 21:02:47 +0100 Subject: [PATCH 4/5] Add VersionedRunnable to RegionListener --- .../de/steamwar/bausystem/world/RegionListener.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java index cb1fa12..64f5cf0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.world; import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; @@ -28,10 +29,10 @@ 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; import org.bukkit.ChatColor; -import com.comphenix.protocol.ProtocolLibrary; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Sign; @@ -105,13 +106,8 @@ public class RegionListener implements Listener { if(command.startsWith(shortcut)) return true; - switch(Core.getVersion()){ - case 12: - return RegionListener_12.isWorldEditCommand(command); - case 15: - default: - return RegionListener_15.isWorldEditCommand(command); - } + return VersionedCallable.call(new VersionedCallable<>(() -> RegionListener_12.isWorldEditCommand(command), 8), + new VersionedCallable<>(() -> RegionListener_15.isWorldEditCommand(command), 15)); } @EventHandler -- 2.39.5 From 1696aa4e546dc3ed2910040e04d4e188961b95f3 Mon Sep 17 00:00:00 2001 From: jojo Date: Mon, 8 Feb 2021 21:03:00 +0100 Subject: [PATCH 5/5] Add VersionedRunnable to ScriptListener --- .../de/steamwar/bausystem/world/ScriptListener.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java index 60c3121..07cffe3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java @@ -23,7 +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.core.Core; +import de.steamwar.core.VersionedCallable; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -72,13 +72,8 @@ public class ScriptListener implements Listener { } private boolean isNoBook(ItemStack item){ - switch(Core.getVersion()){ - case 12: - return ScriptListener_12.isNoBook(item); - case 15: - default: - return ScriptListener_15.isNoBook(item); - } + return VersionedCallable.call(new VersionedCallable<>(() -> ScriptListener_12.isNoBook(item), 8), + new VersionedCallable<>(() -> ScriptListener_15.isNoBook(item), 15)); } private static class ScriptExecutor { -- 2.39.5