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