geforkt von Mirrors/Paper
SPIGOT-3403: Add an EntityPickupItemEvent
By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
Ursprung
1c45976aee
Commit
cefcc3e3bc
@ -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;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren