Implement mutual exclusivity to prevent stacking
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
d0f97430ae
Commit
1e327c3588
@ -20,6 +20,7 @@ public class WinconditionPumpkinTechKO extends Wincondition {
|
||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||
private static final Material PUMPKIN_LANTERN = SWItem.getMaterial("JACK_O_LANTERN");
|
||||
private BukkitTask task;
|
||||
private static boolean running = false;
|
||||
|
||||
public WinconditionPumpkinTechKO(){
|
||||
super(Config.PumpkinTechKO, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING));
|
||||
@ -43,6 +44,9 @@ public class WinconditionPumpkinTechKO extends Wincondition {
|
||||
}
|
||||
|
||||
private static void recursiveCheck(){
|
||||
if(running)
|
||||
return;
|
||||
running = true;
|
||||
teamRedPumpkins = getPumpkins(Config.TeamRedCornerX,
|
||||
Config.TeamRedCornerY,
|
||||
Config.TeamRedCornerZ,
|
||||
@ -58,6 +62,7 @@ public class WinconditionPumpkinTechKO extends Wincondition {
|
||||
|
||||
checkKO(Fight.getRedTeam(), teamRedPumpkins);
|
||||
checkKO(Fight.getBlueTeam(), teamBluePumpkins);
|
||||
running = false;
|
||||
}
|
||||
|
||||
private static int getPumpkins(int minX, int minY, int minZ, int maxX, int maxY, int maxZ){
|
||||
|
@ -61,6 +61,7 @@ public class WinconditionRelativePercent extends Wincondition{
|
||||
private final FightTeam team;
|
||||
private final int blockCount;
|
||||
private final BukkitTask task;
|
||||
private boolean running = false;
|
||||
|
||||
private int currentBlocks;
|
||||
|
||||
@ -70,8 +71,12 @@ public class WinconditionRelativePercent extends Wincondition{
|
||||
this.currentBlocks = blockCount;
|
||||
|
||||
task = Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), () -> {
|
||||
if(running)
|
||||
return;
|
||||
running = true;
|
||||
currentBlocks = currentBlocks();
|
||||
checkPercentDefeat();
|
||||
running = false;
|
||||
}, 400, 400);
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ public class WinconditionTechKO extends ListenerWincondition {
|
||||
private TechKOCountdown smallerZcountdown = null;
|
||||
private TechKOCountdown biggerZcountdown = null;
|
||||
private BukkitTask task;
|
||||
private boolean running = false;
|
||||
|
||||
/**
|
||||
* Works only for z-Axis fight direction for performance reasons
|
||||
@ -59,6 +60,10 @@ public class WinconditionTechKO extends ListenerWincondition {
|
||||
}
|
||||
|
||||
private void run(){
|
||||
if(running)
|
||||
return;
|
||||
running = true;
|
||||
|
||||
for(TNTPrimed tnt : world.getEntitiesByClass(TNTPrimed.class)){
|
||||
int id = tnt.getEntityId();
|
||||
boolean smallerZ = tnt.getLocation().getZ() < toggle;
|
||||
@ -87,6 +92,7 @@ public class WinconditionTechKO extends ListenerWincondition {
|
||||
|
||||
smallerZtime--;
|
||||
biggerZtime--;
|
||||
running = false;
|
||||
}
|
||||
|
||||
private FightTeam smallerTeam(){
|
||||
|
@ -19,6 +19,7 @@ public class WinconditionWaterTechKO extends Wincondition {
|
||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||
|
||||
private BukkitTask task;
|
||||
private boolean running = false;
|
||||
|
||||
public WinconditionWaterTechKO() {
|
||||
super(Config.WaterTechKO, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING));
|
||||
@ -44,13 +45,16 @@ public class WinconditionWaterTechKO extends Wincondition {
|
||||
}
|
||||
|
||||
private void checkEmpty(FightTeam team, int teamWater){
|
||||
if(teamWater == 0 && FightSystem.getFightState() != FightState.SPECTATE){
|
||||
if(teamWater == 0){
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§eDas Team " + team.getColoredName() + " §eist Tech K.O.!");
|
||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> FightSystem.setSpectateState(Fight.getOpposite(team), "WaterTechKO"));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkTask() {
|
||||
if(running)
|
||||
return;
|
||||
running = true;
|
||||
teamRedWater = calcWater(
|
||||
Config.TeamRedCornerX,
|
||||
Config.TeamRedCornerY,
|
||||
@ -68,6 +72,7 @@ public class WinconditionWaterTechKO extends Wincondition {
|
||||
|
||||
checkEmpty(Fight.getRedTeam(), teamRedWater);
|
||||
checkEmpty(Fight.getBlueTeam(), teamBlueWater);
|
||||
running = false;
|
||||
}
|
||||
|
||||
private int calcWater(int minX, int minY, int minZ, int maxX, int maxY, int maxZ){
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren