当前位置: 首页>>代码示例>>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;未经允许,请勿转载。