當前位置: 首頁>>代碼示例>>Java>>正文


Java BookMeta.setPages方法代碼示例

本文整理匯總了Java中org.bukkit.inventory.meta.BookMeta.setPages方法的典型用法代碼示例。如果您正苦於以下問題:Java BookMeta.setPages方法的具體用法?Java BookMeta.setPages怎麽用?Java BookMeta.setPages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.inventory.meta.BookMeta的用法示例。


在下文中一共展示了BookMeta.setPages方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadWikiBook

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
public static BookMeta loadWikiBook(BookMeta im)
{
	String path = "plugins/Breakpoint/wikiBook/";
	List<String> contents = new ArrayList<String>();
	int page = 0;
	File file = new File(path + page + ".txt");
	while (file.exists())
	{
		String pageContent = getString(file);
		contents.add(pageContent);
		page++;
		file = new File(path + page + ".txt");
	}
	im.setPages(contents);
	
	return im;
}
 
開發者ID:Limeth,項目名稱:Breakpoint,代碼行數:18,代碼來源:FileManager.java

示例2: setbookunsigned

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
@SubCommand(value = "setbookunsigned", permission = "nu.setbook")
public void setbookunsigned(CommandSender sender, Arguments args) {
    Player p = asPlayer(sender);
    ItemStack item = p.getInventory().getItemInMainHand();
    if (item == null || !item.getType().equals(Material.WRITTEN_BOOK)) {
        msg(sender, "user.setbook.no_book");
        return;
    }
    BookMeta meta = (BookMeta) item.getItemMeta();
    ItemStack newbook = new ItemStack(Material.BOOK_AND_QUILL, 1);
    BookMeta newbookMeta = (BookMeta) newbook.getItemMeta();
    newbookMeta.setPages(meta.getPages());
    newbook.setItemMeta(newbookMeta);
    p.getInventory().setItemInMainHand(newbook);
    msg(sender, "user.setbook.success");
}
 
開發者ID:NyaaCat,項目名稱:NyaaUtils,代碼行數:17,代碼來源:CommandHandler.java

示例3: getSpellTome

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
public static ItemStack getSpellTome(Spell spell, User user) {
	ItemStack stack = new ItemStack(Material.WRITTEN_BOOK);
	BookMeta meta = (BookMeta) stack.getItemMeta();

	StringBuilder page = new StringBuilder();

	page.append("Spell: " + spell.getName() + "\n");
	page.append(spell.getDescription() + "\n");
	page.append("Mana Cost: " + spell.getManaCost());
	page.append("\n\n");
	page.append("Cast this spell with /cast " + WordUtils.capitalize(spell.getName()) + "\n\n");
	page.append("Learn this spell by left clicking the book");

	meta.setPages(page.toString());
	meta.setAuthor(user.<Player> getPlayer().getName());
	meta.setDisplayName(ChatColor.GOLD + "Spell Tome" + ChatColor.GRAY + SEPERATOR
			+ WordUtils.capitalize(spell.getName()));
	meta.setLore(Lists.newArrayList(ChatColor.GRAY + "Learn by left clicking"));
	stack.setItemMeta(meta);
	return stack;
}
 
開發者ID:mcardy,項目名稱:Zephyr,代碼行數:22,代碼來源:SpellTome.java

示例4: setBookPages

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
/**
 * Adds pages to the BookMeta. A Spigot commit in the late days of Minecraft 1.11.2 started enforcing extremely low
 * limits (why? If it's not broken, don't fix it.), with books limited in page size and total number of pages, as
 * well as title length. This function bypasses such limits and restores the original CraftBukkit behaviour. See
 * https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/4acd0f49e07e0912096e79494472535baf0db2ab
 * for more information.
 *
 * @param bookPages
 * @param bookMeta
 */
