本文整理汇总了Java中org.bukkit.inventory.meta.BookMeta.hasTitle方法的典型用法代码示例。如果您正苦于以下问题:Java BookMeta.hasTitle方法的具体用法?Java BookMeta.hasTitle怎么用?Java BookMeta.hasTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.meta.BookMeta
的用法示例。
在下文中一共展示了BookMeta.hasTitle方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serializeBookMeta
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
/**
* Gets a JSONObject representation of a BookMeta. Book and Quills books will have a pages key, while
* finished, written, books will also have an author and title key.
*
* @param meta The BookMeta to serialize
* @return A JSON Representation of the give BookMeta
*/
public static JSONObject serializeBookMeta(BookMeta meta) {
try {
JSONObject root = new JSONObject();
if (meta.hasTitle())
root.put("title", meta.getTitle());
if (meta.hasAuthor())
root.put("author", meta.getAuthor());
if (meta.hasPages()) {
String[] pages = meta.getPages().toArray(new String[]{});
root.put("pages", pages);
}
return root;
} catch (JSONException e) {
e.printStackTrace();
return null;
}
}
示例2: check
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
public boolean check(Event e) {
BookMeta book = (BookMeta) item.getSingle(e).getItemMeta();
if (book.hasTitle()) {
if (boo == true) {
return true;
} else {
return false;
}
} else {
if (boo == false) {
return true;
} else {
return false;
}
}
}
示例3: matches
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
@Override
public boolean matches(ItemStack item) {
if(item.hasItemMeta()) {
ItemMeta meta = item.getItemMeta();
if(meta instanceof BookMeta) {
BookMeta bookMeta = (BookMeta) meta;
if(bookMeta.hasTitle() == hasTitle() && bookMeta.hasAuthor() == hasAuthor() && bookMeta.hasPages() == hasPages) {
if(hasPages) {
return bookHash(bookMeta.getPages()) == bookHash;
}
else {
return true;
}
}
}
}
return false;
}
示例4: giveQuestBook
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
public void giveQuestBook(){
if(getPlayer() == null) return;
Inventory inventory = getPlayer().getInventory();
if(inventory.contains(Material.WRITTEN_BOOK)){
for(int i = 0; i < inventory.getContents().length; i++){
ItemStack item = inventory.getContents()[i];
if(item != null && item.getType() == Material.WRITTEN_BOOK){
BookMeta bookMeta = (BookMeta)item.getItemMeta();
if(bookMeta.hasTitle() && bookMeta.getTitle().equals("Quest Book")) return;
}
}
}
ItemStack book = new ItemStack(Material.WRITTEN_BOOK, 1);
inventory.addItem(book);
OpenBookListener.UpdateBook(this);
}
示例5: onEditBook
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
@EventHandler
public void onEditBook(PlayerItemHeldEvent event){
//Get player and the action
Player player = event.getPlayer();
EpicPlayer epicPlayer = EpicSystem.getEpicPlayer(player.getUniqueId());
ItemStack inHand = player.getInventory().getItem(event.getNewSlot());
if(inHand != null && inHand.getType() == Material.WRITTEN_BOOK){
BookMeta book = (BookMeta)inHand.getItemMeta();
if(book.hasTitle() && book.getTitle().equalsIgnoreCase("Quest Book")){
//Open zeh quest book!
inHand.setItemMeta(SetQuestBookPages(epicPlayer, book));
}
}
}
示例6: onPlayerDeath
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event){
if(event.getDrops().isEmpty()){
return;
}
ItemStack itemToRemove = null;
for(ItemStack item : event.getDrops()){
if(item != null && item.getType() == Material.WRITTEN_BOOK){
BookMeta bookMeta = (BookMeta)item.getItemMeta();
if(bookMeta.hasTitle() && bookMeta.getTitle().equals("Quest Book")){
itemToRemove = item;
}
}
}
if(itemToRemove != null) event.getDrops().remove(itemToRemove);
}
示例7: getBookTextArray
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
public static List<String> getBookTextArray(final ItemStack book, final boolean byline) {
if (! book.hasItemMeta() || !(book.getItemMeta() instanceof BookMeta))
return null;
final BookMeta meta = (BookMeta) book.getItemMeta();
final List<String> out = new ArrayList<String>(meta.getPages());
if (byline && meta.hasTitle())
out.add(0, meta.getTitle() + (meta.hasAuthor() ? " by " + meta.getAuthor() : ""));
return out;
}
示例8: onPlayerDropItem
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event){
ItemStack droppedItem = event.getItemDrop().getItemStack();
if(droppedItem.getType() == Material.WRITTEN_BOOK){
BookMeta book = (BookMeta)droppedItem.getItemMeta();
if(book.hasTitle() && book.getTitle().equalsIgnoreCase("Quest Book")){
event.setCancelled(true);
}
}
}
示例9: addQuestJournal
import org.bukkit.inventory.meta.BookMeta; //导入方法依赖的package包/类
public static void addQuestJournal(QuestPlayer qp) {
if (!qp.getPlayer().isOnline()) {
return;
}
if (!QuestManagerPlugin.questManagerPlugin.getPluginConfiguration()
.getWorlds().contains(qp.getPlayer().getPlayer().getWorld().getName())) {
return;
}
Player play = qp.getPlayer().getPlayer();
Inventory inv = play.getInventory();
if (inv.firstEmpty() == -1) {
//no room!
return;
}
ItemStack book = null;
for (ItemStack item : inv.all(Material.BOOK_AND_QUILL).values()) {
if (item.hasItemMeta()) {
BookMeta meta = (BookMeta) item.getItemMeta();
if (meta.hasTitle() && meta.getTitle().equals("Journal")
&& meta.hasAuthor() && meta.getAuthor().equals(play.getName())
&& item.getEnchantmentLevel(Enchantment.LUCK) == 5) {
book = item;
break;
}
}
}
if (book == null) {
book = new ItemStack(Material.BOOK_AND_QUILL);
BookMeta bookMeta = (BookMeta) book.getItemMeta();
bookMeta.setTitle("Journal");
bookMeta.setDisplayName("Journal");
bookMeta.setAuthor(play.getName());
book.setItemMeta(bookMeta);
book.addUnsafeEnchantment(Enchantment.LUCK, 5);
inv.addItem(book);
play.sendMessage(ChatColor.GRAY + "A " + ChatColor.DARK_GREEN
+ "Quest Journal" + ChatColor.GRAY + " has been added to your inventory."
+ ChatColor.RESET);
}
updateQuestJournal(qp, true);
}
示例10: 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;
}