本文整理汇总了Java中org.bukkit.event.player.PlayerItemHeldEvent.getPlayer方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerItemHeldEvent.getPlayer方法的具体用法?Java PlayerItemHeldEvent.getPlayer怎么用?Java PlayerItemHeldEvent.getPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerItemHeldEvent
的用法示例。
在下文中一共展示了PlayerItemHeldEvent.getPlayer方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onQuickSlotHeld
import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的package包/类
@EventHandler
public void onQuickSlotHeld(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
if (!InventoryManager.playerIsLoaded(player)) {
return;
}
int slotId = event.getNewSlot();
Slot slot = InventoryManager.getQuickSlot(slotId);
if (slot != null && slot.isCup(player.getInventory().getItem(slotId))) {
event.setCancelled(true);
InventoryUtils.heldFreeSlot(player, slotId,
(event.getPreviousSlot() + 1) % 9 == slotId ? InventoryUtils.SearchType.NEXT : InventoryUtils.SearchType.PREV);
}
}
示例2: onTakeRune
import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的package包/类
@EventHandler
public void onTakeRune(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
if(plugin.getRuneManager().getEffect(player) != null && plugin.getRuneManager().getActiveRune(player) == null) {
plugin.getRuneManager().removeEffect(event.getPlayer());
}
ItemStack item = event.getPlayer().getInventory().getItem(event.getNewSlot());
if(item == null || item.getItemMeta() == null || !item.getType().equals(Material.ENCHANTED_BOOK)) {
return;
}
Rune rune = plugin.getRuneManager().getRune(item.getItemMeta().getDisplayName().substring(2));
if(rune == null) {
return;
}
plugin.getRuneManager().startHoldingEffect(player, rune);
}
示例3: onMapHold
import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的package包/类
/**
* Make sure all player held maps have triangle overlays. (todo: make sure all maps on item frames do as well)
* There seem to be some bugs around this. It doesn't always take on the first try.
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled=true)
public void onMapHold(final PlayerItemHeldEvent event) {
Player player = event.getPlayer();
ItemStack itemInHand = player.getInventory().getItem(event.getNewSlot());
if (itemInHand == null) return;
if (!Material.MAP.equals(itemInHand.getType())) {
return;
}
if (!player.getWorld().equals(getBeaconzWorld())) {
return;
}
@SuppressWarnings("deprecation")
MapView map = Bukkit.getMap(itemInHand.getDurability());
for (MapRenderer renderer : map.getRenderers()) {
if (renderer instanceof TerritoryMapRenderer) {
return;
}
}
map.addRenderer(new TerritoryMapRenderer(getBeaconzPlugin()));
}
示例4: onItemHeld
import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
void onItemHeld(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE) return;
ItemStack newItemInHand = player.getInventory().getItem(event.getNewSlot());
if (!Settings.isShopCreationItem(newItemInHand)) {
return;
}
if (!ShopkeepersPlugin.getInstance().hasCreatePermission(player)) {
// player cannot create any shopkeeper at all
return;
}
// print info message about usage:
Utils.sendMessage(player, Settings.msgCreationItemSelected);
}
示例5: onEditBook
import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的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: onItemHeld
import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onItemHeld(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
PvpClass equipped = plugin.getPvpClassManager().getEquippedClass(player);
if (equipped == null || !equipped.equals(this)) {
return;
}
UUID uuid = player.getUniqueId();
long lastMessage = msgCooldowns.get(uuid);
long millis = System.currentTimeMillis();
if (lastMessage != msgCooldowns.getNoEntryValue() && lastMessage - millis > 0L) {
return;
}
ItemStack newStack = player.getInventory().getItem(event.getNewSlot());
if (newStack != null) {
BardEffect bardEffect = bardEffects.get(newStack.getType());
if (bardEffect != null) {
msgCooldowns.put(uuid, millis + 1500L);
player.sendMessage(ChatColor.GOLD + "Bard Effect: " + ChatColor.GOLD);
player.sendMessage(ChatColor.GOLD + "\u00bb " + ChatColor.YELLOW + "Clickable Effect: " + ChatColor.AQUA + Lang.fromPotionEffectType(bardEffect.clickable.getType()) + ' '
+ (bardEffect.clickable.getAmplifier() + 1) + ChatColor.GRAY + " (" + (bardEffect.clickable.getDuration() / 20) + "s)");
player.sendMessage(ChatColor.GOLD + "\u00bb " + ChatColor.YELLOW + "Energy Cost: " + ChatColor.AQUA + bardEffect.energyCost);
}
}
}
示例7: onPlayerItemHeld
import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
PearlNameFaker pearlNameFaker = itemNameFakes.get(player.getUniqueId());
if (pearlNameFaker != null) {
int previousSlot = event.getPreviousSlot();
ItemStack item = player.getInventory().getItem(previousSlot);
if (item == null)
return;
pearlNameFaker.setFakeItem(((CraftItemStack) item).handle, previousSlot);
}
}
示例8: onHeld
import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的package包/类
@EventHandler
public void onHeld(PlayerItemHeldEvent e) {
if (e.isCancelled()) {
return;
}
if (!Utils.isInArena(e.getPlayer())) {
return;
}
if (e.getNewSlot() == 0) {
return;
}
if (e.getNewSlot() >= 2 && e.getNewSlot() <= 4) {
int slot = e.getNewSlot();
Player p = e.getPlayer();
PlayerInventory inv = p.getInventory();
ItemStack item = inv.getItem(slot).clone();
item.setAmount(1);
if (SkillManager.getInstance().isSkillSelector(item)) {
Skill skill = SkillManager.getInstance().getSkillBySelector(item);
if(skill.getSkillType().equals(SkillType.ITEM)){
inv.setItem(0, skill.getShow());
}
else{
Class<?> skillClazz=skill.getClass();
try {
Method method =skillClazz.getMethod("doUpgrade",Player.class);
if(method!=null){
method.invoke(SkillManager.getInstance().getSkillByName(skill.getName()),p);
}
} catch (Exception e1) {
e1.printStackTrace();
}
}
inv.setItem(2, ItemManager.getForbidden(3));
inv.setItem(3, ItemManager.getForbidden(4));
inv.setItem(4, ItemManager.getForbidden(5));
}
}
e.setCancelled(true);
}
示例9: onPlayerItemHoldEvent
import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerItemHoldEvent(final PlayerItemHeldEvent event) {
final Player bukkitPlayer = event.getPlayer();
if (bukkitPlayer.isSneaking()) {
return;
}
FawePlayer<Object> fp = FawePlayer.wrap(bukkitPlayer);
com.sk89q.worldedit.entity.Player player = fp.getPlayer();
LocalSession session = fp.getSession();
Tool tool = session.getTool(player);
if (tool instanceof ScrollTool) {
final int slot = event.getNewSlot();
final int oldSlot = event.getPreviousSlot();
final int ri;
if ((((slot - oldSlot) <= 4) && ((slot - oldSlot) > 0)) || (((slot - oldSlot) < -4))) {
ri = 1;
} else {
ri = -1;
}
ScrollTool scrollable = (ScrollTool) tool;
if (scrollable.increment(player, ri)) {
if (Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES) {
bukkitPlayer.getInventory().setHeldItemSlot(oldSlot);
} else {
final PlayerInventory inv = bukkitPlayer.getInventory();
final ItemStack item = inv.getItem(slot);
final ItemStack newItem = inv.getItem(oldSlot);
inv.setItem(slot, newItem);
inv.setItem(oldSlot, item);
bukkitPlayer.updateInventory();
}
}
}
}
示例10: onPlayerItemHeld
import org.bukkit.event.player.PlayerItemHeldEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItem(event.getPreviousSlot());
if (this.manager.isDeincartItem(item)) {
player.getInventory().setItem(event.getPreviousSlot(), null);
player.updateInventory();
}
}