本文整理匯總了Java中org.bukkit.inventory.meta.BookMeta.getAuthor方法的典型用法代碼示例。如果您正苦於以下問題:Java BookMeta.getAuthor方法的具體用法?Java BookMeta.getAuthor怎麽用?Java BookMeta.getAuthor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.inventory.meta.BookMeta
的用法示例。
在下文中一共展示了BookMeta.getAuthor方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getMeta
import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
@Override
public List<ItemMetaValue> getMeta(ItemStack itemStack) {
PreCon.notNull(itemStack);
List<ItemMetaValue> result = new ArrayList<>(1);
ItemMeta itemMeta = itemStack.getItemMeta();
if (!(itemMeta instanceof BookMeta))
return result;
BookMeta bookMeta = (BookMeta)itemMeta;
if (bookMeta.getAuthor() == null)
return result;
result.add(new ItemMetaValue(getMetaName(), bookMeta.getAuthor()));
itemStack.setItemMeta(bookMeta);
return result;
}
示例2: 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();
}
示例3: 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;
}
示例4: 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);
}
示例5: 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();
}
示例6: 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();
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
}
}
}
}
}
示例10: 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);
}
示例11: get
import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
@Override
@Nullable
protected String[] get(Event e) {
BookMeta book = (BookMeta) item.getSingle(e).getItemMeta();
return new String[]{book.getAuthor()};
}
示例12: isAuthor
import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
private boolean isAuthor(BookMeta bmeta, String player)
{
String author = bmeta.getAuthor();
return author != null && author.equalsIgnoreCase(player);
}
示例13: BookMetadata
import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
public BookMetadata(BookMeta bookMeta) {
this.title = bookMeta.hasTitle() ? bookMeta.getTitle() : null;
this.author = bookMeta.hasAuthor() ? bookMeta.getAuthor() : null;
this.hasPages = bookMeta.hasPages();
this.bookHash = this.hasPages ? bookHash(bookMeta.getPages()) : 0;
}