mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-01 21:21:27 +01:00
Added ItemSpawnEvent. Thanks myers!
By: EvilSeph <evilseph@unaligned.org>
This commit is contained in:
parent
1e4c2bd7b1
commit
4d68ae490e
@ -463,7 +463,7 @@ public abstract class Event implements Serializable {
|
||||
/**
|
||||
* Called when an ItemEntity spawns in the world
|
||||
*
|
||||
* @todo: add javadoc see comment
|
||||
* @see org.bukkit.event.entity.ItemSpawnEvent
|
||||
*/
|
||||
ITEM_SPAWN (Category.WORLD),
|
||||
/**
|
||||
|
@ -12,6 +12,8 @@ public class EntityListener implements Listener {
|
||||
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {}
|
||||
|
||||
public void onItemSpawn(ItemSpawnEvent event) {}
|
||||
|
||||
public void onEntityCombust(EntityCombustEvent event) {}
|
||||
|
||||
public void onEntityDamage(EntityDamageEvent event) {}
|
||||
|
@ -0,0 +1,47 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
/**
|
||||
* Called when an item is spawned into a world
|
||||
*/
|
||||
public class ItemSpawnEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private Location location;
|
||||
private boolean canceled;
|
||||
|
||||
public ItemSpawnEvent(Entity spawnee, Location loc) {
|
||||
super(Type.ITEM_SPAWN, spawnee);
|
||||
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 item is spawning.
|
||||
* @return The location at which the item is spawning
|
||||
*/
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
}
|
@ -655,6 +655,13 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
}
|
||||
};
|
||||
|
||||
case ITEM_SPAWN:
|
||||
return new EventExecutor() {
|
||||
public void execute(Listener listener, Event event) {
|
||||
((EntityListener) listener).onItemSpawn((ItemSpawnEvent) event);
|
||||
}
|
||||
};
|
||||
|
||||
case PIG_ZAP:
|
||||
return new EventExecutor() {
|
||||
public void execute(Listener listener, Event event) {
|
||||
|
Loading…
Reference in New Issue
Block a user