@SuppressWarnings("unchecked")
private void setBookPages(List<String> bookPages, BookMeta bookMeta) {
	if (plugin.getServerVersion() >= 11) {
		try {
			// Code we're trying to execute: this.pages.add(CraftChatMessage.fromString(page, true)[0]); in
			// CraftMetaBook.java.
			Class<?> craftMetaBookClass = PackageType.CRAFTBUKKIT
					.getClass(PACKAGE_INVENTORY + "." + CLASS_CRAFT_META_BOOK);
			List<Object> pages = (List<Object>) craftMetaBookClass.getField(FIELD_PAGES)
					.get(craftMetaBookClass.cast(bookMeta));
			Method fromStringMethod = PackageType.CRAFTBUKKIT
					.getClass(PACKAGE_UTIL + "." + CLASS_CRAFT_CHAT_MESSAGE)
					.getMethod(METHOD_FROM_STRING, String.class, boolean.class);
			for (String bookPage : bookPages) {
				pages.add(((Object[]) fromStringMethod.invoke(null, bookPage, true))[0]);
			}
		} catch (Exception e) {
			plugin.getLogger().warning(
					"Error while creating book pages. Your achievements book may be trimmed down to 50 pages.");
			bookMeta.setPages(bookPages);
		}
	} else {
		bookMeta.setPages(bookPages);
	}
}
 
開發者ID:PyvesB,項目名稱:AdvancedAchievements,代碼行數:36,代碼來源:BookCommand.java

示例5: sendBook

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
private void sendBook( CommandSender sender, String title, List<String> pages ) {

		if ( !(sender instanceof Player) ) {
			sender.sendMessage( ChatColor.YELLOW + "We are unable to give you a debug book. :(" );
			return;
		}

		pages = pages.stream().map( page -> ChatColor.translateAlternateColorCodes( '&', page ) ).collect( Collectors.toList() );

		ItemStack is = new ItemStack( Material.WRITTEN_BOOK, 1 );
		BookMeta bookMeta = ((BookMeta) is.getItemMeta());

		bookMeta.setAuthor( ChatColor.GREEN.toString() + ChatColor.BOLD + "Minecraftly" );
		bookMeta.setTitle( ChatColor.GOLD.toString() + ChatColor.BOLD + "Debugging Book || " + title );
		bookMeta.setGeneration( BookMeta.Generation.ORIGINAL );
		bookMeta.setPages( pages );

		is.setItemMeta( bookMeta );

		Player player = ((Player) sender);
		player.getWorld().dropItem( player.getLocation().add( 0, 1, 0 ), is );
		player.playSound( player.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1, 1 );

	}
 
開發者ID:nguyenexpeditions,項目名稱:kosmos,代碼行數:25,代碼來源:DebugCommand.java

示例6: clearBook

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
/**
 * ミッション告知用の本の內容をすべて削除します。
 */
public void clearBook() {
    for (Player player : Bukkit.getServer().getOnlinePlayers()) {
        for (ItemStack item : player.getInventory().getContents()) {
            if (item == null) {
                return;
            }
            if (item.getType().equals(Material.WRITTEN_BOOK)) {
                BookMeta meta = (BookMeta) item.getItemMeta();
                if (meta.getTitle().equals("逃走中")) {
                    List<String> list = new ArrayList<String>();
                    meta.setPages(list);
                    item.setItemMeta(meta);
                }
            }
        }
    }
}
 
開發者ID:pekomiya,項目名稱:TosoGame3,代碼行數:21,代碼來源:BookAPI.java

示例7: UpgradeItem

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
public UpgradeItem(SQTechDrill plugin)
{
	this.main = plugin;
	upgradeItem = new ItemStack(Material.WRITTEN_BOOK);
	
	BookMeta bookMeta = (BookMeta) upgradeItem.getItemMeta();
	//bookMeta.setDisplayName(ChatColor.BLUE + "" + ChatColor.ITALIC + "Drill Upgrade");
	bookMeta.setAuthor(ChatColor.AQUA + "Drill");
	bookMeta.setPages("Test pgae 1\n s","asgsgge 2");
	bookMeta.setGeneration(BookMeta.Generation.ORIGINAL);
	bookMeta.setTitle(ChatColor.BLUE + "" + ChatColor.ITALIC + "Drill Upgrade");
	upgradeItem.setItemMeta(bookMeta);
	
	ShapelessRecipe recipe = new ShapelessRecipe(upgradeItem);
	
	//TODO temp recipe
	recipe.addIngredient(Material.DIRT); //Adds the specified ingredient.
	
	main.getServer().addRecipe(recipe);
}
 
