mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-13 11:18:23 +01:00
SPIGOT-4889: Add PlayerTakeLecternBookEvent
By: Brokkonaut <hannos17@gmx.de>
This commit is contained in:
parent
a3e5b8bdf0
commit
4952796313
1 changed files with 67 additions and 0 deletions
|
@ -0,0 +1,67 @@
|
|||
package org.bukkit.event.player;
|
||||
|
||||
import org.bukkit.block.Lectern;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* This event is called when a player clicks the button to take a book of a
|
||||
* Lectern. If this event is cancelled the book remains on the lectern.
|
||||
*/
|
||||
public class PlayerTakeLecternBookEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
//
|
||||
private boolean cancelled;
|
||||
private final Lectern lectern;
|
||||
|
||||
public PlayerTakeLecternBookEvent(@NotNull Player who, @NotNull Lectern lectern) {
|
||||
super(who);
|
||||
this.lectern = lectern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the lectern involved.
|
||||
*
|
||||
* @return the Lectern
|
||||
*/
|
||||
@NotNull
|
||||
public Lectern getLectern() {
|
||||
return lectern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current ItemStack on the lectern.
|
||||
*
|
||||
* @return the ItemStack on the Lectern
|
||||
*/
|
||||
@Nullable
|
||||
public ItemStack getBook() {
|
||||
return lectern.getInventory().getItem(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue