mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-12-24 01:48:11 +01:00
added has(sender, node) for quick has check on commandsenders in the API
This commit is contained in:
parent
61f1a93791
commit
d495694dae
@ -24,6 +24,7 @@ import java.util.logging.Logger;
|
||||
import net.milkbowl.vault.Vault;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
@ -77,6 +78,17 @@ public abstract class Permission {
|
||||
return playerHas(world.getName(), player, permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a CommandSender has a permission node.
|
||||
* For easy checking of a commandsender
|
||||
* @param sender
|
||||
* @param permission
|
||||
* @return true if the sender has the permission
|
||||
*/
|
||||
public boolean has(CommandSender sender, String permission) {
|
||||
return sender.hasPermission(permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if player has a permission node. (Short for playerHas(...)
|
||||
* @param player Player Object
|
||||
|
@ -27,6 +27,8 @@ import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.command.ColouredConsoleSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event.Type;
|
||||
@ -114,6 +116,15 @@ public class Permission_Permissions3 extends Permission {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(CommandSender sender, String permission) {
|
||||
if (sender.isOp() || sender instanceof ColouredConsoleSender) {
|
||||
return true;
|
||||
} else {
|
||||
return has(((Player) sender).getWorld().getName(), sender.getName(), permission);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String worldName, String playerName, String groupName) {
|
||||
if (worldName == null)
|
||||
|
Loading…
Reference in New Issue
Block a user