From e9987079056ddc6cb89c794e2685656c24d02741 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 24 Mar 2021 10:18:00 +0100 Subject: [PATCH] =?UTF-8?q?Bugfixes=20noch=20und=20n=C3=B6cher!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lixfel --- .../src/de/steamwar/fightsystem/Config.java | 11 ++++--- .../fightsystem/utils/ITechHider.java | 4 +-- .../de/steamwar/fightsystem/utils/Region.java | 26 ++++++++------- .../fightsystem/commands/Commands.java | 7 ++-- .../fightsystem/fight/FightSchematic.java | 7 +++- .../steamwar/fightsystem/fight/FightTeam.java | 25 +++++++++----- .../fightsystem/fight/FightWorld.java | 1 + .../fightsystem/listener/ArenaBorder.java | 2 +- .../fightsystem/listener/NormalJoin.java | 8 ----- .../fightsystem/listener/Recording.java | 2 +- .../fightsystem/listener/SetupQuit.java | 3 +- .../states/OneShotStateDependent.java | 1 + .../fightsystem/states/StateDependent.java | 6 +++- .../states/StateDependentCommand.java | 1 + .../states/StateDependentCountdown.java | 2 ++ .../states/StateDependentListener.java | 3 ++ .../states/StateDependentTask.java | 2 ++ .../steamwar/fightsystem/utils/TechHider.java | 33 +++++++------------ .../EventTeamOffWincondition.java | 2 +- .../winconditions/Wincondition.java | 2 ++ .../WinconditionPercentSystem.java | 6 ++-- .../winconditions/WinconditionPoints.java | 7 ++-- .../WinconditionPumpkinTechKO.java | 7 +++- .../WinconditionRelativePercent.java | 8 +++-- .../WinconditionWaterTechKO.java | 5 ++- 25 files changed, 105 insertions(+), 76 deletions(-) diff --git a/FightSystem_API/src/de/steamwar/fightsystem/Config.java b/FightSystem_API/src/de/steamwar/fightsystem/Config.java index 3db29fe..f8da8bc 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/Config.java +++ b/FightSystem_API/src/de/steamwar/fightsystem/Config.java @@ -289,13 +289,14 @@ public class Config { RedRotate = teamRedRotate; BlueRotate = teamBlueRotate; + int arenaYSize = schemsizeY + PreperationArea; + RedPasteRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ); BluePasteRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ); - RedExtendRegion = new Region(teamRedCornerX, underBorder, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea); - BlueExtendRegion = new Region(blueCornerX, underBorder, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea); - int upperArenaBorder = blueCornerY + schemsizeY + PreperationArea; - ArenaRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, upperArenaBorder - underBorder, arenaMaxZ - arenaMinZ); + RedExtendRegion = new Region(teamRedCornerX, underBorder, teamRedCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea); + BlueExtendRegion = new Region(blueCornerX, underBorder, blueCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea); + ArenaRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, arenaYSize, arenaMaxZ - arenaMinZ); EventKampfID = Integer.parseInt(System.getProperty("fightID", "0")); if(EventKampfID >= 1){ @@ -380,7 +381,7 @@ public class Config { } public static boolean test(){ - return ArenaMode.Test.contains(ArenaMode.TEST); + return ArenaMode.Test.contains(mode); } public static boolean recording(){ return mode == ArenaMode.EVENT; diff --git a/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java b/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java index 572b888..ade4044 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java +++ b/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java @@ -40,9 +40,9 @@ public class ITechHider { if(ft == null){ return Config.ArenaRegion.chunkOutside(chunkX, chunkZ); }else if(ft.isBlue()){ - return ft.canPlayerEntern(p) || Config.BlueExtendRegion.chunkOutside(chunkX, chunkZ); - }else{ return ft.canPlayerEntern(p) || Config.RedExtendRegion.chunkOutside(chunkX, chunkZ); + }else{ + return ft.canPlayerEntern(p) || Config.BlueExtendRegion.chunkOutside(chunkX, chunkZ); } } diff --git a/FightSystem_API/src/de/steamwar/fightsystem/utils/Region.java b/FightSystem_API/src/de/steamwar/fightsystem/utils/Region.java index 9375b0c..d9df230 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/utils/Region.java +++ b/FightSystem_API/src/de/steamwar/fightsystem/utils/Region.java @@ -14,9 +14,9 @@ public class Region { private final int maxY; private final int maxZ; - public Region(int minX, int minY, int minZ, int sizeX, int maxY, int sizeZ, int extendX, int extendZ) { + public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ, int extendX, int extendZ) { this(minX - extendX, minY, minZ - extendZ, - minX + sizeX + extendX, maxY, minZ + sizeZ + extendZ); + sizeX + extendX * 2, sizeY, sizeZ + extendZ * 2); } public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) { @@ -52,20 +52,24 @@ public class Region { return maxZ; } - public int getMinChunkX(){ - return ITechHider.posToChunk(minX); + public double posToChunk(int pos){ + return pos / 16.0; } - public int getMaxChunkX(){ - return ITechHider.posToChunk(maxX); + private int getMinChunkX(){ + return (int) Math.floor(posToChunk(minX)); } - public int getMinChunkZ(){ - return ITechHider.posToChunk(minZ); + private int getMaxChunkX(){ + return (int) Math.ceil(posToChunk(maxX)); } - public int getMaxChunkZ(){ - return ITechHider.posToChunk(maxZ); + private int getMinChunkZ(){ + return (int) Math.floor(posToChunk(minZ)); + } + + private int getMaxChunkZ(){ + return (int) Math.ceil(posToChunk(maxZ)); } public boolean chunkOutside(int cX, int cZ) { @@ -110,7 +114,7 @@ public class Region { } public boolean playerInRegion(Location location){ - return in2dRegion(location) && minY < location.getY() && location.getY() + 1.8 < maxY; + return in2dRegion(location) && minY <= location.getY() && location.getY() + 1.8 < maxY; } public boolean in2dRegion(Block block){ diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java b/FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java index 94ad0fb..973440a 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java @@ -96,9 +96,6 @@ public class Commands { } static void toggleSkip(Player p){ - if(checkSetup(p)) - return; - FightTeam fightTeam = checkGetTeam(p); if(fightTeam == null || checkGetLeader(p) == null) return; @@ -213,8 +210,10 @@ public class Commands { Kit k = null; if(Config.PersonalKits){ PersonalKit kit = PersonalKit.get(SteamwarUser.get(p.getUniqueId()).getId(), Config.SchematicType.toDB(), kitName); - if(kit != null) + if(kit != null){ kit.setInUse(); + k = new Kit(kit); + } }else{ k = Kit.getKitByName(kitName); } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightSchematic.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightSchematic.java index c0f857c..7a76a2c 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightSchematic.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightSchematic.java @@ -60,10 +60,11 @@ public class FightSchematic extends StateDependent { this.team = team; this.region = team.getSchemRegion(); this.rotate = rotate; + register(); } public boolean hasSchematic(){ - return clipboard == null; + return clipboard != null; } public int getId(){ @@ -109,6 +110,10 @@ public class FightSchematic extends StateDependent { else RecordSystem.redSchem(schematic); + Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::paste); + } + + private void paste(){ FreezeWorld freezer = new FreezeWorld(); DyeColor c = ColorConverter.chat2dye(team.getColor()); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java index 7e67e09..e7fcacc 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -140,15 +140,18 @@ public class FightTeam implements IFightTeam{ } public void reset(){ + skip = false; + ready = false; schematic.reset(); invited.clear(); + Set playerSet = new HashSet<>(players.keySet()); for(Player player : playerSet){ - if(!player.isOnline()) + if(!Bukkit.getOnlinePlayers().contains(player)) removePlayer(player); } FightPlayer leaderBackup = leader; - playerSet.removeIf(player -> !player.isOnline()); + playerSet.removeIf(player -> !Bukkit.getOnlinePlayers().contains(player)); players.clear(); leader = null; @@ -183,6 +186,7 @@ public class FightTeam implements IFightTeam{ Fight.setPlayerGamemode(player, GameMode.SURVIVAL); player.setHealth(20); player.setFoodLevel(20); + player.getInventory().clear(); BasicListener.setAttackSpeed(player); player.teleport(spawn); if(Kit.getAvailableKits(false).size() > 1 || Config.PersonalKits) @@ -234,13 +238,12 @@ public class FightTeam implements IFightTeam{ private void setLeader(FightPlayer leader) { if (leader == null) { - if (FightState.getFightState() == FightState.PRE_LEADER_SETUP){ - this.leader = null; - }else if(!players.isEmpty()) { + this.leader = null; + if(!players.isEmpty()) { setLeader(players.values().iterator().next()); Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + this.leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!"); - }else if(!ArenaMode.RankedEvent.contains(Config.mode)){ - FightSystem.setPreLeaderState(); + }else if(FightState.getFightState() != FightState.PRE_LEADER_SETUP && !ArenaMode.RankedEvent.contains(Config.mode)){ + Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), FightSystem::setPreLeaderState, 1); } return; } @@ -271,6 +274,10 @@ public class FightTeam implements IFightTeam{ if(Config.test() || FightState.getFightState() != FightState.POST_SCHEM_SETUP) inventory.setItem(0, new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§e" + Config.GameName + " wählen").build()); + + if(FightState.getFightState() == FightState.PRE_LEADER_SETUP && !Fight.getOpposite(this).isLeaderless()){ + FightSystem.setPreSchemState(); + } } public Collection getPlayers() { @@ -284,7 +291,7 @@ public class FightTeam implements IFightTeam{ public void pasteSchem(Schematic schematic){ setSchem(schematic); - if(ArenaMode.Test.contains(Config.mode)) + if(Config.test()) this.schematic.enable(); else if(Fight.getOpposite(this).hasSchematic()){ FightSystem.setPostSchemState(); @@ -385,6 +392,7 @@ public class FightTeam implements IFightTeam{ private class KitLoader extends StateDependent { private KitLoader() { super(ArenaMode.All, FightState.Ingame); + register(); } @Override @@ -408,6 +416,7 @@ public class FightTeam implements IFightTeam{ private class SpectateHandler extends StateDependent { private SpectateHandler() { super(ArenaMode.All, FightState.Spectate); + register(); } @Override diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightWorld.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightWorld.java index 6245c59..0ae81ef 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightWorld.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightWorld.java @@ -18,6 +18,7 @@ public class FightWorld extends StateDependent { public FightWorld() { super(ArenaMode.Restartable, FightState.Schem); + register(); } @Override diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArenaBorder.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArenaBorder.java index 989e8ac..d0ceee8 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArenaBorder.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArenaBorder.java @@ -59,7 +59,7 @@ public class ArenaBorder implements Listener { player.damage(2); else if(!Config.GroundWalkable) player.teleport(team.getSpawn()); - }else if(to.getY() + 1.8 <= Config.ArenaRegion.getMaxY()){ + }else if(to.getY() + 1.8 > Config.ArenaRegion.getMaxY()){ reset(event); } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/NormalJoin.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/NormalJoin.java index a7e3937..c8c08c4 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/NormalJoin.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/NormalJoin.java @@ -21,9 +21,7 @@ package de.steamwar.fightsystem.listener; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; -import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; -import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; @@ -50,11 +48,5 @@ public class NormalJoin implements Listener { Fight.getRedTeam().addMember(player); } } - - FightPlayer redLeader = Fight.getRedTeam().getLeader(); - FightPlayer blueLeader = Fight.getBlueTeam().getLeader(); - if(redLeader != null && blueLeader != null && (Fight.getRedTeam().getLeader().getPlayer() == player || Fight.getBlueTeam().getLeader().getPlayer() == player)) { - FightSystem.setPreSchemState(); - } } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Recording.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/Recording.java index fdcb5cd..1e5c287 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Recording.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/Recording.java @@ -70,7 +70,7 @@ public class Recording implements Listener { despawnTeam(Fight.getBlueTeam()); despawnTNT(); } - }; + }.register(); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/SetupQuit.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/SetupQuit.java index 15776f3..e4360dd 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/SetupQuit.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/SetupQuit.java @@ -26,7 +26,6 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; @@ -36,7 +35,7 @@ public class SetupQuit implements Listener { new StateDependentListener(ArenaMode.All, FightState.Setup, this); } - @EventHandler(priority = EventPriority.HIGH) + @EventHandler public void handlePlayerQuit(PlayerQuitEvent event) { event.setQuitMessage(null); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/OneShotStateDependent.java b/FightSystem_Main/src/de/steamwar/fightsystem/states/OneShotStateDependent.java index 46d719e..6093d58 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/states/OneShotStateDependent.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/states/OneShotStateDependent.java @@ -11,6 +11,7 @@ public class OneShotStateDependent extends StateDependent{ public OneShotStateDependent(Set mode, Set states, Runnable runnable) { super(mode, states); this.runnable = runnable; + register(); } @Override diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependent.java b/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependent.java index 9b17b43..be9d0eb 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependent.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependent.java @@ -9,6 +9,7 @@ import java.util.Set; public abstract class StateDependent implements IStateDependent { private final Set enabled; + private final boolean register; protected StateDependent(Winconditions wincondition, Set states){ this(Config.ActiveWinconditions.contains(wincondition), states); @@ -20,8 +21,11 @@ public abstract class StateDependent implements IStateDependent { protected StateDependent(boolean enabled, Set states){ this.enabled = states; + this.register = enabled; + } - if(enabled) + public void register(){ + if(register) FightState.registerStateDependent(this); } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentCommand.java b/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentCommand.java index 03bcf29..a0da55a 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentCommand.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentCommand.java @@ -42,6 +42,7 @@ public class StateDependentCommand extends StateDependent { this.command = FightSystem.getPlugin().getCommand(name); assert command != null; disable(); + register(); } @Override diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentCountdown.java b/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentCountdown.java index 57bc00b..dd205cc 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentCountdown.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentCountdown.java @@ -33,11 +33,13 @@ public class StateDependentCountdown extends StateDependent { public StateDependentCountdown(Set mode, Set states, Countdown countdown) { super(mode, states); this.countdown = countdown; + register(); } public StateDependentCountdown(Winconditions wincondition, Set states, Countdown countdown) { super(Config.ActiveWinconditions.contains(wincondition), states); this.countdown = countdown; + register(); } public Countdown getCountdown(){ diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentListener.java b/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentListener.java index 8a34a3e..f5cfffc 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentListener.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentListener.java @@ -36,16 +36,19 @@ public class StateDependentListener extends StateDependent{ public StateDependentListener(Winconditions wincondition, Set states, Listener listener){ super(Config.ActiveWinconditions.contains(wincondition), states); this.listener = listener; + register(); } public StateDependentListener(boolean enabled, Set states, Listener listener){ super(enabled, states); this.listener = listener; + register(); } public StateDependentListener(Set mode, Set states, Listener listener) { super(mode, states); this.listener = listener; + register(); } @Override diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentTask.java b/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentTask.java index cc219a8..950fbcb 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentTask.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentTask.java @@ -45,6 +45,7 @@ public class StateDependentTask extends StateDependent { this.runnable = runnable; this.delay = delay; this.period = period; + register(); } public StateDependentTask(Set mode, Set states, Runnable runnable, long delay, long period) { @@ -52,6 +53,7 @@ public class StateDependentTask extends StateDependent { this.runnable = runnable; this.delay = delay; this.period = period; + register(); } @Override diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java b/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java index 1cf0331..e7933fc 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java @@ -38,7 +38,7 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.IFightSystem; import de.steamwar.fightsystem.states.FightState; -import de.steamwar.fightsystem.states.IStateDependent; +import de.steamwar.fightsystem.states.StateDependent; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Material; @@ -48,11 +48,10 @@ import java.util.*; import static de.steamwar.fightsystem.utils.ITechHider.bypass; -public class TechHider implements IStateDependent { +public class TechHider extends StateDependent { - private static final boolean DISABLED = !Config.OnlyPublicSchematics && !Config.test() && Config.TechhiderActive; + private static final boolean enabled = !Config.OnlyPublicSchematics && !Config.test() && Config.TechhiderActive; - private final Set enabled; private final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); private final Map packetCache = new HashMap<>(); private final Material obfuscateMaterial; @@ -60,10 +59,7 @@ public class TechHider implements IStateDependent { private final int threadMultiplier; public TechHider(){ - FightState.registerStateDependent(this); - enabled = DISABLED - ? EnumSet.noneOf(FightState.class) - : EnumSet.complementOf(EnumSet.of(FightState.PRE_LEADER_SETUP, FightState.PRE_SCHEM_SETUP)); + super(enabled, FightState.Schem); Set hiddenBlockIds = VersionedCallable.call( new VersionedCallable<>(Collections::emptySet, 8), @@ -76,7 +72,7 @@ public class TechHider implements IStateDependent { new VersionedCallable<>(TechHider_14::getObfuscateWith, 14), new VersionedCallable<>(TechHider_15::getObfuscateWith, 15)); - obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith); + obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith.toUpperCase()); chunkHider = VersionedCallable.call(new VersionedCallable<>(() -> null, 8), new VersionedCallable<>(() -> TechHider_12.chunkHider(hiddenBlockIds, obfuscateWith), 12), new VersionedCallable<>(() -> TechHider_14.chunkHider(hiddenBlockIds, obfuscateWith), 14)); @@ -86,9 +82,6 @@ public class TechHider implements IStateDependent { else threadMultiplier = 1; - if(DISABLED) - return; - Bukkit.getScheduler().runTaskTimer(IFightSystem.getPlugin(), packetCache::clear, 1, 1); if(Core.getVersion() > 8){ @@ -111,11 +104,7 @@ public class TechHider implements IStateDependent { e.setCancelled(true); } }); - } - - @Override - public Set enabled() { - return enabled; + register(); } @Override @@ -174,7 +163,7 @@ public class TechHider implements IStateDependent { boolean changed = false; for(MultiBlockChangeInfo mbci : changes){ WrappedBlockData block = mbci.getData(); - if(Config.HiddenBlocks.contains(block.getType().name())){ + if(Config.HiddenBlocks.contains(block.getType().name().toLowerCase())){ changed = true; block.setType(obfuscateMaterial); mbci.setData(block); @@ -208,7 +197,7 @@ public class TechHider implements IStateDependent { e.setPacket(cached); StructureModifier blockStructure = cached.getBlockData(); WrappedBlockData block = blockStructure.read(0); - if(Config.HiddenBlocks.contains(block.getType().name())){ + if(Config.HiddenBlocks.contains(block.getType().name().toLowerCase())){ block.setType(obfuscateMaterial); blockStructure.write(0, block); } @@ -251,7 +240,7 @@ public class TechHider implements IStateDependent { e.setPacket(cached); StructureModifier blockStructure = cached.getBlockData(); WrappedBlockData block = blockStructure.read(0); - if(Config.HiddenBlocks.contains(block.getType().name())){ + if(Config.HiddenBlocks.contains(block.getType().name().toLowerCase())){ block.setType(obfuscateMaterial); blockStructure.write(0, block); } @@ -277,7 +266,7 @@ public class TechHider implements IStateDependent { }; public static List prepareChunkReload(Player p){ - if(DISABLED) + if(enabled) return Collections.emptyList(); List chunksToReload = new ArrayList<>(); Config.ArenaRegion.forEachChunk((x, z) -> { @@ -288,7 +277,7 @@ public class TechHider implements IStateDependent { } public static void reloadChunks(Player p, List chunksToReload){ - if(DISABLED) + if(enabled) return; Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> { for(ChunkPos chunk : chunksToReload){ diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java index ca74fdb..1e3941b 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java @@ -44,7 +44,7 @@ public class EventTeamOffWincondition extends Wincondition{ public void disable() { //Team off is a one time trigger } - }; + }.register(); } private void teamOff(FightTeam team){ diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/Wincondition.java b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/Wincondition.java index f24d7a8..984fe29 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/Wincondition.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/Wincondition.java @@ -57,6 +57,8 @@ public abstract class Wincondition { } public static Countdown getTimeOverCountdown(){ + if(timeOverCountdown == null) + return null; return timeOverCountdown.getCountdown(); } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java index baed79b..5e6a838 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java @@ -37,12 +37,14 @@ public class WinconditionPercentSystem extends Wincondition implements Listener, public WinconditionPercentSystem() { super("Percent", "§cTeam ", " §chat den Gegnern"); - printableWinconditions.add(this); - percentWincondition = this; teamMap.put(Fight.getBlueTeam(), new TeamPercent(Fight.getBlueTeam())); teamMap.put(Fight.getRedTeam(), new TeamPercent(Fight.getRedTeam())); new StateDependentListener(Winconditions.PERCENT_SYSTEM, FightState.Running, this); + if(Config.ActiveWinconditions.contains(Winconditions.PERCENT_SYSTEM)){ + printableWinconditions.add(this); + percentWincondition = this; + } } @EventHandler diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java index 3fa6a78..46caf0e 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java @@ -19,6 +19,7 @@ package de.steamwar.fightsystem.winconditions; +import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.countdown.TimeOverCountdown; import de.steamwar.fightsystem.fight.Fight; @@ -46,7 +47,6 @@ public class WinconditionPoints extends Wincondition implements PrintableWincond teamMap.put(Fight.getBlueTeam(), new TeamPoints(Fight.getBlueTeam())); teamMap.put(Fight.getRedTeam(), new TeamPoints(Fight.getRedTeam())); - printableWinconditions.add(this); new StateDependentListener(Winconditions.POINTS, FightState.Ingame, this); timeOverCountdown = new StateDependentCountdown(Winconditions.POINTS, FightState.Running, new TimeOverCountdown(this::timeOver)); @@ -60,7 +60,10 @@ public class WinconditionPoints extends Wincondition implements PrintableWincond public void disable() { teamMap.values().forEach(TeamPoints::disable); } - }; + }.register(); + if(Config.ActiveWinconditions.contains(Winconditions.POINTS)){ + printableWinconditions.add(this); + } } protected void timeOver() { diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java index fb1fcb0..187502d 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java @@ -19,6 +19,7 @@ package de.steamwar.fightsystem.winconditions; +import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; @@ -40,9 +41,13 @@ public class WinconditionPumpkinTechKO extends Wincondition implements Printable public WinconditionPumpkinTechKO(){ super("PumpkinTechKO", "§cDas Team ", " §cist Tech K.O.!"); - new StateDependentTask(Winconditions.PUMPKIN_TECH_KO, FightState.Ingame, this::check, 0, 200); teamMap.put(Fight.getRedTeam(), new TeamPumpkin(Fight.getRedTeam())); teamMap.put(Fight.getBlueTeam(), new TeamPumpkin(Fight.getBlueTeam())); + + new StateDependentTask(Winconditions.PUMPKIN_TECH_KO, FightState.Ingame, this::check, 0, 200); + if(Config.ActiveWinconditions.contains(Winconditions.PUMPKIN_TECH_KO)){ + printableWinconditions.add(this); + } } private void check(){ diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java index c6aeedc..ba8c35b 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java @@ -50,8 +50,6 @@ public class WinconditionRelativePercent extends Wincondition implements Printab super("RelativePercent", null); teamMap.put(Fight.getBlueTeam(), new TeamPercent(Fight.getBlueTeam())); teamMap.put(Fight.getRedTeam(), new TeamPercent(Fight.getRedTeam())); - printableWinconditions.add(this); - percentWincondition = this; new StateDependent(Winconditions.RELATIVE_PERCENT, FightState.Running){ @Override public void enable() { @@ -62,7 +60,11 @@ public class WinconditionRelativePercent extends Wincondition implements Printab public void disable() { teamMap.values().forEach(TeamPercent::disable); } - }; + }.register(); + if(Config.ActiveWinconditions.contains(Winconditions.RELATIVE_PERCENT)){ + printableWinconditions.add(this); + percentWincondition = this; + } } @Override diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java index 4516630..a95ebb5 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java @@ -19,6 +19,7 @@ package de.steamwar.fightsystem.winconditions; +import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.listener.WaterRemover; @@ -40,9 +41,11 @@ public class WinconditionWaterTechKO extends Wincondition implements PrintableWi super("WaterTechKO", "§cDas Team ", " §cwurde Tech K.O. gesetzt!"); teamMap.put(Fight.getBlueTeam(), new TeamWater(Fight.getBlueTeam())); teamMap.put(Fight.getRedTeam(), new TeamWater(Fight.getRedTeam())); - printableWinconditions.add(this); new StateDependentTask(Winconditions.WATER_TECH_KO, FightState.Ingame, this::check, 200, 200); + if(Config.ActiveWinconditions.contains(Winconditions.WATER_TECH_KO)){ + printableWinconditions.add(this); + } } private void check() {