WaterTechKO fix
Dieser Commit ist enthalten in:
Ursprung
c3f5412ed7
Commit
e068a72f49
@ -1,7 +1,6 @@
|
|||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.winconditions.WinconditionWaterTechKO;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -61,10 +60,7 @@ public class WaterRemover {
|
|||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> {
|
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> blocksToRemove.forEach((Block b) -> b.setType(Material.AIR)));
|
||||||
blocksToRemove.forEach((Block b) -> b.setType(Material.AIR));
|
|
||||||
WinconditionWaterTechKO.removeWater();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Set<Block> getSourceBlocksOfWater(Block startBlock) {
|
private static Set<Block> getSourceBlocksOfWater(Block startBlock) {
|
||||||
|
@ -8,6 +8,7 @@ import de.steamwar.fightsystem.utils.Config;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -16,6 +17,7 @@ public class WinconditionWaterTechKO {
|
|||||||
|
|
||||||
private static final Set<Location> teamRedWater = new HashSet<>();
|
private static final Set<Location> teamRedWater = new HashSet<>();
|
||||||
private static final Set<Location> teamBlueWater = new HashSet<>();
|
private static final Set<Location> teamBlueWater = new HashSet<>();
|
||||||
|
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
public WinconditionWaterTechKO() {
|
public WinconditionWaterTechKO() {
|
||||||
if(!Config.WaterTechKO)
|
if(!Config.WaterTechKO)
|
||||||
@ -61,17 +63,25 @@ public class WinconditionWaterTechKO {
|
|||||||
checkEmpty(Fight.getBlueTeam(), teamBlueWater);
|
checkEmpty(Fight.getBlueTeam(), teamBlueWater);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeWater() {
|
private void checkForWater(Set<Location> teamWater, int minX, int minY, int minZ, int maxX, int maxY, int maxZ){
|
||||||
if(!Config.WaterTechKO)
|
teamWater.clear();
|
||||||
return;
|
|
||||||
if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING)
|
|
||||||
return;
|
|
||||||
|
|
||||||
checkWaterspots(teamRedWater);
|
for(int x = minX; x <= maxX; x++) {
|
||||||
checkWaterspots(teamBlueWater);
|
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);
|
private static void checkEmpty(FightTeam team, Set<Location> teamWater){
|
||||||
checkEmpty(Fight.getBlueTeam(), teamBlueWater);
|
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() {
|
public static int getTeamBlueWater() {
|
||||||
@ -81,29 +91,4 @@ public class WinconditionWaterTechKO {
|
|||||||
public static int getTeamRedWater() {
|
public static int getTeamRedWater() {
|
||||||
return teamRedWater.size();
|
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren