Added total play time to stats command
This commit is contained in:
parent
36f4896dce
commit
8ba67b35d1
@ -10,6 +10,13 @@ public class StatCommand {
|
|||||||
public static boolean Run(CommandSender sender){
|
public static boolean Run(CommandSender sender){
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
// Calculate total play time from ticks (Minecraft runs at 20 ticks per second)
|
||||||
|
long totalTicks = player.getStatistic(Statistic.TOTAL_WORLD_TIME);
|
||||||
|
long totalSeconds = totalTicks / 20;
|
||||||
|
long hours = totalSeconds / 3600;
|
||||||
|
long minutes = (totalSeconds % 3600) / 60;
|
||||||
|
long seconds = totalSeconds % 60;
|
||||||
|
|
||||||
player.sendMessage(STPlugin.getInstance().getPrefix() + ChatColor.GREEN + " === Your statistics === ");
|
player.sendMessage(STPlugin.getInstance().getPrefix() + ChatColor.GREEN + " === Your statistics === ");
|
||||||
player.sendMessage(ChatColor.AQUA+"Connects: " + (player.getStatistic(Statistic.LEAVE_GAME)+1));
|
player.sendMessage(ChatColor.AQUA+"Connects: " + (player.getStatistic(Statistic.LEAVE_GAME)+1));
|
||||||
player.sendMessage(ChatColor.AQUA+"Deaths: " + player.getStatistic(Statistic.DEATHS));
|
player.sendMessage(ChatColor.AQUA+"Deaths: " + player.getStatistic(Statistic.DEATHS));
|
||||||
@ -17,6 +24,7 @@ public class StatCommand {
|
|||||||
player.sendMessage(ChatColor.AQUA+"Player kills: " + player.getStatistic(Statistic.PLAYER_KILLS));
|
player.sendMessage(ChatColor.AQUA+"Player kills: " + player.getStatistic(Statistic.PLAYER_KILLS));
|
||||||
player.sendMessage(ChatColor.AQUA+"Sleep count: " + player.getStatistic(Statistic.SLEEP_IN_BED));
|
player.sendMessage(ChatColor.AQUA+"Sleep count: " + player.getStatistic(Statistic.SLEEP_IN_BED));
|
||||||
player.sendMessage(ChatColor.AQUA+"Enchant count: " + player.getStatistic(Statistic.ITEM_ENCHANTED));
|
player.sendMessage(ChatColor.AQUA+"Enchant count: " + player.getStatistic(Statistic.ITEM_ENCHANTED));
|
||||||
|
player.sendMessage(ChatColor.AQUA + "Total Play Time: " + hours + "h " + minutes + "m " + seconds + "s");
|
||||||
player.sendMessage(ChatColor.GREEN+" =================== ");
|
player.sendMessage(ChatColor.GREEN+" =================== ");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user