13
0
geforkt von Mirrors/Paper

Added ItemSpawnEvent. Thanks myers!

By: EvilSeph <evilseph@unaligned.org>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2011-06-11 00:26:18 -04:00
Ursprung 1e4c2bd7b1
Commit 4d68ae490e
4 geänderte Dateien mit 57 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -463,7 +463,7 @@ public abstract class Event implements Serializable {
/** /**
* Called when an ItemEntity spawns in the world * Called when an ItemEntity spawns in the world
* *
* @todo: add javadoc see comment * @see org.bukkit.event.entity.ItemSpawnEvent
*/ */
ITEM_SPAWN (Category.WORLD), ITEM_SPAWN (Category.WORLD),
/** /**

Datei anzeigen

@ -12,6 +12,8 @@ public class EntityListener implements Listener {
public void onCreatureSpawn(CreatureSpawnEvent event) {} public void onCreatureSpawn(CreatureSpawnEvent event) {}
public void onItemSpawn(ItemSpawnEvent event) {}
public void onEntityCombust(EntityCombustEvent event) {} public void onEntityCombust(EntityCombustEvent event) {}
public void onEntityDamage(EntityDamageEvent event) {} public void onEntityDamage(EntityDamageEvent event) {}

Datei anzeigen

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

Datei anzeigen

@ -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: case PIG_ZAP:
return new EventExecutor() { return new EventExecutor() {
public void execute(Listener listener, Event event) { public void execute(Listener listener, Event event) {