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 World WORLD = Bukkit.getWorlds().get(0);
|
||||||
private static final Material PUMPKIN_LANTERN = SWItem.getMaterial("JACK_O_LANTERN");
|
private static final Material PUMPKIN_LANTERN = SWItem.getMaterial("JACK_O_LANTERN");
|
||||||
private BukkitTask task;
|
private BukkitTask task;
|
||||||
|
private static boolean running = false;
|
||||||
|
|
||||||
public WinconditionPumpkinTechKO(){
|
public WinconditionPumpkinTechKO(){
|
||||||
super(Config.PumpkinTechKO, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING));
|
super(Config.PumpkinTechKO, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING));
|
||||||
@ -43,6 +44,9 @@ public class WinconditionPumpkinTechKO extends Wincondition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void recursiveCheck(){
|
private static void recursiveCheck(){
|
||||||
|
if(running)
|
||||||
|
return;
|
||||||
|
running = true;
|
||||||
teamRedPumpkins = getPumpkins(Config.TeamRedCornerX,
|
teamRedPumpkins = getPumpkins(Config.TeamRedCornerX,
|
||||||
Config.TeamRedCornerY,
|
Config.TeamRedCornerY,
|
||||||
Config.TeamRedCornerZ,
|
Config.TeamRedCornerZ,
|
||||||
@ -58,6 +62,7 @@ public class WinconditionPumpkinTechKO extends Wincondition {
|
|||||||
|
|
||||||
checkKO(Fight.getRedTeam(), teamRedPumpkins);
|
checkKO(Fight.getRedTeam(), teamRedPumpkins);
|
||||||
checkKO(Fight.getBlueTeam(), teamBluePumpkins);
|
checkKO(Fight.getBlueTeam(), teamBluePumpkins);
|
||||||
|
running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getPumpkins(int minX, int minY, int minZ, int maxX, int maxY, int maxZ){
|
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 FightTeam team;
|
||||||
private final int blockCount;
|
private final int blockCount;
|
||||||
private final BukkitTask task;
|
private final BukkitTask task;
|
||||||
|
private boolean running = false;
|
||||||
|
|
||||||
private int currentBlocks;
|
private int currentBlocks;
|
||||||
|
|
||||||
@ -70,8 +71,12 @@ public class WinconditionRelativePercent extends Wincondition{
|
|||||||
this.currentBlocks = blockCount;
|
this.currentBlocks = blockCount;
|
||||||
|
|
||||||
task = Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), () -> {
|
task = Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), () -> {
|
||||||
|
if(running)
|
||||||
|
return;
|
||||||
|
running = true;
|
||||||
currentBlocks = currentBlocks();
|
currentBlocks = currentBlocks();
|
||||||
checkPercentDefeat();
|
checkPercentDefeat();
|
||||||
|
running = false;
|
||||||
}, 400, 400);
|
}, 400, 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ public class WinconditionTechKO extends ListenerWincondition {
|
|||||||
private TechKOCountdown smallerZcountdown = null;
|
private TechKOCountdown smallerZcountdown = null;
|
||||||
private TechKOCountdown biggerZcountdown = null;
|
private TechKOCountdown biggerZcountdown = null;
|
||||||
private BukkitTask task;
|
private BukkitTask task;
|
||||||
|
private boolean running = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Works only for z-Axis fight direction for performance reasons
|
* Works only for z-Axis fight direction for performance reasons
|
||||||
@ -59,6 +60,10 @@ public class WinconditionTechKO extends ListenerWincondition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void run(){
|
private void run(){
|
||||||
|
if(running)
|
||||||
|
return;
|
||||||
|
running = true;
|
||||||
|
|
||||||
for(TNTPrimed tnt : world.getEntitiesByClass(TNTPrimed.class)){
|
for(TNTPrimed tnt : world.getEntitiesByClass(TNTPrimed.class)){
|
||||||
int id = tnt.getEntityId();
|
int id = tnt.getEntityId();
|
||||||
boolean smallerZ = tnt.getLocation().getZ() < toggle;
|
boolean smallerZ = tnt.getLocation().getZ() < toggle;
|
||||||
@ -87,6 +92,7 @@ public class WinconditionTechKO extends ListenerWincondition {
|
|||||||
|
|
||||||
smallerZtime--;
|
smallerZtime--;
|
||||||
biggerZtime--;
|
biggerZtime--;
|
||||||
|
running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FightTeam smallerTeam(){
|
private FightTeam smallerTeam(){
|
||||||
|
@ -19,6 +19,7 @@ public class WinconditionWaterTechKO extends Wincondition {
|
|||||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
private BukkitTask task;
|
private BukkitTask task;
|
||||||
|
private boolean running = false;
|
||||||
|
|
||||||
public WinconditionWaterTechKO() {
|
public WinconditionWaterTechKO() {
|
||||||
super(Config.WaterTechKO, EnumSet.of(FightState.PRE_RUNNING, FightState.RUNNING));
|
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){
|
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.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 checkTask() {
|
private void checkTask() {
|
||||||
|
if(running)
|
||||||
|
return;
|
||||||
|
running = true;
|
||||||
teamRedWater = calcWater(
|
teamRedWater = calcWater(
|
||||||
Config.TeamRedCornerX,
|
Config.TeamRedCornerX,
|
||||||
Config.TeamRedCornerY,
|
Config.TeamRedCornerY,
|
||||||
@ -68,6 +72,7 @@ public class WinconditionWaterTechKO extends Wincondition {
|
|||||||
|
|
||||||
checkEmpty(Fight.getRedTeam(), teamRedWater);
|
checkEmpty(Fight.getRedTeam(), teamRedWater);
|
||||||
checkEmpty(Fight.getBlueTeam(), teamBlueWater);
|
checkEmpty(Fight.getBlueTeam(), teamBlueWater);
|
||||||
|
running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int calcWater(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){
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren