SteamWar/FightSystem
Archiviert
13
1

Use SpigotCore VersionDependent #297

Zusammengeführt
Lixfel hat 1 Commits von useSpigotVersion nach master 2021-10-29 11:59:26 +02:00 zusammengeführt
9 geänderte Dateien mit 23 neuen und 57 gelöschten Zeilen

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem;
import de.steamwar.core.Core;
import java.lang.reflect.InvocationTargetException;
public class VersionDependent {
private VersionDependent() {}
public static <T> 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);
}
}

Datei anzeigen

@ -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);

Datei anzeigen

@ -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);

Datei anzeigen

@ -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);

Datei anzeigen

@ -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();

Datei anzeigen

@ -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);

Datei anzeigen

@ -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);

Datei anzeigen

@ -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);

Datei anzeigen

@ -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;