diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/VersionDependent.java b/FightSystem_Core/src/de/steamwar/fightsystem/VersionDependent.java deleted file mode 100644 index d44a1e6..0000000 --- a/FightSystem_Core/src/de/steamwar/fightsystem/VersionDependent.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2021 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.fightsystem; - -import de.steamwar.core.Core; - -import java.lang.reflect.InvocationTargetException; - -public class VersionDependent { - private VersionDependent() {} - - public static T getVersionImpl(String className){ - for(int version = Core.getVersion(); version >= 8; version--) { - try { - return (T) Class.forName(className + version).getDeclaredConstructor().newInstance(); - } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { - throw new SecurityException("Could not load version dependent class", e); - } catch (ClassNotFoundException e) { - // try next version - } - } - throw new SecurityException("Unable to find version dependent implementation for " + className); - } -} diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/BlockIdWrapper.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/BlockIdWrapper.java index d293875..4d262e5 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/BlockIdWrapper.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/BlockIdWrapper.java @@ -19,7 +19,8 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.fightsystem.VersionDependent; +import de.steamwar.core.VersionDependent; +import de.steamwar.fightsystem.FightSystem; import org.bukkit.World; import org.bukkit.block.Block; @@ -28,7 +29,7 @@ import java.util.Set; public class BlockIdWrapper { private BlockIdWrapper() {} - public static final IBlockIdWrapper impl = VersionDependent.getVersionImpl(BlockIdWrapper.class.getName()); + public static final IBlockIdWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); public interface IBlockIdWrapper { int blockToId(Block block); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java index b951a68..18a2706 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java @@ -19,7 +19,8 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.fightsystem.VersionDependent; +import de.steamwar.core.VersionDependent; +import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.FightTeam; import org.bukkit.World; import org.bukkit.entity.Player; @@ -31,7 +32,7 @@ import java.util.UUID; public class BountifulWrapper { private BountifulWrapper() {} - public static final IBountifulWrapper impl = VersionDependent.getVersionImpl(BountifulWrapper.class.getName()); + public static final IBountifulWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); public interface IBountifulWrapper { boolean mainHand(Object packet); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper.java index a39b895..7724d75 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper.java @@ -19,7 +19,8 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.fightsystem.VersionDependent; +import de.steamwar.core.VersionDependent; +import de.steamwar.fightsystem.FightSystem; import org.bukkit.World; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -28,7 +29,7 @@ import org.bukkit.inventory.ItemStack; public class CraftbukkitWrapper { private CraftbukkitWrapper() {} - public static final ICraftbukkitWrapper impl = VersionDependent.getVersionImpl(CraftbukkitWrapper.class.getName()); + public static final ICraftbukkitWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); public interface ICraftbukkitWrapper { void resetChunk(World world, World backup, int x, int z); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java index 1317a16..13a5ab1 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java @@ -19,7 +19,8 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.fightsystem.VersionDependent; +import de.steamwar.core.VersionDependent; +import de.steamwar.fightsystem.FightSystem; import org.bukkit.DyeColor; import org.bukkit.World; import org.bukkit.block.Block; @@ -31,7 +32,7 @@ import org.bukkit.inventory.meta.ItemMeta; public class FlatteningWrapper { private FlatteningWrapper() {} - public static final IFlatteningWrapper impl = VersionDependent.getVersionImpl(FlatteningWrapper.class.getName()); + public static final IFlatteningWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); public interface IFlatteningWrapper { DyeColor getSilver(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/SWSound.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/SWSound.java index 9d6ece4..9ae178d 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/SWSound.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/SWSound.java @@ -19,7 +19,8 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.fightsystem.VersionDependent; +import de.steamwar.core.VersionDependent; +import de.steamwar.fightsystem.FightSystem; import org.bukkit.Sound; public enum SWSound { @@ -28,7 +29,7 @@ public enum SWSound { BLOCK_NOTE_BASS, ENTITY_GENERIC_EXPLODE; - private static final ISWSound impl = VersionDependent.getVersionImpl(SWSound.class.getName()); + private static final ISWSound impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); public Sound getSound() { return impl.getSound(this); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/TechHider.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/TechHider.java index 8b79648..61d9085 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/TechHider.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/TechHider.java @@ -22,10 +22,10 @@ package de.steamwar.fightsystem.utils; import com.comphenix.tinyprotocol.Reflection; import com.google.common.primitives.Bytes; import de.steamwar.core.Core; +import de.steamwar.core.VersionDependent; import de.steamwar.core.events.ChunkListener; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; -import de.steamwar.fightsystem.VersionDependent; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; @@ -66,7 +66,7 @@ public class TechHider extends StateDependent { public TechHider(){ super(ENABLED, FightState.Schem); - chunkDataHider = VersionDependent.getVersionImpl(TechHider.class.getName()); + chunkDataHider = VersionDependent.getVersionImpl(FightSystem.getPlugin()); techhiders.put(blockActionPacket, this::blockActionHider); techhiders.put(blockChangePacket, this::blockChangeHider); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper.java index 2bd0c37..8ca148a 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper.java @@ -19,7 +19,8 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.fightsystem.VersionDependent; +import de.steamwar.core.VersionDependent; +import de.steamwar.fightsystem.FightSystem; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Sound; @@ -30,7 +31,7 @@ import org.bukkit.scoreboard.Team; public class WorldOfColorWrapper { private WorldOfColorWrapper() {} - public static final IWorldOfColorWrapper impl = VersionDependent.getVersionImpl(WorldOfColorWrapper.class.getName()); + public static final IWorldOfColorWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); public interface IWorldOfColorWrapper { void setTeamColor(Team team, ChatColor color); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldeditWrapper.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldeditWrapper.java index d96df0a..35f3d37 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldeditWrapper.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldeditWrapper.java @@ -22,7 +22,8 @@ package de.steamwar.fightsystem.utils; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.transform.AffineTransform; -import de.steamwar.fightsystem.VersionDependent; +import de.steamwar.core.VersionDependent; +import de.steamwar.fightsystem.FightSystem; import de.steamwar.sql.Schematic; import org.bukkit.DyeColor; import org.bukkit.Location; @@ -33,7 +34,7 @@ import java.io.IOException; public class WorldeditWrapper { private WorldeditWrapper() {} - public static final IWorldeditWrapper impl = VersionDependent.getVersionImpl(WorldeditWrapper.class.getName()); + public static final IWorldeditWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); public interface IWorldeditWrapper { void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException;