当前位置: 首页>>代码示例>>Java>>正文


Java Material.WRITTEN_BOOK属性代码示例

本文整理汇总了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);
}
 
开发者ID:SamaGames,项目名称:SamaGamesAPI,代码行数:22,代码来源:ItemUtils.java

示例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();
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:25,代码来源:EventFilterMatchModule.java

示例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);
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:21,代码来源:CreateBullCommand.java

示例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;
}
 
开发者ID:cadox8,项目名称:PA,代码行数:17,代码来源:ItemUtil.java

示例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;
}
 
开发者ID:Jannyboy11,项目名称:CustomRecipes,代码行数:11,代码来源:BookCloneRecipe.java

示例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;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:11,代码来源:BukkitUtils.java

示例7: build

public ItemStack build() {
	ItemStack i = new ItemStack(Material.WRITTEN_BOOK, 1);

    this.createPages(this.pages);
	i.setItemMeta(this.bookMeta);
	return i;
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:7,代码来源:BookBuilder.java

示例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;
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:13,代码来源:FBull.java

示例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);
            }
        }
    }
}
 
开发者ID:cadox8,项目名称:PA,代码行数:29,代码来源:GameEvents.java

示例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);
        }
    }
}
 
开发者ID:SamaGames,项目名称:AgarMC,代码行数:37,代码来源:PlayerListener.java

示例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);
}
 
开发者ID:MohibMirza,项目名称:RPGPlus,代码行数:56,代码来源:JoinGUI.java

示例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);
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:5,代码来源:NMSHandler.java

示例13: BookBuilder

public BookBuilder() {
	ItemStack book = new ItemStack(Material.WRITTEN_BOOK, 1);
	BookMeta m = (BookMeta) book.getItemMeta();
	this.bookMeta = m;
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:5,代码来源:BookBuilder.java

示例14: ItemBook

public ItemBook(ItemStack item) {
    super(item);
    this.signed = item.getType() == Material.WRITTEN_BOOK;
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:4,代码来源:ItemBook.java

示例15: getRawStack

@Override
public ItemStack getRawStack() {
    return new ItemStack(isSigned() ? Material.WRITTEN_BOOK : Material.BOOK_AND_QUILL);
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:4,代码来源:ItemBook.java


注:本文中的org.bukkit.Material.WRITTEN_BOOK属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。