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; } } 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 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)); } } } 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 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 {