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