com.amoebaman.kitmaster.objects
Class Kit

java.lang.Object
  extended by com.amoebaman.kitmaster.objects.Kit
All Implemented Interfaces:
java.lang.Cloneable

public class Kit
extends java.lang.Object
implements java.lang.Cloneable


Field Summary
 java.util.HashMap<Attribute,java.lang.Object> attributes
          The set of attributes that have been defined for the kit.
 java.util.ArrayList<org.bukkit.potion.PotionEffect> effects
          The set of potion effects that the kit will apply.
 java.util.ArrayList<org.bukkit.inventory.ItemStack> items
          The set of items that the kit will give.
 java.lang.String name
          The name of the kit.
 java.util.ArrayList<java.lang.String> permissions
          The set of (temporary) permissions that the kit will grant.
 
Constructor Summary
Kit(java.lang.String name, java.util.List<org.bukkit.inventory.ItemStack> items, java.util.List<org.bukkit.potion.PotionEffect> effects, java.util.List<java.lang.String> permissions, java.util.HashMap<Attribute,java.lang.Object> attributes)
          Constructs a kit from the given specifications.
 
Method Summary
 Kit applyParentAttributes()
          Gets a new copy of this kit that replaces all undefined attributes of this kit with those defined by its parent.
 boolean booleanAttribute(Attribute type)
          Retrives the value of an attribute as a boolean.
 Kit clone()
          Clones the kit for safe modification.
 boolean containsEffect(org.bukkit.potion.PotionEffect potion)
          Tests whether the kit's items contain an effect.
 boolean containsItem(org.bukkit.inventory.ItemStack stack)
          Tests whether the kit's items contain an item.
 double doubleAttribute(Attribute type)
          Retrives the value of an attribute as a double.
 boolean equals(java.lang.Object other)
          Two kits are considered equal so long as their names match.
 java.lang.Object getAttribute(Attribute type)
          Retrives the value of an attribute as it has been defined for this kit.
 Kit getParent()
          Gets the kit that this kit regards as its parent.
 int integerAttribute(Attribute type)
          Retrives the value of an attribute as an int.
 boolean setAttribute(Attribute type, java.lang.Object newValue)
          Defines/redefines the value of an attribute for this kit.
 java.lang.String stringAttribute(Attribute type)
          Retrives the value of an attribute as a String.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

public final java.lang.String name
The name of the kit.


items

public final java.util.ArrayList<org.bukkit.inventory.ItemStack> items
The set of items that the kit will give.


effects

public final java.util.ArrayList<org.bukkit.potion.PotionEffect> effects
The set of potion effects that the kit will apply.


permissions

public final java.util.ArrayList<java.lang.String> permissions
The set of (temporary) permissions that the kit will grant.


attributes

public final java.util.HashMap<Attribute,java.lang.Object> attributes
The set of attributes that have been defined for the kit.

Constructor Detail

Kit

public Kit(java.lang.String name,
           java.util.List<org.bukkit.inventory.ItemStack> items,
           java.util.List<org.bukkit.potion.PotionEffect> effects,
           java.util.List<java.lang.String> permissions,
           java.util.HashMap<Attribute,java.lang.Object> attributes)
Constructs a kit from the given specifications. The lists/maps will be copied onto the kit's lists/maps rather than adopted.

Parameters:
name - The name of the kit.
items - The items of the kit.
effects - The applied potion effects of the kit.
permissions - The granted permissions of the kit.
attributes - The defined attributes of the kit.
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Two kits are considered equal so long as their names match. This is done to prevent two kits from possessing the same name.

Overrides:
equals in class java.lang.Object

containsItem

public boolean containsItem(org.bukkit.inventory.ItemStack stack)
Tests whether the kit's items contain an item.

Parameters:
stack - The ItemStack to test for.
Returns:
True if the kit contains the given ItemStack

containsEffect

public boolean containsEffect(org.bukkit.potion.PotionEffect potion)
Tests whether the kit's items contain an effect.

Parameters:
potion - The PotionEffect to test for.
Returns:
True if the kit contains the given PotionEffect

getAttribute

public java.lang.Object getAttribute(Attribute type)
Retrives the value of an attribute as it has been defined for this kit.

Parameters:
type - The Attribute to retrieve.
Returns:
The value of the attribute, or the attribute's default value if it was not explicitly defined.

booleanAttribute

public boolean booleanAttribute(Attribute type)
Retrives the value of an attribute as a boolean. See getAttribute(Attribute)


integerAttribute

public int integerAttribute(Attribute type)
Retrives the value of an attribute as an int. See getAttribute(Attribute)


doubleAttribute

public double doubleAttribute(Attribute type)
Retrives the value of an attribute as a double. See getAttribute(Attribute)


stringAttribute

public java.lang.String stringAttribute(Attribute type)
Retrives the value of an attribute as a String. See getAttribute(Attribute)


setAttribute

public boolean setAttribute(Attribute type,
                            java.lang.Object newValue)
Defines/redefines the value of an attribute for this kit. If newValue does not match type's enumerated class type, the operation will fail.

Parameters:
type - The attribute type to set.
newValue - The new value for the attribute.
Returns:
False if newValue did not match the designated class of type, true otherwise.

getParent

public Kit getParent()
Gets the kit that this kit regards as its parent.

Returns:
The parent kit, or null if no parent kit is found.

applyParentAttributes

public Kit applyParentAttributes()
Gets a new copy of this kit that replaces all undefined attributes of this kit with those defined by its parent.

Returns:
A copy of this kit with its parent's attributes applied.

clone

public Kit clone()
Clones the kit for safe modification.

Overrides:
clone in class java.lang.Object
Returns:
A perfect copy of this kit.