Fix nullpointer when command requires no permissions

- Add test to verify connections among the command initialization
This commit is contained in:
ljacqu
2015-11-29 12:04:01 +01:00
parent 7c652feac2
commit d7513ecc7b
2 changed files with 29 additions and 4 deletions
@@ -108,12 +108,15 @@ public class FoundCommandResult {
* @return True if the command sender has permission, false otherwise.
*/
public boolean hasPermission(CommandSender sender) {
// Make sure the command description is valid
if (this.commandDescription == null)
if (commandDescription == null) {
return false;
} else if (commandDescription.getCommandPermissions() == null) {
return true;
}
// Get and return the permission
return this.commandDescription.getCommandPermissions().hasPermission(sender);
// TODO: Move permissions check to the permission package; command package should not define permission-checking
// API
return commandDescription.getCommandPermissions().hasPermission(sender);
}
/**