開發者ID:StarQuestMinecraft,項目名稱:StarQuestCode,代碼行數:21,代碼來源:UpgradeItem.java

示例8: getTP

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
private boolean getTP(CommandSender sender, Command cmd, String label, String[] args) {
    if (sender instanceof Player) {
        if (sender.hasPermission("cpu.command.gettp")) {
            Player player = (Player) sender;
            Location location = player.getLocation();
            ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
            BookMeta bookMeta = (BookMeta) book.getItemMeta();

            bookMeta.setTitle("Destination");
            bookMeta.setPages(Arrays.asList(location.getWorld().getName() + " " + location.getX() + " " + location.getY() + " " + location.getZ() + " " + location.getYaw() + " " + location.getPitch()));
            book.setItemMeta(bookMeta);
            player.getInventory().addItem(book);
            return true;
        }
        sender.sendMessage(ChatColor.RED + "[CPU] You do not have enough permission to run this command!");
        return true;
    }
    sender.sendMessage(ChatColor.RED + "[CPU] Only players can get the teleport coordinates!");
    return true;
}
 
開發者ID:waicool20,項目名稱:CPU,代碼行數:21,代碼來源:Commands.java

示例9: giveItem

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
public void giveItem(Player ply, Registration plugin) {
	ItemStack i = new ItemStack(Material.WRITTEN_BOOK);
	
	ItemFactory itemFactory = plugin.getServer().getItemFactory();
	
	BookMeta bookMeta = (BookMeta) itemFactory.getItemMeta(Material.WRITTEN_BOOK);
	
	bookMeta.setTitle("The Manual");
	bookMeta.setAuthor("Shank");
	bookMeta.setPages("Welcome to BlockShock, a ShankShock Production.\n\nThis manual contains the rules, commands, and basics for surviving on the server.\n\nMore info @ ShankShock.Com.",
			"## The Rules\n\n1. No chat spamming.\n2. No hacking mods.\n3. Don't steal, break, or cause grief to any player or their creations.\n4. Don't ask for admin.\n5. Don't advertise.\n6. Respect all players.",
			"## Commands\n\n1. The usual home/warp commands.\n2. /inventory\n3. /shop\n4. /name",
			"## Mods\n\nExplosions & TNT are disabled. Creepers can't break your stuff. You can't drown. Falling damage and fire spread are disabled too.",
			"## Conversations\n\nSome commands, such as the inventory and shop commands, will take over your chat box. Simply type a response to what they ask for to use them. You can always exit with /quit.",
			"## Exiting Spawn\n\nTo exit spawn, simply warp to another location.\n\n/warp ShadowVale",
			"## Help\n\nAdmins have light blue name colors in chat. The owners are dark red and cyan. You can ask them for any help you need, though they don't have to give it. Admins aren't your slaves.",
			"## More Info\n\nMore information can be found at:\n\nwiki.shankshock.com\nshankshock.com");
	
	i.setItemMeta(bookMeta);
	
	ply.getInventory().addItem(i);
}
 
開發者ID:hakusaro,項目名稱:ShankShock-Core,代碼行數:23,代碼來源:RuleBookItem.java

示例10: getBook

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
/**
 * Get book
 * 
 * @param document
 * @return
 */
