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
Nur Änderungen aus Commit a9d4785a42 werden angezeigt - Alle Commits anzeigen

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; 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.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -28,7 +29,7 @@ import java.util.Set;
public class BlockIdWrapper { public class BlockIdWrapper {
private 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 { public interface IBlockIdWrapper {
int blockToId(Block block); int blockToId(Block block);

Datei anzeigen

@ -19,7 +19,8 @@
package de.steamwar.fightsystem.utils; 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 de.steamwar.fightsystem.fight.FightTeam;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -31,7 +32,7 @@ import java.util.UUID;
public class BountifulWrapper { public class BountifulWrapper {
private 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 { public interface IBountifulWrapper {
boolean mainHand(Object packet); boolean mainHand(Object packet);

Datei anzeigen

@ -19,7 +19,8 @@
package de.steamwar.fightsystem.utils; 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.World;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -28,7 +29,7 @@ import org.bukkit.inventory.ItemStack;
public class CraftbukkitWrapper { public class CraftbukkitWrapper {
private 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 { public interface ICraftbukkitWrapper {
void resetChunk(World world, World backup, int x, int z); void resetChunk(World world, World backup, int x, int z);

Datei anzeigen

@ -19,7 +19,8 @@
package de.steamwar.fightsystem.utils; 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.DyeColor;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -31,7 +32,7 @@ import org.bukkit.inventory.meta.ItemMeta;
public class FlatteningWrapper { public class FlatteningWrapper {
private 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 { public interface IFlatteningWrapper {
DyeColor getSilver(); DyeColor getSilver();

Datei anzeigen

@ -19,7 +19,8 @@
package de.steamwar.fightsystem.utils; package de.steamwar.fightsystem.utils;
import de.steamwar.fightsystem.VersionDependent; import de.steamwar.core.VersionDependent;
import de.steamwar.fightsystem.FightSystem;
import org.bukkit.Sound; import org.bukkit.Sound;
public enum SWSound { public enum SWSound {
@ -28,7 +29,7 @@ public enum SWSound {
BLOCK_NOTE_BASS, BLOCK_NOTE_BASS,
ENTITY_GENERIC_EXPLODE; 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() { public Sound getSound() {
return impl.getSound(this); return impl.getSound(this);

Datei anzeigen

@ -22,10 +22,10 @@ package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.Reflection;
import com.google.common.primitives.Bytes; import com.google.common.primitives.Bytes;
import de.steamwar.core.Core; import de.steamwar.core.Core;
import de.steamwar.core.VersionDependent;
import de.steamwar.core.events.ChunkListener; import de.steamwar.core.events.ChunkListener;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.VersionDependent;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
@ -66,7 +66,7 @@ public class TechHider extends StateDependent {
public TechHider(){ public TechHider(){
super(ENABLED, FightState.Schem); super(ENABLED, FightState.Schem);
chunkDataHider = VersionDependent.getVersionImpl(TechHider.class.getName()); chunkDataHider = VersionDependent.getVersionImpl(FightSystem.getPlugin());
techhiders.put(blockActionPacket, this::blockActionHider); techhiders.put(blockActionPacket, this::blockActionHider);
techhiders.put(blockChangePacket, this::blockChangeHider); techhiders.put(blockChangePacket, this::blockChangeHider);

Datei anzeigen

@ -19,7 +19,8 @@
package de.steamwar.fightsystem.utils; 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.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -30,7 +31,7 @@ import org.bukkit.scoreboard.Team;
public class WorldOfColorWrapper { public class WorldOfColorWrapper {
private 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 { public interface IWorldOfColorWrapper {
void setTeamColor(Team team, ChatColor color); 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.WorldEditException;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.transform.AffineTransform; 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 de.steamwar.sql.Schematic;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Location; import org.bukkit.Location;
@ -33,7 +34,7 @@ import java.io.IOException;
public class WorldeditWrapper { public class WorldeditWrapper {
private 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 { public interface IWorldeditWrapper {
void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException; void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException;