当前位置: 首页>>代码示例>>Java>>正文


Java PlayerItemHeldEvent.getPlayer方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:17,代码来源:InventoryListener.java

示例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);
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:20,代码来源:RuneListener.java

示例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()));
}
 
开发者ID:tastybento,项目名称:beaconz,代码行数:25,代码来源:BeaconLinkListener.java

示例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);
}
 
开发者ID:nisovin,项目名称:Shopkeepers,代码行数:18,代码来源:CreateListener.java

示例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));
		}
	}
}
 
开发者ID:Randehh,项目名称:EpicQuest,代码行数:19,代码来源:OpenBookListener.java

示例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);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:28,代码来源:BardClass.java

示例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);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:14,代码来源:EnderPearlTimer.java

示例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);
}
 
开发者ID:Soldier233,项目名称:ArchersBattle,代码行数:41,代码来源:InventoryListener.java

示例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();
            }
        }
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:35,代码来源:BrushListener.java

示例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();
	}
}
 
开发者ID:Howaner,项目名称:DeinCart,代码行数:10,代码来源:DeinCartListener.java


注:本文中的org.bukkit.event.player.PlayerItemHeldEvent.getPlayer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。