diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 6409ad8..53e5b0a 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -127,6 +127,7 @@ public class BungeeCore extends Plugin { new VerifyCommand(); new ReplayCommand(); 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..23e16a0 --- /dev/null +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -0,0 +1,49 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2020 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +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 org.apache.commons.lang3.LocaleUtils; + +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.util.Locale; + +public class PlaytimeCommand extends BasicCommand{ + + public PlaytimeCommand() { + super("playtime", null); + } + + @Override + public void execute(CommandSender sender, String[] strings) { + if(!(sender instanceof ProxiedPlayer)) + return; + + NumberFormat format = NumberFormat.getNumberInstance(((ProxiedPlayer)sender).getLocale()); + format.setMaximumFractionDigits(2); + String formattedText = format.format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600)); + + Message.send("HOURS_PLAYED", sender, formattedText); + } +} diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index e8c1686..e0a8b7a 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -568,4 +568,7 @@ GDPR_STATUS_WORLD=§7Packe Bauwelten... GDPR_STATUS_INVENTORIES=§7Suche und packe Inventare... GDPR_STATUS_DATABASE=§7Packe Datenbankinhalte... GDPR_STATUS_LOGS=§7Suche und packe logs... -GDPR_STATUS_FINISHED=§7Packen abgeschlossen \ No newline at end of file +GDPR_STATUS_FINISHED=§7Packen abgeschlossen + +#Playtime Command +HOURS_PLAYED=§7Deine Spielzeit beträgt§8: §e{0}h \ No newline at end of file