13
0

Add Speed to BoatRace
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Chaoscaot 2023-04-08 15:30:56 +02:00
Ursprung 5ca8381482
Commit 98609f7a62
2 geänderte Dateien mit 6 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -150,7 +150,7 @@ GAMES_LEFT = §7{0} left the game
BOAT_RACE_TIME = §7Finished in §e{0} BOAT_RACE_TIME = §7Finished in §e{0}
BOAT_RACE_NEW_BEST = §aNew best time! BOAT_RACE_NEW_BEST = §aNew best time!
BOAT_RACE_TITLE = §6Checkpoint {0}/6§7: {1} BOAT_RACE_TITLE = §6Checkpoint {0}/6§7: {1} §8• §e{2}km/h
# Easter Egg Hunt # Easter Egg Hunt
DIFFICULTY_EASY = §aEasy DIFFICULTY_EASY = §aEasy

Datei anzeigen

@ -57,11 +57,14 @@ public class BoatRace implements EventListener, Listener {
private final BukkitTask task; private final BukkitTask task;
private final BossBar bossBar; private final BossBar bossBar;
private boolean hasBacked = false; private boolean hasBacked = false;
private double lastDistance;
@EventHandler @EventHandler
public void onBoatMove(VehicleMoveEvent event) { public void onBoatMove(VehicleMoveEvent event) {
if (event.getVehicle() != boat) return; if (event.getVehicle() != boat) return;
lastDistance = event.getFrom().distance(event.getTo());
if(nextCheckpoint == 0 && inRegion(player, BoatRacePositions.BACKWARDS[0], BoatRacePositions.BACKWARDS[1])) { if(nextCheckpoint == 0 && inRegion(player, BoatRacePositions.BACKWARDS[0], BoatRacePositions.BACKWARDS[1])) {
player.eject(); player.eject();
player.teleport(BoatRacePositions.END); player.teleport(BoatRacePositions.END);
@ -137,8 +140,9 @@ public class BoatRace implements EventListener, Listener {
task = Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { task = Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> {
hasBacked = false; hasBacked = false;
if (nextCheckpoint != 0) { if (nextCheckpoint != 0) {
double kmh = lastDistance * 20 * 3.6;
bossBar.setProgress((nextCheckpoint - 1d) / (BoatRacePositions.CHECKPOINTS.length - 1d)); bossBar.setProgress((nextCheckpoint - 1d) / (BoatRacePositions.CHECKPOINTS.length - 1d));
bossBar.setTitle(LobbySystem.getMessage().parse("BOAT_RACE_TITLE", player, nextCheckpoint, renderTime(System.currentTimeMillis() - startTime))); bossBar.setTitle(LobbySystem.getMessage().parse("BOAT_RACE_TITLE", player, nextCheckpoint, renderTime(System.currentTimeMillis() - startTime), (int) kmh));
} }
}, 0, 1); }, 0, 1);
Bukkit.getPluginManager().registerEvents(this, LobbySystem.getPlugin()); Bukkit.getPluginManager().registerEvents(this, LobbySystem.getPlugin());