Java 类org.bukkit.event.player.PlayerItemHeldEvent 实例源码

项目:RPGInventory    文件:InventoryListener.java   
@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);
    }
}
项目:AsgardAscension    文件:RuneListener.java   
@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);
}
项目:QuestManager    文件:Imbuement.java   
@EventHandler
public void onWeaponSwitch(PlayerItemHeldEvent e) {
    if (!player.getPlayer().isOnline()) {
        return;
    }

    if (!e.getPlayer().getUniqueId().equals(player.getPlayer().getUniqueId())) {
        return;
    }

    if (!(QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getWorlds()
            .contains(e.getPlayer().getWorld().getName()))) {
        return;
    }

    //not allowed to switch weapons, cheater!
    this.cancel();
    e.getPlayer().sendMessage(FADE_MESSAGE);
}
项目:QuestManager    文件:ForgeSequence.java   
@EventHandler
public void onToolSwap(PlayerItemHeldEvent e) {
    if (!e.getPlayer().getUniqueId().equals(player.getPlayer().getUniqueId())) {
        return;
    }

    if (!isWrongTool && !skill.isTool(e.getPlayer().getInventory().getItem(e.getNewSlot()))) {
        this.isWrongTool = true;
        e.getPlayer().sendMessage(WRONG_TOOL_MESSAGE);
        this.wrongItemTimeLeft = WRONG_TOOL_TIMEOUT;
        return;
    }

    if (skill.isTool(e.getPlayer().getInventory().getItem(e.getNewSlot()))) {
        this.isWrongTool = false;
        return;
    }
}
项目:QuestManager    文件:ChargeAction.java   
@EventHandler
public void onItemSwitch(PlayerItemHeldEvent e) {
    if (canChangeItems) {
        return;
    }

    if (!player.getPlayer().isOnline()) {
        return;
    }

    if (!e.getPlayer().getUniqueId().equals(player.getPlayer().getUniqueId())) {
        return;
    }

    if (!(QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getWorlds()
            .contains(e.getPlayer().getWorld().getName()))) {
        return;
    }

    //not allowed to switch weapons, cheater!
    doneCasting();
    e.getPlayer().sendMessage(DISTURBED_MESSAGE);
}
项目:CraftBukkit    文件:PlayerConnection.java   
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
    // CraftBukkit start
    if (this.player.dead) return;

    if (packetplayinhelditemslot.c() >= 0 && packetplayinhelditemslot.c() < PlayerInventory.getHotbarSize()) {
        PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.c());
        this.server.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            this.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
            this.player.v();
            return;
        }
        // CraftBukkit end

        this.player.inventory.itemInHandIndex = packetplayinhelditemslot.c();
        this.player.v();
    } else {
        c.warn(this.player.getName() + " tried to set an invalid carried item");
        this.disconnect("Nope!"); // CraftBukkit
    }
}
项目:beaconz    文件:BeaconLinkListener.java   
/**
 * 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()));
}
项目:civcraft    文件:CustomItemManager.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onItemHeld(PlayerItemHeldEvent event) {
    if (event.isCancelled()) {
        return;
    }

    ItemStack stack = event.getPlayer().getItemInHand();
    if (stack == null) {
        return;
    }

    LoreMaterial material = LoreMaterial.getMaterial(stack);
    if (material != null) {
        material.onHold(event);
    }
}
项目:Almura-Server    文件:PlayerConnection.java   
public void a(Packet16BlockItemSwitch packet16blockitemswitch) {
    // CraftBukkit start
    if (this.player.dead) return;

    if (packet16blockitemswitch.itemInHandIndex >= 0 && packet16blockitemswitch.itemInHandIndex < PlayerInventory.getHotbarSize()) {
        PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packet16blockitemswitch.itemInHandIndex);
        this.server.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            this.sendPacket(new Packet16BlockItemSwitch(this.player.inventory.itemInHandIndex));
            this.player.u();
            return;
        }
        // CraftBukkit end

        this.player.inventory.itemInHandIndex = packet16blockitemswitch.itemInHandIndex;
        this.player.u();
    } else {
        this.minecraftServer.getLogger().warning(this.player.getName() + " tried to set an invalid carried item");
        this.disconnect("Nope!"); // CraftBukkit
    }
}
项目:Tweakkit-Server    文件:PlayerConnection.java   
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
    // CraftBukkit start
    if (this.player.dead) return;

    if (packetplayinhelditemslot.c() >= 0 && packetplayinhelditemslot.c() < PlayerInventory.getHotbarSize()) {
        PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.c());
        this.server.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            this.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
            this.player.v();
            return;
        }
        // CraftBukkit end

        this.player.inventory.itemInHandIndex = packetplayinhelditemslot.c();
        this.player.v();
    } else {
        c.warn(this.player.getName() + " tried to set an invalid carried item");
        this.disconnect("Invalid hotbar selection (Hacking?)"); // CraftBukkit //Spigot "Nope" -> Descriptive reason
    }
}
项目:sensibletoolbox    文件:MultiBuilder.java   
@Override
public void onItemHeld(PlayerItemHeldEvent event) {
    int delta = event.getNewSlot() - event.getPreviousSlot();
    if (delta == 0) {
        return;
    } else if (delta >= 6) {
        delta -= 9;
    } else if (delta <= -6) {
        delta += 9;
    }
    delta = (delta > 0) ? 1 : -1;
    int o = getMode().ordinal() + delta;
    if (o < 0) {
        o = Mode.values().length - 1;
    } else if (o >= Mode.values().length) {
        o = 0;
    }
    setMode(Mode.values()[o]);
    event.getPlayer().setItemInHand(toItemStack());
}
项目:SpigotSource    文件:PlayerConnection.java   
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
    PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.x());
    if (this.player.dead) return; // CraftBukkit
    if (packetplayinhelditemslot.a() >= 0 && packetplayinhelditemslot.a() < PlayerInventory.getHotbarSize()) {
        PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.a());
        this.server.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            this.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
            this.player.resetIdleTimer();
            return;
        }
        // CraftBukkit end
        this.player.inventory.itemInHandIndex = packetplayinhelditemslot.a();
        this.player.resetIdleTimer();
    } else {
        PlayerConnection.LOGGER.warn(this.player.getName() + " tried to set an invalid carried item");
        this.disconnect("Invalid hotbar selection (Hacking?)"); // CraftBukkit //Spigot "Nope" -> Descriptive reason
    }
}
项目:Craft-city    文件:PlayerConnection.java   
public void a(Packet16BlockItemSwitch packet16blockitemswitch) {
    // CraftBukkit start
    if (this.player.dead) return;

    if (packet16blockitemswitch.itemInHandIndex >= 0 && packet16blockitemswitch.itemInHandIndex < PlayerInventory.getHotbarSize()) {
        PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packet16blockitemswitch.itemInHandIndex);
        this.server.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            this.sendPacket(new Packet16BlockItemSwitch(this.player.inventory.itemInHandIndex));
            return;
        }
        // CraftBukkit end

        this.player.inventory.itemInHandIndex = packet16blockitemswitch.itemInHandIndex;
    } else {
        this.minecraftServer.getLogger().warning(this.player.name + " tried to set an invalid carried item");
        this.disconnect("Nope!"); // CraftBukkit
    }
}
项目:Shopkeepers    文件:CreateListener.java   
@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);
}
项目:EpicQuest    文件:OpenBookListener.java   
@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));
        }
    }
}
项目:ZentrelaRPG    文件:CombatManager.java   
@EventHandler
public void onChangeItemInHand_equipItem(final PlayerItemHeldEvent event) {
    RScheduler.schedule(plugin, new Runnable() {
        public void run() {
            PlayerDataRPG pd = plugin.getPD((Player) (event.getPlayer()));
            if (pd != null)
                pd.updateEquipmentStats();
        }
    });
}
项目:HCFCore    文件:BardClass.java   
@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);
        }
    }
}
项目:HCFCore    文件:EnderPearlTimer.java   
@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);
    }
}
项目:HCFCore    文件:BardClass.java   
@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);
        }
    }
}
项目:HCFCore    文件:EnderPearlTimer.java   
@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);
    }
}
项目:ArchersBattle    文件:InventoryListener.java   
@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);
}
项目:FlexMC    文件:HeldItemListener.java   
@Override
public void handle( ConnectionHandler connectionHandler, MessageC1AHeldItemChange message ) {
    FlexPlayer p = connectionHandler.getPlayer();
    p.handleSetHeldItemSlot( message.getSlot() );
    ItemStack stack = connectionHandler.getPlayer().getInventory().getItem( message.getSlot() );
    EventFactory.call( new PlayerItemHeldEvent( p, p.getHeldItemSlot(), message.getSlot() ) );
    for( FlexPlayer player : connectionHandler.getPlayer().getWorld().getPlayerSet() ) {
        if( !player.equals( connectionHandler.getPlayer() ) ) {
            player.getConnectionHandler().sendMessage( new MessageS3FEntityEquipment( connectionHandler.getPlayer().getEntityId(), 0, stack ) );
        }
    }
}
项目:Chambers    文件:EnderpearlListener.java   
@EventHandler
public void onPlayerItemHeldEvent(PlayerItemHeldEvent event) {
    ItemStack itemStack = event.getPlayer().getInventory().getItem(event.getPreviousSlot());
    if (itemStack != null && itemStack.getType() == Material.ENDER_PEARL && itemStack.getItemMeta() != null) {
        ItemMeta itemMeta = itemStack.getItemMeta();
        itemMeta.setDisplayName(null);
        itemStack.setItemMeta(itemMeta);
    }
}
项目:McLink    文件:ActionBind.java   
@EventHandler
public void onNewItem(PlayerItemHeldEvent event) {
    for (int s = 0; s < 103; s++) {
        ItemStack i = event.getPlayer().getInventory().getItem(s);
        if (i != null && i.getItemMeta() != null && !i.getType().equals(Material.AIR) && ItemId.extract(i).equals("")) {
            event.getPlayer().getInventory().setItem(s, ItemId.attach(i, "minecraft:" + i.getType().name().toLowerCase()));
        }
    }
}
项目:NeoHG    文件:Events.java   
@EventHandler
private void onBar(PlayerItemHeldEvent event) {
    if (!CONFIG_RESULTS[0])
        return;
    if (Game.getState() != State.STARTING)
        return;
    if (event.getPlayer().getInventory().getItem(event.getNewSlot()) != null)
        event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1.0F, 1.0F);
}
项目:ExilePearl    文件:PlayerListener.java   
/**
 * Announce the person in a pearl when a player holds it
 * @param event
 */
