mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-22 06:55:36 +01:00
Added PLAYER_DROP_ITEM
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
811c06d099
commit
c76bf04e6d
4 changed files with 68 additions and 0 deletions
|
@ -213,6 +213,13 @@ public abstract class Event {
|
||||||
*/
|
*/
|
||||||
PLAYER_ITEM_HELD (Category.PLAYER),
|
PLAYER_ITEM_HELD (Category.PLAYER),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player drops an item
|
||||||
|
*
|
||||||
|
* @see org.bukkit.event.player.PlayerDropItemEvent
|
||||||
|
*/
|
||||||
|
PLAYER_DROP_ITEM (Category.PLAYER),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BLOCK EVENTS
|
* BLOCK EVENTS
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
|
||||||
|
package org.bukkit.event.player;
|
||||||
|
|
||||||
|
import org.bukkit.entity.ItemDrop;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when a player drops an item from their inventory
|
||||||
|
*/
|
||||||
|
public class PlayerDropItemEvent extends PlayerEvent implements Cancellable {
|
||||||
|
private final ItemDrop drop;
|
||||||
|
private boolean cancel = false;
|
||||||
|
|
||||||
|
public PlayerDropItemEvent(final Type type, final Player player, final ItemDrop drop) {
|
||||||
|
super(type, player);
|
||||||
|
this.drop = drop;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the ItemDrop created by the player
|
||||||
|
*
|
||||||
|
* @return ItemDrop
|
||||||
|
*/
|
||||||
|
public ItemDrop getItemDrop() {
|
||||||
|
return drop;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cancellation state of this event. A cancelled event will not
|
||||||
|
* be executed in the server, but will still pass to other plugins
|
||||||
|
*
|
||||||
|
* @return true if this event is cancelled
|
||||||
|
*/
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event. A cancelled 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) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
}
|
|
@ -105,4 +105,12 @@ public class PlayerListener implements Listener {
|
||||||
*/
|
*/
|
||||||
public void onItemHeldChange(PlayerItemHeldEvent event) {
|
public void onItemHeldChange(PlayerItemHeldEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player drops an item from their inventory
|
||||||
|
*
|
||||||
|
* @param event Relevant event details
|
||||||
|
*/
|
||||||
|
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,6 +178,11 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||||
((PlayerListener)listener).onItemHeldChange( (PlayerItemHeldEvent)event );
|
((PlayerListener)listener).onItemHeldChange( (PlayerItemHeldEvent)event );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
case PLAYER_DROP_ITEM:
|
||||||
|
return new EventExecutor() { public void execute( Listener listener, Event event ) {
|
||||||
|
((PlayerListener)listener).onPlayerDropItem( (PlayerDropItemEvent)event );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Block Events
|
// Block Events
|
||||||
case BLOCK_PHYSICS:
|
case BLOCK_PHYSICS:
|
||||||
|
|
Loading…
Add table
Reference in a new issue