mirror of
https://github.com/kaboomserver/extras.git
synced 2024-11-27 09:55:36 -05:00
Add ping command (#14)
* Add ping command * Add new command to readme * Make command description make sense * Add alpha-sort and a tab. * No longer use CraftBukkit to get the player's ping, and instead use the Player's spigot object. * Make command description shorter
This commit is contained in:
parent
97696ae601
commit
0e6db230d4
6 changed files with 49 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@ target/
|
|||
.classpath
|
||||
.project
|
||||
*.iml
|
||||
.theia/
|
|
@ -14,6 +14,7 @@ Extras is a Bukkit plugin that that adds extra functionality to the Kaboom serve
|
|||
|/enchantall | | extras.enchantall | Adds every enchantment to a held item|
|
||||
|/jumpscare | /scare | extras.jumpscare | Scares a player|
|
||||
|/kaboom | | extras.kaboom | I wonder...|
|
||||
|/ping | /ms, /delay | extras.ping | Gets your ping|
|
||||
|/prefix | /rank, /tag | extras.prefix | Changes your tag|
|
||||
|/pumpkin | | extras.pumpkin | Places a pumpkin on a player's head|
|
||||
|/serverinfo | /specs | extras.serverinfo | Shows detailed server information|
|
||||
|
|
|
@ -13,6 +13,7 @@ import pw.kaboom.extras.commands.CommandDestroyEntities;
|
|||
import pw.kaboom.extras.commands.CommandEnchantAll;
|
||||
import pw.kaboom.extras.commands.CommandJumpscare;
|
||||
import pw.kaboom.extras.commands.CommandKaboom;
|
||||
import pw.kaboom.extras.commands.CommandPing;
|
||||
import pw.kaboom.extras.commands.CommandPrefix;
|
||||
import pw.kaboom.extras.commands.CommandPumpkin;
|
||||
import pw.kaboom.extras.commands.CommandServerInfo;
|
||||
|
@ -65,6 +66,7 @@ public final class Main extends JavaPlugin {
|
|||
this.getCommand("enchantall").setExecutor(new CommandEnchantAll());
|
||||
this.getCommand("jumpscare").setExecutor(new CommandJumpscare());
|
||||
this.getCommand("kaboom").setExecutor(new CommandKaboom());
|
||||
this.getCommand("ping").setExecutor(new CommandPing());
|
||||
this.getCommand("prefix").setExecutor(new CommandPrefix());
|
||||
this.getCommand("pumpkin").setExecutor(new CommandPumpkin());
|
||||
this.getCommand("serverinfo").setExecutor(new CommandServerInfo());
|
||||
|
|
40
src/main/java/pw/kaboom/extras/commands/CommandPing.java
Normal file
40
src/main/java/pw/kaboom/extras/commands/CommandPing.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
package pw.kaboom.extras.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public final class CommandPing implements CommandExecutor {
|
||||
|
||||
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
|
||||
final Player player = (Player) sender;
|
||||
final int ping = player.spigot().getPing();
|
||||
final int d = (int) Math.floor(ping / 100);
|
||||
ChatColor highlighting = ChatColor.WHITE;
|
||||
|
||||
switch (d) {
|
||||
case 0:
|
||||
highlighting = ChatColor.GREEN;
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
highlighting = ChatColor.YELLOW;
|
||||
break;
|
||||
case 5:
|
||||
highlighting = ChatColor.RED;
|
||||
break;
|
||||
default:
|
||||
if (d > 5) {
|
||||
highlighting = ChatColor.DARK_RED;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
player.sendMessage("Your ping is " + highlighting + ping + "ms.");
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -34,6 +34,10 @@ commands:
|
|||
kaboom:
|
||||
description: I wonder...
|
||||
permission: extras.kaboom
|
||||
ping:
|
||||
aliases: [delay, ms]
|
||||
description: Gets your ping
|
||||
permission: extras.ping
|
||||
prefix:
|
||||
aliases: [rank, tag]
|
||||
description: Changes your tag
|
||||
|
|
Loading…
Reference in a new issue