#2568: Check permissions for inject_commands
This commit is contained in:
@@ -51,4 +51,15 @@ public abstract class Command
|
||||
* @param args arguments used to invoke this command
|
||||
*/
|
||||
public abstract void execute(CommandSender sender, String[] args);
|
||||
|
||||
/**
|
||||
* Check if this command can be executed by the given sender.
|
||||
*
|
||||
* @param sender the sender to check
|
||||
* @return whether the sender can execute this
|
||||
*/
|
||||
public boolean hasPermission(CommandSender sender)
|
||||
{
|
||||
return permission == null || permission.isEmpty() || sender.hasPermission( permission );
|
||||
}
|
||||
}
|
||||
|
@@ -144,8 +144,7 @@ public class PluginManager
|
||||
return false;
|
||||
}
|
||||
|
||||
String permission = command.getPermission();
|
||||
if ( permission != null && !permission.isEmpty() && !sender.hasPermission( permission ) )
|
||||
if ( !command.hasPermission( sender ) )
|
||||
{
|
||||
if ( tabResults == null )
|
||||
{
|
||||
@@ -435,8 +434,8 @@ public class PluginManager
|
||||
*
|
||||
* @return commands
|
||||
*/
|
||||
public Collection<String> getCommands()
|
||||
public Collection<Map.Entry<String, Command>> getCommands()
|
||||
{
|
||||
return Collections.unmodifiableCollection( commandMap.keySet() );
|
||||
return Collections.unmodifiableCollection( commandMap.entrySet() );
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user