SteamWar/FightSystem
Archiviert
13
1

Merge remote-tracking branch 'origin/Meteor' into Meteor
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2022-01-15 14:59:58 +01:00
Commit abc7e1a4f7

Datei anzeigen

@ -10,6 +10,7 @@ import de.steamwar.fightsystem.utils.Message;
import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.fightsystem.winconditions.Winconditions;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -18,6 +19,7 @@ import org.bukkit.entity.Fireball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
@ -32,6 +34,7 @@ public class Meteor implements Listener {
private Meteor.State current = Meteor.State.PRE;
private int currentDrops = 0;
private Meteor.MeteorCountdown currentCountdown;
private BukkitTask currentDropping;
public void startCountdown() {
if (current == Meteor.State.PRE) {
@ -54,6 +57,9 @@ public class Meteor implements Listener {
}
public void drop() {
final AtomicInteger amount = new AtomicInteger(current.minAmount + random.nextInt(current.maxAmount - current.minAmount));
currentDropping = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), () -> {
int xOffset = getStart(xLength);
int zOffset = getStart(zLength);
int yOffset = getHeightStart();
@ -72,6 +78,11 @@ public class Meteor implements Listener {
fireballBlue.setBounce(false);
fireballBlue.setIsIncendiary(false);
fireballBlue.setYield(0);
if (amount.decrementAndGet() <= 0) {
currentDropping.cancel();
}
}, 0L, 4L);
}
private int getStart(int regionSize) {
@ -132,25 +143,29 @@ public class Meteor implements Listener {
private enum State {
PRE(60, 80, 1, 0),
FIRST(40, 60, 3, 2),
SECOND(30, 40, 4, 4),
THIRD(20, 30, 4, 6),
FOURTH(10, 20, 5, 8),
LAST(5, 10, 0, 10);
PRE(60, 80, 1, 0, 0, 0),
FIRST(40, 60, 3, 2, 1, 3),
SECOND(30, 40, 4, 4, 2, 5),
THIRD(20, 30, 4, 6, 3, 7),
FOURTH(10, 20, 5, 8, 5, 10),
LAST(5, 10, 0, 10, 7, 15);
State(int minTime, int maxTime, int switchAfter, int explosionSize) {
State(int minTime, int maxTime, int switchAfter, int explosionSize, int minAmount, int maxAmount) {
this.MIN_TIME = minTime;
this.MAX_TIME = maxTime;
this.SWITCH_AFTER = switchAfter;
this.explosionSize = explosionSize;
this.minAmount = minAmount;
this.maxAmount = maxAmount;
}
private final int MIN_TIME; //NOSONAR
private final int MAX_TIME; //NOSONAR
private final int SWITCH_AFTER; //NOSONAR
private final int explosionSize; //NOSONAR
private final int minAmount;
private final int maxAmount;
public Meteor.State getNext() {