Do you run a server? Do you want to know much lag your server has? Then this plugin is for you! With one single command you can know if its lagging, by showing you a message, if this message is slow, then you know its lagging! My first simple plugin. I know it is a very very basic plugin but I am just starting. Hope you enjoy. Version: v2.0. Features: Single command to telling you how much lag you have. Easy to use. Easy to understand. Commands: /lagtest - Shows the current server ping. Changelog: Version 2.0 Added a simple timer that returns in ms. Thanks -_Husky_- Complete code rewrite. Updated to 1.3.2R0.1. Version 1.0 Implemented a more useful message. Plugin Release. DOWNLOAD v2.0
Oops I'll change it now Updated download link. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
This has already been stated, but Essentials comes with a very handy command for that. Try to run /ping
add a simple timer, that returns in MS. Code:java //when command is performedlong l1 =System.currentTimeMillis();//then return the ms from the new timelong l2 =System.currentTimeMillis();long ping = l1-l2;// send player resultp.sendMessage(ChatColor.whatever + "Ping: " + ping); Soooo... Code:Java package code.husky; import org.bukkit.ChatColor;import org.bukkit.command.Command;import org.bukkit.command.CommandSender;import org.bukkit.entity.Player;import org.bukkit.plugin.java.JavaPlugin; public class GetPing extends JavaPlugin{ public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {Player p = (Player) sender;if(commandLabel.equalsIgnoreCase("cms")) {long l1 =System.currentTimeMillis();p.sendMessage("");long l2 =System.currentTimeMillis();long ping = l1-l2;p.sendMessage(ChatColor.GREEN + "Ping: " + ping + "ms");return true;}return false;} } Is basically what you need //EDIT - think i stuffed it.. >.> let me check
that would be your command class. Soooo.. your class would look like this Code:java package me.Iain.test; import org.bukkit.ChatColor;import org.bukkit.command.Command;import org.bukkit.command.CommandSender;import org.bukkit.entity.Player;import org.bukkit.plugin.java.JavaPlugin; public class Test extends JavaPlugin{ // dont need onenable + ondisable anymore public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {Player p = (Player) sender;if(commandLabel.equalsIgnoreCase("lagtest")) {long l1 =System.currentTimeMillis();p.sendMessage("");long l2 =System.currentTimeMillis();long ping = l1-l2;p.sendMessage(ChatColor.GREEN + "Ping: " + ping + "ms");return true;}return false;}} EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Haha...what is happening on these forums. I've seen so many silly post today I don't even want to reply to most of them. 1.3 isn't even out...
Updated to 1.3! Changes: Added a simple timer that returns in MS, thanks -_Husky_- Complete code rewrite. Updated to 1.3.2 R0.1.