本文整理汇总了Java中org.bukkit.inventory.meta.BookMeta.getPages方法的典型用法代码示例。如果您正苦于以下问题:Java BookMeta.getPages方法的具体用法?Java BookMeta.getPages怎么用?Java BookMeta.getPages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.meta.BookMeta
的用法示例。
在下文中一共展示了BookMeta.getPages方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveWikiBook
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
public static void saveWikiBook()
{
String path = "plugins/Breakpoint/wikiBook/";
BookMeta im = (BookMeta) InventoryMenuManager.wikiBook.getItemMeta();
List<String> contents = im.getPages();
for (int page = 0; page < contents.size(); page++)
{
File file = new File(path + page + ".txt");
File pathFile = new File(path);
pathFile.mkdirs();
try
{
if (!file.exists())
file.createNewFile();
setString(file, contents.get(page));
}
catch (IOException e)
{
Breakpoint.warn("Wiki book did not save properly.");
e.printStackTrace();
}
}
}
示例2: check
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
private void check(Player player, ItemStack book) {
if (this.playerToItemStack.containsKey(player.getName())) {
ItemStack wand = null;
if (book.getItemMeta() instanceof BookMeta) {
BookMeta meta = (BookMeta) book.getItemMeta();
List<String> code = meta.getPages();
wand = this.playerToItemStack.get(player.getName());
ItemMeta itemMeta = wand.getItemMeta();
itemMeta.setLore(code);
wand.setItemMeta(itemMeta);
}
player.getPlayer().setItemInHand(wand);
this.playerToItemStack.remove(player.getName());
}
}
示例3: getBookMetaString
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
private static String getBookMetaString(final BookMeta meta) {
final String author = meta.getAuthor();
final String title = meta.getTitle();
final List<String> pages = meta.getPages();
final List<String> stringList = new ArrayList<>();
stringList.add(title);
stringList.add(author);
stringList.addAll(pages);
final String separator = StringUtil.getPossibleSeparator(stringList, 2);
final StringBuilder builder = new StringBuilder();
for (final String string : stringList) {
builder.append(separator).append(string);
}
return builder.toString();
}
示例4: setFrom
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
@Override
public SubMeta setFrom(ItemMeta meta) {
if(meta instanceof BookMeta)
{
BookMeta metaSub = (BookMeta) meta;
author = metaSub.getAuthor();
page = metaSub.getPages();
}
return this;
}
示例5: getItem
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private Item getItem(ItemStack is, Byte slot) {
byte count = (byte) is.getAmount();
short damage = (short) is.getData().getData();
short itemid = (short) is.getTypeId();
ItemTag itemtag = null;
if (is.hasItemMeta()) {
List<Ench> enchants = null;
ItemMeta im = is.getItemMeta();
Map<Enchantment, Integer> isEnchants = im.getEnchants();
if (isEnchants != null) {
enchants = new ArrayList<>();
for (Enchantment ench : isEnchants.keySet()) {
enchants.add(new Ench((short) ench.getId(), isEnchants.get(ench).shortValue()));
}
}
List<String> lore = im.getLore();
String name = im.getDisplayName();
Display display = new Display(name, lore);
String author = null;
String title = null;
List<String> pages = null;
if (im instanceof BookMeta) {
BookMeta bm = (BookMeta) im;
author = bm.getAuthor();
title = bm.getTitle();
pages = bm.getPages();
}
itemtag = new ItemTag(0, enchants, display, author, title, pages);
}
return new Item(count, slot, damage, itemid, itemtag);
}
示例6: CardboardMetaBook
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public CardboardMetaBook(ItemStack book) {
BookMeta meta = (BookMeta) book.getItemMeta();
this.id = book.getTypeId();
this.title = meta.getTitle();
this.author = meta.getAuthor();
this.pages = meta.getPages();
}
示例7: CardboardMetaBook
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
public CardboardMetaBook(ItemStack book) {
BookMeta meta = (BookMeta) book.getItemMeta();
this.id = book.getTypeId();
this.title = meta.getTitle();
this.author = meta.getAuthor();
this.pages = meta.getPages();
}
示例8: apply
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
@Override
public boolean apply(ItemStack itemStack, ItemMetaValue meta) {
PreCon.notNull(itemStack);
PreCon.notNull(meta);
ItemMeta itemMeta = itemStack.getItemMeta();
if (!(itemMeta instanceof BookMeta))
return false;
BookMeta bookMeta = (BookMeta)itemMeta;
List<String> pages = bookMeta.getPages();
List<String> newPages = pages == null
? new ArrayList<String>(5)
: new ArrayList<String>(pages.size() + 1);
if (pages != null) {
for (String page : pages) {
newPages.add(page);
}
}
newPages.add(meta.getRawData());
bookMeta.setPages(newPages);
itemStack.setItemMeta(bookMeta);
return true;
}
示例9: initialize
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
@Override
public SerialItemData initialize(ItemStack stack) {
ItemMeta meta = stack.getItemMeta();
if(meta instanceof BookMeta) {
BookMeta bookMeta = (BookMeta)meta;
valid = true;
title = bookMeta.getTitle();
author = bookMeta.getAuthor();
pages = bookMeta.getPages();
}
return this;
}
示例10: getPlateResult
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
private NamedItemStack getPlateResult() {
for (ItemStack stack : getInventory().getContents()) {
if (stack == null) {
continue;
}
if (stack.getType().equals(Material.BOOK_AND_QUILL) ||
stack.getType().equals(Material.WRITTEN_BOOK)) {
ItemMeta meta = stack.getItemMeta();
if (meta instanceof BookMeta) {
// Found a book
BookMeta bookData = (BookMeta) meta;
String title = bookData.getTitle();
String author = bookData.getAuthor();
if (author == null) {
author = "";
}
List<String> pages = new ArrayList<String>(bookData.getPages());
NamedItemStack plates = new NamedItemStack(Material.WRITTEN_BOOK, 1, (short) 0, "plate");
BookMeta plateMeta = (BookMeta) plates.getItemMeta();
plateMeta.setTitle(title);
plateMeta.setAuthor(author);
plateMeta.setPages(pages);
int watermark = new Random().nextInt(9000) + 1000;
List<String> lore = new ArrayList<String>();
lore.add("Print plates #" + Integer.toString(watermark));
plateMeta.setLore(lore);
plates.setItemMeta(plateMeta);
return plates;
}
}
}
return null;
}
示例11: PrintResult
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
PrintResult() {
Pattern printPlateRE = Pattern.compile("^Print plates #([0-9]{4})$");
Inventory inventory = getInventory();
title = "";
author = "";
watermark = 0;
valid = false;
pages = new ArrayList<String>();
for (ItemStack stack : inventory.getContents()) {
if (stack == null) {
continue;
}
if (stack.getType().equals(Material.BOOK_AND_QUILL) ||
stack.getType().equals(Material.WRITTEN_BOOK)) {
ItemMeta meta = stack.getItemMeta();
List<String> lore = meta.getLore();
if (lore != null && !lore.isEmpty()) {
String firstLore = lore.get(0);
Matcher match = printPlateRE.matcher(firstLore);
if (match.matches()) {
if (meta instanceof BookMeta) {
BookMeta bookData = (BookMeta) meta;
title = bookData.getTitle();
author = bookData.getAuthor();
if (author == null) {
author = "";
}
watermark = Integer.parseInt(match.group(1));
pages = new ArrayList<String>(bookData.getPages());
valid = true;
break;
}
}
}
}
}
}
示例12: getBookTextArray
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
public static List<String> getBookTextArray(final ItemStack book, final boolean byline) {
if (! book.hasItemMeta() || !(book.getItemMeta() instanceof BookMeta))
return null;
final BookMeta meta = (BookMeta) book.getItemMeta();
final List<String> out = new ArrayList<String>(meta.getPages());
if (byline && meta.hasTitle())
out.add(0, meta.getTitle() + (meta.hasAuthor() ? " by " + meta.getAuthor() : ""));
return out;
}
示例13: getMeta
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
@Override
public List<ItemMetaValue> getMeta(ItemStack itemStack) {
PreCon.notNull(itemStack);
ItemMeta itemMeta = itemStack.getItemMeta();
if (!(itemMeta instanceof BookMeta))
return new ArrayList<>(0);
BookMeta bookMeta = (BookMeta)itemMeta;
List<String> pages = bookMeta.getPages();
if (pages == null || pages.isEmpty())
return new ArrayList<>(0);
List<ItemMetaValue> result = new ArrayList<>(pages.size());
for (String page : pages) {
result.add(new ItemMetaValue(getMetaName(), page));
}
itemStack.setItemMeta(bookMeta);
return result;
}
示例14: onCommand
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if (args.length >= 1) {
if (args[0].equalsIgnoreCase("create")) {
for (ItemStack remainder : player.getInventory().addItem(new ItemStack(Material.BOOK_AND_QUILL, 1)).values()) {
player.getWorld().dropItem(player.getLocation(), remainder);
}
sender.sendMessage(plugin.getPrefix() + ChatColor.GREEN + "Please write your issue in the book, titling it with the title of the issue, then use /issue submit [plugin] with the book in hand when done.");
} else if (args[0].equalsIgnoreCase("submit")) {
if (player.getInventory().getItemInMainHand() != null) {
if (player.getInventory().getItemInMainHand().hasItemMeta()) {
if (player.getInventory().getItemInMainHand().getItemMeta() instanceof BookMeta) {
BookMeta meta = (BookMeta) player.getInventory().getItemInMainHand().getItemMeta();
StringBuilder issueBody = new StringBuilder();
for (String pageText : meta.getPages()) {
issueBody.append("> ").append(pageText.replace("\n", "\n> ")).append('\n');
}
issueBody.append("> — ").append(sender.getName()).append("\n");
try {
GHRepository repo = plugin.getGitHub().getRepository("WaywardRealms/Wayward");
GHIssue issue = repo.createIssue(meta.hasTitle() ? meta.getTitle() : "Issue").body(issueBody.toString()).create();
player.getInventory().setItemInMainHand(null);
sender.sendMessage(plugin.getPrefix() + ChatColor.GREEN + "Issue submitted. Thank you!");
sender.sendMessage(plugin.getPrefix() + ChatColor.GREEN + "You can view it at " + issue.getUrl().toString());
} catch (IOException exception) {
sender.sendMessage(plugin.getPrefix() + ChatColor.RED + "Failed to create issue.");
exception.printStackTrace();
}
} else {
sender.sendMessage(plugin.getPrefix() + ChatColor.RED + "You must be holding a book in order to create an issue.");
}
} else {
sender.sendMessage(plugin.getPrefix() + ChatColor.RED + "You must be holding a book in order to create an issue.");
}
} else {
sender.sendMessage(plugin.getPrefix() + ChatColor.RED + "You must be holding a book in order to create an issue.");
}
} else {
sender.sendMessage(plugin.getPrefix() + ChatColor.RED + "Usage: /issue [submit|create]");
}
} else {
sender.sendMessage(plugin.getPrefix() + ChatColor.RED + "Usage: /issue [submit|create]");
}
} else {
sender.sendMessage(plugin.getPrefix() + ChatColor.RED + "You must be a player to report issues.");
}
return true;
}