Added EntityTame event. Thanks halvors!

By: EvilSeph <evilseph@unaligned.org>
This commit is contained in:
Bukkit/Spigot 2011-06-09 03:57:50 -04:00
parent 6e1fca7350
commit 10d7e607c8
4 changed files with 64 additions and 0 deletions

View file

@ -592,6 +592,12 @@ public abstract class Event implements Serializable {
* @see org.bukkit.event.entity.PigZapEvent * @see org.bukkit.event.entity.PigZapEvent
*/ */
PIG_ZAP (Category.LIVING_ENTITY), PIG_ZAP (Category.LIVING_ENTITY),
/**
* Called when a LivingEntity is tamed
*
* @see org.bukkit.event.entity.EntityTameEvent
*/
ENTITY_TAME (Category.LIVING_ENTITY),
/** /**
* WEATHER EVENTS * WEATHER EVENTS

View file

@ -35,4 +35,6 @@ public class EntityListener implements Listener {
public void onPigZap(PigZapEvent event) {} public void onPigZap(PigZapEvent event) {}
public void onCreeperPower(CreeperPowerEvent event) {} public void onCreeperPower(CreeperPowerEvent event) {}
public void onEntityTame(EntityTameEvent event) {}
} }

View file

@ -0,0 +1,49 @@
package org.bukkit.event.entity;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
/**
* Thrown when a LivingEntity is tamed
*/
public class EntityTameEvent extends EntityEvent implements Cancellable {
private boolean cancelled;
private AnimalTamer owner;
public EntityTameEvent(Entity entity, AnimalTamer owner) {
super(Type.ENTITY_TAME, entity);
this.owner = owner;
}
/**
* Gets the cancellation state of this event. Set to true if you
* want to prevent the entity from being tamed
*
* @return boolean cancellation state
*/
public boolean isCancelled() {
return cancelled;
}
/**
* Sets the cancellation state of this event. A canceled event will not
* be executed in the server, but will still pass to other plugins
*
* Canceling this event will prevent the entity from being tamed
*
* @param cancel true if you wish to cancel this event
*/
public void setCancelled(boolean cancel) {
cancelled = cancel;
}
/**
* Gets the owning AnimalTamer
*
* @return the owning AnimalTamer
*/
public AnimalTamer getOwner() {
return owner;
}
}

View file

@ -669,6 +669,13 @@ public final class JavaPluginLoader implements PluginLoader {
} }
}; };
case ENTITY_TAME:
return new EventExecutor() {
public void execute(Listener listener, Event event) {
((EntityListener) listener).onEntityTame((EntityTameEvent) event);
}
};
// Vehicle Events // Vehicle Events
case VEHICLE_CREATE: case VEHICLE_CREATE:
return new EventExecutor() { return new EventExecutor() {