From 7a621a780e211f3d08199ca5fd39cb6dae487e15 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 8 Apr 2023 00:06:03 +0200 Subject: [PATCH] Add JumpAndRunCommand --- src/de/steamwar/lobby/LobbySystem.java | 2 ++ src/de/steamwar/lobby/LobbySystem.properties | 2 ++ .../steamwar/lobby/LobbySystem_de.properties | 4 ++- .../lobby/jumpandrun/JumpAndRunCommand.java | 30 +++++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/de/steamwar/lobby/jumpandrun/JumpAndRunCommand.java diff --git a/src/de/steamwar/lobby/LobbySystem.java b/src/de/steamwar/lobby/LobbySystem.java index f87d9d4..3fce387 100644 --- a/src/de/steamwar/lobby/LobbySystem.java +++ b/src/de/steamwar/lobby/LobbySystem.java @@ -25,6 +25,7 @@ import de.steamwar.lobby.command.HologramCommand; import de.steamwar.lobby.command.ModifyCommand; import de.steamwar.lobby.command.PortalCommand; import de.steamwar.lobby.jumpandrun.JumpAndRun; +import de.steamwar.lobby.jumpandrun.JumpAndRunCommand; import de.steamwar.lobby.listener.*; import de.steamwar.lobby.map.CustomMapCommand; import de.steamwar.lobby.particle.ParticleListener; @@ -61,6 +62,7 @@ public class LobbySystem extends JavaPlugin { new CustomMapCommand(); new JumpAndRun(); + new JumpAndRunCommand(); config = new Config(getConfig()); new PlayerSpawn(); diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 5b3dbca..86ee7ef 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -131,6 +131,8 @@ JUMP_AND_RUN_CANCEL = {0} JUMP_AND_RUN_TIME = mm:ss SSS JUMP_AND_RUN_FINISHED = §aFinished in {0} with {1} fails JUMP_AND_RUN_PERSONAL_BEST = §aNice! You beat your personal best by {0} +JUMP_AND_RUN_PERSONAL_BEST_TIME = §aPersonal best in {0} +JUMP_AND_RUN_PERSONAL_BEST_NO_TIME = §cNo personal best # Easter Egg Hunt DIFFICULTY_EASY = §aEasy diff --git a/src/de/steamwar/lobby/LobbySystem_de.properties b/src/de/steamwar/lobby/LobbySystem_de.properties index 5bd4406..b451a73 100644 --- a/src/de/steamwar/lobby/LobbySystem_de.properties +++ b/src/de/steamwar/lobby/LobbySystem_de.properties @@ -120,7 +120,9 @@ PARTICLE_EGG_HUNT_ADVANCED = §5Abheben PARTICLE_EGG_HUNT_HALF = §fDie Jagd ist eröffnet JUMP_AND_RUN_FINISHED = §aBeendet in {0} mit {1} Fails -JUMP_AND_RUN_PERSONAL_BEST = §aNice! Du hast deinen Rekord um {0} Sekunden verbessert! +JUMP_AND_RUN_PERSONAL_BEST = §aNice! Du hast deinen Rekord um {0} verbessert! +JUMP_AND_RUN_PERSONAL_BEST_TIME = §aDein Rekord ist {0} +JUMP_AND_RUN_PERSONAL_BEST_NO_TIME = §cDu hast noch keinen Rekord # Easter Egg Hunt DIFFICULTY_EASY = §aLeicht diff --git a/src/de/steamwar/lobby/jumpandrun/JumpAndRunCommand.java b/src/de/steamwar/lobby/jumpandrun/JumpAndRunCommand.java new file mode 100644 index 0000000..680f01b --- /dev/null +++ b/src/de/steamwar/lobby/jumpandrun/JumpAndRunCommand.java @@ -0,0 +1,30 @@ +package de.steamwar.lobby.jumpandrun; + +import de.steamwar.command.SWCommand; +import de.steamwar.lobby.LobbySystem; +import de.steamwar.sql.UserConfig; +import org.bukkit.entity.Player; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + +public class JumpAndRunCommand extends SWCommand { + + public JumpAndRunCommand() { + super("jumpandrun"); + } + + @Register + public void genericCommand(Player player, String... args) { + String time = UserConfig.getConfig(player.getUniqueId(), "jump_and_run"); + if (time == null) { + LobbySystem.getMessage().sendPrefixless("JUMP_AND_RUN_PERSONAL_BEST_NO_TIME", player); + return; + } + long timeLong = Long.parseLong(time); + SimpleDateFormat format = new SimpleDateFormat(LobbySystem.getMessage().parse("JUMP_AND_RUN_TIME", player), Locale.ROOT); + String parsed = format.format(new Date(timeLong)); + LobbySystem.getMessage().sendPrefixless("JUMP_AND_RUN_PERSONAL_BEST_TIME", player, parsed); + } +}