From 0bda040a608b6ab9f081e78ae3605dcce59082c4 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 21 May 2013 14:23:58 +1200 Subject: [PATCH] Read description Added command undisguise Changed perm for undisguise to libsdisguises.undisguise Moved where the commands are set incase of errors. --- plugin.yml | 4 +++- .../disguise/DisguiseCommand.java | 2 +- .../libraryaddict/disguise/LibsDisguises.java | 3 ++- .../disguise/UndisguiseCommand.java | 23 +++++++++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 src/me/libraryaddict/disguise/UndisguiseCommand.java diff --git a/plugin.yml b/plugin.yml index a4b4803a..9131892f 100644 --- a/plugin.yml +++ b/plugin.yml @@ -5,4 +5,6 @@ author: libraryaddict depend: [ProtocolLib] commands: disguise: - aliases: [d, dis] \ No newline at end of file + aliases: [d, dis] + undisguise: + aliases: [undis] \ No newline at end of file diff --git a/src/me/libraryaddict/disguise/DisguiseCommand.java b/src/me/libraryaddict/disguise/DisguiseCommand.java index ef214d3c..4478a96f 100644 --- a/src/me/libraryaddict/disguise/DisguiseCommand.java +++ b/src/me/libraryaddict/disguise/DisguiseCommand.java @@ -64,7 +64,7 @@ public class DisguiseCommand implements CommandExecutor { } else sender.sendMessage(ChatColor.RED + "You do not have permission to use this command."); } else if (args[0].equalsIgnoreCase("undiguise") || args[0].equalsIgnoreCase("undis") || args[0].equalsIgnoreCase("un")) { - if (sender.hasPermission("libsdisguises.disguise.undisguise")) { + if (sender.hasPermission("libsdisguises.undisguise")) { if (DisguiseAPI.isDisguised(p.getName())) { DisguiseAPI.undisguiseToAll(p); sender.sendMessage(ChatColor.RED + "You are no longer disguised"); diff --git a/src/me/libraryaddict/disguise/LibsDisguises.java b/src/me/libraryaddict/disguise/LibsDisguises.java index f3741a0c..9fc4ad92 100644 --- a/src/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/me/libraryaddict/disguise/LibsDisguises.java @@ -26,7 +26,6 @@ import com.comphenix.protocol.reflect.StructureModifier; public class LibsDisguises extends JavaPlugin { public void onEnable() { - getCommand("disguise").setExecutor(new DisguiseCommand()); ProtocolLibrary.getProtocolManager().addPacketListener( new PacketAdapter(this, ConnectionSide.SERVER_SIDE, ListenerPriority.NORMAL, Packets.Server.NAMED_ENTITY_SPAWN, Packets.Server.ENTITY_METADATA, Packets.Server.NAMED_SOUND_EFFECT, Packets.Server.ARM_ANIMATION) { @@ -149,5 +148,7 @@ public class LibsDisguises extends JavaPlugin { } } }); + getCommand("disguise").setExecutor(new DisguiseCommand()); + getCommand("undisguise").setExecutor(new UndisguiseCommand()); } } \ No newline at end of file diff --git a/src/me/libraryaddict/disguise/UndisguiseCommand.java b/src/me/libraryaddict/disguise/UndisguiseCommand.java new file mode 100644 index 00000000..b143cb62 --- /dev/null +++ b/src/me/libraryaddict/disguise/UndisguiseCommand.java @@ -0,0 +1,23 @@ +package me.libraryaddict.disguise; + +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 class UndisguiseCommand implements CommandExecutor { + + public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { + Player p = (Player) sender; + if (sender.hasPermission("libsdisguises.undisguise")) { + if (DisguiseAPI.isDisguised(p.getName())) { + DisguiseAPI.undisguiseToAll(p); + sender.sendMessage(ChatColor.RED + "You are no longer disguised"); + } else + sender.sendMessage(ChatColor.RED + "You are not disguised!"); + } else + sender.sendMessage(ChatColor.RED + "You do not have permission to use this command."); + return true; + } +}