@EventHandler(priority = EventPriority.MONITOR)
public void onItemHeldChange(PlayerItemHeldEvent event) {

    Inventory inv = event.getPlayer().getInventory();
    ItemStack item = inv.getItem(event.getNewSlot());
    ItemStack newitem = validatePearl(item);
    if (newitem != null) {
        inv.setItem(event.getNewSlot(), newitem);
    }
}
项目:Pokkit    文件:InventoryEvents.java   
@EventHandler(ignoreCancelled = false)
public void onDrop(cn.nukkit.event.player.PlayerDropItemEvent event) {
    if (canIgnore(PlayerItemHeldEvent.getHandlerList())) {
        return;
    }

    PokkitItemEntity pokkit = new PokkitItemEntity(event.getItem(), event.getPlayer().getLocation());
    PlayerDropItemEvent bukkitEvent = new PlayerDropItemEvent(PokkitPlayer.toBukkit(event.getPlayer()), pokkit);
    callCancellable(event, bukkitEvent);
}
项目:Skellett    文件:ExprHotbarSwitchSlot.java   
@SuppressWarnings({ "unchecked", "rawtypes" })
public boolean init(Expression<?>[] e, int matchedPattern, Kleenean isDelayed, ParseResult parser) {
    if (!ScriptLoader.isCurrentEvent((Class)PlayerItemHeldEvent.class)) {
        Skript.error("changed hotbar slot can only be used within the on hotbar change event!");
        return false;
    }
    if (parser.mark == 2) {boo = false;}
    return true;
}
项目:Skellett    文件:ExprHotbarSwitchSlot.java   
@Nullable
protected Integer[] get(Event e) {
    if (boo) {
        return new Integer[]{((PlayerItemHeldEvent)e).getPreviousSlot()};
    } else {
        return new Integer[]{((PlayerItemHeldEvent)e).getNewSlot()};
    }
}
项目:FastAsyncWorldedit    文件:BrushListener.java   
@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();
            }
        }
    }
}
项目:Transformer    文件:WandListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onSwitch(PlayerItemHeldEvent event){
    if(event.getPlayer().getInventory().getItem(event.getNewSlot()) != null) {
        if (event.getPlayer().getInventory().getItem(event.getNewSlot()).isSimilar(R.wand)) {
            ActionAPI.sendAction(event.getPlayer(), ChatColor.GOLD + "Press Q To Open Control Center!");
        }
    }
}
项目:civcraft    文件:CustomItemManager.java   
@EventHandler(priority = EventPriority.NORMAL)
public void OnInventoryHold(PlayerItemHeldEvent event) {

    ItemStack stack = event.getPlayer().getInventory().getItem(event.getNewSlot());
    if (stack == null) {
        return;
    }

    LoreCraftableMaterial craftMat = LoreCraftableMaterial.getCraftMaterial(stack);
    if (craftMat == null) {
        return;
    }

    craftMat.onHold(event);
}
项目:civcraft    文件:BonusGoodieManager.java   
@EventHandler(priority = EventPriority.MONITOR)
public void OnItemHeldChange(PlayerItemHeldEvent event) {
    Inventory inv = event.getPlayer().getInventory();
    ItemStack stack = inv.getItem(event.getNewSlot());

    BonusGoodie goodie = CivGlobal.getBonusGoodie(stack);
    if (goodie == null) {
        return;
    }

    CivMessage.send(event.getPlayer(), CivColor.Purple+"Bonus Goodie: "+CivColor.Yellow+goodie.getDisplayName());

}
项目:civcraft    文件:RangedAttack.java   
@Override
public void onHold(PlayerItemHeldEvent event) { 

    Resident resident = CivGlobal.getResident(event.getPlayer());
    if (!resident.hasTechForItem(event.getPlayer().getInventory().getItem(event.getNewSlot()))) {       
        CivMessage.send(resident, CivColor.Rose+"Warning - "+CivColor.LightGray+
                "You do not have the required technology to use this item. It's attack output will be reduced in half.");
    }
}
项目:civcraft    文件:Attack.java   
@Override
public void onHold(PlayerItemHeldEvent event) { 

    Resident resident = CivGlobal.getResident(event.getPlayer());
    if (!resident.hasTechForItem(event.getPlayer().getInventory().getItem(event.getNewSlot()))) {       
        CivMessage.send(resident, CivColor.Rose+"Warning - "+CivColor.LightGray+
                "You do not have the required technology to use this item. It's attack output will be reduced in half.");
    }
}
项目:civcraft    文件:Defense.java   
@Override
public void onHold(PlayerItemHeldEvent event) { 

    Resident resident = CivGlobal.getResident(event.getPlayer());
    if (!resident.hasTechForItem(event.getPlayer().getInventory().getItem(event.getNewSlot()))) {       
        CivMessage.send(resident, CivColor.Rose+"Warning - "+CivColor.LightGray+
                "You do not have the required technology to use this item. It's defense output will be reduced in half.");
    }
}
项目:DeinCart    文件:DeinCartListener.java   
@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();
    }
}
项目:Cauldron    文件:NetHandlerPlayServer.java   
public void processHeldItemChange(C09PacketHeldItemChange p_147355_1_)
{
    // CraftBukkit start
    if (this.playerEntity.isDead)
    {
        return;
    }

    if (p_147355_1_.func_149614_c() >= 0 && p_147355_1_.func_149614_c() < InventoryPlayer.getHotbarSize())
    {
        PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayerB(), this.playerEntity.inventory.currentItem, p_147355_1_.func_149614_c());
        this.server.getPluginManager().callEvent(event);

        if (event.isCancelled())
        {
            this.sendPacket(new S09PacketHeldItemChange(this.playerEntity.inventory.currentItem));
            this.playerEntity.func_143004_u();
            return;
        }

        // CraftBukkit end
        this.playerEntity.inventory.currentItem = p_147355_1_.func_149614_c();
        this.playerEntity.func_143004_u();
    }
    else
    {
        logger.warn(this.playerEntity.getCommandSenderName() + " tried to set an invalid carried item");
        this.kickPlayerFromServer("Nope!"); // CraftBukkit
    }
}
项目:sensibletoolbox    文件:GeneralListener.java   
@EventHandler(ignoreCancelled = true)
public void onItemChanged(PlayerItemHeldEvent event) {
    if (event.getPlayer().isSneaking()) {
        ItemStack stack = event.getPlayer().getItemInHand();
        BaseSTBItem item = SensibleToolbox.getItemRegistry().fromItemStack(stack);
        if (item != null) {
            item.onItemHeld(event);
            event.setCancelled(true);
        }
    }
}
项目:Skript    文件:ExprTool.java   
@SuppressWarnings("unchecked")
@Override
public boolean setTime(final int time) {
    return super.setTime(time, getExpr(), PlayerItemHeldEvent.class, PlayerBucketFillEvent.class, PlayerBucketEmptyEvent.class);
}