001 package org.bukkit.permissions;
002
003 import java.util.Set;
004 import org.bukkit.plugin.Plugin;
005
006 /**
007 * Represents an object that may be assigned permissions
008 */
009 public interface Permissible extends ServerOperator {
010 /**
011 * Checks if this object contains an override for the specified permission, by fully qualified name
012 *
013 * @param name Name of the permission
014 * @return true if the permission is set, otherwise false
015 */
016 public boolean isPermissionSet(String name);
017
018 /**
019 * Checks if this object contains an override for the specified {@link Permission}
020 *
021 * @param perm Permission to check
022 * @return true if the permission is set, otherwise false
023 */
024 public boolean isPermissionSet(Permission perm);
025
026 /**
027 * Gets the value of the specified permission, if set.
028 * <p />
029 * If a permission override is not set on this object, the default value of the permission will be returned.
030 *
031 * @param name Name of the permission
032 * @return Value of the permission
033 */
034 public boolean hasPermission(String name);
035
036 /**
037 * Gets the value of the specified permission, if set.
038 * <p />
039 * If a permission override is not set on this object, the default value of the permission will be returned
040 *
041 * @param perm Permission to get
042 * @return Value of the permission
043 */
044 public boolean hasPermission(Permission perm);
045
046 /**
047 * Adds a new {@link PermissionAttachment} with a single permission by name and value
048 *
049 * @param plugin Plugin responsible for this attachment, may not be null or disabled
050 * @param name Name of the permission to attach
051 * @param value Value of the permission
052 * @return The PermissionAttachment that was just created
053 */
054 public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value);
055
056 /**
057 * Adds a new empty {@link PermissionAttachment} to this object
058 *
059 * @param plugin Plugin responsible for this attachment, may not be null or disabled
060 * @return The PermissionAttachment that was just created
061 */
062 public PermissionAttachment addAttachment(Plugin plugin);
063
064 /**
065 * Temporarily adds a new {@link PermissionAttachment} with a single permission by name and value
066 *
067 * @param plugin Plugin responsible for this attachment, may not be null or disabled
068 * @param name Name of the permission to attach
069 * @param value Value of the permission
070 * @param ticks Amount of ticks to automatically remove this attachment after
071 * @return The PermissionAttachment that was just created
072 */
073 public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks);
074
075 /**
076 * Temporarily adds a new empty {@link PermissionAttachment} to this object
077 *
078 * @param plugin Plugin responsible for this attachment, may not be null or disabled
079 * @param ticks Amount of ticks to automatically remove this attachment after
080 * @return The PermissionAttachment that was just created
081 */
082 public PermissionAttachment addAttachment(Plugin plugin, int ticks);
083
084 /**
085 * Removes the given {@link PermissionAttachment} from this object
086 *
087 * @param attachment Attachment to remove
088 * @throws IllegalArgumentException Thrown when the specified attachment isn't part of this object
089 */
090 public void removeAttachment(PermissionAttachment attachment);
091
092 /**
093 * Recalculates the permissions for this object, if the attachments have changed values.
094 * <p />
095 * This should very rarely need to be called from a plugin.
096 */
097 public void recalculatePermissions();
098
099 /**
100 * Gets a set containing all of the permissions currently in effect by this object
101 *
102 * @return Set of currently effective permissions
103 */
104 public Set<PermissionAttachmentInfo> getEffectivePermissions();
105 }