SteamWar/FightSystem
Archiviert
13
1

WaterTechKO improver & bugfixer

Dieser Commit ist enthalten in:
Lixfel 2019-10-06 17:22:23 +02:00
Ursprung 43276797fe
Commit 8a1aa18ace
4 geänderte Dateien mit 39 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -181,6 +181,8 @@ public class FightSystem extends JavaPlugin {
if(allFightPlayers.getPlayer() == null) if(allFightPlayers.getPlayer() == null)
continue; continue;
allFightPlayers.getPlayer().getInventory().clear(); allFightPlayers.getPlayer().getInventory().clear();
if(allFightPlayers.getKit() == null)
continue;
allFightPlayers.getKit().loadToPlayer(allFightPlayers.getPlayer()); allFightPlayers.getKit().loadToPlayer(allFightPlayers.getPlayer());
} }
} }

Datei anzeigen

@ -2,10 +2,10 @@ package de.steamwar.fightsystem.listener;
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.fight.FightTeam;
import de.steamwar.fightsystem.utils.Config;
import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightState; 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.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
@ -57,8 +57,8 @@ public class PlayerConnectionListener extends BasicListener{
}else if(fightState == FightState.PRE_RUNNING || fightState == FightState.RUNNING){ }else if(fightState == FightState.PRE_RUNNING || fightState == FightState.RUNNING){
FightPlayer fightPlayer = fightTeam.getFightPlayer(player); FightPlayer fightPlayer = fightTeam.getFightPlayer(player);
if(fightPlayer.isLiving()) { if(fightPlayer.isLiving()) {
fightTeam.getFightPlayer(player).setOut();
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + fightTeam.getPrefix() + player.getName() + " §chat den Kampf verlassen!"); Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + fightTeam.getPrefix() + player.getName() + " §chat den Kampf verlassen!");
fightTeam.getFightPlayer(player).setOut();
} }
} }
} }

Datei anzeigen

@ -14,7 +14,7 @@ public class WaterRemover {
private WaterRemover(){} private WaterRemover(){}
private static Map<Location, Integer> explodedBlocks = new HashMap<>(); private static final Map<Location, Integer> explodedBlocks = new HashMap<>();
private static Set<Block> waterList = new HashSet<>(); private static Set<Block> waterList = new HashSet<>();
public static void init() { public static void init() {
@ -25,26 +25,28 @@ public class WaterRemover {
} }
public static void add(List<Block> l) { public static void add(List<Block> 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() { private static void wateredCheck() {
Iterator<Map.Entry<Location, Integer>> it = explodedBlocks.entrySet().iterator(); synchronized (explodedBlocks){
while (it.hasNext()) { Iterator<Map.Entry<Location, Integer>> it = explodedBlocks.entrySet().iterator();
Map.Entry<Location, Integer> e = it.next(); while (it.hasNext()) {
Block b = e.getKey().getBlock(); Map.Entry<Location, Integer> e = it.next();
if (b.getType() == Material.WATER || b.getType() == Material.STATIONARY_WATER) { Block b = e.getKey().getBlock();
waterList.add(b); if (b.getType() == Material.STATIONARY_WATER || b.getType() == Material.WATER)
} waterList.add(b);
if(b.getType() != Material.AIR){ if(b.getType() != Material.AIR){
it.remove(); it.remove();
continue; continue;
} }
explodedBlocks.replace(e.getKey(), e.getValue() + 1); e.setValue(e.getValue() + 1);
if(explodedBlocks.get(e.getKey()) > 15){ if(e.getValue() > 15)
it.remove(); it.remove();
} }
} }
} }
@ -55,9 +57,8 @@ public class WaterRemover {
while(it.hasNext()){ while(it.hasNext()){
Block b = it.next(); Block b = it.next();
blocksToRemove.addAll(getSourceBlocksOfWater(b)); blocksToRemove.addAll(getSourceBlocksOfWater(b));
if (b.getType() != Material.WATER && b.getType() != Material.STATIONARY_WATER) { if (b.getType() != Material.STATIONARY_WATER)
it.remove(); it.remove();
}
} }
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> { Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> {

Datei anzeigen

@ -21,7 +21,21 @@ public class WinconditionWaterTechKO {
if(!Config.WaterTechKO) if(!Config.WaterTechKO)
return; 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() { private void addWater() {