private ItemStack getBook(Document document)
{   
    ItemStack book = new ItemStack(Material.BOOK_AND_QUILL);
    
    BookMeta bookMeta = (BookMeta)book.getItemMeta();
    
    String id = document.getId();
    String author = (String)document.getPropertyValue(PropertyIds.CREATED_BY);
    String name = document.getName();
    
    ContentCraftPlugin.logger.info("Setting document meta-data - " + id + "," + name + "," + author);
    
    bookMeta.setDisplayName(name);        
    bookMeta.setAuthor(author);        
    bookMeta.setLocalizedName(id);
    
    String content = CommonUtil.getContentAsString(document.getContentStream());  
    List<String> pages = CommonUtil.split(content, 16, 265);
    bookMeta.setPages(pages);   
    
    book.setItemMeta(bookMeta);
    
    return book;
}
 
開發者ID:rwetherall,項目名稱:ContentCraft,代碼行數:31,代碼來源:ChestListener.java

示例11: MythicTome

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
/**
 * Instantiates a new MythicTome with a specified {@link MaterialData} of a {@link TomeType}. It is also
 * instantiated with a specified title and author, specified lore and pages.
 *
 * @param tomeType Type of tome to create
 * @param title Name of the tome
 * @param author Author of the tome
 * @param lore Lore of the tome
 * @param pages Pages for the tome
 */
public MythicTome(TomeType tomeType, String title, String author, List<String> lore,
    String[] pages) {
  super(tomeType.toMaterial());
  ItemMeta itemMeta = getItemMeta();
  List<String> coloredLore = new ArrayList<>();
  for (String s : lore) {
    coloredLore.add(s.replace('&', '\u00A7').replace("\u00A7\u00A7", "&"));
  }
  if (itemMeta instanceof BookMeta) {
    BookMeta bookMeta = (BookMeta) itemMeta;
    bookMeta.setTitle(title.replace('&', '\u00A7').replace("\u00A7\u00A7", "&"));
    bookMeta.setAuthor(author);
    bookMeta.setLore(coloredLore);
    bookMeta.setPages(pages);
    setItemMeta(bookMeta);
  } else {
    itemMeta.setDisplayName(title.replace('&', '\u00A7').replace("\u00A7\u00A7", "&"));
    itemMeta.setLore(coloredLore);
    setItemMeta(itemMeta);
  }
  setAmount(1);
}
 
開發者ID:Nunnery,項目名稱:MythicDrops,代碼行數:33,代碼來源:MythicTome.java

示例12: generateBook

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
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,代碼行數:12,代碼來源:BukkitUtils.java

示例13: removeBookContent

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
/**
 * Get a clone of the item where all book pages are removed
 * if not a book, then the same item is returned
 *
 * @param item the book
 * @return book without contents.
 */
public ItemStack removeBookContent(ItemStack item) {
    if (item.hasItemMeta() && item.getItemMeta() instanceof BookMeta) {
        ItemStack itemStack = item.clone();
        BookMeta meta = (BookMeta) itemStack.getItemMeta();
        meta.setPages(new ArrayList<String>());
        itemStack.setItemMeta(meta);
        return itemStack;
    }
    return item;
}
 
開發者ID:NyaaCat,項目名稱:NyaaCore,代碼行數:18,代碼來源:Message.java

示例14: setTo

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
@Override
public void setTo(ItemMeta meta) {
    if(meta instanceof BookMeta){
        BookMeta metaSub = (BookMeta) meta;
        metaSub.setAuthor(author);
        metaSub.setPages(page);
    }
}
 
開發者ID:DevCrafters,項目名稱:SaveableSerializing,代碼行數:9,代碼來源:SaveableBookMeta.java

示例15: get

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
@Override
protected ItemStack[] get(Event event) {
	ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
	BookMeta meta = (BookMeta) book.getItemMeta();
	meta.setTitle(title.getSingle(event));
	meta.setAuthor(author.getSingle(event));
	meta.setPages(texts.getArray(event));
	book.setItemMeta(meta);
	return new ItemStack[]{book};
}
 
開發者ID:MundoSK,項目名稱:MundoSK,代碼行數:11,代碼來源:ExprBook.java


注:本文中的org.bukkit.inventory.meta.BookMeta.setPages方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。