Advertisement
LucKYsHoTSzZz

Untitled

Jul 24th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.65 KB | None | 0 0
  1. package com.earth2me.essentials.commands;
  2.  
  3. import com.earth2me.essentials.CommandSource;
  4. import com.earth2me.essentials.EssentialsTimer;
  5. import com.earth2me.essentials.I18n;
  6. import com.earth2me.essentials.utils.DateUtil;
  7. import com.earth2me.essentials.utils.NumberUtil;
  8. import java.lang.management.ManagementFactory;
  9. import java.lang.management.RuntimeMXBean;
  10. import java.util.List;
  11. import java.util.logging.Level;
  12. import java.util.logging.Logger;
  13. import net.ess3.api.IEssentials;
  14. import org.bukkit.Bukkit;
  15. import org.bukkit.ChatColor;
  16. import org.bukkit.Chunk;
  17. import org.bukkit.Server;
  18. import org.bukkit.World;
  19.  
  20. public class Commandgc extends EssentialsCommand
  21. {
  22.   public Commandgc()
  23.   {
  24.     super("gc");
  25.   }
  26.  
  27.   protected void run(Server server, CommandSource sender, String commandLabel, String[] args)
  28.     throws Exception
  29.   {
  30.     double tps = this.ess.getTimer().getAverageTPS();
  31.     ChatColor color;
  32.     ChatColor color;
  33.     if (tps >= 18.0D)
  34.     {
  35.       color = ChatColor.GREEN;
  36.     }
  37.     else
  38.     {
  39.       ChatColor color;
  40.       if (tps >= 15.0D)
  41.       {
  42.         color = ChatColor.YELLOW;
  43.       }
  44.       else
  45.       {
  46.         color = ChatColor.RED;
  47.       }
  48.     }
  49.     sender.sendMessage(I18n.tl("uptime", new Object[] { DateUtil.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime()) }));
  50.     sender.sendMessage(I18n.tl("tps", new Object[] { "" + color + NumberUtil.formatDouble(tps) }));
  51.     sender.sendMessage(I18n.tl("gcmax", new Object[] { Long.valueOf(Runtime.getRuntime().maxMemory() / 1024L / 1024L) }));
  52.     sender.sendMessage(I18n.tl("gctotal", new Object[] { Long.valueOf(Runtime.getRuntime().totalMemory() / 1024L / 1024L) }));
  53.     sender.sendMessage(I18n.tl("gcfree", new Object[] { Long.valueOf(Runtime.getRuntime().freeMemory() / 1024L / 1024L) }));
  54.  
  55.     List worlds = server.getWorlds();
  56.     for (World w : worlds)
  57.     {
  58.       String worldType = "World";
  59.       switch (1.$SwitchMap$org$bukkit$World$Environment[w.getEnvironment().ordinal()])
  60.       {
  61.       case 1:
  62.         worldType = "Nether";
  63.         break;
  64.       case 2:
  65.         worldType = "The End";
  66.       }
  67.  
  68.       int tileEntities = 0;
  69.       try
  70.       {
  71.         for (Chunk chunk : w.getLoadedChunks())
  72.         {
  73.           tileEntities += chunk.getTileEntities().length;
  74.         }
  75.       }
  76.       catch (ClassCastException ex)
  77.       {
  78.         Bukkit.getLogger().log(Level.SEVERE, "Corrupted chunk data on world " + w, ex);
  79.       }
  80.  
  81.       sender.sendMessage(I18n.tl("gcWorld", new Object[] { worldType, w.getName(), Integer.valueOf(w.getLoadedChunks().length), Integer.valueOf(w.getEntities().size()), Integer.valueOf(tileEntities) }));
  82.     }
  83.   }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement