當前位置: 首頁>>代碼示例>>Java>>正文


Java BookMeta.getAuthor方法代碼示例

本文整理匯總了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;
}
 
開發者ID:JCThePants,項目名稱:NucleusFramework,代碼行數:21,代碼來源:ItemBookAuthor.java

示例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();
}
 
開發者ID:Ribesg,項目名稱:NPlugins,代碼行數:18,代碼來源:ItemMetaUtil.java

示例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;
}
 
開發者ID:DevCrafters,項目名稱:SaveableSerializing,代碼行數:11,代碼來源:SaveableBookMeta.java

示例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);
}
 
開發者ID:WorldCretornica,項目名稱:PlotMe-Core,代碼行數:41,代碼來源:SchematicUtil.java

示例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();
}
 
開發者ID:StarQuestMinecraft,項目名稱:StarQuestCode,代碼行數:10,代碼來源:CardboardMetaBook.java

示例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();
	}
 
開發者ID:StarQuestMinecraft,項目名稱:StarQuestCode,代碼行數:9,代碼來源:CardboardMetaBook.java

示例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;
}
 
開發者ID:TheNewEconomy,項目名稱:TNE-Bukkit,代碼行數:14,代碼來源:BookData.java

示例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;
}
 
開發者ID:gmlaxfanatic,項目名稱:FactoryMod,代碼行數:35,代碼來源:PrintingPress.java

示例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;
					}
				}
			}
		}
	}
}
 
開發者ID:gmlaxfanatic,項目名稱:FactoryMod,代碼行數:41,代碼來源:PrintingPress.java

示例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);
}
 
開發者ID:GelandiAssociation,項目名稱:EscapeLag,代碼行數:46,代碼來源:CheatBookBlocker.java

示例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()};
}
 
開發者ID:TheLimeGlass,項目名稱:Skellett,代碼行數:7,代碼來源:ExprBookAuthor.java

示例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);
}
 
開發者ID:Curtis3321,項目名稱:Essentials,代碼行數:6,代碼來源:Commandbook.java

示例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;
}
 
開發者ID:gmlaxfanatic,項目名稱:ItemExchange,代碼行數:7,代碼來源:BookMetadata.java


注:本文中的org.bukkit.inventory.meta.BookMeta.getAuthor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。