diff options
Diffstat (limited to 'src/main/java/org')
4 files changed, 65 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java index 80e28132..3bbd7ab8 100644 --- a/src/main/java/org/bukkit/event/Event.java +++ b/src/main/java/org/bukkit/event/Event.java @@ -90,7 +90,7 @@ public abstract class Event implements Serializable { /** * Represents Player-based events - * + * * @see #LIVING_ENTITY */ PLAYER, @@ -690,6 +690,12 @@ public abstract class Event implements Serializable { */ PROJECTILE_HIT (Category.ENTITY), /** + * Called when a Slime splits into smaller Slimes upon death + * + * @see org.bukkit.event.entity.SlimeSplitEvent + */ + SLIME_SPLIT (Category.LIVING_ENTITY), + /** * Called when a LivingEntity is regains health * * @see org.bukkit.event.entity.EntityRegainHealthEvent diff --git a/src/main/java/org/bukkit/event/entity/EntityListener.java b/src/main/java/org/bukkit/event/entity/EntityListener.java index 20fb9bbe..c325cb37 100644 --- a/src/main/java/org/bukkit/event/entity/EntityListener.java +++ b/src/main/java/org/bukkit/event/entity/EntityListener.java @@ -155,4 +155,11 @@ public class EntityListener implements Listener { * @param event Relevant event details */ public void onFoodLevelChange(FoodLevelChangeEvent event) {} + + /** + * Called when a Slime splits into smaller Slimes upon death + * + * @param event Relevant event details + */ + public void onSlimeSplit(SlimeSplitEvent event) {} } diff --git a/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java b/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java new file mode 100644 index 00000000..3ca784a9 --- /dev/null +++ b/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java @@ -0,0 +1,44 @@ +package org.bukkit.event.entity; + +import org.bukkit.entity.Entity; +import org.bukkit.event.Cancellable; + +/** + * Called when a Slime splits into smaller Slimes upon death + */ +public class SlimeSplitEvent extends EntityEvent implements Cancellable { + private boolean cancel; + private int count; + + public SlimeSplitEvent(Entity what, int count) { + super(Type.SLIME_SPLIT, what); + this.cancel = false; + this.count = count; + } + + public boolean isCancelled() { + return cancel; + } + + public void setCancelled(boolean cancel) { + this.cancel = cancel; + } + + /** + * Gets the amount of smaller slimes to spawn + * + * @return the amount of slimes to spawn + */ + public int getCount() { + return count; + } + + /** + * Sets how many smaller slimes will spawn on the split + * + * @param count the amount of slimes to spawn + */ + public void setCount(int count) { + this.count = count; + } +}
\ No newline at end of file diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index 5489b852..7b61a266 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -797,6 +797,13 @@ public class JavaPluginLoader implements PluginLoader { } }; + case SLIME_SPLIT: + return new EventExecutor() { + public void execute(Listener listener, Event event) { + ((EntityListener) listener).onSlimeSplit((SlimeSplitEvent) event); + } + }; + // Vehicle Events case VEHICLE_CREATE: return new EventExecutor() { |