13
0
geforkt von Mirrors/Paper

SPIGOT-3403: Add an EntityPickupItemEvent

By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2017-07-28 17:47:51 +10:00
Ursprung 1c45976aee
Commit cefcc3e3bc
2 geänderte Dateien mit 65 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,62 @@
package org.bukkit.event.entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* Thrown when a entity picks an item up from the ground
*/
public class EntityPickupItemEvent extends EntityEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Item item;
private boolean cancel = false;
private final int remaining;
public EntityPickupItemEvent(final LivingEntity entity, final Item item, final int remaining) {
super(entity);
this.item = item;
this.remaining = remaining;
}
@Override
public LivingEntity getEntity() {
return (LivingEntity) entity;
}
/**
* Gets the Item picked up by the entity.
*
* @return Item
*/
public Item getItem() {
return item;
}
/**
* Gets the amount remaining on the ground, if any
*
* @return amount remaining on the ground
*/
public int getRemaining() {
return remaining;
}
public boolean isCancelled() {
return cancel;
}
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

Datei anzeigen

@ -4,10 +4,13 @@ import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityPickupItemEvent;
/** /**
* Thrown when a player picks an item up from the ground * Thrown when a player picks an item up from the ground
* @deprecated {@link EntityPickupItemEvent}
*/ */
@Deprecated
public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable { public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private final Item item; private final Item item;