mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-23 09:27:45 +01:00
Add Player#openBook(ItemStack) method
This PR adds the openBook(ItemStack) method to Player that allows opening a Material.WRITTEN_BOOK for a player on demand.
This commit is contained in:
parent
b7db6fba12
commit
649921e5ba
@ -108,6 +108,7 @@ import org.bukkit.event.player.PlayerRegisterChannelEvent;
|
|||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.event.player.PlayerUnregisterChannelEvent;
|
import org.bukkit.event.player.PlayerUnregisterChannelEvent;
|
||||||
import org.bukkit.inventory.InventoryView.Property;
|
import org.bukkit.inventory.InventoryView.Property;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.map.MapCursor;
|
import org.bukkit.map.MapCursor;
|
||||||
import org.bukkit.map.MapView;
|
import org.bukkit.map.MapView;
|
||||||
import org.bukkit.metadata.MetadataValue;
|
import org.bukkit.metadata.MetadataValue;
|
||||||
@ -1638,4 +1639,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
|
|
||||||
getHandle().server.getCommandDispatcher().a(getHandle());
|
getHandle().server.getCommandDispatcher().a(getHandle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openBook(ItemStack book) {
|
||||||
|
Validate.isTrue(book != null, "book == null");
|
||||||
|
Validate.isTrue(book.getType() == Material.WRITTEN_BOOK, "Book must be Material.WRITTEN_BOOK");
|
||||||
|
|
||||||
|
ItemStack hand = getInventory().getItemInMainHand();
|
||||||
|
getInventory().setItemInMainHand(book);
|
||||||
|
getHandle().a(org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(book), net.minecraft.server.EnumHand.MAIN_HAND); // PAIL rename openBook
|
||||||
|
getInventory().setItemInMainHand(hand);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user