本文整理汇总了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;
}
示例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");
}
示例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;
}
示例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);
}
}
示例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 );
}
示例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);
}
}
}
}
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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};
}