mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-08-31 22:22:49 +00:00
SPIGOT-3403: Add an EntityPickupItemEvent
This commit is contained in:
parent
650f5090d6
commit
1b414f0247
2 changed files with 65 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -4,10 +4,13 @@ import org.bukkit.entity.Item;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
|
||||
/**
|
||||
* Thrown when a player picks an item up from the ground
|
||||
* @deprecated {@link EntityPickupItemEvent}
|
||||
*/
|
||||
@Deprecated
|
||||
public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final Item item;
|
||||
|
|
Loading…
Add table
Reference in a new issue