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)
continue;
allFightPlayers.getPlayer().getInventory().clear();
if(allFightPlayers.getKit() == null)
continue;
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.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();
}
}
}

Datei anzeigen

@ -14,7 +14,7 @@ public class 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<>();
public static void init() {
@ -25,26 +25,28 @@ public class WaterRemover {
}
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() {
Iterator<Map.Entry<Location, Integer>> it = explodedBlocks.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Location, Integer> e = it.next();
Block b = e.getKey().getBlock();
if (b.getType() == Material.WATER || b.getType() == Material.STATIONARY_WATER) {
waterList.add(b);
}
synchronized (explodedBlocks){
Iterator<Map.Entry<Location, Integer>> it = explodedBlocks.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Location, Integer> 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(), () -> {

Datei anzeigen

@ -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() {