summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorWizjany <wizjany@gmail.com>2011-09-17 20:18:43 -0400
committerDinnerbone <dinnerbone@dinnerbone.com>2011-09-20 18:48:56 +0100
commit4f028644471d006e4954b78b10f941946bfd9f35 (patch)
tree893982e4becef97d40d7897ff202675b8cccf0c3 /src/main/java
parent65fde9ee8c3bd9b55fa83e3b362dee73464b1949 (diff)
downloadbukkit-4f028644471d006e4954b78b10f941946bfd9f35.tar
bukkit-4f028644471d006e4954b78b10f941946bfd9f35.tar.gz
bukkit-4f028644471d006e4954b78b10f941946bfd9f35.tar.lz
bukkit-4f028644471d006e4954b78b10f941946bfd9f35.tar.xz
bukkit-4f028644471d006e4954b78b10f941946bfd9f35.zip
Added events for endermen pickup/placement blocks and methods to get/set the block that an enderman is holding. Thanks Wizjany
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/bukkit/entity/Enderman.java19
-rw-r--r--src/main/java/org/bukkit/event/Event.java13
-rw-r--r--src/main/java/org/bukkit/event/entity/EndermanPickupEvent.java34
-rw-r--r--src/main/java/org/bukkit/event/entity/EndermanPlaceEvent.java34
-rw-r--r--src/main/java/org/bukkit/event/entity/EntityListener.java14
-rw-r--r--src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java14
6 files changed, 126 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/entity/Enderman.java b/src/main/java/org/bukkit/entity/Enderman.java
index 184c4d7e..0b66a923 100644
--- a/src/main/java/org/bukkit/entity/Enderman.java
+++ b/src/main/java/org/bukkit/entity/Enderman.java
@@ -1,6 +1,23 @@
package org.bukkit.entity;
+import org.bukkit.material.MaterialData;
+
/**
* Represents an Enderman.
*/
-public interface Enderman extends Monster {}
+public interface Enderman extends Monster {
+
+ /**
+ * Get the id and data of the block that the Enderman is carrying.
+ *
+ * @return MaterialData containing the id and data of the block
+ */
+ public MaterialData getCarriedMaterial();
+
+ /**
+ * Set the id and data of the block that the Enderman is carring.
+ *
+ * @param material data to set the carried block to
+ */
+ public void setCarriedMaterial(MaterialData material);
+}
diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java
index 5066622e..236575fb 100644
--- a/src/main/java/org/bukkit/event/Event.java
+++ b/src/main/java/org/bukkit/event/Event.java
@@ -679,13 +679,24 @@ public abstract class Event implements Serializable {
* @see org.bukkit.event.entity.ProjectileHitEvent
*/
PROJECTILE_HIT (Category.ENTITY),
-
/**
* Called when a LivingEntity is regains health
*
* @see org.bukkit.event.entity.EntityRegainHealthEvent
*/
ENTITY_REGAIN_HEALTH (Category.LIVING_ENTITY),
+ /**
+ * Called when an Enderman picks a block up
+ *
+ * @see org.bukkit.event.entity.EndermanPickupEvent
+ */
+ ENDERMAN_PICKUP (Category.LIVING_ENTITY),
+ /**
+ * Called when an Enderman places a block
+ *
+ * @see org.bukkit.event.entity.EndermanPlaceEvent
+ */
+ ENDERMAN_PLACE (Category.LIVING_ENTITY),
/**
* WEATHER EVENTS
diff --git a/src/main/java/org/bukkit/event/entity/EndermanPickupEvent.java b/src/main/java/org/bukkit/event/entity/EndermanPickupEvent.java
new file mode 100644
index 00000000..9624000d
--- /dev/null
+++ b/src/main/java/org/bukkit/event/entity/EndermanPickupEvent.java
@@ -0,0 +1,34 @@
+package org.bukkit.event.entity;
+
+import org.bukkit.block.Block;
+import org.bukkit.entity.Entity;
+import org.bukkit.event.Cancellable;
+
+public class EndermanPickupEvent extends EntityEvent implements Cancellable {
+
+ private boolean cancel;
+ private Block block;
+
+ public EndermanPickupEvent(Entity what, Block block) {
+ super(Type.ENDERMAN_PICKUP, what);
+ this.block = block;
+ this.cancel = false;
+ }
+
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ /**
+ * Get the block that the enderman is going to pick up.
+ *
+ * @return block the enderman is about to pick up
+ */
+ public Block getBlock() {
+ return block;
+ }
+}
diff --git a/src/main/java/org/bukkit/event/entity/EndermanPlaceEvent.java b/src/main/java/org/bukkit/event/entity/EndermanPlaceEvent.java
new file mode 100644
index 00000000..aca6228a
--- /dev/null
+++ b/src/main/java/org/bukkit/event/entity/EndermanPlaceEvent.java
@@ -0,0 +1,34 @@
+package org.bukkit.event.entity;
+
+import org.bukkit.Location;
+import org.bukkit.entity.Entity;
+import org.bukkit.event.Cancellable;
+
+public class EndermanPlaceEvent extends EntityEvent implements Cancellable {
+
+ private boolean cancel;
+ private Location location;
+
+ public EndermanPlaceEvent(Entity what, Location location) {
+ super(Type.ENDERMAN_PLACE, what);
+ this.location = location;
+ this.cancel = false;
+ }
+
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ /**
+ * Get the location that is target of the enderman's placement.
+ *
+ * @return location where the enderman will place its block
+ */
+ public Location getLocation() {
+ return location;
+ }
+}
diff --git a/src/main/java/org/bukkit/event/entity/EntityListener.java b/src/main/java/org/bukkit/event/entity/EntityListener.java
index 86b9c93a..00a7b568 100644
--- a/src/main/java/org/bukkit/event/entity/EntityListener.java
+++ b/src/main/java/org/bukkit/event/entity/EntityListener.java
@@ -134,4 +134,18 @@ public class EntityListener implements Listener {
* @param event Relevant event details
*/
public void onProjectileHit(ProjectileHitEvent event) {}
+
+ /**
+ * Called when an Enderman picks a block up
+ *
+ * @param event Relevant event details
+ */
+ public void onEndermanPickup(EndermanPickupEvent event) {}
+
+ /**
+ * Called when an Enderman places a block
+ *
+ * @param event Relevant event details
+ */
+ public void onEndermanPlace(EndermanPlaceEvent event) {}
}
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
index a5dbf5e7..d5f7dd0c 100644
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
@@ -762,6 +762,20 @@ public class JavaPluginLoader implements PluginLoader {
}
};
+ case ENDERMAN_PICKUP:
+ return new EventExecutor() {
+ public void execute(Listener listener, Event event) {
+ ((EntityListener) listener).onEndermanPickup((EndermanPickupEvent) event);
+ }
+ };
+
+ case ENDERMAN_PLACE:
+ return new EventExecutor() {
+ public void execute(Listener listener, Event event) {
+ ((EntityListener) listener).onEndermanPlace((EndermanPlaceEvent) event);
+ }
+ };
+
// Vehicle Events
case VEHICLE_CREATE:
return new EventExecutor() {