Added CREATURE_SPAWN event
This commit is contained in:
parent
e345a982eb
commit
93f6e5191e
@ -0,0 +1,66 @@
|
|||||||
|
package org.bukkit.event.entity;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.MobType;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores data for damage events
|
||||||
|
*/
|
||||||
|
public class CreatureSpawnEvent extends EntityEvent implements Cancellable {
|
||||||
|
|
||||||
|
private Location location;
|
||||||
|
private boolean canceled;
|
||||||
|
private MobType mobtype;
|
||||||
|
|
||||||
|
public CreatureSpawnEvent(Entity spawnee, MobType mobtype, Location loc) {
|
||||||
|
super(Event.Type.CREATURE_SPAWN, spawnee);
|
||||||
|
this.mobtype = mobtype;
|
||||||
|
this.location = loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected CreatureSpawnEvent(Event.Type type, Entity spawnee, MobType mobtype, Location loc) {
|
||||||
|
super(type, spawnee);
|
||||||
|
this.mobtype = mobtype;
|
||||||
|
this.location = loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cancellation state of this event. A canceled event will not
|
||||||
|
* be executed in the server, but will still pass to other plugins
|
||||||
|
*
|
||||||
|
* @return true if this event is canceled
|
||||||
|
*/
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return canceled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event. A canceled event will not
|
||||||
|
* be executed in the server, but will still pass to other plugins
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
canceled = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the location at which the creature is spawning.
|
||||||
|
* @return The location at which the creature is spawning
|
||||||
|
*/
|
||||||
|
public Location getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the type of creature being spawned.
|
||||||
|
*
|
||||||
|
* @return A CreatureType value detailing the type of creature being spawned
|
||||||
|
*/
|
||||||
|
public MobType getMobType() {
|
||||||
|
return mobtype;
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,9 @@ public class EntityListener implements Listener {
|
|||||||
public EntityListener() {
|
public EntityListener() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
public void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
|
public void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,6 +358,11 @@ public final class JavaPluginLoader implements PluginLoader {
|
|||||||
((EntityListener)listener).onEntityTarget( (EntityTargetEvent)event );
|
((EntityListener)listener).onEntityTarget( (EntityTargetEvent)event );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
case CREATURE_SPAWN:
|
||||||
|
return new EventExecutor() { public void execute( Listener listener, Event event ) {
|
||||||
|
((EntityListener)listener).onCreatureSpawn( (CreatureSpawnEvent)event );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Vehicle Events
|
// Vehicle Events
|
||||||
case VEHICLE_CREATE:
|
case VEHICLE_CREATE:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user