Added SlimeSplit event. Thanks garbagemule!

The SlimeSplit event is fired when a Slime attempts to split upon death. The event may be cancelled, and the amount of smaller slimes may be customized.

By: EvilSeph <evilseph@gmail.com>
This commit is contained in:
Bukkit/Spigot 2011-09-30 19:34:06 -04:00
parent d0f0db958d
commit 5db08677a3
4 changed files with 65 additions and 1 deletions

View file

@ -90,7 +90,7 @@ public abstract class Event implements Serializable {
/**
* Represents Player-based events
*
*
* @see #LIVING_ENTITY
*/
PLAYER,
@ -689,6 +689,12 @@ public abstract class Event implements Serializable {
* @see org.bukkit.event.entity.ProjectileHitEvent
*/
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
*

View file

@ -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) {}
}

View file

@ -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;
}
}

View file

@ -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() {