From ed56c3458fadac1865aa634f1aabbca01fb2b4e9 Mon Sep 17 00:00:00 2001 From: asofold Date: Fri, 25 Jan 2013 20:41:38 +0100 Subject: [PATCH] Add "/ncp version" command. --- .../nocheatplus/command/CommandHandler.java | 2 ++ .../command/admin/NCPVersionCommand.java | 34 +++++++++++++++++++ .../nocheatplus/permissions/Permissions.java | 1 + NCPPlugin/src/main/resources/plugin.yml | 5 ++- 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/command/admin/NCPVersionCommand.java diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/command/CommandHandler.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/command/CommandHandler.java index b2f3f60e..25824ba3 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/command/CommandHandler.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/command/CommandHandler.java @@ -30,6 +30,7 @@ import fr.neatmonster.nocheatplus.command.admin.ExemptCommand; import fr.neatmonster.nocheatplus.command.admin.ExemptionsCommand; import fr.neatmonster.nocheatplus.command.admin.InfoCommand; import fr.neatmonster.nocheatplus.command.admin.LagCommand; +import fr.neatmonster.nocheatplus.command.admin.NCPVersionCommand; import fr.neatmonster.nocheatplus.command.admin.ReloadCommand; import fr.neatmonster.nocheatplus.command.admin.RemovePlayerCommand; import fr.neatmonster.nocheatplus.command.admin.UnexemptCommand; @@ -110,6 +111,7 @@ public class CommandHandler implements TabExecutor { new KickCommand(plugin), new KickListCommand(plugin), new LagCommand(plugin), + new NCPVersionCommand(plugin), new ReloadCommand(plugin, notifyReload), new RemovePlayerCommand(plugin), new TellCommand(plugin), diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/command/admin/NCPVersionCommand.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/command/admin/NCPVersionCommand.java new file mode 100644 index 00000000..f37cca54 --- /dev/null +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/command/admin/NCPVersionCommand.java @@ -0,0 +1,34 @@ +package fr.neatmonster.nocheatplus.command.admin; + +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; + +import fr.neatmonster.nocheatplus.NoCheatPlus; +import fr.neatmonster.nocheatplus.command.NCPCommand; +import fr.neatmonster.nocheatplus.compat.MCAccess; +import fr.neatmonster.nocheatplus.permissions.Permissions; + +public class NCPVersionCommand extends NCPCommand{ + + public NCPVersionCommand(NoCheatPlus plugin) { + super(plugin, "version", Permissions.ADMINISTRATION_VERSION, new String[]{"versions", "ver"}); + } + + @Override + public boolean onCommand(CommandSender sender, Command command, + String label, String[] args) { + MCAccess mc = NoCheatPlus.getMCAccess(); + sender.sendMessage(new String[]{ + "---- Version information ----", + "#### Server ####", + Bukkit.getServer().getVersion(), + "#### NoCheatPlus ####", + "Plugin: " + plugin.getDescription().getVersion(), + "MCAccess: " + mc.getMCVersion() + " / " + mc.getServerVersionTag(), + + }); + return true; + } + +} diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/permissions/Permissions.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/permissions/Permissions.java index 8f1636a1..fcbd5c1d 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/permissions/Permissions.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/permissions/Permissions.java @@ -43,6 +43,7 @@ public class Permissions { public static final String ADMINISTRATION_TELL = ADMINISTRATION + ".tell"; public static final String ADMINISTRATION_TEMPKICK = ADMINISTRATION + ".tempkick"; public static final String ADMINISTRATION_UNKICK = ADMINISTRATION + ".unkick"; + public static final String ADMINISTRATION_VERSION = ADMINISTRATION + ".version"; // Debug permission, for player spam (not in plugin.yml, currently). public static final String ADMINISTRATION_DEBUG = ADMINISTRATION + ".debug"; diff --git a/NCPPlugin/src/main/resources/plugin.yml b/NCPPlugin/src/main/resources/plugin.yml index 4bbf132a..9ccc4908 100644 --- a/NCPPlugin/src/main/resources/plugin.yml +++ b/NCPPlugin/src/main/resources/plugin.yml @@ -15,7 +15,8 @@ commands: # permissions: nocheatplus.admin.(...) usage: | Administrative commands overview: - / reload: reload NoCheatPlus configuration + / version: Show version information. + / reload: reload the configuration / lag: Lag related info [expect changes] / info (player): Display the violations of a player / removeplayer (player) [(check type)]: Remove data @@ -61,6 +62,8 @@ permissions: description: Allow use of the ncp tempkick command. nocheatplus.admin.unkick: description: Allow use of the ncp unkick command. + nocheatplus.admin.version: + description: Allow use of the ncp version command. nocheatplus.admin.removeplayer: description: Allow use of the ncp removeplayer command. nocheatplus.admin.commands: