Add ability to change player item in hand. Adds BUKKIT-3318
This commit is contained in:
parent
45147986bf
commit
d18bdf14e9
@ -1,13 +1,15 @@
|
|||||||
package org.bukkit.event.player;
|
package org.bukkit.event.player;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when a player changes their currently held item
|
* Fired when a player changes their currently held item
|
||||||
*/
|
*/
|
||||||
public class PlayerItemHeldEvent extends PlayerEvent {
|
public class PlayerItemHeldEvent extends PlayerEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
private final int previous;
|
private final int previous;
|
||||||
private final int current;
|
private final int current;
|
||||||
|
|
||||||
@ -35,6 +37,14 @@ public class PlayerItemHeldEvent extends PlayerEvent {
|
|||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
|
@ -102,6 +102,16 @@ public interface PlayerInventory extends Inventory {
|
|||||||
*/
|
*/
|
||||||
public int getHeldItemSlot();
|
public int getHeldItemSlot();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the slot number of the currently held item.
|
||||||
|
* <p>
|
||||||
|
* This validates whether the slot is between 0 and 8 inclusive.
|
||||||
|
*
|
||||||
|
* @param slot The new slot number
|
||||||
|
* @throws IllegalArgumentException Thrown if slot is not between 0 and 8 inclusive
|
||||||
|
*/
|
||||||
|
public void setHeldItemSlot(int slot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears all matching items from the inventory. Setting either value to -1 will skip it's check,
|
* Clears all matching items from the inventory. Setting either value to -1 will skip it's check,
|
||||||
* while setting both to -1 will clear all items in your inventory unconditionally.
|
* while setting both to -1 will clear all items in your inventory unconditionally.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user