General cleanup (deprecated+whitespace)

This commit is contained in:
Erik Broes 2011-02-02 00:02:08 +01:00
parent cbe32fca80
commit 01988e8f6b
27 changed files with 224 additions and 244 deletions

View File

@ -31,7 +31,7 @@ public interface Chunk {
/** /**
* Gets a block from this chunk * Gets a block from this chunk
* *
* @param x 0-15 * @param x 0-15
* @param y 0-127 * @param y 0-127
* @param z 0-15 * @param z 0-15

View File

@ -62,11 +62,11 @@ public class Location implements Cloneable {
public double getX() { public double getX() {
return x; return x;
} }
/** /**
* Gets the floored value of the X component, indicating the block that * Gets the floored value of the X component, indicating the block that
* this location is contained with. * this location is contained with.
* *
* @return block X * @return block X
*/ */
public int getBlockX() { public int getBlockX() {
@ -94,7 +94,7 @@ public class Location implements Cloneable {
/** /**
* Gets the floored value of the Y component, indicating the block that * Gets the floored value of the Y component, indicating the block that
* this location is contained with. * this location is contained with.
* *
* @return block y * @return block y
*/ */
public int getBlockY() { public int getBlockY() {
@ -122,7 +122,7 @@ public class Location implements Cloneable {
/** /**
* Gets the floored value of the Z component, indicating the block that * Gets the floored value of the Z component, indicating the block that
* this location is contained with. * this location is contained with.
* *
* @return block z * @return block z
*/ */
public int getBlockZ() { public int getBlockZ() {
@ -211,7 +211,7 @@ public class Location implements Cloneable {
public String toString() { public String toString() {
return "Location{" + "world=" + world + "x=" + x + "y=" + y + "z=" + z + "pitch=" + pitch + "yaw=" + yaw + '}'; return "Location{" + "world=" + world + "x=" + x + "y=" + y + "z=" + z + "pitch=" + pitch + "yaw=" + yaw + '}';
} }
public Vector toVector() { public Vector toVector() {
return new Vector(x, y, z); return new Vector(x, y, z);
} }

View File

@ -306,7 +306,7 @@ public enum Material {
* @return true if this material is a block * @return true if this material is a block
*/ */
public boolean isBlock() { public boolean isBlock() {
return id < 256; return id < 256;
} }
/** /**
@ -355,7 +355,7 @@ public enum Material {
return result; return result;
} }
static { static {
for (Material material : values()) { for (Material material : values()) {
lookupId.put(material.getId(), material); lookupId.put(material.getId(), material);

View File

@ -30,10 +30,10 @@ public interface Server {
* @return An array of Players that are currently online * @return An array of Players that are currently online
*/ */
public Player[] getOnlinePlayers(); public Player[] getOnlinePlayers();
/** /**
* Broadcast a message to all players. * Broadcast a message to all players.
* *
* @param message the message * @param message the message
* @return the number of players * @return the number of players
*/ */
@ -75,24 +75,6 @@ public interface Server {
*/ */
public World[] getWorlds(); public World[] getWorlds();
/**
* Gets the in-game time on the server (in hours*1000)
*
* @return The current time in hours*1000
* @deprecated Use World.getTime
*/
@Deprecated
public long getTime();
/**
* Sets the in-game time on the server (in hours*1000)
*
* @param time The time to set the in-game time to (in hours*1000)
* @deprecated Use World.setTime
*/
@Deprecated
public void setTime(long time);
/** /**
* Reloads the server, refreshing settings and plugin information * Reloads the server, refreshing settings and plugin information
*/ */

View File

@ -100,57 +100,55 @@ public interface World {
/** /**
* Drop an item exactly at the specified location. * Drop an item exactly at the specified location.
* *
* @param loc * @param loc
* @param item * @param item
* @return dropped item entity * @return dropped item entity
*/ */
public ItemDrop dropItem(Location loc, ItemStack item); public ItemDrop dropItem(Location loc, ItemStack item);
/** /**
* Drop an item as if it was mined (randomly placed). * Drop an item as if it was mined (randomly placed).
* *
* @param loc * @param loc
* @param item * @param item
* @return dropped item entity * @return dropped item entity
*/ */
public ItemDrop dropItemNaturally(Location loc, ItemStack item); public ItemDrop dropItemNaturally(Location loc, ItemStack item);
/** /**
* Spawns an arrow. * Spawns an arrow.
* *
* @param loc * @param loc
* @param velocity velocity vector * @param velocity velocity vector
* @param speed a reasonable speed is 0.6 * @param speed a reasonable speed is 0.6
* @param spread a reasonable spread is 12 * @param spread a reasonable spread is 12
* @return the arrow entity * @return the arrow entity
*/ */
public Arrow spawnArrow(Location loc, Vector velocity, public Arrow spawnArrow(Location loc, Vector velocity, float speed, float spread);
float speed, float spread);
/** /**
* Spawns a tree at a location. * Spawns a tree at a location.
* *
* @param loc * @param loc
* @param type * @param type
* @return whether the tree was created * @return whether the tree was created
*/ */
public boolean generateTree(Location loc, TreeType type); public boolean generateTree(Location loc, TreeType type);
/** /**
* Spawns a tree at a location. * Spawns a tree at a location.
* *
* @param loc * @param loc
* @param type * @param type
* @param delegate * @param delegate
* @return whether the tree was created * @return whether the tree was created
*/ */
public boolean generateTree(Location loc, TreeType type, public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate);
BlockChangeDelegate delegate);
/** /**
* Spawns a regular passenger minecart. * Spawns a regular passenger minecart.
* *
* @param loc * @param loc
* @return * @return
*/ */
@ -158,7 +156,7 @@ public interface World {
/** /**
* Spawns a storage minecart. * Spawns a storage minecart.
* *
* @param loc * @param loc
* @return * @return
*/ */
@ -166,30 +164,30 @@ public interface World {
/** /**
* Spawns a powered minecart. * Spawns a powered minecart.
* *
* @param loc * @param loc
* @return * @return
*/ */
public PoweredMinecart spawnPoweredMinecart(Location loc); public PoweredMinecart spawnPoweredMinecart(Location loc);
/** /**
* Spawn a boat. * Spawn a boat.
* *
* @param loc * @param loc
* @return * @return
*/ */
public Boat spawnBoat(Location loc); public Boat spawnBoat(Location loc);
/** /**
* Get a list of all entities. * Get a list of all entities.
* *
* @return * @return
*/ */
public List<Entity> getEntities(); public List<Entity> getEntities();
/** /**
* Get a list of all living entities. * Get a list of all living entities.
* *
* @return * @return
*/ */
public List<LivingEntity> getLivingEntities(); public List<LivingEntity> getLivingEntities();
@ -209,7 +207,7 @@ public interface World {
* @return Id of this world * @return Id of this world
*/ */
public long getId(); public long getId();
/** /**
* Gets the default spawn location. * Gets the default spawn location.
*/ */

View File

@ -79,10 +79,10 @@ public interface Block {
* @return block type-id * @return block type-id
*/ */
int getTypeId(); int getTypeId();
/** /**
* Gets the light level between 0-15 * Gets the light level between 0-15
* *
* @return light level * @return light level
*/ */
byte getLightLevel(); byte getLightLevel();
@ -187,17 +187,17 @@ public interface Block {
* @return Biome type containing this block * @return Biome type containing this block
*/ */
Biome getBiome(); Biome getBiome();
/** /**
* Returns true if the block is being powered by Redstone. * Returns true if the block is being powered by Redstone.
* *
* @return * @return
*/ */
boolean isBlockPowered(); boolean isBlockPowered();
/** /**
* Returns true if the block is being indirectly powered by Redstone. * Returns true if the block is being indirectly powered by Redstone.
* *
* @return * @return
*/ */
boolean isBlockIndirectlyPowered(); boolean isBlockIndirectlyPowered();

View File

@ -17,7 +17,7 @@ import org.bukkit.material.MaterialData;
public interface BlockState { public interface BlockState {
/** /**
* Gets the block represented by this BlockState * Gets the block represented by this BlockState
* *
* @return Block that this BlockState represents * @return Block that this BlockState represents
*/ */
Block getBlock(); Block getBlock();

View File

@ -8,40 +8,40 @@ import java.util.Map.Entry;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
public class PluginCommandYamlParser { public class PluginCommandYamlParser {
public static List<Command> parse(Plugin plugin) { public static List<Command> parse(Plugin plugin) {
List<Command> pluginCmds = new ArrayList<Command>(); List<Command> pluginCmds = new ArrayList<Command>();
Object object = plugin.getDescription().getCommands(); Object object = plugin.getDescription().getCommands();
if (object == null) if (object == null)
return pluginCmds; return pluginCmds;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Map<String, Object>> map = (Map<String, Map<String, Object>>)object; Map<String, Map<String, Object>> map = (Map<String, Map<String, Object>>)object;
if (map != null) { if (map != null) {
for(Entry<String, Map<String, Object>> entry : map.entrySet()) { for(Entry<String, Map<String, Object>> entry : map.entrySet()) {
Command newCmd = new PluginCommand(entry.getKey(),plugin); Command newCmd = new PluginCommand(entry.getKey(),plugin);
Object description = entry.getValue().get("description"); Object description = entry.getValue().get("description");
Object usage = entry.getValue().get("usage"); Object usage = entry.getValue().get("usage");
Object aliases = entry.getValue().get("aliases"); Object aliases = entry.getValue().get("aliases");
if (description != null) if (description != null)
newCmd.setTooltip(description.toString()); newCmd.setTooltip(description.toString());
if (usage != null) { if (usage != null) {
newCmd.setUsage(usage.toString()); newCmd.setUsage(usage.toString());
} }
if (aliases != null) { if (aliases != null) {
List<String> aliasList = new ArrayList<String>(); List<String> aliasList = new ArrayList<String>();
for(String a : aliases.toString().split(",")) { for(String a : aliases.toString().split(",")) {
aliasList.add(a); aliasList.add(a);
} }
newCmd.setAliases(aliasList); newCmd.setAliases(aliasList);
} }
pluginCmds.add(newCmd); pluginCmds.add(newCmd);
} }
} }

View File

@ -38,7 +38,7 @@ public interface Entity {
/** /**
* Returns a unique id for this entity * Returns a unique id for this entity
* *
* @return Entity id * @return Entity id
*/ */
public int getEntityId(); public int getEntityId();

View File

@ -24,7 +24,7 @@ public interface HumanEntity extends LivingEntity {
/** /**
* Returns the ItemStack currently in your hand, can be empty. * Returns the ItemStack currently in your hand, can be empty.
* *
* @return The ItemStack of the item you are currently holding. * @return The ItemStack of the item you are currently holding.
*/ */
public ItemStack getItemInHand(); public ItemStack getItemInHand();
@ -32,17 +32,17 @@ public interface HumanEntity extends LivingEntity {
/** /**
* Sets the item to the given ItemStack, this will replace whatever the * Sets the item to the given ItemStack, this will replace whatever the
* user was holding. * user was holding.
* *
* @param item The ItemStack which will end up in the hand * @param item The ItemStack which will end up in the hand
* @return * @return
*/ */
public void setItemInHand(ItemStack item); public void setItemInHand(ItemStack item);
/** /**
* Changes the item in hand to another of your 'action slots'. * Changes the item in hand to another of your 'action slots'.
* *
* @param index The new index to use, only valid ones are 0-8. * @param index The new index to use, only valid ones are 0-8.
* *
public void selectItemInHand( int index ); public void selectItemInHand( int index );
*/ */
} }

View File

@ -18,44 +18,44 @@ public interface LivingEntity extends Entity {
* @param health New health represented from 0-20 * @param health New health represented from 0-20
*/ */
public void setHealth(int health); public void setHealth(int health);
/** /**
* Throws an egg from the entity. * Throws an egg from the entity.
*/ */
public Egg throwEgg(); public Egg throwEgg();
/** /**
* Throws a snowball from the entity. * Throws a snowball from the entity.
*/ */
public Snowball throwSnowball(); public Snowball throwSnowball();
/** /**
* Shoots an arrow from the entity. * Shoots an arrow from the entity.
* *
* @return * @return
*/ */
public Arrow shootArrow(); public Arrow shootArrow();
/** /**
* Returns whether this entity is inside a vehicle. * Returns whether this entity is inside a vehicle.
* *
* @return * @return
*/ */
public boolean isInsideVehicle(); public boolean isInsideVehicle();
/** /**
* Leave the current vehicle. If the entity is currently in a vehicle * Leave the current vehicle. If the entity is currently in a vehicle
* (and is removed from it), true will be returned, otherwise false will * (and is removed from it), true will be returned, otherwise false will
* be returned. * be returned.
* *
* @return * @return
*/ */
public boolean leaveVehicle(); public boolean leaveVehicle();
/** /**
* Get the vehicle that this player is inside. If there is no vehicle, * Get the vehicle that this player is inside. If there is no vehicle,
* null will be returned. * null will be returned.
* *
* @return * @return
*/ */
public Vehicle getVehicle(); public Vehicle getVehicle();

View File

@ -18,7 +18,7 @@ public enum MobType {
SQUID("Squid"); SQUID("Squid");
private String name; private String name;
private static final Map<String, MobType> mapping private static final Map<String, MobType> mapping
= new HashMap<String, MobType>(); = new HashMap<String, MobType>();
@ -35,7 +35,7 @@ public enum MobType {
public String getName() { public String getName() {
return name; return name;
} }
public static MobType fromName(String name) { public static MobType fromName(String name) {
return mapping.get(name); return mapping.get(name);
} }

View File

@ -1,5 +1,5 @@
/** /**
* *
*/ */
package org.bukkit.event.block; package org.bukkit.event.block;
@ -22,7 +22,7 @@ public class BlockCanBuildEvent extends BlockEvent {
/** /**
* Returns whether or not the block can be built here. By default, returns * Returns whether or not the block can be built here. By default, returns
* Minecraft's answer on whether the block can be built * Minecraft's answer on whether the block can be built
* *
* @return boolean whether or not the block can be built * @return boolean whether or not the block can be built
*/ */
public boolean isBuildable() { public boolean isBuildable() {

View File

@ -22,7 +22,7 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable {
/** /**
* Returns the player doing the damage * Returns the player doing the damage
* *
* @return * @return
*/ */
public Player getPlayer() { public Player getPlayer() {
@ -31,7 +31,7 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable {
/** /**
* Returns the level of damage to the block * Returns the level of damage to the block
* *
* @return * @return
*/ */
public BlockDamageLevel getDamageLevel() { public BlockDamageLevel getDamageLevel() {

View File

@ -6,7 +6,7 @@ import org.bukkit.event.Event;
/** /**
* Thrown when a block physics check is called * Thrown when a block physics check is called
* *
* @author Dinnerbone * @author Dinnerbone
*/ */
public class BlockPhysicsEvent extends BlockEvent { public class BlockPhysicsEvent extends BlockEvent {

View File

@ -55,39 +55,39 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable {
public Player getPlayer() { public Player getPlayer() {
return player; return player;
} }
/** /**
* Clarity method for getting the placed block. Not really needed * Clarity method for getting the placed block. Not really needed
* except for reasons of clarity * except for reasons of clarity
* *
* @return Block the block that was placed * @return Block the block that was placed
*/ */
public Block getBlockPlaced() { public Block getBlockPlaced() {
return getBlock(); return getBlock();
} }
/** /**
* Returns the state of the block which was replaced. Material type air mostly. * Returns the state of the block which was replaced. Material type air mostly.
* *
* @return BlockState of block which was replaced. * @return BlockState of block which was replaced.
*/ */
public BlockState getBlockReplacedState() { public BlockState getBlockReplacedState() {
return this.replacedBlockState; return this.replacedBlockState;
} }
/** /**
* Get the block that this block was placed against * Get the block that this block was placed against
* *
* @return Block the block that the new block was placed against * @return Block the block that the new block was placed against
*/ */
public Block getBlockAgainst() { public Block getBlockAgainst() {
return placedAgainst; return placedAgainst;
} }
/** /**
* Returns the item in your hand when you placed the block * Returns the item in your hand when you placed the block
* *
* @return ItemStack the item in your hand when placing the block * @return ItemStack the item in your hand when placing the block
*/ */
public ItemStack getItemInHand() { public ItemStack getItemInHand() {
@ -100,16 +100,16 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable {
* player is in Spawn). Note that this is an entirely different check * player is in Spawn). Note that this is an entirely different check
* than BLOCK_CANBUILD, as this refers to a player, not universe-physics * than BLOCK_CANBUILD, as this refers to a player, not universe-physics
* rule like cactus on dirt. * rule like cactus on dirt.
* *
* @return boolean whether the server would allow a player to build here * @return boolean whether the server would allow a player to build here
*/ */
public boolean canBuild() { public boolean canBuild() {
return this.canBuild; return this.canBuild;
} }
/** /**
* Sets the canBuild state of this event. Set to true if you want the * Sets the canBuild state of this event. Set to true if you want the
* player to be able to build. * player to be able to build.
*/ */
public void setBuild(boolean canBuild) { public void setBuild(boolean canBuild) {
this.canBuild = canBuild; this.canBuild = canBuild;

View File

@ -15,7 +15,7 @@ import org.bukkit.block.BlockFace;
public class BlockRedstoneEvent extends BlockFromToEvent { public class BlockRedstoneEvent extends BlockFromToEvent {
private int oldCurrent; private int oldCurrent;
private int newCurrent; private int newCurrent;
public BlockRedstoneEvent(Block block, BlockFace face, int oldCurrent, int newCurrent) { public BlockRedstoneEvent(Block block, BlockFace face, int oldCurrent, int newCurrent) {
super(Type.REDSTONE_CHANGE, block, face); super(Type.REDSTONE_CHANGE, block, face);
this.oldCurrent = oldCurrent; this.oldCurrent = oldCurrent;

View File

@ -30,17 +30,17 @@ public class BlockRightClickEvent extends BlockEvent {
public Player getPlayer() { public Player getPlayer() {
return player; return player;
} }
/** /**
* Get the block that this block was placed against * Get the block that this block was placed against
* *
* @return Block the block that the new block was placed against * @return Block the block that the new block was placed against
*/ */
public Block getBlockAgainst() { public Block getBlockAgainst() {
return clickedBlock; return clickedBlock;
} }
/** /**
* @return BlockFace the direction this block was clicked * @return BlockFace the direction this block was clicked
*/ */
@ -50,7 +50,7 @@ public class BlockRightClickEvent extends BlockEvent {
/** /**
* Returns the item in your hand when you placed the block * Returns the item in your hand when you placed the block
* *
* @return ItemStack the item in your hand when placing the block * @return ItemStack the item in your hand when placing the block
*/ */
public ItemStack getItemInHand() { public ItemStack getItemInHand() {

View File

@ -16,7 +16,7 @@ public class EntityDamageByEntityEvent extends EntityDamageEvent implements Canc
super(Event.Type.ENTITY_DAMAGEDBY_ENTITY, damagee, cause, damage); super(Event.Type.ENTITY_DAMAGEDBY_ENTITY, damagee, cause, damage);
this.damager = damager; this.damager = damager;
} }
protected EntityDamageByEntityEvent(Type damageType, Entity damager, Entity damagee, DamageCause cause, int damage) protected EntityDamageByEntityEvent(Type damageType, Entity damager, Entity damagee, DamageCause cause, int damage)
{ {
super(damageType, damagee, cause, damage); super(damageType, damagee, cause, damage);

View File

@ -6,30 +6,30 @@ import org.bukkit.entity.Player;
* Represents a player animation event * Represents a player animation event
*/ */
public class PlayerAnimationEvent extends PlayerEvent { public class PlayerAnimationEvent extends PlayerEvent {
private PlayerAnimationType animationType; private PlayerAnimationType animationType;
/* /*
* Construct a new event * Construct a new event
* *
* @param type The event type * @param type The event type
* @param player The player instance * @param player The player instance
*/ */
public PlayerAnimationEvent(final Type type, final Player player) { public PlayerAnimationEvent(final Type type, final Player player) {
super(type, player); super(type, player);
// Only supported animation type for now: // Only supported animation type for now:
animationType = PlayerAnimationType.ARM_SWING; animationType = PlayerAnimationType.ARM_SWING;
} }
/* /*
* Get the type of this animation event * Get the type of this animation event
* *
* @returns the animation type * @returns the animation type
*/ */
public PlayerAnimationType getAnimationType() public PlayerAnimationType getAnimationType()
{ {
return animationType; return animationType;
} }
} }

View File

@ -26,7 +26,7 @@ public class PlayerEggThrowEvent extends PlayerEvent {
/** /**
* Get the egg. * Get the egg.
* *
* @return the egg * @return the egg
*/ */
public Egg getEgg() { public Egg getEgg() {

View File

@ -57,10 +57,10 @@ public class PlayerListener implements Listener {
*/ */
public void onPlayerTeleport(PlayerMoveEvent event) { public void onPlayerTeleport(PlayerMoveEvent event) {
} }
/** /**
* Called when a player uses an item * Called when a player uses an item
* *
* @param event Relevant event details * @param event Relevant event details
*/ */
public void onPlayerItem(PlayerItemEvent event) { public void onPlayerItem(PlayerItemEvent event) {
@ -81,10 +81,10 @@ public class PlayerListener implements Listener {
*/ */
public void onPlayerEggThrow(PlayerEggThrowEvent event) { public void onPlayerEggThrow(PlayerEggThrowEvent event) {
} }
/** /**
* Called when a player plays an animation, such as an arm swing * Called when a player plays an animation, such as an arm swing
* *
* @param event Relevant event details * @param event Relevant event details
*/ */
public void onPlayerAnimation(PlayerAnimationEvent event) { public void onPlayerAnimation(PlayerAnimationEvent event) {

View File

@ -9,21 +9,21 @@ import org.bukkit.Material;
public interface Inventory { public interface Inventory {
/** /**
* Returns the size of the inventory * Returns the size of the inventory
* *
* @return The inventory size * @return The inventory size
*/ */
public int getSize(); public int getSize();
/** /**
* Return the name of the inventory * Return the name of the inventory
* *
* @return The inventory name * @return The inventory name
*/ */
public String getName(); public String getName();
/** /**
* Get the ItemStack found in the slot at the given index * Get the ItemStack found in the slot at the given index
* *
* @param index The index of the Slot's ItemStack to return * @param index The index of the Slot's ItemStack to return
* @return The ItemStack in the slot * @return The ItemStack in the slot
*/ */
@ -31,7 +31,7 @@ public interface Inventory {
/** /**
* Stores the ItemStack at the given index * Stores the ItemStack at the given index
* *
* @param index The index where to put the ItemStack * @param index The index where to put the ItemStack
* @param item The ItemStack to set * @param item The ItemStack to set
*/ */
@ -39,60 +39,60 @@ public interface Inventory {
/** /**
* Stores the given ItemStacks in the inventory. * Stores the given ItemStacks in the inventory.
* *
* This will try to fill existing stacks and empty slots as good as it can. * This will try to fill existing stacks and empty slots as good as it can.
* It will return a HashMap of what it couldn't fit. * It will return a HashMap of what it couldn't fit.
* *
* @param items The ItemStacks to add * @param items The ItemStacks to add
* @return * @return
*/ */
public HashMap<Integer, ItemStack> addItem(ItemStack... items); public HashMap<Integer, ItemStack> addItem(ItemStack... items);
/** /**
* Removes the given ItemStacks from the inventory. * Removes the given ItemStacks from the inventory.
* *
* It will try to remove 'as much as possible' from the types and amounts you * It will try to remove 'as much as possible' from the types and amounts you
* give as arguments. It will return a HashMap of what it couldn't remove. * give as arguments. It will return a HashMap of what it couldn't remove.
* *
* @param items The ItemStacks to remove * @param items The ItemStacks to remove
* @return * @return
*/ */
public HashMap<Integer, ItemStack> removeItem(ItemStack... items); public HashMap<Integer, ItemStack> removeItem(ItemStack... items);
/** /**
* Get all ItemStacks from the inventory * Get all ItemStacks from the inventory
* *
* @return All the ItemStacks from all slots * @return All the ItemStacks from all slots
*/ */
public ItemStack[] getContents(); public ItemStack[] getContents();
/** /**
* Set the inventory's contents * Set the inventory's contents
* *
* @return All the ItemStacks from all slots * @return All the ItemStacks from all slots
*/ */
public void setContents(ItemStack[] items); public void setContents(ItemStack[] items);
/** /**
* Check if the inventory contains any ItemStacks with the given materialId * Check if the inventory contains any ItemStacks with the given materialId
* *
* @param materialId The materialId to check for * @param materialId The materialId to check for
* @return If any ItemStacks were found * @return If any ItemStacks were found
*/ */
public boolean contains(int materialId); public boolean contains(int materialId);
/** /**
* Check if the inventory contains any ItemStacks with the given material * Check if the inventory contains any ItemStacks with the given material
* *
* @param material The material to check for * @param material The material to check for
* @return If any ItemStacks were found * @return If any ItemStacks were found
*/ */
public boolean contains(Material material); public boolean contains(Material material);
/** /**
* Check if the inventory contains any ItemStacks matching the given ItemStack * Check if the inventory contains any ItemStacks matching the given ItemStack
* This will only match if both the type and the amount of the stack match * This will only match if both the type and the amount of the stack match
* *
* @param item The ItemStack to match against * @param item The ItemStack to match against
* @return If any matching ItemStacks were found * @return If any matching ItemStacks were found
*/ */
@ -100,24 +100,24 @@ public interface Inventory {
/** /**
* Find all slots in the inventory containing any ItemStacks with the given materialId * Find all slots in the inventory containing any ItemStacks with the given materialId
* *
* @param materialId The materialId to look for * @param materialId The materialId to look for
* @return The Slots found. * @return The Slots found.
*/ */
public HashMap<Integer, ? extends ItemStack> all(int materialId); public HashMap<Integer, ? extends ItemStack> all(int materialId);
/** /**
* Find all slots in the inventory containing any ItemStacks with the given material * Find all slots in the inventory containing any ItemStacks with the given material
* *
* @param materialId The material to look for * @param materialId The material to look for
* @return The Slots found. * @return The Slots found.
*/ */
public HashMap<Integer, ? extends ItemStack> all(Material material); public HashMap<Integer, ? extends ItemStack> all(Material material);
/** /**
* Find all slots in the inventory containing any ItemStacks with the given ItemStack * Find all slots in the inventory containing any ItemStacks with the given ItemStack
* This will only match slots if both the type and the amount of the stack match * This will only match slots if both the type and the amount of the stack match
* *
* @param item The ItemStack to match against * @param item The ItemStack to match against
* @return The Slots found. * @return The Slots found.
*/ */
@ -125,7 +125,7 @@ public interface Inventory {
/** /**
* Find the first slot in the inventory containing an ItemStack with the given materialId * Find the first slot in the inventory containing an ItemStack with the given materialId
* *
* @param materialId The materialId to look for * @param materialId The materialId to look for
* @return The Slot found. * @return The Slot found.
*/ */
@ -133,7 +133,7 @@ public interface Inventory {
/** /**
* Find the first slot in the inventory containing an ItemStack with the given material * Find the first slot in the inventory containing an ItemStack with the given material
* *
* @param materialId The material to look for * @param materialId The material to look for
* @return The Slot found. * @return The Slot found.
*/ */
@ -142,7 +142,7 @@ public interface Inventory {
/** /**
* Find the first slot in the inventory containing an ItemStack with the given stack * Find the first slot in the inventory containing an ItemStack with the given stack
* This will only match a slot if both the type and the amount of the stack match * This will only match a slot if both the type and the amount of the stack match
* *
* @param item The ItemStack to match against * @param item The ItemStack to match against
* @return The Slot found. * @return The Slot found.
*/ */
@ -150,21 +150,21 @@ public interface Inventory {
/** /**
* Find the first empty Slot. * Find the first empty Slot.
* *
* @return The first empty Slot found. * @return The first empty Slot found.
*/ */
public int firstEmpty(); public int firstEmpty();
/** /**
* Remove all stacks in the inventory matching the given materialId. * Remove all stacks in the inventory matching the given materialId.
* *
* @param materialId The material to remove * @param materialId The material to remove
*/ */
public void remove(int materialId); public void remove(int materialId);
/** /**
* Remove all stacks in the inventory matching the given material. * Remove all stacks in the inventory matching the given material.
* *
* @param material The material to remove * @param material The material to remove
*/ */
public void remove(Material material); public void remove(Material material);
@ -172,14 +172,14 @@ public interface Inventory {
/** /**
* Remove all stacks in the inventory matching the given stack. * Remove all stacks in the inventory matching the given stack.
* This will only match a slot if both the type and the amount of the stack match * This will only match a slot if both the type and the amount of the stack match
* *
* @param item The ItemStack to match against * @param item The ItemStack to match against
*/ */
public void remove(ItemStack item); public void remove(ItemStack item);
/** /**
* Clear out a particular slot in the index * Clear out a particular slot in the index
* *
* @param index The index to empty. * @param index The index to empty.
*/ */
public void clear(int index); public void clear(int index);

View File

@ -6,21 +6,21 @@ package org.bukkit.inventory;
public interface Slot { public interface Slot {
/** /**
* Gets the inventory this slot belongs to * Gets the inventory this slot belongs to
* *
* @return The inventory * @return The inventory
*/ */
public Inventory getInventory(); public Inventory getInventory();
/** /**
* Get the index this slot belongs to * Get the index this slot belongs to
* *
* @return Index of the slot * @return Index of the slot
*/ */
public int getIndex(); public int getIndex();
/** /**
* Get the item from the slot. * Get the item from the slot.
* *
* @return ItemStack in the slot. * @return ItemStack in the slot.
*/ */
public ItemStack getItem(); public ItemStack getItem();

View File

@ -23,7 +23,7 @@ public class Dye extends MaterialData {
public Dye(final Material type, final byte data) { public Dye(final Material type, final byte data) {
super(type, data); super(type, data);
} }
/** /**
* Gets the current color of this dye * Gets the current color of this dye
* *
@ -41,4 +41,4 @@ public class Dye extends MaterialData {
public void setColor(DyeColor color) { public void setColor(DyeColor color) {
setData(color.getData()); setData(color.getData());
} }
} }

View File

@ -39,7 +39,7 @@ public class MaterialData {
/** /**
* Sets the raw data of this material * Sets the raw data of this material
* *
* @param data New raw data * @param data New raw data
*/ */
public void setData(byte data) { public void setData(byte data) {

View File

@ -9,23 +9,23 @@ import org.bukkit.World;
* storing Vectors long term may be dangerous if passing code modifies the * storing Vectors long term may be dangerous if passing code modifies the
* Vector later. If you want to keep around a Vector, it may be wise to call * Vector later. If you want to keep around a Vector, it may be wise to call
* <code>clone()</code> in order to get a copy. * <code>clone()</code> in order to get a copy.
* *
* @author sk89q * @author sk89q
*/ */
public class Vector implements Cloneable { public class Vector implements Cloneable {
private static final long serialVersionUID = -2657651106777219169L; private static final long serialVersionUID = -2657651106777219169L;
private static Random random = new Random(); private static Random random = new Random();
/** /**
* Threshold for fuzzy equals(). * Threshold for fuzzy equals().
*/ */
private static final double epsilon = 0.000001; private static final double epsilon = 0.000001;
protected double x; protected double x;
protected double y; protected double y;
protected double z; protected double z;
/** /**
* Construct the vector with all components as 0. * Construct the vector with all components as 0.
*/ */
@ -34,10 +34,10 @@ public class Vector implements Cloneable {
this.y = 0; this.y = 0;
this.z = 0; this.z = 0;
} }
/** /**
* Construct the vector with provided integer components. * Construct the vector with provided integer components.
* *
* @param x * @param x
* @param y * @param y
* @param z * @param z
@ -50,7 +50,7 @@ public class Vector implements Cloneable {
/** /**
* Construct the vector with provided double components. * Construct the vector with provided double components.
* *
* @param x * @param x
* @param y * @param y
* @param z * @param z
@ -63,7 +63,7 @@ public class Vector implements Cloneable {
/** /**
* Construct the vector with provided float components. * Construct the vector with provided float components.
* *
* @param x * @param x
* @param y * @param y
* @param z * @param z
@ -76,7 +76,7 @@ public class Vector implements Cloneable {
/** /**
* Adds the vector by another. * Adds the vector by another.
* *
* @param vec * @param vec
* @return the same vector * @return the same vector
*/ */
@ -89,7 +89,7 @@ public class Vector implements Cloneable {
/** /**
* Subtracts the vector by another. * Subtracts the vector by another.
* *
* @param vec * @param vec
* @return the same vector * @return the same vector
*/ */
@ -102,7 +102,7 @@ public class Vector implements Cloneable {
/** /**
* Multiplies the vector by another. * Multiplies the vector by another.
* *
* @param vec * @param vec
* @return the same vector * @return the same vector
*/ */
@ -112,10 +112,10 @@ public class Vector implements Cloneable {
z *= vec.z; z *= vec.z;
return this; return this;
} }
/** /**
* Divides the vector by another. * Divides the vector by another.
* *
* @param vec * @param vec
* @return the same vector * @return the same vector
*/ */
@ -125,56 +125,56 @@ public class Vector implements Cloneable {
z /= vec.z; z /= vec.z;
return this; return this;
} }
/** /**
* Gets the magnitude of the vector, defined as sqrt(x^2+y^2+z^2). The value * Gets the magnitude of the vector, defined as sqrt(x^2+y^2+z^2). The value
* of this method is not cached and uses a costly square-root function, so * of this method is not cached and uses a costly square-root function, so
* do not repeatedly call this method to get the vector's magnitude. NaN * do not repeatedly call this method to get the vector's magnitude. NaN
* will be returned if the inner result of the sqrt() function overflows, * will be returned if the inner result of the sqrt() function overflows,
* which will be caused if the length is too long. * which will be caused if the length is too long.
* *
* @return the magnitude * @return the magnitude
*/ */
public double length() { public double length() {
return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2)); return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2));
} }
/** /**
* Gets the magnitude of the vector squared. * Gets the magnitude of the vector squared.
* *
* @return the magnitude * @return the magnitude
*/ */
public double lengthSquared() { public double lengthSquared() {
return Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2); return Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2);
} }
/** /**
* Get the distance between this vector and another. The value * Get the distance between this vector and another. The value
* of this method is not cached and uses a costly square-root function, so * of this method is not cached and uses a costly square-root function, so
* do not repeatedly call this method to get the vector's magnitude. NaN * do not repeatedly call this method to get the vector's magnitude. NaN
* will be returned if the inner result of the sqrt() function overflows, * will be returned if the inner result of the sqrt() function overflows,
* which will be caused if the distance is too long. * which will be caused if the distance is too long.
* *
* @return the distance * @return the distance
*/ */
public double distance(Vector o) { public double distance(Vector o) {
return Math.sqrt(Math.pow(x - o.x, 2) + Math.pow(y - o.y, 2) return Math.sqrt(Math.pow(x - o.x, 2) + Math.pow(y - o.y, 2)
+ Math.pow(z - o.z, 2)); + Math.pow(z - o.z, 2));
} }
/** /**
* Get the squared distance between this vector and another. * Get the squared distance between this vector and another.
* *
* @return the distance * @return the distance
*/ */
public double distanceSquared(Vector o) { public double distanceSquared(Vector o) {
return Math.pow(x - o.x, 2) + Math.pow(y - o.y, 2) return Math.pow(x - o.x, 2) + Math.pow(y - o.y, 2)
+ Math.pow(z - o.z, 2); + Math.pow(z - o.z, 2);
} }
/** /**
* Gets the angle between this vector and another in radians. * Gets the angle between this vector and another in radians.
* *
* @param other * @param other
* @return angle in radians * @return angle in radians
*/ */
@ -182,10 +182,10 @@ public class Vector implements Cloneable {
double dot = dot(other) / (length() * other.length()); double dot = dot(other) / (length() * other.length());
return (float)Math.acos(dot); return (float)Math.acos(dot);
} }
/** /**
* Sets this vector to the midpoint between this vector and another. * Sets this vector to the midpoint between this vector and another.
* *
* @param other * @param other
* @return this same vector (now a midpoint) * @return this same vector (now a midpoint)
*/ */
@ -195,10 +195,10 @@ public class Vector implements Cloneable {
z = (z + other.z) / 2; z = (z + other.z) / 2;
return this; return this;
} }
/** /**
* Gets a new midpoint vector between this vector and another. * Gets a new midpoint vector between this vector and another.
* *
* @param other * @param other
* @return a new midpoint vector * @return a new midpoint vector
*/ */
@ -208,10 +208,10 @@ public class Vector implements Cloneable {
z = (z + other.z) / 2; z = (z + other.z) / 2;
return new Vector(x, y, z); return new Vector(x, y, z);
} }
/** /**
* Performs scalar multiplication, multiplying all components with a scalar. * Performs scalar multiplication, multiplying all components with a scalar.
* *
* @param m * @param m
* @return the same vector * @return the same vector
*/ */
@ -221,10 +221,10 @@ public class Vector implements Cloneable {
z *= m; z *= m;
return this; return this;
} }
/** /**
* Performs scalar multiplication, multiplying all components with a scalar. * Performs scalar multiplication, multiplying all components with a scalar.
* *
* @param m * @param m
* @return the same vector * @return the same vector
*/ */
@ -234,10 +234,10 @@ public class Vector implements Cloneable {
z *= m; z *= m;
return this; return this;
} }
/** /**
* Performs scalar multiplication, multiplying all components with a scalar. * Performs scalar multiplication, multiplying all components with a scalar.
* *
* @param m * @param m
* @return the same vector * @return the same vector
*/ */
@ -247,26 +247,26 @@ public class Vector implements Cloneable {
z *= m; z *= m;
return this; return this;
} }
/** /**
* Calculates the dot product of this vector with another. The dot product * Calculates the dot product of this vector with another. The dot product
* is defined as x1*x2+y1*y2+z1*z2. The returned value is a scalar. * is defined as x1*x2+y1*y2+z1*z2. The returned value is a scalar.
* *
* @param other * @param other
* @return dot product * @return dot product
*/ */
public double dot(Vector other) { public double dot(Vector other) {
return x * other.x + y * other.y + z * other.z; return x * other.x + y * other.y + z * other.z;
} }
/** /**
* Calculates the cross product of this vector with another. The cross * Calculates the cross product of this vector with another. The cross
* product is defined as: * product is defined as:
* *
* x = y1 * z2 - y2 * z1<br/> * x = y1 * z2 - y2 * z1<br/>
* y = z1 * x2 - z2 * x1<br/> * y = z1 * x2 - z2 * x1<br/>
* z = x1 * y2 - x2 * y1 * z = x1 * y2 - x2 * y1
* *
* @param o * @param o
* @return the same vector * @return the same vector
*/ */
@ -279,25 +279,25 @@ public class Vector implements Cloneable {
z = newZ; z = newZ;
return this; return this;
} }
/** /**
* Converts this vector to a unit vector (a vector with length of 1). * Converts this vector to a unit vector (a vector with length of 1).
* *
* @return the same vector * @return the same vector
*/ */
public Vector normalize() { public Vector normalize() {
double length = length(); double length = length();
x /= length; x /= length;
y /= length; y /= length;
z /= length; z /= length;
return this; return this;
} }
/** /**
* Zero this vector's components. * Zero this vector's components.
* *
* @return the same vector * @return the same vector
*/ */
public Vector zero() { public Vector zero() {
@ -306,12 +306,12 @@ public class Vector implements Cloneable {
z = 0; z = 0;
return this; return this;
} }
/** /**
* Returns whether this vector is in an axis-aligned bounding box. * Returns whether this vector is in an axis-aligned bounding box.
* The minimum and maximum vectors given must be truly the minimum and * The minimum and maximum vectors given must be truly the minimum and
* maximum X, Y and Z components. * maximum X, Y and Z components.
* *
* @param min * @param min
* @param max * @param max
* @return whether this vector is in the AABB * @return whether this vector is in the AABB
@ -321,10 +321,10 @@ public class Vector implements Cloneable {
&& y >= min.y && y <= max.y && y >= min.y && y <= max.y
&& z >= min.z && z <= max.z; && z >= min.z && z <= max.z;
} }
/** /**
* Returns whether this vector is within a sphere. * Returns whether this vector is within a sphere.
* *
* @param origin * @param origin
* @param radius * @param radius
* @return whether this vector is in the sphere * @return whether this vector is in the sphere
@ -335,29 +335,29 @@ public class Vector implements Cloneable {
+ Math.pow(origin.z - z, 2)) + Math.pow(origin.z - z, 2))
<= Math.pow(radius, 2); <= Math.pow(radius, 2);
} }
/** /**
* Gets the X component. * Gets the X component.
* *
* @return * @return
*/ */
public double getX() { public double getX() {
return x; return x;
} }
/** /**
* Gets the floored value of the X component, indicating the block that * Gets the floored value of the X component, indicating the block that
* this vector is contained with. * this vector is contained with.
* *
* @return block X * @return block X
*/ */
public int getBlockX() { public int getBlockX() {
return (int)Math.floor(x); return (int)Math.floor(x);
} }
/** /**
* Gets the Y component. * Gets the Y component.
* *
* @return * @return
*/ */
public double getY() { public double getY() {
@ -367,16 +367,16 @@ public class Vector implements Cloneable {
/** /**
* Gets the floored value of the Y component, indicating the block that * Gets the floored value of the Y component, indicating the block that
* this vector is contained with. * this vector is contained with.
* *
* @return block y * @return block y
*/ */
public int getBlockY() { public int getBlockY() {
return (int)Math.floor(y); return (int)Math.floor(y);
} }
/** /**
* Gets the Z component. * Gets the Z component.
* *
* @return * @return
*/ */
public double getZ() { public double getZ() {
@ -386,16 +386,16 @@ public class Vector implements Cloneable {
/** /**
* Gets the floored value of the Z component, indicating the block that * Gets the floored value of the Z component, indicating the block that
* this vector is contained with. * this vector is contained with.
* *
* @return block z * @return block z
*/ */
public int getBlockZ() { public int getBlockZ() {
return (int)Math.floor(z); return (int)Math.floor(z);
} }
/** /**
* Set the X component. * Set the X component.
* *
* @param x * @param x
* @return x * @return x
*/ */
@ -406,7 +406,7 @@ public class Vector implements Cloneable {
/** /**
* Set the X component. * Set the X component.
* *
* @param x * @param x
* @return x * @return x
*/ */
@ -417,7 +417,7 @@ public class Vector implements Cloneable {
/** /**
* Set the X component. * Set the X component.
* *
* @param x * @param x
* @return x * @return x
*/ */
@ -428,7 +428,7 @@ public class Vector implements Cloneable {
/** /**
* Set the Y component. * Set the Y component.
* *
* @param y * @param y
* @return y * @return y
*/ */
@ -439,7 +439,7 @@ public class Vector implements Cloneable {
/** /**
* Set the Y component. * Set the Y component.
* *
* @param y * @param y
* @return y * @return y
*/ */
@ -450,7 +450,7 @@ public class Vector implements Cloneable {
/** /**
* Set the Y component. * Set the Y component.
* *
* @param y * @param y
* @return y * @return y
*/ */
@ -461,7 +461,7 @@ public class Vector implements Cloneable {
/** /**
* Set the Z component. * Set the Z component.
* *
* @param z * @param z
* @return z * @return z
*/ */
@ -472,7 +472,7 @@ public class Vector implements Cloneable {
/** /**
* Set the Z component. * Set the Z component.
* *
* @param z * @param z
* @return z * @return z
*/ */
@ -483,7 +483,7 @@ public class Vector implements Cloneable {
/** /**
* Set the Z component. * Set the Z component.
* *
* @param z * @param z
* @return z * @return z
*/ */
@ -494,19 +494,19 @@ public class Vector implements Cloneable {
/** /**
* Checks to see if two objects are equal. * Checks to see if two objects are equal.
* *
* Only two Vectors can ever return true. This method uses a fuzzy match * Only two Vectors can ever return true. This method uses a fuzzy match
* to account for floating point errors. The epsilon can be retrieved * to account for floating point errors. The epsilon can be retrieved
* with epsilon. * with epsilon.
*/ */
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (!(obj instanceof Vector)) { if (!(obj instanceof Vector)) {
return false; return false;
} }
Vector other = (Vector)obj; Vector other = (Vector)obj;
return Math.abs(x - other.x) < epsilon return Math.abs(x - other.x) < epsilon
&& Math.abs(y - other.y) < epsilon && Math.abs(y - other.y) < epsilon
&& Math.abs(z - other.z) < epsilon; && Math.abs(z - other.z) < epsilon;
@ -515,7 +515,7 @@ public class Vector implements Cloneable {
/** /**
* Returns a hash code for this vector. Due to floating point errors, this * Returns a hash code for this vector. Due to floating point errors, this
* hash code should not be used in hash tables of any sort. * hash code should not be used in hash tables of any sort.
* *
* @return hash code * @return hash code
*/ */
@Override @Override
@ -527,7 +527,7 @@ public class Vector implements Cloneable {
/** /**
* Get a new vector. * Get a new vector.
* *
* @return vector * @return vector
*/ */
@Override @Override
@ -537,16 +537,16 @@ public class Vector implements Cloneable {
/** /**
* Returns this vector's components as x,y,z. * Returns this vector's components as x,y,z.
* *
*/ */
@Override @Override
public String toString() { public String toString() {
return x + "," + y + "," + z; return x + "," + y + "," + z;
} }
/** /**
* Gets a Location version of this vector with yaw and pitch being 0. * Gets a Location version of this vector with yaw and pitch being 0.
* *
* @param world * @param world
* @return the location * @return the location
*/ */
@ -556,26 +556,26 @@ public class Vector implements Cloneable {
/** /**
* Gets a Location version of this vector. * Gets a Location version of this vector.
* *
* @param world * @param world
* @return the location * @return the location
*/ */
public Location toLocation(World world, float yaw, float pitch) { public Location toLocation(World world, float yaw, float pitch) {
return new Location(world, x, y, z, yaw, pitch); return new Location(world, x, y, z, yaw, pitch);
} }
/** /**
* Get the threshold used for equals(). * Get the threshold used for equals().
* *
* @return * @return
*/ */
public static double getEpsilon() { public static double getEpsilon() {
return epsilon; return epsilon;
} }
/** /**
* Gets the minimum components of two vectors. * Gets the minimum components of two vectors.
* *
* @param v1 * @param v1
* @param v2 * @param v2
* @return minimum * @return minimum
@ -586,10 +586,10 @@ public class Vector implements Cloneable {
Math.min(v1.y, v2.y), Math.min(v1.y, v2.y),
Math.min(v1.z, v2.z)); Math.min(v1.z, v2.z));
} }
/** /**
* Gets the maximum components of two vectors. * Gets the maximum components of two vectors.
* *
* @param v1 * @param v1
* @param v2 * @param v2
* @return maximum * @return maximum
@ -600,11 +600,11 @@ public class Vector implements Cloneable {
Math.max(v1.y, v2.y), Math.max(v1.y, v2.y),
Math.max(v1.z, v2.z)); Math.max(v1.z, v2.z));
} }
/** /**
* Gets a random vector with components having a random value between * Gets a random vector with components having a random value between
* 0 and 1. * 0 and 1.
* *
* @return * @return
*/ */
public static Vector getRandom() { public static Vector getRandom() {