From 4134e564cc1a5c8fa79cefb29930cf3d5ef49f56 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 15 Jun 2022 20:12:25 +0200 Subject: [PATCH] Update PlaytimeCommand --- .../bungeecore/commands/PlaytimeCommand.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java index 23e16a0..c9c3850 100644 --- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -21,6 +21,7 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.command.SWCommand; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.connection.ProxiedPlayer; import org.apache.commons.lang3.LocaleUtils; @@ -29,21 +30,18 @@ import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Locale; -public class PlaytimeCommand extends BasicCommand{ +public class PlaytimeCommand extends SWCommand { public PlaytimeCommand() { - super("playtime", null); + super("playtime"); } - @Override - public void execute(CommandSender sender, String[] strings) { - if(!(sender instanceof ProxiedPlayer)) - return; - - NumberFormat format = NumberFormat.getNumberInstance(((ProxiedPlayer)sender).getLocale()); + @Register + public void genericCommand(ProxiedPlayer player) { + NumberFormat format = NumberFormat.getNumberInstance((player).getLocale()); format.setMaximumFractionDigits(2); - String formattedText = format.format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600)); + String formattedText = format.format((SteamwarUser.get(player).getOnlinetime() / (double) 3600)); - Message.send("HOURS_PLAYED", sender, formattedText); + Message.send("HOURS_PLAYED", player, formattedText); } }