diff --git a/src/de/steamwar/fightsystem/FightSystem.java b/src/de/steamwar/fightsystem/FightSystem.java index 1b257e3..9019fe9 100644 --- a/src/de/steamwar/fightsystem/FightSystem.java +++ b/src/de/steamwar/fightsystem/FightSystem.java @@ -181,6 +181,8 @@ public class FightSystem extends JavaPlugin { if(allFightPlayers.getPlayer() == null) continue; allFightPlayers.getPlayer().getInventory().clear(); + if(allFightPlayers.getKit() == null) + continue; allFightPlayers.getKit().loadToPlayer(allFightPlayers.getPlayer()); } } diff --git a/src/de/steamwar/fightsystem/listener/PlayerConnectionListener.java b/src/de/steamwar/fightsystem/listener/PlayerConnectionListener.java index 912bc84..19c13a8 100644 --- a/src/de/steamwar/fightsystem/listener/PlayerConnectionListener.java +++ b/src/de/steamwar/fightsystem/listener/PlayerConnectionListener.java @@ -2,10 +2,10 @@ package de.steamwar.fightsystem.listener; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; -import de.steamwar.fightsystem.fight.FightTeam; -import de.steamwar.fightsystem.utils.Config; import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.fight.FightState; +import de.steamwar.fightsystem.fight.FightTeam; +import de.steamwar.fightsystem.utils.Config; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.attribute.Attribute; @@ -57,8 +57,8 @@ public class PlayerConnectionListener extends BasicListener{ }else if(fightState == FightState.PRE_RUNNING || fightState == FightState.RUNNING){ FightPlayer fightPlayer = fightTeam.getFightPlayer(player); if(fightPlayer.isLiving()) { - fightTeam.getFightPlayer(player).setOut(); Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + fightTeam.getPrefix() + player.getName() + " §chat den Kampf verlassen!"); + fightTeam.getFightPlayer(player).setOut(); } } } diff --git a/src/de/steamwar/fightsystem/utils/WaterRemover.java b/src/de/steamwar/fightsystem/utils/WaterRemover.java index 4a0e9ce..dd72072 100644 --- a/src/de/steamwar/fightsystem/utils/WaterRemover.java +++ b/src/de/steamwar/fightsystem/utils/WaterRemover.java @@ -14,7 +14,7 @@ public class WaterRemover { private WaterRemover(){} - private static Map explodedBlocks = new HashMap<>(); + private static final Map explodedBlocks = new HashMap<>(); private static Set waterList = new HashSet<>(); public static void init() { @@ -25,26 +25,28 @@ public class WaterRemover { } public static void add(List l) { - l.forEach((Block b) -> explodedBlocks.put(b.getLocation(), 0)); + synchronized (explodedBlocks){ + l.forEach((Block b) -> explodedBlocks.put(b.getLocation(), 0)); + } } private static void wateredCheck() { - Iterator> it = explodedBlocks.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry e = it.next(); - Block b = e.getKey().getBlock(); - if (b.getType() == Material.WATER || b.getType() == Material.STATIONARY_WATER) { - waterList.add(b); - } + synchronized (explodedBlocks){ + Iterator> it = explodedBlocks.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry e = it.next(); + Block b = e.getKey().getBlock(); + if (b.getType() == Material.STATIONARY_WATER || b.getType() == Material.WATER) + waterList.add(b); - if(b.getType() != Material.AIR){ - it.remove(); - continue; - } - explodedBlocks.replace(e.getKey(), e.getValue() + 1); + if(b.getType() != Material.AIR){ + it.remove(); + continue; + } + e.setValue(e.getValue() + 1); - if(explodedBlocks.get(e.getKey()) > 15){ - it.remove(); + if(e.getValue() > 15) + it.remove(); } } } @@ -55,9 +57,8 @@ public class WaterRemover { while(it.hasNext()){ Block b = it.next(); blocksToRemove.addAll(getSourceBlocksOfWater(b)); - if (b.getType() != Material.WATER && b.getType() != Material.STATIONARY_WATER) { + if (b.getType() != Material.STATIONARY_WATER) it.remove(); - } } Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> { diff --git a/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java b/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java index aa704cc..e3cdf91 100644 --- a/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java +++ b/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java @@ -21,7 +21,21 @@ public class WinconditionWaterTechKO { if(!Config.WaterTechKO) return; - Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), this::addWater, 0, 200); + Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), this::addWater, 200, 200); + checkForWater(teamRedWater, + Config.TeamRedCornerX, + Config.TeamRedCornerY, + Config.TeamRedCornerZ, + Config.TeamRedCornerX + Config.SchemsizeX, + Config.TeamRedCornerY + Config.SchemsizeY, + Config.TeamRedCornerZ + Config.SchemsizeZ); + checkForWater(teamBlueWater, + Config.TeamBlueCornerX, + Config.TeamBlueCornerY, + Config.TeamBlueCornerZ, + Config.TeamBlueCornerX + Config.SchemsizeX, + Config.TeamBlueCornerY + Config.SchemsizeY, + Config.TeamBlueCornerZ + Config.SchemsizeZ); } private void addWater() {