本文整理汇总了Java中org.bukkit.inventory.meta.BookMeta.setLore方法的典型用法代码示例。如果您正苦于以下问题:Java BookMeta.setLore方法的具体用法?Java BookMeta.setLore怎么用?Java BookMeta.setLore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.meta.BookMeta
的用法示例。
在下文中一共展示了BookMeta.setLore方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: 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);
}
示例4: create
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
public static ItemStack create(ItemStack item, String name) {
if (!(item.getItemMeta() instanceof BookMeta)) {
return null;
}
BookMeta meta = (BookMeta) item.getItemMeta();
meta.setAuthor(name);
meta.setTitle(meta.getTitle());
meta.setLore(Arrays.asList(FMessage.BULL_ID.getMessage(), FMessage.BULL_RIGHT_KLICK.getMessage()));
meta.setGeneration(Generation.ORIGINAL);
ItemStack bull = new ItemStack(Material.WRITTEN_BOOK);
bull.setItemMeta(meta);
return bull;
}
示例5: fillBook
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
/**
* Constructs the pages of a book.
*
* @param achievements
* @param player
*/
private void fillBook(List<AwardedDBAchievement> achievements, Player player) {
ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
List<String> bookPages = new ArrayList<>(achievements.size());
BookMeta bookMeta = (BookMeta) book.getItemMeta();
for (AwardedDBAchievement achievement : achievements) {
String currentAchievement = "&0" + achievement.getName()
+ configBookSeparator + achievement.getMessage()
+ configBookSeparator + achievement.getFormattedDate();
currentAchievement = translateColorCodes(currentAchievement);
bookPages.add(currentAchievement);
}
if (bookPages.isEmpty()) {
player.sendMessage(langBookNotReceived);
return;
}
// Set the pages and other elements of the book (author, title and date of reception).
setBookPages(bookPages, bookMeta);
bookMeta.setAuthor(player.getName());
bookMeta.setTitle(langBookName);
bookMeta.setLore(Arrays
.asList(StringUtils.replaceOnce(langBookDate, "DATE", dateFormat.format(System.currentTimeMillis()))));
book.setItemMeta(bookMeta);
// Check whether player has room in his inventory, else drop book on the ground.
if (player.getInventory().firstEmpty() != -1) {
player.getInventory().addItem(book);
} else {
player.getWorld().dropItem(player.getLocation(), book);
}
player.sendMessage(langBookReceived);
}
示例6: onPlayerDeath
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
@Override
public void onPlayerDeath(EntityDeathEvent event, ItemStack stack) {
Player player = (Player)event.getEntity();
Resident resident = CivGlobal.getResident(player);
if (resident == null || !resident.hasTown()) {
return;
}
ArrayList<String> bookout = MissionLogger.getMissionLogs(resident.getTown());
ItemStack book = new ItemStack(Material.WRITTEN_BOOK, 1);
BookMeta meta = (BookMeta) book.getItemMeta();
ArrayList<String> lore = new ArrayList<String>();
lore.add("Mission Report");
meta.setAuthor("Mission Reports");
meta.setTitle("Missions From "+resident.getTown().getName());
String out = "";
for (String str : bookout) {
out += str+"\n";
}
BookUtil.paginate(meta, out);
meta.setLore(lore);
book.setItemMeta(meta);
player.getWorld().dropItem(player.getLocation(), book);
}
示例7: 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;
}
示例8: createBook
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
/**
* Creates a book with the given variables.
*
* @param title the title of the new book.
* @param author the author of the new book.
* @param pages the pages of the new book.
* @param lore the lore of the new book.
* @return the ItemStack of the newly created book.
*/
public static ItemStack createBook(String title, String author, List<String> pages, List<String> lore) {
ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
BookMeta meta = (BookMeta) book.getItemMeta();
meta.setTitle(title);
meta.setAuthor(author);
meta.setPages(pages);
if (lore != null) meta.setLore(lore);
book.setItemMeta(meta);
return book;
}
示例9: 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;
}
示例10: 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;
}
示例11: 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);
}
示例12: onBookEdit
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBookEdit(PlayerEditBookEvent evt) {
if (!noCheatBook) return;
BookMeta prev = evt.getPreviousBookMeta();
BookMeta meta = evt.getNewBookMeta();
if (prev.equals(meta)) return;
// Illegally modify lore
if (prev.hasLore()) {
if (!meta.hasLore() || !prev.getLore().equals(meta.getLore())) {
meta.setLore(prev.getLore());
}
} else if (meta.hasLore()) {
meta.setLore(null);
}
// Illegally modify enchants
if (prev.hasEnchants()) {
if (!meta.hasEnchants()) {
addEnchantFrom(prev, meta);
} else if (!prev.getLore().equals(meta.getLore())) {
clearEnchant(meta);
addEnchantFrom(prev, meta);
}
} else if (meta.hasEnchants()) {
clearEnchant(meta);
}
// They cannot change title by edit it!
String title = prev.getTitle();
if (!title.equals(meta.getTitle())) {
meta.setTitle(title);
}
// Book and quill doesn't has a generation!
if (meta.getGeneration() != null) meta.setGeneration(null);
// Book and quill doesn't has an author!
if (meta.getAuthor() != null) meta.setAuthor(null);
evt.setNewBookMeta(meta);
AzureAPI.log(evt.getPlayer(), messageCheatBook);
}
示例13: performInvestigateTown
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private static void performInvestigateTown(Player player, ConfigMission mission) throws CivException {
Resident resident = CivGlobal.getResident(player);
if (resident == null || !resident.hasTown()) {
throw new CivException("Only residents of towns can perform spy missions.");
}
// Must be within enemy town borders.
ChunkCoord coord = new ChunkCoord(player.getLocation());
TownChunk tc = CivGlobal.getTownChunk(coord);
if (tc == null || tc.getTown().getCiv() == resident.getTown().getCiv()) {
throw new CivException("Must be in another civilization's town's borders.");
}
if(processMissionResult(player, tc.getTown(), mission)) {
ItemStack book = new ItemStack(Material.WRITTEN_BOOK, 1);
BookMeta meta = (BookMeta) book.getItemMeta();
ArrayList<String> lore = new ArrayList<String>();
lore.add("Mission Report");
meta.setAuthor("Mission Reports");
meta.setTitle("Investigate Town");
// ArrayList<String> out = new ArrayList<String>();
String out = "";
out += ChatColor.UNDERLINE+"Town:"+tc.getTown().getName()+"\n"+ChatColor.RESET;
out += ChatColor.UNDERLINE+"Civ:"+tc.getTown().getCiv().getName()+"\n\n"+ChatColor.RESET;
SimpleDateFormat sdf = new SimpleDateFormat("M/dd h:mm:ss a z");
out += "Time: "+sdf.format(new Date())+"\n";
out += ("Treasury: "+tc.getTown().getTreasury().getBalance()+"\n");
out += ("Hammers: "+tc.getTown().getHammers().total+"\n");
out += ("Culture: "+tc.getTown().getCulture().total+"\n");
out += ("Growth: "+tc.getTown().getGrowth().total+"\n");
out += ("Beakers(civ): "+tc.getTown().getBeakers().total+"\n");
if (tc.getTown().getCiv().getResearchTech() != null) {
out += ("Researching: "+tc.getTown().getCiv().getResearchTech().name+"\n");
} else {
out += ("Researching:Nothing"+"\n");
}
BookUtil.paginate(meta, out);
out = ChatColor.UNDERLINE+"Upkeep Info\n\n"+ChatColor.RESET;
try {
out += "From Spread:"+tc.getTown().getSpreadUpkeep()+"\n";
out += "From Structures:"+tc.getTown().getStructureUpkeep()+"\n";
out += "Total:"+tc.getTown().getTotalUpkeep();
BookUtil.paginate(meta, out);
} catch (InvalidConfiguration e) {
e.printStackTrace();
throw new CivException("Internal configuration exception.");
}
meta.setLore(lore);
book.setItemMeta(meta);
HashMap<Integer, ItemStack> leftovers = player.getInventory().addItem(book);
for (ItemStack stack : leftovers.values()) {
player.getWorld().dropItem(player.getLocation(), stack);
}
player.updateInventory();
CivMessage.sendSuccess(player, "Mission Accomplished");
}
}
示例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;
}