mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-31 21:37:39 +01:00
Added PLAYER_ITEM_HELD event
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
7d5f8c95d4
commit
497ac626bf
@ -206,6 +206,13 @@ public abstract class Event {
|
||||
*/
|
||||
PLAYER_TELEPORT (Category.PLAYER),
|
||||
|
||||
/**
|
||||
* Called when a player changes their held item
|
||||
*
|
||||
* @see org.bukkit.event.player.PlayerItemHeldEvent
|
||||
*/
|
||||
PLAYER_ITEM_HELD (Category.PLAYER),
|
||||
|
||||
/**
|
||||
* BLOCK EVENTS
|
||||
*/
|
||||
|
@ -0,0 +1,36 @@
|
||||
|
||||
package org.bukkit.event.player;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Fired when a player changes their currently held item
|
||||
*/
|
||||
public class PlayerItemHeldEvent extends PlayerEvent {
|
||||
private int previous;
|
||||
private int current;
|
||||
|
||||
public PlayerItemHeldEvent(final Type type, final Player player, final int previous, final int current) {
|
||||
super(type, player);
|
||||
this.previous = previous;
|
||||
this.current = current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the previous held slot index
|
||||
*
|
||||
* @return Previous slot index
|
||||
*/
|
||||
public int getPreviousSlot() {
|
||||
return previous;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the new held slot index
|
||||
*
|
||||
* @return New slot index
|
||||
*/
|
||||
public int getNewSlot() {
|
||||
return current;
|
||||
}
|
||||
}
|
@ -97,4 +97,12 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
public void onInventoryOpen(PlayerInventoryEvent event) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player changes their held item
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
public void onItemHeldChange(PlayerItemHeldEvent event) {
|
||||
}
|
||||
}
|
||||
|
@ -173,6 +173,11 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
((PlayerListener)listener).onInventoryOpen( (PlayerInventoryEvent)event );
|
||||
}
|
||||
};
|
||||
case PLAYER_ITEM_HELD:
|
||||
return new EventExecutor() { public void execute( Listener listener, Event event ) {
|
||||
((PlayerListener)listener).onItemHeldChange( (PlayerItemHeldEvent)event );
|
||||
}
|
||||
};
|
||||
|
||||
// Block Events
|
||||
case BLOCK_PHYSICS:
|
||||
|
Loading…
Reference in New Issue
Block a user