Archiviert
1
0

Merge pull request 'Update PlaytimeCommand' (#391) from CommandPlaytime into master

Reviewed-on: SteamWar/BungeeCore#391
Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Lixfel 2022-06-16 13:14:58 +02:00
Commit 8ae6e90628

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import org.apache.commons.lang3.LocaleUtils; import org.apache.commons.lang3.LocaleUtils;
@ -29,21 +30,18 @@ import java.text.DecimalFormat;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.Locale; import java.util.Locale;
public class PlaytimeCommand extends BasicCommand{ public class PlaytimeCommand extends SWCommand {
public PlaytimeCommand() { public PlaytimeCommand() {
super("playtime", null); super("playtime");
} }
@Override @Register
public void execute(CommandSender sender, String[] strings) { public void genericCommand(ProxiedPlayer player) {
if(!(sender instanceof ProxiedPlayer)) NumberFormat format = NumberFormat.getNumberInstance((player).getLocale());
return;
NumberFormat format = NumberFormat.getNumberInstance(((ProxiedPlayer)sender).getLocale());
format.setMaximumFractionDigits(2); 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);
} }
} }