本文整理汇总了Java中org.bukkit.event.player.PlayerEditBookEvent.setNewBookMeta方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerEditBookEvent.setNewBookMeta方法的具体用法?Java PlayerEditBookEvent.setNewBookMeta怎么用?Java PlayerEditBookEvent.setNewBookMeta使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerEditBookEvent
的用法示例。
在下文中一共展示了PlayerEditBookEvent.setNewBookMeta方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSignBook
import org.bukkit.event.player.PlayerEditBookEvent; //导入方法依赖的package包/类
@EventHandler
public void onSignBook(PlayerEditBookEvent event)
{
BytecraftPlayer player = plugin.getPlayer(event.getPlayer());
if(event.isSigning()){
BookMeta meta = event.getNewBookMeta();
meta.setAuthor(player.getNameColor() + player.getName());
event.setNewBookMeta(meta);
}
}
示例2: onPlayerEditBook
import org.bukkit.event.player.PlayerEditBookEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerEditBook(PlayerEditBookEvent event) {
if (event.isSigning()) {
BookMeta meta = event.getNewBookMeta();
meta.setAuthor(plugin.getActiveCharacter(event.getPlayer()).getName());
event.setNewBookMeta(meta);
}
}
示例3: createBook
import org.bukkit.event.player.PlayerEditBookEvent; //导入方法依赖的package包/类
@EventHandler
public void createBook(PlayerEditBookEvent e) {
if(!e.isSigning()) {
if(!e.getPreviousBookMeta().hasAuthor()) {
BookMeta meta = e.getNewBookMeta();
meta.setAuthor(e.getPlayer().getName());
e.setNewBookMeta(meta);
e.setSigning(true);
sendMessage(e.getPlayer(), ChatColor.GREEN + "book automatic signed, by anti addvertise system!");
}
}
}
示例4: onBookEdit
import org.bukkit.event.player.PlayerEditBookEvent; //导入方法依赖的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);
}