本文整理匯總了Java中org.bukkit.inventory.meta.BookMeta.setAuthor方法的典型用法代碼示例。如果您正苦於以下問題:Java BookMeta.setAuthor方法的具體用法?Java BookMeta.setAuthor怎麽用?Java BookMeta.setAuthor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.inventory.meta.BookMeta
的用法示例。
在下文中一共展示了BookMeta.setAuthor方法的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: CustomBookOverlay
import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
public CustomBookOverlay(String title, String author, TellRawMessage... pages) {
this.book = new ItemStack(Material.WRITTEN_BOOK);
BookMeta meta = (BookMeta) this.book.getItemMeta();
meta.setTitle(title);
meta.setAuthor(author);
for (TellRawMessage page: pages) {
try {
addPage(meta, page);
} catch (Exception e) {
e.printStackTrace();
}
}
this.book.setItemMeta(meta);
}
示例5: setbookauthor
import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
@SubCommand(value = "setbookauthor", permission = "nu.setbook")
public void setbookauthor(CommandSender sender, Arguments args) {
if (!(args.length() > 1)) {
msg(sender, "manual.setbookauthor.usage");
return;
}
String author = args.next();
Player p = asPlayer(sender);
author = ChatColor.translateAlternateColorCodes('&', author);
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();
meta.setAuthor(author);
item.setItemMeta(meta);
msg(sender, "user.setbook.success");
}
示例6: 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;
}
示例7: 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 );
}
示例8: 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);
}
示例9: 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;
bookMeta.setAuthor(meta.getRawData());
itemStack.setItemMeta(bookMeta);
return true;
}
示例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: 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;
}
示例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: 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;
}