Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Commit

Permalink
More detailed TPS command
Browse files Browse the repository at this point in the history
  • Loading branch information
windcolor-dev committed Mar 21, 2022
1 parent 05bc44a commit 5e1a595
Showing 1 changed file with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package org.spigotmc;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;

import net.minecraft.server.MinecraftServer;
import net.minecraft.server.WorldServer;

public class TicksPerSecondCommand extends Command {

public TicksPerSecondCommand(String name) {
Expand All @@ -26,13 +30,33 @@ public boolean execute(CommandSender sender, String currentAlias, String[] args)
for (int i = 0; i < tps.length; i++) {
tpsAvg[i] = format(tps[i]);
}

// WindSpigot - more detailed tps cmd

int entityCount = 0;

for (WorldServer world : MinecraftServer.getServer().worlds) {
entityCount = entityCount + world.entityList.size();
}

int tileEntityCount = 0;

for (WorldServer world : MinecraftServer.getServer().worlds) {
tileEntityCount = tileEntityCount + world.tileEntityList.size();
}

sender.sendMessage(ChatColor.DARK_AQUA + "WindSpigot Performance:");
sender.sendMessage(ChatColor.GOLD + "TPS from last 1m, 5m, 15m: "
sender.sendMessage(ChatColor.AQUA + "TPS from last 1m, 5m, 15m: "
+ org.apache.commons.lang.StringUtils.join(tpsAvg, ", "));
sender.sendMessage(ChatColor.GOLD + "Current Memory Usage: " + ChatColor.GREEN
sender.sendMessage(ChatColor.AQUA + "Current Memory Usage: " + ChatColor.GREEN
+ ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / (1024 * 1024)) + "/"
+ (Runtime.getRuntime().totalMemory() / (1024 * 1024)) + " mb (Max: "
+ (Runtime.getRuntime().maxMemory() / (1024 * 1024)) + " mb)");
sender.sendMessage(ChatColor.AQUA + "Online Players: " + ChatColor.GREEN + Bukkit.getOnlinePlayers().size());
sender.sendMessage(ChatColor.AQUA + "Entity Count: " + ChatColor.GREEN + entityCount);
sender.sendMessage(ChatColor.AQUA + "Tile Entity Count: " + ChatColor.GREEN + tileEntityCount);
sender.sendMessage(ChatColor.AQUA + "Mob AI: " + ChatColor.GREEN + MinecraftServer.getServer().worlds.get(0).nachoSpigotConfig.enableMobAI);

return true;
}

Expand Down

0 comments on commit 5e1a595

Please sign in to comment.