RefactoringVersionDependant #226
@ -21,7 +21,7 @@ package de.steamwar.fightsystem.fight;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import de.steamwar.comms.packets.TablistNamePacket;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.VersionedRunnable;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.IFightSystem;
|
||||
@ -277,26 +277,17 @@ public class FightTeam implements IFightTeam{
|
||||
return;
|
||||
}
|
||||
|
||||
EditSession e;
|
||||
|
||||
try {
|
||||
switch(Core.getVersion()){
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
e = FightTeam_8.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate);
|
||||
VersionedRunnable.call(new VersionedRunnable(() -> {
|
||||
EditSession e = FightTeam_8.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate);
|
||||
FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
||||
break;
|
||||
case 12:
|
||||
e = FightTeam_8.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate);
|
||||
}, 8), new VersionedRunnable(() -> {
|
||||
EditSession e = FightTeam_8.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate);
|
||||
FightTeam_12.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
||||
break;
|
||||
case 14:
|
||||
case 15:
|
||||
default:
|
||||
e = FightTeam_14.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate);
|
||||
}, 12), new VersionedRunnable(() -> {
|
||||
EditSession e = FightTeam_14.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate);
|
||||
FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
||||
}
|
||||
}, 14));
|
||||
} catch (Schematic.WrongVersionException ex) {
|
||||
broadcast(FightSystem.PREFIX + "§cDie gewählte Schematic kann nicht in dieser Version geladen werden");
|
||||
HandlerList.unregisterAll(freezer);
|
||||
@ -444,22 +435,10 @@ public class FightTeam implements IFightTeam{
|
||||
}
|
||||
|
||||
private void setTeamColor(Team team, ChatColor color){
|
||||
switch(Core.getVersion()){
|
||||
case 8:
|
||||
FightTeam_8.setTeamColor(team, color);
|
||||
break;
|
||||
case 9:
|
||||
case 10:
|
||||
FightTeam_9.setTeamColor(team, color);
|
||||
break;
|
||||
case 12:
|
||||
FightTeam_12.setTeamColor(team, color);
|
||||
break;
|
||||
case 14:
|
||||
case 15:
|
||||
default:
|
||||
FightTeam_14.setTeamColor(team, color);
|
||||
}
|
||||
VersionedRunnable.call(new VersionedRunnable(() -> FightTeam_8.setTeamColor(team, color), 8),
|
||||
new VersionedRunnable(() -> FightTeam_9.setTeamColor(team, color), 9),
|
||||
new VersionedRunnable(() -> FightTeam_12.setTeamColor(team, color), 12),
|
||||
new VersionedRunnable(() -> FightTeam_14.setTeamColor(team, color), 14));
|
||||
}
|
||||
|
||||
private static class FreezeWorld implements Listener {
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.VersionedRunnable;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
@ -46,47 +46,18 @@ public abstract class BasicListener implements Listener, StateDependent {
|
||||
}
|
||||
|
||||
public static void toActionbar(Player player, BaseComponent... components){
|
||||
switch(Core.getVersion()){
|
||||
case 8:
|
||||
BasicListener_8.toActionbar(player, components);
|
||||
break;
|
||||
case 9:
|
||||
case 10:
|
||||
case 12:
|
||||
case 14:
|
||||
case 15:
|
||||
default:
|
||||
BasicListener_9.toActionbar(player, components);
|
||||
}
|
||||
VersionedRunnable.call(new VersionedRunnable(() -> BasicListener_8.toActionbar(player, components), 8),
|
||||
new VersionedRunnable(() -> BasicListener_9.toActionbar(player, components), 9));
|
||||
}
|
||||
|
||||
public static void toChat(Player player, BaseComponent... components){
|
||||
switch(Core.getVersion()){
|
||||
case 8:
|
||||
BasicListener_8.toChat(player, components);
|
||||
break;
|
||||
case 9:
|
||||
case 10:
|
||||
case 12:
|
||||
case 14:
|
||||
case 15:
|
||||
default:
|
||||
BasicListener_9.toChat(player, components);
|
||||
}
|
||||
VersionedRunnable.call(new VersionedRunnable(() -> BasicListener_8.toChat(player, components), 8),
|
||||
new VersionedRunnable(() -> BasicListener_9.toChat(player, components), 9));
|
||||
}
|
||||
|
||||
void setAttackSpeed(Player player){
|
||||
switch(Core.getVersion()){
|
||||
case 8:
|
||||
break;
|
||||
case 9:
|
||||
case 10:
|
||||
case 12:
|
||||
case 14:
|
||||
case 15:
|
||||
default:
|
||||
BasicListener_9.setAttackSpeed(player);
|
||||
}
|
||||
VersionedRunnable.call(new VersionedRunnable(() -> {}, 8),
|
||||
new VersionedRunnable(() -> BasicListener_9.setAttackSpeed(player), 9));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,6 +20,7 @@
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.VersionedCallable;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
@ -177,21 +178,12 @@ public class PersonalKitCreator extends BasicListener {
|
||||
}
|
||||
|
||||
private static boolean hasItems(ItemStack stack){
|
||||
switch(Core.getVersion()){
|
||||
case 8:
|
||||
return PersonalKitCreator_8.hasItems(stack);
|
||||
case 9:
|
||||
return PersonalKitCreator_9.hasItems(stack);
|
||||
case 10:
|
||||
return PersonalKitCreator_10.hasItems(stack);
|
||||
case 12:
|
||||
return PersonalKitCreator_12.hasItems(stack);
|
||||
case 14:
|
||||
return PersonalKitCreator_14.hasItems(stack);
|
||||
case 15:
|
||||
default:
|
||||
return PersonalKitCreator_15.hasItems(stack);
|
||||
}
|
||||
return VersionedCallable.call(new VersionedCallable<>(() -> PersonalKitCreator_8.hasItems(stack), 8),
|
||||
new VersionedCallable<>(() -> PersonalKitCreator_9.hasItems(stack), 9),
|
||||
new VersionedCallable<>(() -> PersonalKitCreator_10.hasItems(stack), 10),
|
||||
new VersionedCallable<>(() -> PersonalKitCreator_12.hasItems(stack), 12),
|
||||
new VersionedCallable<>(() -> PersonalKitCreator_14.hasItems(stack), 14),
|
||||
new VersionedCallable<>(() -> PersonalKitCreator_15.hasItems(stack), 15));
|
||||
}
|
||||
|
||||
private static class InventoryBackup{
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.record;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.VersionedCallable;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
@ -289,15 +289,7 @@ public class RecordSystem {
|
||||
}
|
||||
|
||||
private static int blockToId(Block block){
|
||||
switch(Core.getVersion()){
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 12:
|
||||
return RecordSystem_8.blockToId(block);
|
||||
case 15:
|
||||
default:
|
||||
return RecordSystem_15.blockToId(block);
|
||||
}
|
||||
return VersionedCallable.call(new VersionedCallable<>(() -> RecordSystem_8.blockToId(block), 8),
|
||||
new VersionedCallable<>(() -> RecordSystem_15.blockToId(block), 15));
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.VersionedRunnable;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
|
||||
@ -49,19 +49,8 @@ public class ColorConverter {
|
||||
chat2dye.put(ChatColor.BLACK, DyeColor.BLACK);
|
||||
//Rosa 9pink, Braun 3brown
|
||||
|
||||
switch(Core.getVersion()){
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 12:
|
||||
chat2dye.put(ChatColor.GRAY, ColorConverter_8.getSilver());
|
||||
break;
|
||||
case 14:
|
||||
case 15:
|
||||
default:
|
||||
chat2dye.put(ChatColor.GRAY, ColorConverter_14.getSilver());
|
||||
break;
|
||||
}
|
||||
VersionedRunnable.call(new VersionedRunnable(() -> chat2dye.put(ChatColor.GRAY, ColorConverter_8.getSilver()), 8),
|
||||
new VersionedRunnable(() -> chat2dye.put(ChatColor.GRAY, ColorConverter_14.getSilver()), 14));
|
||||
}
|
||||
|
||||
public static DyeColor chat2dye(ChatColor color){
|
||||
|
@ -30,6 +30,7 @@ import com.comphenix.protocol.wrappers.ChunkCoordIntPair;
|
||||
import com.comphenix.protocol.wrappers.MultiBlockChangeInfo;
|
||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.VersionedRunnable;
|
||||
import de.steamwar.core.events.ChunkListener;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
@ -87,20 +88,10 @@ public class TechHider {
|
||||
blockHider();
|
||||
multiBlockHider();
|
||||
updateBlockEntity();
|
||||
switch(Core.getVersion()){
|
||||
case 15:
|
||||
TechHider_15.start();
|
||||
break;
|
||||
case 14:
|
||||
TechHider_14.start();
|
||||
break;
|
||||
case 10:
|
||||
case 9:
|
||||
case 8:
|
||||
break;
|
||||
default:
|
||||
TechHider_12.start();
|
||||
}
|
||||
VersionedRunnable.call(new VersionedRunnable(() -> {}, 8),
|
||||
new VersionedRunnable(TechHider_12::start, 12),
|
||||
new VersionedRunnable(TechHider_14::start, 14),
|
||||
new VersionedRunnable(TechHider_15::start, 15));
|
||||
}
|
||||
|
||||
private static void multiBlockHider(){
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.VersionedCallable;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@ -58,31 +58,13 @@ public class WaterRemover {
|
||||
}
|
||||
|
||||
public static boolean isWater(Block block){
|
||||
switch(Core.getVersion()){
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 12:
|
||||
return WaterRemover_8.isWater(block);
|
||||
case 14:
|
||||
case 15:
|
||||
default:
|
||||
return WaterRemover_14.isWater(block);
|
||||
}
|
||||
return VersionedCallable.call(new VersionedCallable<>(() -> WaterRemover_8.isWater(block), 8),
|
||||
new VersionedCallable<>(() -> WaterRemover_14.isWater(block), 14));
|
||||
}
|
||||
|
||||
public static boolean removeWater(Block block){
|
||||
//checks for water and removes it, if present
|
||||
switch(Core.getVersion()){
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 12:
|
||||
return WaterRemover_8.removeWater(block);
|
||||
case 14:
|
||||
case 15:
|
||||
default:
|
||||
return WaterRemover_14.removeWater(block);
|
||||
}
|
||||
return VersionedCallable.call(new VersionedCallable<>(() -> WaterRemover_8.removeWater(block), 8),
|
||||
new VersionedCallable<>(() -> WaterRemover_14.removeWater(block), 14));
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren