SteamWar/FightSystem
Archiviert
13
1

WaterTechKO fix

Dieser Commit ist enthalten in:
Lixfel 2019-11-10 18:03:23 +01:00
Ursprung c3f5412ed7
Commit e068a72f49
2 geänderte Dateien mit 20 neuen und 39 gelöschten Zeilen

Datei anzeigen

@ -1,7 +1,6 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.winconditions.WinconditionWaterTechKO;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -61,10 +60,7 @@ public class WaterRemover {
it.remove();
}
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> {
blocksToRemove.forEach((Block b) -> b.setType(Material.AIR));
WinconditionWaterTechKO.removeWater();
});
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> blocksToRemove.forEach((Block b) -> b.setType(Material.AIR)));
}
private static Set<Block> getSourceBlocksOfWater(Block startBlock) {

Datei anzeigen

@ -8,6 +8,7 @@ import de.steamwar.fightsystem.utils.Config;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import java.util.HashSet;
import java.util.Set;
@ -16,6 +17,7 @@ public class WinconditionWaterTechKO {
private static final Set<Location> teamRedWater = new HashSet<>();
private static final Set<Location> teamBlueWater = new HashSet<>();
private static final World WORLD = Bukkit.getWorlds().get(0);
public WinconditionWaterTechKO() {
if(!Config.WaterTechKO)
@ -61,17 +63,25 @@ public class WinconditionWaterTechKO {
checkEmpty(Fight.getBlueTeam(), teamBlueWater);
}
public static void removeWater() {
if(!Config.WaterTechKO)
return;
if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING)
return;
private void checkForWater(Set<Location> teamWater, int minX, int minY, int minZ, int maxX, int maxY, int maxZ){
teamWater.clear();
checkWaterspots(teamRedWater);
checkWaterspots(teamBlueWater);
for(int x = minX; x <= maxX; x++) {
for(int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
Material type = WORLD.getBlockAt(x, y, z).getType();
if (type == Material.STATIONARY_WATER || type == Material.WATER)
teamWater.add(new Location(WORLD, x, y, z));
}
}
}
}
checkEmpty(Fight.getRedTeam(), teamRedWater);
checkEmpty(Fight.getBlueTeam(), teamBlueWater);
private static void checkEmpty(FightTeam team, Set<Location> teamWater){
if(teamWater.isEmpty()){
Bukkit.broadcastMessage(FightSystem.PREFIX + "§eDas Team " + team.getName() + " §eist Tech K.O.!");
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> FightSystem.setSpectateState(Fight.getOpposite(team)));
}
}
public static int getTeamBlueWater() {
@ -81,29 +91,4 @@ public class WinconditionWaterTechKO {
public static int getTeamRedWater() {
return teamRedWater.size();
}
private void checkForWater(Set<Location> teamWater, int minX, int minY, int minZ, int maxX, int maxY, int maxZ){
teamWater.clear();
for(int x = minX; x <= maxX; x++) {
for(int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
Location location = new Location(Bukkit.getWorlds().get(0), x, y, z);
if (location.getBlock().getType() == Material.STATIONARY_WATER || location.getBlock().getType() == Material.WATER)
teamWater.add(location);
}
}
}
}
private static void checkWaterspots(Set<Location> teamWater){
teamWater.removeIf(location -> location.getBlock().getType() != Material.STATIONARY_WATER && location.getBlock().getType() != Material.WATER);
}
private static void checkEmpty(FightTeam team, Set<Location> teamWater){
if(teamWater.isEmpty()){
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + team.getName() + " §6ist Tech K.O.!");
FightSystem.setSpectateState(Fight.getOpposite(team));
}
}
}