本文整理汇总了Java中org.bukkit.Material.WRITTEN_BOOK属性的典型用法代码示例。如果您正苦于以下问题:Java Material.WRITTEN_BOOK属性的具体用法?Java Material.WRITTEN_BOOK怎么用?Java Material.WRITTEN_BOOK使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.Material
的用法示例。
在下文中一共展示了Material.WRITTEN_BOOK属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openWrittenBook
/**
* Open the given written book
*
* @param book Written book
* @param player Player
*/
public static void openWrittenBook(ItemStack book, Player player)
{
if (book.getType() != Material.WRITTEN_BOOK)
return;
ItemStack previous = player.getInventory().getItemInHand();
player.getInventory().setItemInHand(book);
ByteBuf buffer = Unpooled.buffer(256);
buffer.setByte(0, (byte) 1);
buffer.writerIndex(1);
Reflection.sendPacket(player, new PacketPlayOutCustomPayload("MC|BOpen", new PacketDataSerializer(buffer)));
player.getInventory().setItemInHand(previous);
}
示例2: onInteract
@EventHandler(priority = EventPriority.HIGHEST)
public void onInteract(final PlayerInteractEvent event) {
if(cancelUnlessInteracting(event, event.getPlayer())) {
// Allow the how-to book to be read
if(event.getMaterial() == Material.WRITTEN_BOOK) {
event.setUseItemInHand(Event.Result.ALLOW);
} else {
event.setUseItemInHand(Event.Result.DENY);
event.setUseInteractedBlock(Event.Result.DENY);
}
MatchPlayer player = getMatch().getPlayer(event.getPlayer());
if(player == null) return;
if(!player.isSpawned()) {
ClickType clickType = convertClick(event.getAction(), event.getPlayer());
if(clickType == null) return;
getMatch().callEvent(new ObserverInteractEvent(player, clickType, event.getClickedBlock(), null, event.getItem()));
}
// Right-clicking armor will put it on unless we do this
event.getPlayer().updateInventory();
}
}
示例3: onExecute
@Override
public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender;
ItemStack item = player.getInventory().getItemInMainHand();
if (item == null || item.getType() != Material.WRITTEN_BOOK) {
displayHelp(player);
return;
}
String author = new String();
for (String arg : args) {
if (args[0] != arg) {
if (!author.isEmpty()) {
author += " ";
}
author += arg;
}
}
player.getInventory().addItem(FBull.create(item, author));
ParsingUtil.sendMessage(player, FMessage.CMD_CREATE_BULL_SUCCESS.getMessage(), author);
}
示例4: createBook
public static ItemStack createBook(String name, List<String> lore, String... pages) {
ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
BookMeta meta = (BookMeta) book.getItemMeta();
ItemMeta bookMeta = book.getItemMeta();
bookMeta.setDisplayName(Utils.colorize(name));
ArrayList<String> colorLore = new ArrayList<>();
if (lore != null) lore.forEach(str -> colorLore.add(Utils.colorize(str)));
bookMeta.setLore(colorLore);
meta.addPage(pages);
meta.setAuthor(Utils.colorize("&6ProjectAlpha"));
book.setItemMeta(bookMeta);
return book;
}
示例5: getRepresentation
/**
* {@inheritDoc}
*/
@Override
public default ItemStack getRepresentation() {
ItemStack stack = new ItemStack(Material.WRITTEN_BOOK);
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(ChatColor.GRAY + "Book Clone");
stack.setItemMeta(meta);
return stack;
}
示例6: generateBook
public static ItemStack generateBook(String title, String author, List<String> pages) {
ItemStack stack = new ItemStack(Material.WRITTEN_BOOK);
BookMeta meta = (BookMeta) factory.getItemMeta(Material.WRITTEN_BOOK);
meta.setTitle(title);
meta.setAuthor(author);
meta.setPages(pages);
stack.setItemMeta(meta);
return stack;
}
示例7: build
public ItemStack build() {
ItemStack i = new ItemStack(Material.WRITTEN_BOOK, 1);
this.createPages(this.pages);
i.setItemMeta(this.bookMeta);
return i;
}
示例8: create
public static ItemStack create(ItemStack item, String name) {
if (!(item.getItemMeta() instanceof BookMeta)) {
return null;
}
BookMeta meta = (BookMeta) item.getItemMeta();
meta.setAuthor(name);
meta.setTitle(meta.getTitle());
meta.setLore(Arrays.asList(FMessage.BULL_ID.getMessage(), FMessage.BULL_RIGHT_KLICK.getMessage()));
meta.setGeneration(Generation.ORIGINAL);
ItemStack bull = new ItemStack(Material.WRITTEN_BOOK);
bull.setItemMeta(meta);
return bull;
}
示例9: onInteract
@EventHandler
public void onInteract(PlayerInteractEvent e) {
final TOAUser u = TOA.getPlayer(e.getPlayer());
if (e.getItem() != null) {
Material m = e.getItem().getType();
if (m == Material.WRITTEN_BOOK || m == Material.BOW || m == Material.SHEARS || m == Material.DIAMOND_SWORD) return;
Ability.useAbility(u, e.getItem().getType());
e.setCancelled(true);
}
if (!u.isOnRank(PACmd.Grupo.Builder)) {
if (e.getClickedBlock() != null) {
if (e.getClickedBlock().getType().equals(Material.TRAP_DOOR) || e.getClickedBlock().getType().equals(Material.IRON_TRAPDOOR)
|| e.getClickedBlock().getType().equals(Material.FENCE_GATE) || e.getClickedBlock().getType().equals(Material.FIRE)
|| e.getClickedBlock().getType().equals(Material.CAULDRON) || e.getClickedBlock().getRelative(BlockFace.UP).getType().equals(Material.FIRE)
|| e.getClickedBlock().getType() == Material.CHEST || e.getClickedBlock().getType() == Material.TRAPPED_CHEST
|| e.getClickedBlock().getType() == Material.DROPPER || e.getClickedBlock().getType() == Material.DISPENSER
|| e.getClickedBlock().getType() == Material.BED_BLOCK || e.getClickedBlock().getType() == Material.BED
|| e.getClickedBlock().getType() == Material.WORKBENCH || e.getClickedBlock().getType() == Material.BREWING_STAND
|| e.getClickedBlock().getType() == Material.ANVIL || e.getClickedBlock().getType() == Material.DARK_OAK_FENCE_GATE
|| e.getClickedBlock().getType() == Material.SPRUCE_FENCE_GATE || e.getClickedBlock().getType() == Material.FURNACE
|| e.getClickedBlock().getType() == Material.BURNING_FURNACE || e.getClickedBlock().getType() == Material.HOPPER
|| e.getClickedBlock().getType() == Material.STONE_BUTTON || e.getClickedBlock().getType() == Material.WOOD_BUTTON) {
e.setCancelled(true);
}
}
}
}
示例10: onPlayerInteract
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
e.setCancelled(true);
e.getPlayer().updateInventory();
ItemStack item = e.getItem();
if(item == null) return;
Player player = e.getPlayer();
CPlayer cplayer = AgarMC.get().getGame().getCPlayer(player);
if(cplayer == null) return;
if(item.getType() == Material.WRITTEN_BOOK) {
e.setCancelled(false);
return ;
} else if(item.getType() == Material.WOOL) {
TeamSelectorGui.display(player);
} else if(item.getType() == SamaGamesAPI.get().getGameManager().getCoherenceMachine().getLeaveItem().getType()) {
SamaGamesAPI.get().getGameManager().kickPlayer(player, ChatColor.RED + "Vous avez quitté la partie");
}
if(!cplayer.isPlaying()) {
if(item.getType() == Material.NETHER_STAR) {
player.sendMessage(ChatColor.DARK_GREEN + "Vous entrez dans le jeu, bonne chance !");
cplayer.play();
}
} else {
if(item.getType() == Material.MAGMA_CREAM) {
cplayer.split();
} else if(item.getType() == Material.SLIME_BALL) {
cplayer.ejectMass();
} else if(item.getType() == Material.DIODE) {
MenuGui.display(player);
}
}
}
示例11: openJoinGUI
public static void openJoinGUI(Player p) {
inv = Bukkit.createInventory(null, 27, title);
List<String> WizardLore = new ArrayList<String>();
List<String> SwordsmanLore = new ArrayList<String>();
List<String> ArcherLore = new ArrayList<String>();
List<String> TopLore = new ArrayList<String>();
ItemStack WizardChoose = new ItemStack(Material.BLAZE_ROD);
ItemMeta WizardMeta = WizardChoose.getItemMeta();
ItemStack SwordsmanChoose = new ItemStack(Material.IRON_SWORD);
ItemMeta SwordsmanMeta = SwordsmanChoose.getItemMeta();
ItemStack ArcherChoose = new ItemStack(Material.BOW);
ItemMeta ArcherMeta = ArcherChoose.getItemMeta();
ItemStack Top = new ItemStack(Material.WRITTEN_BOOK);
ItemMeta TopMeta = Top.getItemMeta();
WizardMeta.setDisplayName(Main.colorThis("&9Wizard"));
WizardMeta.setLore(WizardLore);
WizardChoose.setItemMeta(WizardMeta);
TopMeta.setDisplayName(Main.colorThis("&c&lRealm of Mythos"));
SwordsmanMeta.setDisplayName(Main.colorThis("&4Swordsman"));
SwordsmanMeta.setLore(SwordsmanLore);
SwordsmanChoose.setItemMeta(SwordsmanMeta);
ArcherMeta.setDisplayName(Main.colorThis("&cArcher"));
ArcherMeta.setLore(ArcherLore);
ArcherChoose.setItemMeta(ArcherMeta);
TopMeta.setLore(TopLore);
Top.setItemMeta(TopMeta);
inv.setItem(4, Top);
inv.setItem(12, WizardChoose);
inv.setItem(13, SwordsmanChoose);
inv.setItem(14, ArcherChoose);
ItemStack block = new ItemStack(Material.STAINED_GLASS_PANE);
block.getItemMeta().setDisplayName("");
for(int i = 0; i < 27; i++){
if(i == 4 || i == 12 || i == 13 || i == 14){
}else{
inv.setItem(i, block);
}
}
p.openInventory(inv);
}
示例12: setBook
@Override
public ItemStack setBook(Tag item) {
Bukkit.getLogger().warning("Written books in schematics not supported with this version of server");
return new ItemStack(Material.WRITTEN_BOOK);
}
示例13: BookBuilder
public BookBuilder() {
ItemStack book = new ItemStack(Material.WRITTEN_BOOK, 1);
BookMeta m = (BookMeta) book.getItemMeta();
this.bookMeta = m;
}
示例14: ItemBook
public ItemBook(ItemStack item) {
super(item);
this.signed = item.getType() == Material.WRITTEN_BOOK;
}
示例15: getRawStack
@Override
public ItemStack getRawStack() {
return new ItemStack(isSigned() ? Material.WRITTEN_BOOK : Material.BOOK_AND_QUILL);
}