mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 11:44:19 +01:00
Added EntityTame event. Thanks halvors!
By: EvilSeph <evilseph@unaligned.org>
This commit is contained in:
parent
6e1fca7350
commit
10d7e607c8
4 changed files with 64 additions and 0 deletions
|
@ -592,6 +592,12 @@ public abstract class Event implements Serializable {
|
|||
* @see org.bukkit.event.entity.PigZapEvent
|
||||
*/
|
||||
PIG_ZAP (Category.LIVING_ENTITY),
|
||||
/**
|
||||
* Called when a LivingEntity is tamed
|
||||
*
|
||||
* @see org.bukkit.event.entity.EntityTameEvent
|
||||
*/
|
||||
ENTITY_TAME (Category.LIVING_ENTITY),
|
||||
|
||||
/**
|
||||
* WEATHER EVENTS
|
||||
|
|
|
@ -35,4 +35,6 @@ public class EntityListener implements Listener {
|
|||
public void onPigZap(PigZapEvent event) {}
|
||||
|
||||
public void onCreeperPower(CreeperPowerEvent event) {}
|
||||
|
||||
public void onEntityTame(EntityTameEvent event) {}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
case VEHICLE_CREATE:
|
||||
return new EventExecutor() {
|
||||
|
|
Loading…
Reference in a new issue