summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorstevenh <steven.hartland@multiplay.co.uk>2011-01-04 23:32:38 +0000
committerstevenh <steven.hartland@multiplay.co.uk>2011-01-04 23:32:38 +0000
commit94ef32973d452ec5d8a6be9f49354ac0041d69bd (patch)
treec0ea8312951cf2b048441cb11cf211e42f20d01b /src/main
parent846831634b7f30a375a5bb1fb512b98fba7e8f66 (diff)
parentf2533d1fd7458f4af3618d4d181c7303e4fcb516 (diff)
downloadbukkit-94ef32973d452ec5d8a6be9f49354ac0041d69bd.tar
bukkit-94ef32973d452ec5d8a6be9f49354ac0041d69bd.tar.gz
bukkit-94ef32973d452ec5d8a6be9f49354ac0041d69bd.tar.lz
bukkit-94ef32973d452ec5d8a6be9f49354ac0041d69bd.tar.xz
bukkit-94ef32973d452ec5d8a6be9f49354ac0041d69bd.zip
Merge branch 'master' of github.com:Bukkit/Bukkit
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/bukkit/Chunk.java6
-rw-r--r--src/main/java/org/bukkit/ItemStack.java199
-rw-r--r--src/main/java/org/bukkit/event/Event.java4
-rw-r--r--src/main/java/org/bukkit/event/block/BlockListener.java170
-rw-r--r--src/main/java/org/bukkit/event/block/BlockPlacedEvent.java24
-rw-r--r--src/main/java/org/bukkit/event/block/LeavesDecayEvent.java36
-rw-r--r--src/main/java/org/bukkit/event/world/ChunkLoadedEvent.java26
-rw-r--r--src/main/java/org/bukkit/event/world/ChunkUnloadedEvent.java36
-rw-r--r--src/main/java/org/bukkit/event/world/WorldEvent.java27
-rw-r--r--src/main/java/org/bukkit/event/world/WorldListener.java25
-rw-r--r--src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java17
11 files changed, 400 insertions, 170 deletions
diff --git a/src/main/java/org/bukkit/Chunk.java b/src/main/java/org/bukkit/Chunk.java
index 4bb9431f..3f158f5b 100644
--- a/src/main/java/org/bukkit/Chunk.java
+++ b/src/main/java/org/bukkit/Chunk.java
@@ -20,4 +20,10 @@ public interface Chunk {
*/
int getZ();
+ /**
+ * Gets the world containing this chunk
+ *
+ * @return Parent World
+ */
+ World getWorld();
}
diff --git a/src/main/java/org/bukkit/ItemStack.java b/src/main/java/org/bukkit/ItemStack.java
index 2ca42274..af176698 100644
--- a/src/main/java/org/bukkit/ItemStack.java
+++ b/src/main/java/org/bukkit/ItemStack.java
@@ -1,81 +1,118 @@
-
-package org.bukkit;
-
-/**
- * Represents a stack of items
- */
-public class ItemStack {
- private int type;
- private int amount = 0;
-
- public ItemStack(final int type) {
- this.type = type;
- }
-
- public ItemStack(final Material type) {
- this(type.getID());
- }
-
- public ItemStack(final int type, final int amount) {
- this.type = type;
- this.amount = amount;
- }
-
- public ItemStack(final Material type, final int amount) {
- this(type.getID(), amount);
- }
-
- /**
- * Gets the type of this item
- *
- * @return Type of the items in this stack
- */
- public Material getType() {
- return Material.getMaterial(type);
- }
-
- /**
- * Sets the type of this item
- *
- * @param type New type to set the items in this stack to
- */
- public void setType(Material type) {
- this.type = type.getID();
- }
-
- /**
- * Gets the type ID of this item
- *
- * @return Type ID of the items in this stack
- */
- public int getTypeID() {
- return type;
- }
-
- /**
- * Sets the type ID of this item
- *
- * @param type New type ID to set the items in this stack to
- */
- public void setTypeID(int type) {
- this.type = type;
- }
-
- /**
- * Gets the amount of items in this stack
- *
- * @return Amount of items in this stick
- */
- public int getAmount() {
- return amount;
- }
-
- /**
- * Sets the amount of items in this stack
- *
- * @param amount New amount of items in this stack
- */
- public void setAmount(int amount) {
- this.amount = amount;
- }
-}
+
+package org.bukkit;
+
+/**
+ * Represents a stack of items
+ */
+public class ItemStack {
+ private int type;
+ private int amount = 0;
+ private byte damage = 0;
+
+ public ItemStack(final int type) {
+ this.type = type;
+ }
+
+ public ItemStack(final Material type) {
+ this(type.getID());
+ }
+
+ public ItemStack(final int type, final int amount) {
+ this.type = type;
+ this.amount = amount;
+ }
+
+ public ItemStack(final Material type, final int amount) {
+ this(type.getID(), amount);
+ }
+
+ public ItemStack(final int type, final int amount, final byte damage) {
+ this.type = type;
+ this.amount = amount;
+ this.damage = damage;
+ }
+
+ public ItemStack(final Material type, final int amount, final byte damage) {
+ this(type.getID(), amount, damage);
+ }
+
+ /**
+ * Gets the type of this item
+ *
+ * @return Type of the items in this stack
+ */
+ public Material getType() {
+ return Material.getMaterial(type);
+ }
+
+ /**
+ * Sets the type of this item
+ *
+ * @param type New type to set the items in this stack to
+ */
+ public void setType(Material type) {
+ this.type = type.getID();
+ }
+
+ /**
+ * Gets the type ID of this item
+ *
+ * @return Type ID of the items in this stack
+ */
+ public int getTypeID() {
+ return type;
+ }
+
+ /**
+ * Sets the type ID of this item
+ *
+ * @param type New type ID to set the items in this stack to
+ */
+ public void setTypeID(int type) {
+ this.type = type;
+ }
+
+ /**
+ * Gets the amount of items in this stack
+ *
+ * @return Amount of items in this stick
+ */
+ public int getAmount() {
+ return amount;
+ }
+
+ /**
+ * Sets the amount of items in this stack
+ *
+ * @param amount New amount of items in this stack
+ */
+ public void setAmount(int amount) {
+ this.amount = amount;
+ }
+
+ /**
+ * Sets the damage of this item<br /><br />
+ *
+ * 0x00 represents an item which cannot be damaged<br />
+ * 0x01 represents an item at maximum health<br />
+ * 0x32 represents an item with no health left
+ *
+ * @param damage Damage of this item
+ */
+ public void setDamage(final byte damage) {
+ this.damage = damage;
+ }
+
+ /**
+ * Gets the damage of this item<br /><br />
+ *
+ * 0x00 represents an item which cannot be damaged<br />
+ * 0x01 represents an item at maximum health<br />
+ * 0x32 represents an item with no health left
+ *
+ * @return Damage of this item
+ */
+ public byte getDamage() {
+ return damage;
+ }
+}
diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java
index fe1d6920..045da30e 100644
--- a/src/main/java/org/bukkit/event/Event.java
+++ b/src/main/java/org/bukkit/event/Event.java
@@ -217,9 +217,9 @@ public abstract class Event {
BLOCK_PLACED (Category.BLOCK),
/**
- * Called when a specific block is being sent to a player
+ * Called when leaves are decaying naturally
*/
- BLOCK_SENT (Category.BLOCK),
+ LEAVES_DECAY (Category.BLOCK),
/**
* Called when a liquid attempts to flow into a block which already
diff --git a/src/main/java/org/bukkit/event/block/BlockListener.java b/src/main/java/org/bukkit/event/block/BlockListener.java
index c7607588..723572f9 100644
--- a/src/main/java/org/bukkit/event/block/BlockListener.java
+++ b/src/main/java/org/bukkit/event/block/BlockListener.java
@@ -1,81 +1,89 @@
-package org.bukkit.event.block;
-
-import org.bukkit.event.Listener;
-
-/**
- * Handles all events thrown in relation to Blocks
- *
- * @author durron597
- */
-public class BlockListener implements Listener {
- /**
- * Default Constructor
- */
- public BlockListener() {
- }
-
- /**
- * Called when a block is broken (or destroyed)
- *
- * @param event Relevant event details
- */
- public void onBlockBroken(BlockBrokenEvent event) {
- }
-
- /**
- * Called when we try to place a block, to see if we can build it
- */
- public void onBlockCanBuild(BlockCanBuildEvent event) {
- }
-
- /**
- * Called when a block flows (water/lava)
- *
- * @param event Relevant event details
- */
- public void onBlockFlow(BlockFromToEvent event) {
- }
-
- /**
- * Called when a block gets ignited
- *
- * @param event Relevant event details
- */
- public void onBlockIgnite(BlockIgniteEvent event) {
- }
-
- /**
- * Called when block physics occurs
- *
- * @param event Relevant event details
- */
- public void onBlockPhysics(BlockPhysicsEvent event) {
- }
-
- /**
- * Called when a player places a block
- *
- * @param event Relevant event details
- */
- public void onBlockPlaced(BlockPlacedEvent event) {
- }
-
- /**
- * Called when redstone changes
- * From: the source of the redstone change
- * To: The redstone dust that changed
- *
- * @param event Relevant event details
- */
- public void onBlockRedstoneChange(BlockFromToEvent event) {
- }
-
- /**
- * Called when a player right clicks a block
- *
- * @param event Relevant event details
- */
- public void onBlockRightClicked(BlockRightClickedEvent event) {
- }
-
-}
+package org.bukkit.event.block;
+
+import org.bukkit.event.Listener;
+
+/**
+ * Handles all events thrown in relation to Blocks
+ *
+ * @author durron597
+ */
+public class BlockListener implements Listener {
+ /**
+ * Default Constructor
+ */
+ public BlockListener() {
+ }
+
+ /**
+ * Called when a block is broken (or destroyed)
+ *
+ * @param event Relevant event details
+ */
+ public void onBlockBroken(BlockBrokenEvent event) {
+ }
+
+ /**
+ * Called when we try to place a block, to see if we can build it
+ */
+ public void onBlockCanBuild(BlockCanBuildEvent event) {
+ }
+
+ /**
+ * Called when a block flows (water/lava)
+ *
+ * @param event Relevant event details
+ */
+ public void onBlockFlow(BlockFromToEvent event) {
+ }
+
+ /**
+ * Called when a block gets ignited
+ *
+ * @param event Relevant event details
+ */
+ public void onBlockIgnite(BlockIgniteEvent event) {
+ }
+
+ /**
+ * Called when block physics occurs
+ *
+ * @param event Relevant event details
+ */
+ public void onBlockPhysics(BlockPhysicsEvent event) {
+ }
+
+ /**
+ * Called when a player places a block
+ *
+ * @param event Relevant event details
+ */
+ public void onBlockPlaced(BlockPlacedEvent event) {
+ }
+
+ /**
+ * Called when redstone changes
+ * From: the source of the redstone change
+ * To: The redstone dust that changed
+ *
+ * @param event Relevant event details
+ */
+ public void onBlockRedstoneChange(BlockFromToEvent event) {
+ }
+
+ /**
+ * Called when a player right clicks a block
+ *
+ * @param event Relevant event details
+ */
+ public void onBlockRightClicked(BlockRightClickedEvent event) {
+ }
+
+ /**
+ * Called when leaves are decaying naturally
+ *
+ * @param event Relevant event details
+ */
+ public void onLeavesDecay(LeavesDecayEvent event) {
+ }
+
+}
diff --git a/src/main/java/org/bukkit/event/block/BlockPlacedEvent.java b/src/main/java/org/bukkit/event/block/BlockPlacedEvent.java
index 030a2dd9..6bc18968 100644
--- a/src/main/java/org/bukkit/event/block/BlockPlacedEvent.java
+++ b/src/main/java/org/bukkit/event/block/BlockPlacedEvent.java
@@ -11,24 +11,36 @@ public class BlockPlacedEvent extends BlockEvent implements Cancellable {
private boolean cancel;
private Player player;
- /**
- * @param type
- * @param theBlock
- */
public BlockPlacedEvent(Type type, Block theBlock) {
super(type, theBlock);
cancel = false;
}
-
+
+ /**
+ * Gets the player who placed this block
+ *
+ * @return Player who placed the block
+ */
public Player getPlayer() {
return player;
}
+ /**
+ * Gets the cancellation state of this event. A cancelled event will not
+ * be executed in the server, but will still pass to other plugins
+ *
+ * @return true if this event is cancelled
+ */
public boolean isCancelled() {
- // TODO Auto-generated method stub
return cancel;
}
+ /**
+ * Sets the cancellation state of this event. A cancelled event will not
+ * be executed in the server, but will still pass to other plugins
+ *
+ * @param cancel true if you wish to cancel this event
+ */
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
diff --git a/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java b/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java
new file mode 100644
index 00000000..1ee2f403
--- /dev/null
+++ b/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java
@@ -0,0 +1,36 @@
+
+package org.bukkit.event.block;
+
+import org.bukkit.Block;
+import org.bukkit.event.Cancellable;
+
+/**
+ * Called on leaves decaying
+ */
+public class LeavesDecayEvent extends BlockEvent implements Cancellable {
+ private boolean cancel = false;
+
+ public LeavesDecayEvent(final Type type, final Block block) {
+ super(type, block);
+ }
+
+ /**
+ * Gets the cancellation state of this event. A cancelled event will not
+ * be executed in the server, but will still pass to other plugins
+ *
+ * @return true if this event is cancelled
+ */
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ /**
+ * Sets the cancellation state of this event. A cancelled event will not
+ * be executed in the server, but will still pass to other plugins
+ *
+ * @param cancel true if you wish to cancel this event
+ */
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+}
diff --git a/src/main/java/org/bukkit/event/world/ChunkLoadedEvent.java b/src/main/java/org/bukkit/event/world/ChunkLoadedEvent.java
new file mode 100644
index 00000000..f91b7aeb
--- /dev/null
+++ b/src/main/java/org/bukkit/event/world/ChunkLoadedEvent.java
@@ -0,0 +1,26 @@
+
+package org.bukkit.event.world;
+
+import org.bukkit.Chunk;
+
+/**
+ * Called when a chunk is loaded
+ */
+public class ChunkLoadedEvent extends WorldEvent {
+ private final Chunk chunk;
+
+ public ChunkLoadedEvent(final Type type, final Chunk chunk) {
+ super(type, chunk.getWorld());
+
+ this.chunk = chunk;
+ }
+
+ /**
+ * Gets the chunk being loaded/unloaded
+ *
+ * @return Chunk that triggered this event
+ */
+ public Chunk getChunk() {
+ return chunk;
+ }
+}
diff --git a/src/main/java/org/bukkit/event/world/ChunkUnloadedEvent.java b/src/main/java/org/bukkit/event/world/ChunkUnloadedEvent.java
new file mode 100644
index 00000000..fc9d57b1
--- /dev/null
+++ b/src/main/java/org/bukkit/event/world/ChunkUnloadedEvent.java
@@ -0,0 +1,36 @@
+
+package org.bukkit.event.world;
+
+import org.bukkit.Chunk;
+import org.bukkit.event.Cancellable;
+
+/**
+ * Called when a chunk is unloaded
+ */
+public class ChunkUnloadedEvent extends ChunkLoadedEvent implements Cancellable {
+ private boolean cancel = false;
+
+ public ChunkUnloadedEvent(final Type type, final Chunk chunk) {
+ super(type, chunk);
+ }
+
+ /**
+ * Gets the cancellation state of this event. A cancelled event will not
+ * be executed in the server, but will still pass to other plugins
+ *
+ * @return true if this event is cancelled
+ */
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ /**
+ * Sets the cancellation state of this event. A cancelled event will not
+ * be executed in the server, but will still pass to other plugins
+ *
+ * @param cancel true if you wish to cancel this event
+ */
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+}
diff --git a/src/main/java/org/bukkit/event/world/WorldEvent.java b/src/main/java/org/bukkit/event/world/WorldEvent.java
new file mode 100644
index 00000000..d877758a
--- /dev/null
+++ b/src/main/java/org/bukkit/event/world/WorldEvent.java
@@ -0,0 +1,27 @@
+
+package org.bukkit.event.world;
+
+import org.bukkit.World;
+import org.bukkit.event.Event;
+
+/**
+ * Represents events within a world
+ */
+public class WorldEvent extends Event {
+ private final World world;
+
+ public WorldEvent(final Type type, final World world) {
+ super(type);
+
+ this.world = world;
+ }
+
+ /**
+ * Gets the world primarily involved with this event
+ *
+ * @return World which caused this event
+ */
+ public World getWorld() {
+ return world;
+ }
+}
diff --git a/src/main/java/org/bukkit/event/world/WorldListener.java b/src/main/java/org/bukkit/event/world/WorldListener.java
new file mode 100644
index 00000000..fc8f5799
--- /dev/null
+++ b/src/main/java/org/bukkit/event/world/WorldListener.java
@@ -0,0 +1,25 @@
+
+package org.bukkit.event.world;
+
+import org.bukkit.event.Listener;
+
+/**
+ * Handles all World related events
+ */
+public class WorldListener implements Listener {
+ /**
+ * Called when a chunk is loaded
+ *
+ * @param event Relevant event details
+ */
+ public void onChunkLoaded(ChunkLoadedEvent event) {
+ }
+
+ /**
+ * Called when a chunk is unloaded
+ *
+ * @param event Relevant event details
+ */
+ public void onChunkUnloaded(ChunkUnloadedEvent event) {
+ }
+}
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
index ba220c3e..2c9b5078 100644
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
@@ -23,6 +23,9 @@ import org.bukkit.event.player.*;
import org.bukkit.event.server.PluginEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.event.vehicle.*;
+import org.bukkit.event.world.ChunkLoadedEvent;
+import org.bukkit.event.world.ChunkUnloadedEvent;
+import org.bukkit.event.world.WorldListener;
import org.bukkit.plugin.*;
/**
@@ -124,6 +127,9 @@ public final class JavaPluginLoader implements PluginLoader {
case BLOCK_FLOW:
trueListener.onBlockFlow((BlockFromToEvent)event);
break;
+ case LEAVES_DECAY:
+ trueListener.onLeavesDecay((LeavesDecayEvent)event);
+ break;
}
} else if(listener instanceof ServerListener) {
ServerListener trueListener = (ServerListener)listener;
@@ -136,6 +142,17 @@ public final class JavaPluginLoader implements PluginLoader {
trueListener.onPluginDisabled((PluginEvent)event);
break;
}
+ } else if(listener instanceof WorldListener) {
+ WorldListener trueListener = (WorldListener)listener;
+
+ switch (event.getType()) {
+ case CHUNK_LOADED:
+ trueListener.onChunkLoaded((ChunkLoadedEvent)event);
+ break;
+ case CHUNK_UNLOADED:
+ trueListener.onChunkUnloaded((ChunkUnloadedEvent)event);
+ break;
+ }
} else if(listener instanceof EntityListener) {
EntityListener trueListener = (EntityListener) listener;
switch(event.getType())