Whitespace + general cleanup

By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
Bukkit/Spigot
2011-05-14 23:22:54 +02:00
parent 8217ff1836
commit 855f4133b6
216 changed files with 1649 additions and 1637 deletions

View File

@@ -7,6 +7,7 @@ import org.bukkit.Material;
* Interface to the various inventories
*/
public interface Inventory {
/**
* Returns the size of the inventory
*
@@ -35,7 +36,7 @@ public interface Inventory {
* @param index The index where to put the ItemStack
* @param item The ItemStack to set
*/
public void setItem(int index, ItemStack item);
public void setItem(int index, ItemStack item);
/**
* Stores the given ItemStacks in the inventory.
@@ -46,7 +47,7 @@ public interface Inventory {
* @param items The ItemStacks to add
* @return
*/
public HashMap<Integer, ItemStack> addItem(ItemStack... items);
public HashMap<Integer, ItemStack> addItem(ItemStack... items);
/**
* Removes the given ItemStacks from the inventory.
@@ -57,7 +58,7 @@ public interface Inventory {
* @param items The ItemStacks to remove
* @return
*/
public HashMap<Integer, ItemStack> removeItem(ItemStack... items);
public HashMap<Integer, ItemStack> removeItem(ItemStack... items);
/**
* Get all ItemStacks from the inventory
@@ -97,28 +98,28 @@ public interface Inventory {
* @return If any matching ItemStacks were found
*/
public boolean contains(ItemStack item);
/**
* Check if the inventory contains any ItemStacks with the given materialId and at least the minimum amount specified
*
*
* @param materialId The materialId to check for
* @param amount The minimum amount to look for
* @return If any ItemStacks were found
*/
public boolean contains(int materialId, int amount);
public boolean contains(int materialId, int amount);
/**
* Check if the inventory contains any ItemStacks with the given material and at least the minimum amount specified
*
*
* @param material The material to check for
* @return If any ItemStacks were found
*/
public boolean contains(Material material, int amount);
public boolean contains(Material material, int amount);
/**
* Check if the inventory contains any ItemStacks matching the given ItemStack and at least the minimum amount specified
* This will only match if both the type and the amount of the stack match
*
*
* @param item The ItemStack to match against
* @return If any matching ItemStacks were found
*/

View File

@@ -1,4 +1,3 @@
package org.bukkit.inventory;
import org.bukkit.Material;
@@ -89,7 +88,7 @@ public class ItemStack {
*/
public void setTypeId(int type) {
this.type = type;
createData((byte)0);
createData((byte) 0);
}
/**
@@ -117,7 +116,7 @@ public class ItemStack {
*/
public MaterialData getData() {
if (Material.getMaterial(getTypeId()).getData() != null) {
data = Material.getMaterial(getTypeId()).getNewData((byte)this.durability);
data = Material.getMaterial(getTypeId()).getNewData((byte) this.durability);
}
return data;
@@ -137,8 +136,7 @@ public class ItemStack {
if ((data.getClass() == mat.getData()) || (data.getClass() == MaterialData.class)) {
this.data = data;
} else {
throw new IllegalArgumentException("Provided data is not of type "
+ mat.getData().getName() + ", found " + data.getClass().getName());
throw new IllegalArgumentException("Provided data is not of type " + mat.getData().getName() + ", found " + data.getClass().getName());
}
}
}
@@ -164,7 +162,7 @@ public class ItemStack {
/**
* Get the maximum stacksize for the material hold in this ItemStack
* Returns -1 if it has no idea.
*
*
* @return The maximum you can stack this material to.
*/
public int getMaxStackSize() {
@@ -173,6 +171,7 @@ public class ItemStack {
private void createData(final byte data) {
Material mat = Material.getMaterial(type);
if (mat == null) {
this.data = new MaterialData(type, data);
} else {
@@ -182,28 +181,31 @@ public class ItemStack {
@Override
public String toString() {
return "ItemStack{"+getType().name()+" x "+getAmount()+"}";
return "ItemStack{" + getType().name() + " x " + getAmount() + "}";
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ItemStack))
if (!(obj instanceof ItemStack)) {
return false;
ItemStack item = (ItemStack)obj;
}
ItemStack item = (ItemStack) obj;
return item.getAmount() == getAmount() && item.getTypeId() == getTypeId();
}
@Override
public ItemStack clone() {
return new ItemStack(type, amount, durability);
}
}
@Override
public int hashCode() {
int hash = 11;
hash = hash * 19 + 7 * getTypeId(); // Overriding hashCode since equals is overridden, it's just
hash = hash * 19 + 7 * getTypeId(); // Overriding hashCode since equals is overridden, it's just
hash = hash * 7 + 23 * getAmount(); // too bad these are mutable values... Q_Q
return hash;
}
}
}

View File

@@ -4,37 +4,38 @@ package org.bukkit.inventory;
* Includes interface to the 4 armor slots
*/
public interface PlayerInventory extends Inventory {
/**
* Get all ItemStacks from the armor slots
*
*
* @return All the ItemStacks from the armor slots
*/
public ItemStack[] getArmorContents();
/**
* Return the ItemStack from the helmet slot
*
*
* @return The ItemStack in the helmet slot
*/
public ItemStack getHelmet();
/**
* Return the ItemStack from the chestplate slot
*
*
* @return The ItemStack in the chestplate slot
*/
public ItemStack getChestplate();
/**
* Return the ItemStack from the leg slot
*
*
* @return The ItemStack in the leg slot
*/
public ItemStack getLeggings();
/**
* Return the ItemStack from the boots slot
*
*
* @return The ItemStack in the boots slot
*/
public ItemStack getBoots();
@@ -49,7 +50,7 @@ public interface PlayerInventory extends Inventory {
/**
* Put the given ItemStack into the helmet slot
* This does not check if the ItemStack is a helmet
*
*
* @param helmet The ItemStack to use as helmet
*/
public void setHelmet(ItemStack helmet);
@@ -57,7 +58,7 @@ public interface PlayerInventory extends Inventory {
/**
* Put the given ItemStack into the chestplate slot
* This does not check if the ItemStack is a chestplate
*
*
* @param chestplate The ItemStack to use as chestplate
*/
public void setChestplate(ItemStack chestplate);
@@ -65,7 +66,7 @@ public interface PlayerInventory extends Inventory {
/**
* Put the given ItemStack into the leg slot
* This does not check if the ItemStack is a pair of leggings
*
*
* @param leggings The ItemStack to use as leggings
*/
public void setLeggings(ItemStack leggings);
@@ -73,28 +74,28 @@ public interface PlayerInventory extends Inventory {
/**
* Put the given ItemStack into the boots slot
* This does not check if the ItemStack is a boots
*
*
* @param boots The ItemStack to use as boots
*/
public void setBoots(ItemStack boots);
/**
* Returns the ItemStack currently hold
*
*
* @return The currently held ItemStack
*/
public ItemStack getItemInHand();
/**
* Sets the item in hand
*
* @param stack Stack to set
*
* @param stack Stack to set
*/
public void setItemInHand(ItemStack stack);
/**
* Get the slot number of the currently held item
*
*
* @return Held item slot number
*/
public int getHeldItemSlot();

View File

@@ -4,6 +4,7 @@ package org.bukkit.inventory;
* Represents some type of crafting recipe.
*/
public interface Recipe {
/**
* Get the result of this recipe.
* @return The result stack

View File

@@ -42,14 +42,15 @@ public class ShapedRecipe implements Recipe {
}
}
this.rows = shape;
// Remove character mappings for characters that no longer exist in the shape
HashMap<Character, MaterialData> ingredientsTemp = this.ingredients;
this.ingredients = new HashMap<Character, MaterialData>();
for (char key : ingredientsTemp.keySet()) {
try {
setIngredient(key, ingredientsTemp.get(key));
} catch (IllegalArgumentException e) {
}
} catch (IllegalArgumentException e) {}
}
return this;
}
@@ -87,6 +88,7 @@ public class ShapedRecipe implements Recipe {
*/
public ShapedRecipe setIngredient(char key, Material ingredient, int raw) {
MaterialData data = ingredient.getNewData((byte) raw);
if (data == null) {
data = new MaterialData(ingredient, (byte) raw);
}
@@ -95,6 +97,7 @@ public class ShapedRecipe implements Recipe {
private boolean hasKey(char c) {
String key = Character.toString(c);
for (String row : rows) {
if (row.contains(key)) {
return true;

View File

@@ -87,6 +87,7 @@ public class ShapelessRecipe implements Recipe {
*/
public ShapelessRecipe addIngredient(int count, Material ingredient, int rawdata) {
MaterialData data = ingredient.getNewData((byte) rawdata);
if (data == null) {
data = new MaterialData(ingredient, (byte) rawdata);
}

View File

@@ -4,6 +4,7 @@ package org.bukkit.inventory;
* Represents a slot in an inventory
*/
public interface Slot {
/**
* Gets the inventory this slot belongs to
*