12
1

State switches are now dependent on amount od bombs dropped, rather than time

Dieser Commit ist enthalten in:
Zeanon 2021-05-14 00:18:59 +02:00
Ursprung 0ac33d0dd4
Commit cabb09a674

Datei anzeigen

@ -88,8 +88,8 @@ public class HellsBells {
private final World world = Bukkit.getWorlds().get(0);
private final int xLength = Config.RedPasteRegion.getMaxX() - Config.RedPasteRegion.getMinX();
private final int zLength = Config.RedPasteRegion.getMaxZ() - Config.RedPasteRegion.getMinZ();
private State current = State.PRE;
private long stateStart = 0;
private State current = State.NONE;
private int currentDrops = 0;
private HellsBellsCountdown currentCountdown;
private static final List<String> startMessages = Arrays.asList("§c!!Achtung!! Bomber im Anflug, noch ca. eine Minute bis zur Ankunft.",
"§cBomber im Anflug, ca. eine Minute bis zur Ankunft.",
@ -100,35 +100,31 @@ public class HellsBells {
public void init() {
stateStart = System.currentTimeMillis();
current = State.PRE;
currentDrops = 0;
currentCountdown = null;
startCountdown();
}
public void terminate() {
current = State.NONE;
currentCountdown.disable();
if (currentCountdown != null) {
currentCountdown.disable();
}
}
public void startCountdown() {
if (current != State.NONE) {
long currentTime = System.currentTimeMillis();
if (current != State.LAST && current != State.PRE && currentTime >= stateStart + (current.switchAfter * 1000L)) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDie Bomben fallen nun schneller.");
current = current.getNext();
stateStart = currentTime;
}
int timer = current.minTime + random.nextInt(current.maxTime - current.minTime);
if (current == State.PRE) {
Bukkit.broadcastMessage(FightSystem.PREFIX + (startMessages.get(random.nextInt(startMessages.size()))));
current = current.getNext();
} else if (current != State.LAST && currentDrops >= current.SWITCH_AFTER) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDie Bomben fallen nun schneller.");
currentDrops = 0;
}
currentCountdown = new HellsBellsCountdown(timer, SWSound.BLOCK_NOTE_BASS, true);
currentDrops++;
currentCountdown = new HellsBellsCountdown(current.MIN_TIME + random.nextInt(current.MAX_TIME - current.MIN_TIME), SWSound.BLOCK_NOTE_BASS, true);
currentCountdown.enable();
}
}
@ -168,8 +164,7 @@ public class HellsBells {
}
}
length.decrementAndGet();
if (length.decrementAndGet() <= 0) {
if (length.addAndGet(-2) <= 0) {
cancel();
}
}
@ -220,34 +215,34 @@ public class HellsBells {
}
public Location addAndToLocation(World world, int x, int y, int z) {
return new Location(world, this.x + x, this.y + y, this.z + z);
return new Location(world, this.x + x, this.y + y, this.z + z); //NOSONAR
}
public Location subtractAndToLocation(World world, int x, int y, int z) {
return new Location(world, this.x - x, this.y - y, this.z - z);
return new Location(world, this.x - x, this.y - y, this.z - z); //NOSONAR
}
}
private enum State {
NONE(0, 0, -1),
PRE(60, 80, 0),
FIRST(40, 60, 5 * 60),
SECOND(30, 40, 4 * 60),
THIRD(20, 30, 3 * 60),
FOURTH(10, 20, 2 * 60),
LAST(5, 10, -1);
NONE(0, 0, 0),
PRE(60, 80, 1),
FIRST(40, 60, 5),
SECOND(30, 40, 6),
THIRD(20, 30, 6),
FOURTH(10, 20, 7),
LAST(5, 10, 0);
State(int minTime, int maxTime, int switchAfter) {
this.minTime = minTime;
this.maxTime = maxTime;
this.switchAfter = switchAfter;
this.MIN_TIME = minTime;
this.MAX_TIME = maxTime;
this.SWITCH_AFTER = switchAfter;
}
private final int minTime;
private final int maxTime;
private final int switchAfter;
private final int MIN_TIME; //NOSONAR
private final int MAX_TIME; //NOSONAR
private final int SWITCH_AFTER; //NOSONAR
public State getNext() {