
org.spigotmc.TicksPerSecondCommand Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of walk-server Show documentation
Show all versions of walk-server Show documentation
A spigot fork to kotlin structure and news.
package org.spigotmc;
import net.minecraft.server.MinecraftServer;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
public class TicksPerSecondCommand extends Command {
public TicksPerSecondCommand(String name) {
super(name);
this.description = "Gets the current ticks per second for the server";
this.usageMessage = "/tps";
this.setPermission("bukkit.command.tps");
}
@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
if (!testPermission(sender)) {
return true;
}
StringBuilder sb = new StringBuilder(ChatColor.GOLD + "TPS from last 1m, 5m, 15m: ");
for (double tps : MinecraftServer.getServer().recentTps) {
sb.append(format(tps));
sb.append(", ");
}
sender.sendMessage(sb.substring(0, sb.length() - 2));
return true;
}
private String format(double tps) {
return ((tps > 18.0) ? ChatColor.GREEN : (tps > 16.0) ? ChatColor.YELLOW : ChatColor.RED)
+ ((tps > 20.0) ? "*" : "") + Math.min(Math.round(tps * 100.0) / 100.0, 20.0);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy