This commit is contained in:
Mathieu Strypsteen 2024-09-21 22:11:10 +02:00
parent ed0a9659f7
commit 25bffc9509

View file

@ -14,6 +14,7 @@ import org.bukkit.scoreboard.Team;
public class FallEvent extends Event { public class FallEvent extends Event {
private final int extraHeight; private final int extraHeight;
private int targetHeight;
public FallEvent(Team team, Difficulty difficulty, int scoreOnSuccess) { public FallEvent(Team team, Difficulty difficulty, int scoreOnSuccess) {
super(team, difficulty, scoreOnSuccess); super(team, difficulty, scoreOnSuccess);
@ -39,6 +40,7 @@ public class FallEvent extends Event {
while (location.y() > 50 && world.getBlockAt(location).getType() == Material.AIR) { while (location.y() > 50 && world.getBlockAt(location).getType() == Material.AIR) {
location.setY(location.getY() - 1); location.setY(location.getY() - 1);
} }
targetHeight = (int) location.getY() + 5;
int blocksToIncrease = extraHeight; int blocksToIncrease = extraHeight;
while (location.y() < 315 && blocksToIncrease > 0) { while (location.y() < 315 && blocksToIncrease > 0) {
location.setY(location.getY() + 1); location.setY(location.getY() + 1);
@ -54,6 +56,16 @@ public class FallEvent extends Event {
super.start(); super.start();
} }
@Override
public void run() {
for (Player player : MC13DTL.board.getPlayers(team)) {
if (player.getLocation().y() > targetHeight) {
return;
}
}
eventSuccess();
}
@Override @Override
protected String getMessage() { protected String getMessage() {
return "And now you should get down again... safely"; return "And now you should get down again... safely";