本文整理汇总了Java中org.bukkit.inventory.meta.BookMeta.addPage方法的典型用法代码示例。如果您正苦于以下问题:Java BookMeta.addPage方法的具体用法?Java BookMeta.addPage怎么用?Java BookMeta.addPage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.meta.BookMeta
的用法示例。
在下文中一共展示了BookMeta.addPage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSpellTome
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
public static ItemStack getSpellTome(String label, Player crafter) {
ItemStack i = new ItemStack(MATERIAL);
Spell spell = MystiCraft.getSpellManager().getSpell(label);
BookMeta meta = (BookMeta)i.getItemMeta();
meta.setDisplayName(DISPLAY_NAME + StringUtils.capitalize(label));
if (crafter != null)
meta.setAuthor(crafter.getName());
else
meta.setAuthor("unknown");
meta.setGeneration(Generation.TATTERED);
meta.setLore(Arrays.asList(new String[]{ChatColor.GRAY + spell.getDescription(), ChatColor.GRAY + "Mana Cost: " + spell.getManaCost()}));
// TODO Add description
meta.addPage("-------------------=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
i.setItemMeta(meta);
return i;
}
示例2: createBook
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
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;
}
示例3: parseBook
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
public static BookMeta parseBook(Element xml, BookMeta source) {
Element book = xml.getChild("book");
if (book != null) {
Attribute author = book.getAttribute("author");
if (author != null) {
source.setAuthor(parseMessage(author.getValue()));
}
Attribute title = book.getAttribute("title");
if (title != null) {
source.setTitle(parseMessage(title.getValue()));
}
for (Element page : book.getChildren("page")) {
source.addPage(parseMessage(page.getTextNormalize()));
}
}
return source;
}
示例4: linePageinate
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
public static void linePageinate(BookMeta meta, ArrayList<String> lines) {
/*
* 13 writeable lines per page, iterate through each line
* and place into the page, when the line count equals 14
* set it back to 0 and add page.
*/
int count = 0;
String page = "";
for (String line : lines) {
count++;
if (count > LINES_PER_PAGE) {
meta.addPage(page);
count = 0;
page = "";
}
page += line+"\n";
}
meta.addPage(page);
}
示例5: writeBook
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
/**
* 「逃走中」というタイトルの本に対してページを追加できます。<br>
* 汎用性をあげるために、権限による分別はしていません。(この本を持っている人のみが対象。逃走者以外でも可)
*
* @param msg ミッション告知用の本「逃走中」に追加するページ内容
*/
public void writeBook(String msg) {
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
for (ItemStack item : player.getInventory().getContents()) {
if (item != null) {
if (item.getType().equals(Material.WRITTEN_BOOK)) {
BookMeta meta = (BookMeta) item.getItemMeta();
if (meta.getTitle().equals("逃走中")) {
meta.addPage(msg);
item.setItemMeta(meta);
}
}
}
}
}
}
示例6: constructBook
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
public static ItemStack constructBook(ItemStack item, String title, String owner, String[] pages)
{
if (item.getItemMeta() instanceof BookMeta)
{
BookMeta meta = (BookMeta)item.getItemMeta();
if (title != null)
meta.setTitle(title);
if (owner != null)
meta.setAuthor(owner);
if (pages != null)
meta.addPage(pages);
item.setItemMeta(meta);
}
return item;
}
示例7: execute
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
@Override
protected void execute(Event e) {
if (book == null) return;
if (book.getSingle(e).getType() == Material.BOOK_AND_QUILL || book.getSingle(e).getType() == Material.WRITTEN_BOOK) {
BookMeta bookMeta = (BookMeta) book.getSingle(e).getItemMeta();
if (string != null) {
bookMeta.addPage(string.getSingle(e));
} else {
bookMeta.addPage();
}
book.getSingle(e).setItemMeta(bookMeta);
}
}
示例8: createSpellTome
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
public static ItemStack createSpellTome(Spell spell) {
ItemStack item = new ItemStack(Material.WRITTEN_BOOK);
BookMeta meta = (BookMeta) item.getItemMeta();
meta.setDisplayName(Language.get("item.spelltome.name", ChatColor.GOLD + "SpellTome"));
meta.setTitle(Language.get("item.spelltome.name", ChatColor.GOLD + "SpellTome"));
meta.setLore(Arrays.asList(ChatColor.GRAY + WordUtils.capitalize(spell.getName())));
meta.addPage(spell.getDescription()
+ "\n\n"
+ Language.get("item.spelltome.cast", "Cast this spell with " + ChatColor.DARK_AQUA + "/cast [SPELL]")
.replace("[SPELL]", WordUtils.capitalize(spell.getName())) + "\n\n"
+ Language.get("item.spelltome.learn", ChatColor.GRAY + "Learn this spell by left-clicking this book"));
item.setItemMeta(meta);
return item;
}
示例9: execute
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
@Override
public void execute(
final ConfigurableCommand command,
final Plugin plugin,
final CommandSender sender,
final String[] args) {
if (!(sender instanceof Player)) {
command.sendMessage(sender, NOT_PLAYER, "&4You must be a player to use this command");
return;
}
final ItemStack book = new ItemStack(Material.BOOK_AND_QUILL);
final BookMeta meta = (BookMeta)book.getItemMeta();
meta.addPage("EnchantmentAPI\nBy Eniripsa96\n\n Enchantment details");
meta.setAuthor("Eniripsa96");
meta.setTitle("EnchantmentAPI");
final ArrayList<CustomEnchantment> enchants = new ArrayList<>(EnchantmentAPI.getRegisteredEnchantments());
Collections.sort(enchants);
for (final CustomEnchantment enchantment : enchants) {
if (enchantment instanceof VanillaEnchantment) continue;
if (enchantment.getDescription() == null) continue;
StringBuilder page = new StringBuilder();
page.append(enchantment.getName()).append(" - ").append(enchantment.getDescription()).append("\n\nItems: ");
boolean first = true;
for (Material item : enchantment.getNaturalItems()) {
if (first) first = false;
else page.append(", ");
page.append(ItemManager.getVanillaName(item));
}
if (first) page.append("None");
meta.addPage(page.toString());
}
book.setItemMeta(meta);
((Player)sender).getInventory().addItem(book);
command.sendMessage(sender, SUCCESS, "&2You have received a book with all enchantment details");
}
示例10: ItemStuffer
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
/**
* Generate common stuff data.
*/
public ItemStuffer()
{
String[] mpages = new String[] {
"\n\n\n\n\n\n�c = BOUC-EMISSAIRE =\n -R�gles du jeu-\n -o-",
"�cBut du jeu:�0\nEtre le dernier joueur vivant.\n\n"
+ "�cBouc-�missaire:�0\nChaque meurtrier devient bouc-�missaire.\n\n"
+ "�cTP:�0\nUn joueur tir� au sort est TP au bouc-�missaire.",
"�c/!\\ TRICHE�0\n\nToute prise en flagrant d�lit de triche quelconque :"
+ "\n\n- X-Ray\n- FlyHack\n- etc.\n\nest punie d'un ban �4permanent�0 et �4irr�versible�0.",
"�cCOMMANDES:�0\n\n�c/votemap�0\nDemander un changement de map au lieu de commencer la partie.",
"\n\n\n\n\n\n �5 Bonne chance !",
};
String[] mpages_bonus = new String[] {
"\n\n\n\n\n\n Ne pas lire\n plus loin\n ...",
"\n\n\n\n\n\n The game.\n\n (On t'avait pr�venu)",
};
manual = new ItemStack(Material.WRITTEN_BOOK);
BookMeta bmeta = (BookMeta) manual.getItemMeta();
bmeta.setAuthor("�6E�flarcis");
bmeta.setTitle(MANUAL_TITLE);
bmeta.addPage(mpages);
manual.setItemMeta(bmeta);
bmeta.addPage(mpages_bonus);
manual_bonus = new ItemStack(manual);
manual_bonus.setItemMeta(bmeta);
spectating_compass = new ItemStack(Material.COMPASS);
ItemMeta cMeta = spectating_compass.getItemMeta();
cMeta.setDisplayName(ChatColor.BLUE + "Menu spectateur");
spectating_compass.setItemMeta(cMeta);
}
示例11: saveToBook
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
public static void saveToBook(BookMeta meta, String data, String dataTitle) {
int max;
int pageMax = 255 - _dataPre.length();
for (int i = 0, l = data.length(); i < l; i += max) {
max = (i == 0 ? pageMax - dataTitle.length() : pageMax);
meta.addPage((i == 0 ? dataTitle : "") + _dataPre + data.substring(i, (i + max > l ? l : i + max)));
}
}
示例12: getSpelltome
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
public static ItemStack getSpelltome(ISpell spell) {
ItemStack i = new ItemStack(Material.BOOK);
BookMeta m = (BookMeta) i.getItemMeta();
List<String> l = new ArrayList<String>();
l.add(ChatColor.GRAY + "" + spell);
m.setLore(l);
m.setTitle(spell.getDisplayName());
m.addPage(spell.getDesc() + "\n\n" + Lang.get("spelltome.cast").replace("[SPELL]", spell.getDisplayName())
+ "\n\n" + Lang.get("spelltome.learn"));
i.setItemMeta(m);
i.addEnchantment(Zephyrus.getInstance().glow, 1);
return i;
}
示例13: createItem
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
public void createItem(ItemStack i) {
setItemName(i, this.name());
BookMeta m = (BookMeta) i.getItemMeta();
List<String> l = new ArrayList<String>();
l.add(ChatColor.GRAY + "" + spell);
m.setLore(l);
m.setTitle(spell);
m.addPage(desc + "\n\n" + Lang.get("spelltome.cast").replace("[SPELL]", spell) + "\n\n"
+ Lang.get("spelltome.learn"));
i.setItemMeta(m);
setGlow(i);
}
示例14: getAsItem
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
/**
* Generates the journal as ItemStack
*
* @return the journal ItemStack
*/
public ItemStack getAsItem() {
// create the book with default title/author
ItemStack item = new ItemStack(Material.WRITTEN_BOOK);
BookMeta meta = (BookMeta) item.getItemMeta();
meta.setTitle(Config.getMessage(lang, "journal_title").replaceAll("&", "§"));
meta.setAuthor(PlayerConverter.getPlayer(playerID).getName());
List<String> lore = new ArrayList<String>();
lore.add(Config.getMessage(lang, "journal_lore").replaceAll("&", "§"));
meta.setLore(lore);
// add main page and generate pages from texts
List<String> finalList = new ArrayList<>();
if (Config.getString("config.journal.one_entry_per_page").equalsIgnoreCase("false")) {
String color = Config.getString("config.journal_colors.line");
StringBuilder stringBuilder = new StringBuilder();
for (String entry : getText()) {
stringBuilder.append(entry + "\n§" + color + "---------------\n");
}
if (mainPage != null && mainPage.length() > 0) {
if (Config.getString("config.journal.full_main_page").equalsIgnoreCase("true")) {
finalList.addAll(Utils.pagesFromString(mainPage));
} else {
stringBuilder.insert(0, mainPage + "\n§" + color + "---------------\n");
}
}
String wholeString = stringBuilder.toString().trim();
finalList.addAll(Utils.pagesFromString(wholeString));
} else {
if (mainPage != null && mainPage.length() > 0) {
finalList.addAll(Utils.pagesFromString(mainPage));
}
finalList.addAll(getText());
}
if (finalList.size() > 0) {
meta.setPages(finalList);
} else {
meta.addPage("");
}
item.setItemMeta(meta);
return item;
}
示例15: applyLobbyInventory
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
/**
* Apply lobby inventory.
*
* @param player the player
*/
@SuppressWarnings("deprecation")
public static void applyLobbyInventory(final Player player) {
ItemStack[] contents = new ItemStack[36];
ItemStack[] armor = new ItemStack[4];
ItemStack bo = new ItemStack(Material.WRITTEN_BOOK);
BookMeta im = (BookMeta) bo.getItemMeta();
im.setDisplayName(Col.Green() + "Welcome To Super Sky Bros");
im.setAuthor(Col.Gold() + "Relicum");
im.setTitle(Col.Aqua() + "Super Sky Bros");
List<String> page = new ArrayList<>();
page.add(Col.Blue() + "Welcome to SuperSkyBros");
page.add(Col.Blue() + "Please read for more details");
String[] strpage = new String[page.size()];
page.toArray(strpage);
im.addPage(page.toArray(strpage));
bo.setItemMeta(im);
ItemStack em = new ItemStack(Material.EMERALD);
ItemMeta iem = em.getItemMeta();
iem.setDisplayName(Col.Green() + "Class Shop");
List<String> lo = new ArrayList<>();
lo.add(Col.Light_Purple() + "Not Currently Open");
lo.add(Col.Light_Purple() + "Hope to be open soon");
iem.setLore(lo);
em.setItemMeta(iem);
contents[0] = bo;
contents[8] = em;
player.getInventory().setContents(contents);
player.getInventory().setArmorContents(armor);
player.closeInventory();
Bukkit.getServer().getScheduler().runTask(SkyApi.getSCB(), new Runnable() {
@Override
public void run() {
player.updateInventory();
}
});
}