From d72c8e612f9164d5d8538eb0e13b1aef40b46996 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Fri, 24 Dec 2021 11:16:29 +0100 Subject: [PATCH] Command implementation --- src/de/steamwar/bungeecore/BungeeCore.java | 1 + .../bungeecore/commands/PlaytimeCommand.java | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/de/steamwar/bungeecore/commands/PlaytimeCommand.java diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 72da98a..fdc019e 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -129,6 +129,7 @@ public class BungeeCore extends Plugin { new StatCommand(); new VerifyCommand(); new GDPRQuery(); + new PlaytimeCommand(); // Punishment Commands: new PunishmentCommand("ban", Punishment.PunishmentType.Ban); diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java new file mode 100644 index 0000000..003f3dc --- /dev/null +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -0,0 +1,21 @@ +package de.steamwar.bungeecore.commands; + +import de.steamwar.bungeecore.Message; +import de.steamwar.bungeecore.sql.SteamwarUser; +import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.connection.ProxiedPlayer; + +import java.text.DecimalFormat; + +public class PlaytimeCommand extends BasicCommand{ + + public PlaytimeCommand() { + super("playtime", null); + } + + @Override public void execute(CommandSender sender, String[] strings) { + ProxiedPlayer player = (ProxiedPlayer) sender; + SteamwarUser user = SteamwarUser.get(player); + Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / (double) 3600)); + } +}