From bb3142078f84cc62cac844f5e87687dd1e67ca95 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Wed, 16 Aug 2023 23:04:53 +0200 Subject: [PATCH] Refactors --- src/de/steamwar/towerrun/countdowns/LobbyCountdown.java | 1 - src/de/steamwar/towerrun/game/TowerRunGame.java | 9 +++++---- .../towerrun/winconditions/OutsideWincondition.java | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/de/steamwar/towerrun/countdowns/LobbyCountdown.java b/src/de/steamwar/towerrun/countdowns/LobbyCountdown.java index f576bac..fe9cc9c 100644 --- a/src/de/steamwar/towerrun/countdowns/LobbyCountdown.java +++ b/src/de/steamwar/towerrun/countdowns/LobbyCountdown.java @@ -63,7 +63,6 @@ public class LobbyCountdown extends Countdown { @Override void timerReset() { - Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§cEs wird noch auf Spieler gewartet..."))); TowerRun.getMessage().broadcastActionbar("GAME_WAITING"); } } diff --git a/src/de/steamwar/towerrun/game/TowerRunGame.java b/src/de/steamwar/towerrun/game/TowerRunGame.java index 2b07d0c..7539974 100644 --- a/src/de/steamwar/towerrun/game/TowerRunGame.java +++ b/src/de/steamwar/towerrun/game/TowerRunGame.java @@ -23,10 +23,7 @@ import de.steamwar.towerrun.TowerRun; import de.steamwar.towerrun.config.WorldConfig; import de.steamwar.towerrun.state.GameState; import de.steamwar.towerrun.state.GameStates; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; +import org.bukkit.*; import org.bukkit.util.Vector; import java.util.ArrayList; @@ -81,6 +78,10 @@ public class TowerRunGame { tPlayer.player().teleport(WorldConfig.SPAWN); tPlayer.player().setGameMode(GameMode.SPECTATOR); TowerRun.getMessage().broadcast("GAME_WIN", tPlayer.player().getName()); + Bukkit.getOnlinePlayers().forEach(player -> { + player.sendTitle(TowerRun.getMessage().parse("GAME_WIN", player, tPlayer.player().getName()), "", 10, 70, 20); + player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_DEATH, 1, 1); + }); GameState.nextState(); } } diff --git a/src/de/steamwar/towerrun/winconditions/OutsideWincondition.java b/src/de/steamwar/towerrun/winconditions/OutsideWincondition.java index 967d209..faab36b 100644 --- a/src/de/steamwar/towerrun/winconditions/OutsideWincondition.java +++ b/src/de/steamwar/towerrun/winconditions/OutsideWincondition.java @@ -22,7 +22,6 @@ package de.steamwar.towerrun.winconditions; import de.steamwar.towerrun.config.WorldConfig; import de.steamwar.towerrun.game.TowerRunGame; import de.steamwar.towerrun.game.TowerRunPlayer; -import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerMoveEvent; @@ -31,6 +30,8 @@ import java.util.Arrays; public abstract class OutsideWincondition extends WinCondition { + private static final double BASE_GRAVITY = -0.0784000015258789; + protected OutsideWincondition(String name) { super(name); } @@ -51,7 +52,7 @@ public abstract class OutsideWincondition extends WinCondition { return; } - if (event.getPlayer().getVelocity().getY() != -0.0784000015258789) { + if (event.getPlayer().getVelocity().getY() != BASE_GRAVITY) { return; }