Dieser Commit ist enthalten in:
Ursprung
02ac3cd665
Commit
8d2fe1df85
@ -4,6 +4,7 @@ import de.steamwar.fightsystem.Config;
|
|||||||
import de.steamwar.fightsystem.countdown.Countdown;
|
import de.steamwar.fightsystem.countdown.Countdown;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependent;
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import de.steamwar.fightsystem.utils.Message;
|
import de.steamwar.fightsystem.utils.Message;
|
||||||
import de.steamwar.fightsystem.utils.SWSound;
|
import de.steamwar.fightsystem.utils.SWSound;
|
||||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||||
@ -13,10 +14,13 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Fireball;
|
import org.bukkit.entity.Fireball;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
|
||||||
public class Meteor {
|
public class Meteor implements Listener {
|
||||||
|
|
||||||
public static final Random random = new Random();
|
public static final Random random = new Random();
|
||||||
|
|
||||||
@ -39,6 +43,13 @@ public class Meteor {
|
|||||||
currentCountdown.enable();
|
currentCountdown.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void explode(ProjectileHitEvent event) {
|
||||||
|
if (event.getEntity() instanceof Fireball) {
|
||||||
|
event.getEntity().getWorld().createExplosion(event.getEntity().getLocation(), current.explosionSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void drop() {
|
public void drop() {
|
||||||
int xOffset = getStart(xLength);
|
int xOffset = getStart(xLength);
|
||||||
int zOffset = getStart(zLength);
|
int zOffset = getStart(zLength);
|
||||||
@ -51,13 +62,13 @@ public class Meteor {
|
|||||||
fireballRed.setDirection(new Vector(0, -1, 0));
|
fireballRed.setDirection(new Vector(0, -1, 0));
|
||||||
fireballRed.setBounce(false);
|
fireballRed.setBounce(false);
|
||||||
fireballRed.setIsIncendiary(false);
|
fireballRed.setIsIncendiary(false);
|
||||||
fireballRed.setYield(current.minExplosion + random.nextInt(current.maxExplosion - current.minExplosion));
|
fireballRed.setYield(current.explosionSize);
|
||||||
|
|
||||||
Fireball fireballBlue = world.spawn(blueStart.toLocation(world), Fireball.class);
|
Fireball fireballBlue = world.spawn(blueStart.toLocation(world), Fireball.class);
|
||||||
fireballBlue.setDirection(new Vector(0, -1, 0));
|
fireballBlue.setDirection(new Vector(0, -1, 0));
|
||||||
fireballBlue.setBounce(false);
|
fireballBlue.setBounce(false);
|
||||||
fireballBlue.setIsIncendiary(false);
|
fireballBlue.setIsIncendiary(false);
|
||||||
fireballBlue.setYield(current.minExplosion + random.nextInt(current.maxExplosion - current.minExplosion));
|
fireballBlue.setYield(current.explosionSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getStart(int regionSize) {
|
private int getStart(int regionSize) {
|
||||||
@ -71,6 +82,8 @@ public class Meteor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Meteor() {
|
public Meteor() {
|
||||||
|
new StateDependentListener(Winconditions.METEOR, FightState.Running, this);
|
||||||
|
|
||||||
new StateDependent(Winconditions.METEOR, FightState.Running) {
|
new StateDependent(Winconditions.METEOR, FightState.Running) {
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
@ -116,27 +129,25 @@ public class Meteor {
|
|||||||
|
|
||||||
private enum State {
|
private enum State {
|
||||||
|
|
||||||
PRE(60, 80, 1, 0, 0),
|
PRE(60, 80, 1, 0),
|
||||||
FIRST(40, 60, 3, 1, 3),
|
FIRST(40, 60, 3, 1),
|
||||||
SECOND(30, 40, 4, 2, 4),
|
SECOND(30, 40, 4, 2),
|
||||||
THIRD(20, 30, 4, 3, 6),
|
THIRD(20, 30, 4, 3),
|
||||||
FOURTH(10, 20, 5, 4, 7),
|
FOURTH(10, 20, 5, 4),
|
||||||
LAST(5, 10, 0, 5, 10);
|
LAST(5, 10, 0, 5);
|
||||||
|
|
||||||
|
|
||||||
State(int minTime, int maxTime, int switchAfter, int minExplosion, int maxExplosion) {
|
State(int minTime, int maxTime, int switchAfter, int explosionSize) {
|
||||||
this.MIN_TIME = minTime;
|
this.MIN_TIME = minTime;
|
||||||
this.MAX_TIME = maxTime;
|
this.MAX_TIME = maxTime;
|
||||||
this.SWITCH_AFTER = switchAfter;
|
this.SWITCH_AFTER = switchAfter;
|
||||||
this.minExplosion = minExplosion;
|
this.explosionSize = explosionSize;
|
||||||
this.maxExplosion = maxExplosion;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final int MIN_TIME; //NOSONAR
|
private final int MIN_TIME; //NOSONAR
|
||||||
private final int MAX_TIME; //NOSONAR
|
private final int MAX_TIME; //NOSONAR
|
||||||
private final int SWITCH_AFTER; //NOSONAR
|
private final int SWITCH_AFTER; //NOSONAR
|
||||||
private final int minExplosion; //NOSONAR
|
private final int explosionSize; //NOSONAR
|
||||||
private final int maxExplosion; //NOSONAR
|
|
||||||
|
|
||||||
|
|
||||||
public Meteor.State getNext() {
|
public Meteor.State getNext() {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren