Hotfix watertechko + simplify and speedup
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
10c461f317
Commit
2ee2d74432
@ -7,51 +7,35 @@ import de.steamwar.fightsystem.fight.FightTeam;
|
|||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.utils.WaterRemover;
|
import de.steamwar.fightsystem.utils.WaterRemover;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class WinconditionWaterTechKO extends Wincondition {
|
public class WinconditionWaterTechKO extends Wincondition {
|
||||||
|
|
||||||
private static final Set<Location> teamRedWater = new HashSet<>();
|
private static int teamRedWater;
|
||||||
private static final Set<Location> teamBlueWater = new HashSet<>();
|
private static int teamBlueWater;
|
||||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
private BukkitTask task;
|
private BukkitTask task;
|
||||||
|
|
||||||
public WinconditionWaterTechKO() {
|
public WinconditionWaterTechKO() {
|
||||||
super(Config.WaterTechKO, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING, FightState.SPECTATE));
|
super(Config.WaterTechKO, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getTeamBlueWater() {
|
public static int getTeamBlueWater() {
|
||||||
return teamBlueWater.size();
|
return teamBlueWater;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getTeamRedWater() {
|
public static int getTeamRedWater() {
|
||||||
return teamRedWater.size();
|
return teamRedWater;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
checkForWater(teamRedWater,
|
checkTask();
|
||||||
Config.TeamRedCornerX,
|
task = Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), this::checkTask, 200, 200);
|
||||||
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);
|
|
||||||
task = Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), this::addWater, 200, 200);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -59,25 +43,22 @@ public class WinconditionWaterTechKO extends Wincondition {
|
|||||||
task.cancel();
|
task.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkEmpty(FightTeam team, Set<Location> teamWater){
|
private void checkEmpty(FightTeam team, int teamWater){
|
||||||
if(teamWater.isEmpty()){
|
if(teamWater == 0){
|
||||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§eDas Team " + team.getColoredName() + " §eist Tech K.O.!");
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§eDas Team " + team.getColoredName() + " §eist Tech K.O.!");
|
||||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> FightSystem.setSpectateState(Fight.getOpposite(team), "WaterTechKO"));
|
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> FightSystem.setSpectateState(Fight.getOpposite(team), "WaterTechKO"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addWater() {
|
private void checkTask() {
|
||||||
if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING)
|
teamRedWater = calcWater(
|
||||||
return;
|
|
||||||
|
|
||||||
checkForWater(teamRedWater,
|
|
||||||
Config.TeamRedCornerX,
|
Config.TeamRedCornerX,
|
||||||
Config.TeamRedCornerY,
|
Config.TeamRedCornerY,
|
||||||
Config.TeamRedCornerZ,
|
Config.TeamRedCornerZ,
|
||||||
Config.TeamRedCornerX + Config.SchemsizeX,
|
Config.TeamRedCornerX + Config.SchemsizeX,
|
||||||
Config.TeamRedCornerY + Config.SchemsizeY,
|
Config.TeamRedCornerY + Config.SchemsizeY,
|
||||||
Config.TeamRedCornerZ + Config.SchemsizeZ);
|
Config.TeamRedCornerZ + Config.SchemsizeZ);
|
||||||
checkForWater(teamBlueWater,
|
teamBlueWater = calcWater(
|
||||||
Config.TeamBlueCornerX,
|
Config.TeamBlueCornerX,
|
||||||
Config.TeamBlueCornerY,
|
Config.TeamBlueCornerY,
|
||||||
Config.TeamBlueCornerZ,
|
Config.TeamBlueCornerZ,
|
||||||
@ -89,16 +70,16 @@ public class WinconditionWaterTechKO extends Wincondition {
|
|||||||
checkEmpty(Fight.getBlueTeam(), teamBlueWater);
|
checkEmpty(Fight.getBlueTeam(), teamBlueWater);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForWater(Set<Location> teamWater, int minX, int minY, int minZ, int maxX, int maxY, int maxZ){
|
private int calcWater(int minX, int minY, int minZ, int maxX, int maxY, int maxZ){
|
||||||
teamWater.clear();
|
int teamWater = 0;
|
||||||
|
|
||||||
for(int x = minX; x <= maxX; x++) {
|
for(int x = minX; x <= maxX; x++) {
|
||||||
for(int y = minY; y <= maxY; y++) {
|
for(int y = minY; y <= maxY; y++) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; z++) {
|
||||||
if (WaterRemover.isWater(WORLD.getBlockAt(x, y, z)))
|
if (WaterRemover.isWater(WORLD.getBlockAt(x, y, z)))
|
||||||
teamWater.add(new Location(WORLD, x, y, z));
|
teamWater++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return teamWater;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren