diff options
author | snowleo <schneeleo@gmail.com> | 2011-06-26 15:47:28 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-06-26 15:47:28 +0200 |
commit | 88ded926f49deed78fb6d238661f3c900483b0a6 (patch) | |
tree | 0a7b82c3ff5eae3d75f3cfb09069423da67475d5 | |
parent | 3b9a07e560d5b486680643c4919c2ffa4076f6eb (diff) | |
download | Essentials-88ded926f49deed78fb6d238661f3c900483b0a6.tar Essentials-88ded926f49deed78fb6d238661f3c900483b0a6.tar.gz Essentials-88ded926f49deed78fb6d238661f3c900483b0a6.tar.lz Essentials-88ded926f49deed78fb6d238661f3c900483b0a6.tar.xz Essentials-88ded926f49deed78fb6d238661f3c900483b0a6.zip |
Corrected all commands of PermCommands
onCommand now supports the change of the permissions prefix
24 files changed, 39 insertions, 37 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 24c9a445e..4c39389ef 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -352,22 +352,13 @@ public class Essentials extends JavaPlugin implements IEssentials return retval; } - @SuppressWarnings("LoggerStringConcat") - public static void previewCommand(CommandSender sender, Command command, String commandLabel, String[] args) - { - if (sender instanceof Player) - { - logger.info(ChatColor.BLUE + "[PLAYER_COMMAND] " + ((Player)sender).getName() + ": /" + commandLabel + " " + EssentialsCommand.getFinalArg(args, 0)); - } - } - @Override public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) { - return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command"); + return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials."); } - public boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath) + public boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix) { if (("msg".equals(commandLabel.toLowerCase()) || "r".equals(commandLabel.toLowerCase()) || "mail".equals(commandLabel.toLowerCase())) && sender instanceof Player) { @@ -416,8 +407,12 @@ public class Essentials extends JavaPlugin implements IEssentials try { - previewCommand(sender, command, commandLabel, args); - User user = sender instanceof Player ? getUser(sender) : null; + User user = null; + if (sender instanceof Player) + { + user = getUser(sender); + logger.log(Level.INFO, String.format("[PLAYER_COMMAND] %s: /%s %s ", ((Player)sender).getName(), commandLabel , EssentialsCommand.getFinalArg(args, 0))); + } // New mail notification if (user != null && !getSettings().isCommandDisabled("mail") && !commandLabel.equals("mail") && user.isAuthorized("essentials.mail")) @@ -449,7 +444,7 @@ public class Essentials extends JavaPlugin implements IEssentials } // Check authorization - if (user != null && !user.isAuthorized(cmd)) + if (user != null && !user.isAuthorized(cmd, permissionPrefix)) { logger.log(Level.WARNING, Util.format("deniedAccessCommand", user.getName())); user.sendMessage(Util.i18n("noAccessCommand")); diff --git a/Essentials/src/com/earth2me/essentials/IEssentials.java b/Essentials/src/com/earth2me/essentials/IEssentials.java index 426724c61..cf6e62e71 100644 --- a/Essentials/src/com/earth2me/essentials/IEssentials.java +++ b/Essentials/src/com/earth2me/essentials/IEssentials.java @@ -16,7 +16,7 @@ public interface IEssentials void reload(); - boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath); + boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix); User getUser(Object base); diff --git a/Essentials/src/com/earth2me/essentials/IUser.java b/Essentials/src/com/earth2me/essentials/IUser.java index cfed0915f..5b2e7075e 100644 --- a/Essentials/src/com/earth2me/essentials/IUser.java +++ b/Essentials/src/com/earth2me/essentials/IUser.java @@ -22,6 +22,8 @@ public interface IUser boolean isAuthorized(String node); boolean isAuthorized(IEssentialsCommand cmd); + + boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix); void setLastTeleportTimestamp(long time); diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index befbf111f..c3384d033 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -31,10 +31,15 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser setBase(base); return this; } - + public boolean isAuthorized(IEssentialsCommand cmd) { - return isAuthorized("essentials." + (cmd.getName().equals("r") ? "msg" : cmd.getName())); + return isAuthorized(cmd, "essentials."); + } + + public boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix) + { + return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName())); } public boolean isAuthorized(String node) diff --git a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangadd.java b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangadd.java index 442729f16..8c22dabdc 100644 --- a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangadd.java +++ b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangadd.java @@ -21,7 +21,7 @@ public class Commandmangadd extends EssentialsCommand throw new NotEnoughArgumentsException(); } final String group = args[0]; - String command = "/permissions g:" + group + " create"; + String command = "permissions g:" + group + " create"; sender.sendMessage(commandLabel + " is deprecated. Use " + command + " instead."); ess.getServer().dispatchCommand(sender, command); } diff --git a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangaddi.java b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangaddi.java index f2eb55ee4..760b5c81f 100644 --- a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangaddi.java +++ b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangaddi.java @@ -22,7 +22,7 @@ public class Commandmangaddi extends EssentialsCommand } final String target = args[0]; final String group = args[1]; - String command = "/permissions g:"+target+" parents add "+group; + String command = "permissions g:"+target+" parents add "+group; sender.sendMessage(commandLabel + " is deprecated. Use " + command + " instead."); ess.getServer().dispatchCommand(sender, command); } diff --git a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangaddp.java b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangaddp.java index e57628c57..e83de4e50 100644 --- a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangaddp.java +++ b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangaddp.java @@ -22,7 +22,7 @@ public class Commandmangaddp extends EssentialsCommand } final String target = args[0]; final String perm = args[1]; - String command = "/permissions g:"+target+" perms add "+perm; + String command = "permissions g:"+target+" perms add "+perm; sender.sendMessage(commandLabel + " is deprecated. Use " + command + " instead."); ess.getServer().dispatchCommand(sender, command); } diff --git a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangcheckp.java b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangcheckp.java index 106dcd791..1152d1a0b 100644 --- a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangcheckp.java +++ b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangcheckp.java @@ -22,7 +22,7 @@ public class Commandmangcheckp extends EssentialsCommand } final String target = args[0]; final String perm = args[1]; - String command = "/permissions g:"+target+" has "+perm; + String command = "permissions g:"+target+" has "+perm; sender.sendMessage(commandLabel + " is deprecated. Use " + command + " instead."); ess.getServer().dispatchCommand(sender, command); } diff --git a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangdel.java b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangdel.java index 52fdc3da2..24ffe2307 100644 --- a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangdel.java +++ b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangdel.java @@ -21,7 +21,7 @@ public class Commandmangdel extends EssentialsCommand throw new NotEnoughArgumentsException(); } final String group = args[0]; - String command = "/permissions g:"+group+" delete"; + String command = "permissions g:"+group+" delete"; sender.sendMessage(commandLabel + " is deprecated. Use " + command + " instead."); ess.getServer().dispatchCommand(sender, command); } diff --git a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangdeli.java b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangdeli.java index 9b3bc3679..aea296735 100644 --- a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangdeli.java +++ b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangdeli.java @@ -22,7 +22,7 @@ public class Commandmangdeli extends EssentialsCommand } final String target = args[0]; final String group = args[1]; - String command = "/permissions g:"+target+" parents remove "+group; + String command = "permissions g:"+target+" parents remove "+group; sender.sendMessage(commandLabel + " is deprecated. Use " + command + " instead."); ess.getServer().dispatchCommand(sender, command); } diff --git a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangdelp.java b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangdelp.java index de4ce8a7e..ef1dd4207 100644 --- a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangdelp.java +++ b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmangdelp.java @@ -22,7 +22,7 @@ public class Commandmangdelp extends EssentialsCommand } final String target = args[0]; final String perm = args[1]; - String command = "/permissions g:"+target+" perms remove "+perm; + String command = "permissions g:"+target+" perms remove "+perm; sender.sendMessage(commandLabel + " is deprecated. Use " + command + " instead."); ess.getServer().dispatchCommand(sender, command); } diff --git a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanglistp.java b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanglistp.java index 2e775c147..715f42774 100644 --- a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanglistp.java +++ b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanglistp.java @@ -21,7 +21,7 @@ public class Commandmanglistp extends EssentialsCommand throw new NotEnoughArgumentsException(); } final String target = args[0]; - String command = "/permissions g:"+target+" perms list"; + String command = "permissions g:"+target+" perms list"; sender.sendMessage(commandLabel + " is deprecated. Use " + command + " instead."); ess.getServer().dispatchCommand(sender, command); } diff --git a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanload.java b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanload.java index 3e1803233..390cb78eb 100644 --- a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanload.java +++ b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanload.java @@ -21,7 +21,7 @@ public class Commandmanload extends EssentialsCommand { world = args[0]; } - String command = "/permissions -reload "+world; + String command = "permissions -reload "+world; sender.sendMessage(commandLabel + " is deprecated. Use " + command + " instead."); ess.getServer().dispatchCommand(sender, command); } diff --git a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanuadd.java b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanuadd.java index 65a4df759..a63a1a36b 100644 --- a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanuadd.java +++ b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanuadd.java @@ -23,7 +23,7 @@ public class Commandmanuadd extends EssentialsCommand final String player = args[0]; final String group = args[1]; //TODO: Make this command add a player if it doesnt exist /permissions +player+ create - String command = "/permissions "+player+" parents add "+group; + String command = "permissions "+player+" parents add "+group; sender.sendMessage(commandLabel + " is deprecated. Use " + command + " instead."); ess.getServer().dispatchCommand(sender, command); } diff --git a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanuaddp.java b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanuaddp.java index 676631c63..3d3d67c72 100644 --- a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanuaddp.java +++ b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanuaddp.java @@ -22,7 +22,7 @@ public class Commandmanuaddp extends EssentialsCommand } final String player = args[0]; final String perm = args[1]; - String command = "/permissions "+player+" perms add "+perm; + String command = "permissions "+player+" perms add "+perm; sender.sendMessage(commandLabel + " is deprecated. Use " + command + " instead."); ess.getServer().dispatchCommand(sender, command); } diff --git a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanuaddsub.java b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanuaddsub.java index ee2cd3147..60d1980af 100644 --- a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanuaddsub.java +++ b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanuaddsub.java @@ -22,7 +22,7 @@ public class Commandmanuaddsub extends EssentialsCommand } final String player = args[0]; final String group = args[1]; - String command = "/permissions "+player+" parents add "+group; + String command = "permissions "+player+" parents add "+group; sender.sendMessage(commandLabel + " is deprecated. Use " + command + " instead."); ess.getServer().dispatchCommand(sender, command); } diff --git a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanucheckp.java b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanucheckp.java index df713fc31..634b447c7 100644 --- a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanucheckp.java +++ b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanucheckp.java @@ -22,7 +22,7 @@ public class Commandmanucheckp extends EssentialsCommand } final String player = args[0]; final String perm = args[1]; - String command = "/permissions "+player+" has "+perm; + String command = "permissions "+player+" has "+perm; sender.sendMessage(commandLabel + " is deprecated. Use " + command + " instead."); ess.getServer().dispatchCommand(sender, command); } diff --git a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanudel.java b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanudel.java index 9e117ac21..72c8fc2af 100644 --- a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanudel.java +++ b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanudel.java @@ -21,7 +21,7 @@ public class Commandmanudel extends EssentialsCommand throw new NotEnoughArgumentsException(); } final String player = args[0]; - String command = "/permissions "+player+" delete"; + String command = "permissions "+player+" delete"; sender.sendMessage(commandLabel + " is deprecated. Use " + command + " instead."); ess.getServer().dispatchCommand(sender, command); } diff --git a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanudelp.java b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanudelp.java index 4a35f628b..01adf97b2 100644 --- a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanudelp.java +++ b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanudelp.java @@ -22,7 +22,7 @@ public class Commandmanudelp extends EssentialsCommand } final String player = args[0]; final String perm = args[1]; - String command = "/permissions "+player+" perms remove "+perm; + String command = "permissions "+player+" perms remove "+perm; sender.sendMessage(commandLabel + " is deprecated. Use " + command + " instead."); ess.getServer().dispatchCommand(sender, command); } diff --git a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanudelsub.java b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanudelsub.java index 4640c68b1..1a1ae2a6d 100644 --- a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanudelsub.java +++ b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanudelsub.java @@ -22,7 +22,7 @@ public class Commandmanudelsub extends EssentialsCommand } final String player = args[0]; final String group = args[1]; - String command = "/permissions "+player+" parents remove "+group; + String command = "permissions "+player+" parents remove "+group; sender.sendMessage(commandLabel + " is deprecated. Use " + command + " instead."); ess.getServer().dispatchCommand(sender, command); } diff --git a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanulistp.java b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanulistp.java index f5d4a484e..f809f3c61 100644 --- a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanulistp.java +++ b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/Commandmanulistp.java @@ -21,7 +21,7 @@ public class Commandmanulistp extends EssentialsCommand throw new NotEnoughArgumentsException(); } final String player = args[0]; - String command = "/permissions "+player+" perms list"; + String command = "permissions "+player+" perms list"; sender.sendMessage(commandLabel + " is deprecated. Use " + command + " instead."); ess.getServer().dispatchCommand(sender, command); } diff --git a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/EssentialsPermissionsCommands.java b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/EssentialsPermissionsCommands.java index e3c3f1dd6..a9651cd31 100644 --- a/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/EssentialsPermissionsCommands.java +++ b/EssentialsPermissionsCommands/src/com/earth2me/essentials/permissions/EssentialsPermissionsCommands.java @@ -35,7 +35,7 @@ public class EssentialsPermissionsCommands extends JavaPlugin @Override public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) { - return Essentials.getStatic().onCommandEssentials(sender, command, label, args, EssentialsPermissionsCommands.class.getClassLoader(), "com.earth2me.essentials.permissions.Command"); + return Essentials.getStatic().onCommandEssentials(sender, command, label, args, EssentialsPermissionsCommands.class.getClassLoader(), "com.earth2me.essentials.permissions.Command", "groupmanager."); } @Override diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java index fb2e712b7..77cb9a3cb 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java @@ -38,6 +38,6 @@ public class EssentialsSpawn extends JavaPlugin @Override public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) { - return Essentials.getStatic().onCommandEssentials(sender, command, commandLabel, args, EssentialsSpawn.class.getClassLoader(), "com.earth2me.essentials.spawn.Command"); + return Essentials.getStatic().onCommandEssentials(sender, command, commandLabel, args, EssentialsSpawn.class.getClassLoader(), "com.earth2me.essentials.spawn.Command", "essentials."); } } diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java index a2ee7bed1..27988f11a 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java @@ -65,7 +65,7 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP @Override public boolean onCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args) { - return Essentials.getStatic().onCommandEssentials(sender, command, commandLabel, args, EssentialsXMPP.class.getClassLoader(), "com.earth2me.essentials.xmpp.Command"); + return Essentials.getStatic().onCommandEssentials(sender, command, commandLabel, args, EssentialsXMPP.class.getClassLoader(), "com.earth2me.essentials.xmpp.Command", "essentials."); } @Override |