Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. package org.spigotmc;
  2.  
  3. import net.minecraft.server.v1_8_R3.MinecraftServer;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.command.Command;
  6. import org.bukkit.command.CommandSender;
  7.  
  8. public class TicksPerSecondCommand
  9. extends Command
  10. {
  11. public TicksPerSecondCommand(String name)
  12. {
  13. super(name);
  14. this.description = "Gets the current ticks per second for the server";
  15. this.usageMessage = "/tps";
  16. setPermission("bukkit.command.tps");
  17. }
  18.  
  19. public boolean execute(CommandSender sender, String currentAlias, String[] args)
  20. {
  21. if (!testPermission(sender)) {
  22. return true;
  23. }
  24. StringBuilder sb = new StringBuilder(ChatColor.GOLD + "TPS from last 1m, 5m, 15m: ");
  25. double[] arrayOfDouble;
  26. int i = (arrayOfDouble = MinecraftServer.getServer().recentTps).length;
  27. for (int j = 0; j < i; j++)
  28. {
  29. double tps = arrayOfDouble[j];
  30.  
  31. sb.append(format(tps));
  32. sb.append(", ");
  33. }
  34. sender.sendMessage(sb.substring(0, sb.length() - 2));
  35.  
  36. return true;
  37. }
  38.  
  39. private String format(double tps)
  40. {
  41. return
  42. (tps > 16.0D ? ChatColor.YELLOW : tps > 18.0D ? ChatColor.GREEN : ChatColor.RED).toString() + (tps > 20.0D ? "*" : "") + Math.min(Math.round(tps * 100.0D) / 100.0D, 20.0D);
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement