summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDinnerbone <dinnerbone@dinnerbone.com>2011-09-21 15:40:00 +0100
committerDinnerbone <dinnerbone@dinnerbone.com>2011-09-21 15:40:00 +0100
commit84732296073fa18a6d838c07ceeed85b8f20c314 (patch)
tree8877d9aef7635e921e15976b9f094423452dfb8c
parente61bc9093d4765ae25361d14f3dec7c979ba9556 (diff)
downloadbukkit-84732296073fa18a6d838c07ceeed85b8f20c314.tar
bukkit-84732296073fa18a6d838c07ceeed85b8f20c314.tar.gz
bukkit-84732296073fa18a6d838c07ceeed85b8f20c314.tar.lz
bukkit-84732296073fa18a6d838c07ceeed85b8f20c314.tar.xz
bukkit-84732296073fa18a6d838c07ceeed85b8f20c314.zip
Added methods to control dropped EXP from EntityDeathEvent, and made a subevent for setting players respawned-exp
-rw-r--r--src/main/java/org/bukkit/event/entity/EntityDeathEvent.java32
-rw-r--r--src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java41
2 files changed, 72 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java b/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java
index 8f8cfbae..34e5348f 100644
--- a/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java
+++ b/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java
@@ -9,10 +9,40 @@ import org.bukkit.inventory.ItemStack;
*/
public class EntityDeathEvent extends EntityEvent {
private List<ItemStack> drops;
+ private int dropExp = 0;
- public EntityDeathEvent(final Entity what, final List<ItemStack> drops) {
+ public EntityDeathEvent(final Entity entity, final List<ItemStack> drops) {
+ this(entity, drops, 0);
+ }
+
+ public EntityDeathEvent(final Entity what, final List<ItemStack> drops, int droppedExp) {
super(Type.ENTITY_DEATH, what);
this.drops = drops;
+ this.dropExp = droppedExp;
+ }
+
+ /**
+ * Gets how much EXP should be dropped from this death.
+ * <p>
+ * This does not indicate how much EXP should be taken from the entity in question,
+ * merely how much should be created after its death.
+ *
+ * @return Amount of EXP to drop.
+ */
+ public int getDroppedExp() {
+ return dropExp;
+ }
+
+ /**
+ * Sets how much EXP should be dropped from this death.
+ * <p>
+ * This does not indicate how much EXP should be taken from the entity in question,
+ * merely how much should be created after its death.
+ *
+ * @param exp Amount of EXP to drop.
+ */
+ public void setDropedExp(int exp) {
+ this.dropExp = exp;
}
/**
diff --git a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
new file mode 100644
index 00000000..112996e6
--- /dev/null
+++ b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
@@ -0,0 +1,41 @@
+package org.bukkit.event.entity;
+
+import java.util.List;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+
+/**
+ * Thrown whenever a {@link Player} dies
+ */
+public class PlayerDeathEvent extends EntityDeathEvent {
+ private int newExp = 0;
+
+ public PlayerDeathEvent(Player player, List<ItemStack> drops, int droppedExp, int newExp) {
+ super(player, drops, droppedExp);
+ this.newExp = newExp;
+ }
+
+ /**
+ * Gets how much EXP the Player should have at respawn.
+ * <p>
+ * This does not indicate how much EXP should be dropped, please see
+ * {@link #getDroppedExp()} for that.
+ *
+ * @return New EXP of the respawned player
+ */
+ public int getNewExp() {
+ return newExp;
+ }
+
+ /**
+ * Sets how much EXP the Player should have at respawn.
+ * <p>
+ * This does not indicate how much EXP should be dropped, please see
+ * {@link #setDropedExp(int)} for that.
+ *
+ * @get exp New EXP of the respawned player
+ */
+ public void setNewExp(int exp) {
+ this.newExp = exp;
+ }
+}