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

项目:SamaGamesAPI    文件:ActivePowerup.java   
@EventHandler
private void onPlayerPickupItem(PlayerPickupItemEvent event)
{
    if (event.getItem().getItemStack() != null && event.getItem().getItemStack().getItemMeta() != null && event.getItem().getItemStack().getItemMeta().getDisplayName() != null)
    {
        if (this.alive && event.getItem().getItemStack().getItemMeta().getDisplayName().equals(this.uuid.toString()))
        {
            event.setCancelled(true);

            HandlerList.unregisterAll(this);

            this.remove(true);
            this.parent.onPickup(event.getPlayer());
        }
    }
}
项目:UltimateSpawn    文件:BasicFeatures.java   
@EventHandler
public void onPickUp(PlayerPickupItemEvent e) {
    Player p = e.getPlayer();

    if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.PickUp.Disable")) {
        if (!ConfigGPlayerItems.getConfig().getBoolean("Server.Items.PickUp.World.All_World")) {
            if (WorldUtils.getWItemPickUp().contains(p.getWorld().getName())) {
            if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.PickUp.Bypass")) {
                 if (!p.hasPermission("ultimatespawn.event.playeritem.bypass.pickup")) {
                     e.setCancelled(true);
                 }
             } else {
                 e.setCancelled(true);
             }
            }
        } else {
            if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.PickUp.Bypass")) {
                if (!p.hasPermission("ultimatespawn.event.playeritem.bypass.pickup")) {
                    e.setCancelled(true);
                }
            } else {
                e.setCancelled(true);
            }
        }
    }
}
项目:RPGInventory    文件:InventoryListener.java   
@EventHandler(ignoreCancelled = true)
public void onPickupToQuickSlot(PlayerPickupItemEvent event) {
    Player player = event.getPlayer();

    if (!InventoryManager.playerIsLoaded(player) || !ItemManager.allowedForPlayer(player, event.getItem().getItemStack(), false)) {
        return;
    }

    for (Slot quickSlot : SlotManager.instance().getQuickSlots()) {
        int slotId = quickSlot.getQuickSlot();
        if (quickSlot.isCup(player.getInventory().getItem(slotId)) && quickSlot.isValidItem(event.getItem().getItemStack())) {
            player.getInventory().setItem(slotId, event.getItem().getItemStack());
            event.getItem().remove();

            player.playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, .3f, 1.7f);
            if (Config.getConfig().getBoolean("attack.auto-held")) {
                player.getInventory().setHeldItemSlot(quickSlot.getQuickSlot());
            }

            event.setCancelled(true);
        }
    }
}
项目:GamePlate    文件:CapturableObjective.java   
@EventHandler
public void onBlockPickup(PlayerPickupItemEvent event) {
    if (event.getItem().getItemStack().getType() == material && event.getItem().getItemStack().getData().getData() == data) {
        if(this.touches.contains(event.getPlayer().getUniqueId())) return;

        TeamModule teamModule = TeamManager.getTeamByPlayer(event.getPlayer());

        if (teamModule == null) return;
        if(super.isCompletedBy(teamModule)) return;

        if (teamModule.getObjectives().contains(this)) {
            this.touches.add(event.getPlayer().getUniqueId());

            for (ScoreboardModule scoreboardModule : GameHandler.getGameHandler().getMatch().getModules().getModules(ScoreboardModule.class)) {
                scoreboardModule.refresh(this);
            }

            for (Player player : Bukkit.getOnlinePlayers()) {
                player.sendMessage(teamModule.getColor() + new LocalizedChatMessage(ChatConstant.GAME_CAPTURABLE_TOUCHED, event.getPlayer().getName() + ChatColor.DARK_AQUA, ChatColor.AQUA + super.getName() + ChatColor.DARK_AQUA, teamModule.getColor() + teamModule.getName() + ChatColor.DARK_AQUA).getMessage(player.spigot().getLocale()));
            }
        }
    }
}
项目:PhantomAdmin    文件:PAEventHandler.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
void onPlayerPickupItem(PlayerPickupItemEvent event)
{
 Player player = event.getPlayer();
 if(!player.isSneaking() && PhantomAdmin.instance.isInvisible(player))
 {
     event.setCancelled(true);
     PlayerData data = PlayerData.FromPlayer(player);
        if(!data.gotItemPickupInfo)
        {
            PhantomAdmin.sendMessage(player, TextMode.Warn, Messages.NoItemPickupWhileInvisible);
            data.gotItemPickupInfo = true;
        }

     return;
 }
}
项目:Minetrace    文件:MinetraceListener.java   
@EventHandler
public void onItemPickup(PlayerPickupItemEvent event)
{
    System.out.println("Item pickup");
    Item item = event.getItem();
    ItemStack stack = item.getItemStack();
    Location location = item.getLocation();
    Player player = event.getPlayer();
    String playerName = player == null ? "null" : player.getName();

    PickupItemObsel obsel = new PickupItemObsel(
            new Date().getTime(),
            stack.getType().toString(),
            stack.getAmount(),
            stack.getData().getData(),
            location.getBlockX(),
            location.getBlockY(),
            location.getBlockZ(),
            location.getWorld().getName(),
            playerName);
    JSONObselManager.getInstance().addObsel(obsel);
}
项目:AutomaticInventory    文件:AIEventHandler.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPickupItem(PlayerPickupItemEvent event)
{
    Player player = event.getPlayer();
    if(featureEnabled(Features.SortInventory, player))
    {
        PlayerData playerData = PlayerData.FromPlayer(player);
        if(playerData.firstEmptySlot >= 0) return;

        PlayerInventory inventory = player.getInventory();
        int firstEmpty = inventory.firstEmpty();
        if(firstEmpty < 9) return;
        playerData.firstEmptySlot = firstEmpty; 
        PickupSortTask task = new PickupSortTask(player, playerData, inventory);
        Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AutomaticInventory.instance, task, 100L);
    }
}
项目:QuestManager    文件:QuestManager.java   
@EventHandler
public void onItemPickup(PlayerPickupItemEvent e) {

    if (e.isCancelled()) {
        return;
    }

    ItemStack item = e.getItem().getItemStack();

    if (item.getType().equals(Material.WRITTEN_BOOK)) {
        BookMeta meta = (BookMeta) item.getItemMeta();

        if (meta.getTitle().equals("Quest Log")) {
            e.getItem().remove();
            e.setCancelled(true);

            QuestManagerPlugin.questManagerPlugin.getPlayerManager().getPlayer(
                    e.getPlayer().getUniqueId()).addQuestBook();

        }
    }

}
项目:QuestManager    文件:DeliverRequirement.java   
@EventHandler
public void onInventoryChange(PlayerPickupItemEvent e) {
    if (this.participants == null) {
        return;
    }
    if (state) {
        return;
    }
    if (!e.isCancelled() && e.getItem().getItemStack().getType() == itemType) {

        for (QuestPlayer qp : participants.getParticipants()) {
            if (qp.getPlayer().getUniqueId().equals(e.getPlayer().getUniqueId())) {
                final Requirement req = this;
                Bukkit.getScheduler().runTaskLater(QuestManagerPlugin.questManagerPlugin, req::update, 1);
            }
        }

    }
}
项目:Statz    文件:ItemsPickedUpListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerPickUp(final PlayerPickupItemEvent event) {

    final PlayerStat stat = PlayerStat.ITEMS_PICKED_UP;

    // Get player
    final Player player = event.getPlayer();

    // Do general check
    if (!plugin.doGeneralCheck(player, stat))
        return;

    // Update value to new stat.
    plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, StatzUtil.makeQuery("uuid",
            player.getUniqueId().toString(), "value", event.getItem().getItemStack().getAmount(), "world", player.getWorld().getName(), "item", event.getItem().getItemStack().getType().toString()));

}
项目:Carbon-2    文件:EntityNewArrow.java   
@Override
public void d(final EntityHuman entityhuman) {
    if (!this.world.isClientSide && this.inGround && (this.shake <= 0)) {
        boolean pickup = (this.fromPlayer == 1) || ((this.fromPlayer == 2) && entityhuman.abilities.canInstantlyBuild);

        ItemStack itemstack = this.getItemStack();
        if ((this.fromPlayer == 1) && !entityhuman.inventory.pickup(itemstack)) {
            pickup = false;
        }

        final EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
        final PlayerPickupItemEvent event = new PlayerPickupItemEvent((Player) entityhuman.getBukkitEntity(), new CraftItem(this.world.getServer(), this, item), 0);
        this.world.getServer().getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return;
        }

        if (pickup) {
            this.makeSound("random.pop", 0.2F, (((this.random.nextFloat() - this.random.nextFloat()) * 0.7F) + 1.0F) * 2.0F);
            entityhuman.receive(this, 1);
            this.die();
        }
    }
}
项目:BedwarsRel    文件:PlayerListener.java   
@EventHandler
public void onPickup(PlayerPickupItemEvent ppie) {
  Player player = ppie.getPlayer();
  Game game = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(player);

  if (game == null) {
    game = BedwarsRel.getInstance().getGameManager().getGameByLocation(player.getLocation());
    if (game == null) {
      return;
    }
  }

  if (game.getState() != GameState.WAITING && game.isInGame(player)) {
    return;
  }

  ppie.setCancelled(true);
}
项目:PickupMoney    文件:MainListener.java   
@EventHandler
    public void onPickup(PlayerPickupItemEvent e){
        Item item = e.getItem();
        if(item.getCustomName()!=null) {
            String name = ChatColor.stripColor(item.getCustomName());
//      if(name!=null && ChatColor.stripColor(language.get("nameSyntax")).replace("{money}", "").equals(name.replaceAll(regex, ""))){
            e.setCancelled(true);
            String money = plugin.getMoney(name);
            Player p = e.getPlayer();
            if (p.hasPermission("PickupMoney.pickup")) {
                item.remove();
                float amount = Float.parseFloat(money);
                if(plugin.pickupMulti.containsKey(p.getUniqueId())) amount*=plugin.pickupMulti.get(p.getUniqueId());
                plugin.giveMoney(amount, p);
                p.sendMessage(plugin.language.get("pickup").replace("{money}", String.valueOf(amount)));
                if (plugin.fc.getBoolean("sound.enable")) {
                    p.getLocation().getWorld().playSound(p.getLocation(), Sound.valueOf(plugin.fc.getString("sound.type"))
                            , (float) plugin.fc.getDouble("sound.volumn")
                            , (float) plugin.fc.getDouble("sound.pitch"));
                }
            }
//      }
        }
    }
项目:Carbon-2    文件:EntityNewArrow.java   
@Override
public void d(final EntityHuman entityhuman) {
    if (!this.world.isClientSide && this.inGround && (this.shake <= 0)) {
        boolean pickup = (this.fromPlayer == 1) || ((this.fromPlayer == 2) && entityhuman.abilities.canInstantlyBuild);

        ItemStack itemstack = this.getItemStack();
        if ((this.fromPlayer == 1) && !entityhuman.inventory.pickup(itemstack)) {
            pickup = false;
        }

        final EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
        final PlayerPickupItemEvent event = new PlayerPickupItemEvent((Player) entityhuman.getBukkitEntity(), new CraftItem(this.world.getServer(), this, item), 0);
        this.world.getServer().getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return;
        }

        if (pickup) {
            this.makeSound("random.pop", 0.2F, (((this.random.nextFloat() - this.random.nextFloat()) * 0.7F) + 1.0F) * 2.0F);
            entityhuman.receive(this, 1);
            this.die();
        }
    }
}
项目:civcraft    文件:PlayerListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerPickup(PlayerPickupItemEvent event) {

    String name;
    boolean rare = false;
    if (event.getItem().getItemStack().getItemMeta().hasDisplayName()) {
        name = event.getItem().getItemStack().getItemMeta().getDisplayName();
        rare = true;
    } else {
        name = event.getItem().getItemStack().getType().name().replace("_", " ").toLowerCase();
    }

    Resident resident = CivGlobal.getResident(event.getPlayer());
    if (resident.getItemMode().equals("all")) {
        CivMessage.send(event.getPlayer(), CivColor.LightGreen+"You've picked up "+CivColor.LightPurple+event.getItem().getItemStack().getAmount()+" "+name);
    } else if (resident.getItemMode().equals("rare") && rare) {
        CivMessage.send(event.getPlayer(), CivColor.LightGreen+"You've picked up "+CivColor.LightPurple+event.getItem().getItemStack().getAmount()+" "+name);
    }
}
项目:civcraft    文件:BonusGoodieManager.java   
@EventHandler(priority = EventPriority.MONITOR) 
public void OnPlayerPickupItem(PlayerPickupItemEvent event) {
    BonusGoodie goodie = CivGlobal.getBonusGoodie(event.getItem().getItemStack());

    if (goodie == null) {
        return;
    }

    try {
        goodie.setHolder(event.getPlayer());
        goodie.update(false);
        goodie.updateLore(event.getItem().getItemStack());
    } catch (CivException e) {
        e.printStackTrace();
    }
}
项目:acidisland    文件:PlayerEvents2.java   
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onVisitorPickup(final PlayerPickupItemEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!IslandGuard.inWorld(e.getPlayer())) {
        return;
    }
    Island island = plugin.getGrid().getIslandAt(e.getItem().getLocation());
    if ((island != null && island.getIgsFlag(SettingsFlag.VISITOR_ITEM_PICKUP)) 
            || e.getPlayer().isOp() || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")
            || plugin.getGrid().locationIsOnIsland(e.getPlayer(), e.getItem().getLocation())) {
        return;
    }
    e.setCancelled(true);
}
项目:askyblock    文件:PlayerEvents2.java   
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onVisitorPickup(final PlayerPickupItemEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!IslandGuard.inWorld(e.getPlayer())) {
        return;
    }
    Island island = plugin.getGrid().getIslandAt(e.getItem().getLocation());
    if ((island != null && island.getIgsFlag(SettingsFlag.VISITOR_ITEM_PICKUP)) 
            || e.getPlayer().isOp() || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")
            || plugin.getGrid().locationIsOnIsland(e.getPlayer(), e.getItem().getLocation())) {
        return;
    }
    e.setCancelled(true);
}
项目:DDCustomPlugin    文件:DirectionBook.java   
public void onPlayerPickupBook(PlayerPickupItemEvent event) {
        final Player player = event.getPlayer();
        if (player.getWorld().equals(griefFree)) {
            Item drop = event.getItem();
            if (drop.equals(droppedBook) || drop.equals(droppedShovel) || drop.equals(droppedStick)) {
//              PlayerInventory playerInv = player.getInventory();
                if (!recieved.contains(player)) {
                    if (drop.equals(droppedBook)) {
                        spawnBook(false);
                        plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
                            @Override 
                            public void run() {
                                recieved.add(player);
                            }
                        }, 2);
                    }
                } else {
                    event.setCancelled(true);
                }
            }
        }
    }
项目:AntiBuild    文件:ItemPickup.java   
/**
     * Checks if player has proper permission to pickup items.
     *
     * @param event that triggers listener.
     */
    @EventHandler(priority = EventPriority.LOW)
    private void PickupItem(PlayerPickupItemEvent event) {
        Player player = event.getPlayer();

        // Pickup item check.
        if (player != null && !player.hasPermission("antibuild.bypass")) {
            if (!player.hasPermission("antibuild.pickupitems")) {
                event.setCancelled(true);
                // We can't message the player here or it spams.
            }
        }

//        // World Check
//        if (!event.isCancelled() && plugin.isUsingLock()) {
//            if (plugin.isLockedWorld(player.getWorld().getName())
//                    && !player.hasPermission("antibuild.lock.bypass") && !player.hasPermission("antibuild.lock
// .bypass" +
//                    "." + player.getWorld().getName())) {
//                event.setCancelled(true);
//                // We can't message the player here or it spams.
//            }
//        }
    }
项目:CardinalPGM    文件:ToolRepair.java   
@EventHandler
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
    if (!event.isCancelled()) {
        ItemStack item1 = event.getItem().getItemStack();
        if (materials.contains(item1.getType()) && event.getPlayer().getInventory().contains(item1.getType())) {
            for (ItemStack item2 : event.getPlayer().getInventory().getContents()) {
                if (item2 != null && Items.toMaxDurability(item1).equals(Items.toMaxDurability(item2))) {
                    event.setCancelled(true);
                    event.getItem().remove();
                    event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.1F, 1);
                    int result = item2.getDurability() - (item1.getType().getMaxDurability() - item1.getDurability());
                    item2.setDurability((short) (result < 0 ? 0 : result));
                    break;
                }
            }
        }
    }
}
项目:TNE-Bukkit    文件:PlayerListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onPickUp(final PlayerPickupItemEvent event) {
  final ItemStack stack = event.getItem().getItemStack();
  final String world = WorldFinder.getWorld(event.getPlayer(), WorldVariant.BALANCE);

  if(event.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
    Optional<TNECurrency> currency = TNE.manager().currencyManager().currencyFromItem(world, stack);
    currency.ifPresent((cur)->{
      UUID id = IDFinder.getID(event.getPlayer());
      TNE.saveManager().addSkip(id);
      Bukkit.getScheduler().runTaskLaterAsynchronously(TNE.instance(), new Runnable() {
        @Override
        public void run() {
          TNEAccount account = TNE.manager().getAccount(id);
          account.setHoldings(world, cur.name(), ItemCalculations.getCurrencyItems(account, cur));
          TNE.manager().addAccount(account);
          TNE.saveManager().removeSkip(id);
        }
      }, 5L);
      event.setCancelled(true);
    });
  }
}
项目:NPlugins    文件:ItemListener.java   
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerPickupItem(final PlayerPickupItemEvent event) {
    this.plugin.entering(this.getClass(), "onPlayerPickupItem");
    final Item i = event.getItem();
    if (this.itemMap.containsKey(i)) {
        this.plugin.debug("Item is handled by an Altar");
        final String playerName = event.getPlayer().getName();
        final String awaitedPlayerName = this.itemMap.get(i);
        if (!playerName.equals(awaitedPlayerName)) {
            if (this.plugin.isDebugEnabled()) {
                this.plugin.debug("Not the right player (" + playerName + "), cancel pickup. Awaited '" + awaitedPlayerName + '\'');
            }
            event.setCancelled(true);
        } else {
            this.plugin.debug("Right player, allow pickup");
            this.itemMap.remove(i);
            final Altar altar = this.plugin.getAltars().get(new ChunkCoord(i.getLocation().getChunk()));
            if (altar != null) {
                this.plugin.getItemProvidedToLockedTransition().doTransition(altar);
            }
        }
    }
    this.plugin.exiting(this.getClass(), "onPlayerPickupItem");
}
项目:UltimateArena    文件:PlayerListener.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerPickupItem(PlayerPickupItemEvent event) 
{
    Player pl = event.getPlayer();
    if (pl != null)
    {
        if (plugin.isInArena(pl))
        {
            if (plugin.getArena(pl).type.equals("Hunger"))
            {
                event.setCancelled(false);
            }
            else
            {
                event.setCancelled(true);
            }
        }
    }
}
项目:simple-survival-games    文件:SSGPlayerListener.java   
@EventHandler
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
    Player p = event.getPlayer();
    ArenaManager am = SimpleSurvivalGames.instance.getArenaManager();

    // Is the current player playing
    if(am.isInArena(p)) {
        ArenaPlayer ap = am.getPlayer(p);

        // Is the player in the lobby of the arena
        if(ap.isInLobby()) {

            // Has the player a arena spawn assigned
            if(ap.hasAssignedAreanSpawn())
                event.setCancelled(true);
        }

        // Is the player an spectators
        if(ap.isSpectator())
            event.setCancelled(true);
    }
}
项目:Essentials    文件:EssentialsAntiBuildListener.java   
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent event)
{

    final Player user = event.getPlayer();
    final ItemStack item = event.getItem().getItemStack();

    if (antib.getSettings().getData().isDisableUse() && !Permissions.BUILD.isAuthorized(user))
    {
        if (!Permissions.PICKUP.isAuthorized(user, item.getType(), item.getData()))
        {
            event.setCancelled(true);
            event.getItem().setPickupDelay(50);
        }
    }
}
项目:BedwarsXP    文件:NewEventListeners.java   
@EventHandler
public void onItemPickup(PlayerPickupItemEvent e) {
    Game bw = io.github.bedwarsrel.BedwarsRel.Main.getInstance()
            .getGameManager().getGameOfPlayer(e.getPlayer());
    if (bw == null) {
        return;
    }
    if (!Config.isGameEnabledXP(bw.getName())) {
        return;
    }
    Player p = e.getPlayer();
    Item entity = e.getItem();
    ItemStack stack = entity.getItemStack();
    int count = Res.convertResToXP(stack);
    if (count == 0) {
        return;
    }
    e.setCancelled(true);
    XPManager.addXP(bw.getName(), p, count);
    p.playSound(p.getLocation(),
            SoundMachine.get("ORB_PICKUP", "ENTITY_EXPERIENCE_ORB_PICKUP"),
            10.0F, 1.0F);
    if (!Config.Message.equals("")) {
        ActionBarUtils.sendActionBar(p,
                Config.Message.replaceAll("%xp%", Integer.toString(count)));
        /*
         * if (!ActionBarUtils.works) {
         * p.sendMessage(Config.Message.replaceAll("%xp%",
         * Integer.toString(count))); }
         */
    }
    entity.remove();
}
项目:BedwarsXP    文件:OldEventListeners.java   
@EventHandler
public void onItemPickup(PlayerPickupItemEvent e) {
    Game bw = io.github.yannici.bedwars.Main.getInstance().getGameManager()
            .getGameOfPlayer(e.getPlayer());
    if (bw == null) {
        return;
    }
    if (!Config.isGameEnabledXP(bw.getName())) {
        return;
    }
    Player p = e.getPlayer();
    Item entity = e.getItem();
    ItemStack stack = entity.getItemStack();
    int count = Res.convertResToXP(stack);
    if (count == 0) {
        return;
    }
    e.setCancelled(true);
    XPManager.addXP(bw.getName(), p, count);
    p.playSound(p.getLocation(),
            SoundMachine.get("ORB_PICKUP", "ENTITY_EXPERIENCE_ORB_PICKUP"),
            10.0F, 1.0F);
    if (!Config.Message.equals("")) {
        ActionBarUtils.sendActionBar(p,
                Config.Message.replaceAll("%xp%", Integer.toString(count)));
        /*
         * if (!ActionBarUtils.works) {
         * p.sendMessage(Config.Message.replaceAll("%xp%",
         * Integer.toString(count))); }
         */
    }
    entity.remove();
}
项目:ZentrelaRPG    文件:DropManager.java   
@EventHandler
public void pickupItemEvent(PlayerPickupItemEvent event) {
    UUID iuuid = event.getItem().getUniqueId();
    if (itemMapTime.containsKey(iuuid)) {
        if (System.currentTimeMillis() - itemMapTime.get(iuuid) < 10000) {
            UUID owneruuid = itemMapOwner.get(iuuid);
            Player owner = plugin.getServer().getPlayer(owneruuid);
            PlayerDataRPG pdo = plugin.getPD(owner);
            PlayerDataRPG pd = plugin.getPD(event.getPlayer());
            if (owneruuid == null || owneruuid.equals(event.getPlayer().getUniqueId()) || (pdo != null && pd != null && pd.party != null && pd.party != pdo.party && pd.party.isLootshareActive())) {
                itemMapTime.remove(iuuid);
                itemMapOwner.remove(iuuid);
                return; // all good
            } else {
                event.setCancelled(true);
                if (plugin.getPD(event.getPlayer()) != null && plugin.getPD(event.getPlayer()).getOption(SakiOption.ITEM_PROTECT)) {
                    if (playerMapMessaged.containsKey(event.getPlayer().getUniqueId()) && System.currentTimeMillis() - playerMapMessaged.get(event.getPlayer().getUniqueId()) < 5000) {
                        // dont spam msg
                    } else {
                        event.getPlayer().sendMessage(ChatColor.RED + " You can't pick up this item yet because of item protection!");
                        event.getPlayer().sendMessage(ChatColor.RED + " Monster drops are only lootable by the highest damage dealer for 10 seconds.");
                        event.getPlayer().sendMessage(ChatColor.RED + " Skill-related items are only lootable by the creator of the item for 10 seconds.");
                        playerMapMessaged.put(event.getPlayer().getUniqueId(), System.currentTimeMillis());
                    }
                }
            }
        } else {
            itemMapTime.remove(iuuid);
            itemMapOwner.remove(iuuid);
        }
    }
}
项目:ZentrelaRPG    文件:DropManager.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onItemPickup(PlayerPickupItemEvent event) {
    if (event.getItem().hasMetadata(RMetadata.META_NO_PICKUP)) {
        event.setCancelled(true);
        return;
    }
    if (event.getRemaining() == 0 && !event.isCancelled())
        removeLabel(event.getItem());
}
项目:EscapeLag    文件:RPGItemPatch.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPickup(PlayerPickupItemEvent evt) {
    if (!fixRPGItemInfItem) return;

    if (evt.getRemaining() <= 0) {
        evt.getItem().remove();
    }
}
项目:Slimefun4-Chinese-Version    文件:ItemPickupListener.java   
@EventHandler
public void onPickup(PlayerPickupItemEvent e) {
    if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true);
    else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith("&5&dALTAR &3Probe - &e")) {
        e.setCancelled(true);
        e.getItem().remove();
    }
}
项目:ProjectAres    文件:ToolRepairMatchModule.java   
private void doRepair(PlayerPickupItemEvent event, ItemStack stack) {
    ItemStack pickup = event.getItem().getItemStack();

    int hitsLeft = pickup.getType().getMaxDurability() - pickup.getDurability() + 1;
    stack.setDurability((short) Math.max(stack.getDurability() - hitsLeft, 0));

    event.setCancelled(true);
    event.getItem().remove();
    event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.5f, 1f);
}
项目:ProjectAres    文件:ToolRepairMatchModule.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void processRepair(PlayerPickupItemEvent event) {
    ItemStack pickup = event.getItem().getItemStack();

    if(this.toRepair.contains(pickup.getType())) {
        PlayerInventory inv = event.getPlayer().getInventory();
        for(ItemStack invStack : inv.contents()) {
            if(this.canRepair(pickup, invStack)) {
                this.doRepair(event, invStack);
                return;
            }
        }
    }
}
项目:ProjectAres    文件:ItemTransferListener.java   
@EventHandler
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
    // When this event is fired, the ItemStack in the Item being picked up is temporarily
    // set to the amount that will actually be picked up, while the difference from the
    // actual amount in the stack is available from getRemaining(). When the event returns,
    // the original amount is restored to the stack, meaning that we can't change the amount
    // from inside the event, so instead we replace the entire stack.

    int initialQuantity = event.getItem().getItemStack().getAmount();
    PlayerItemTransferEvent transferEvent = new PlayerItemTransferEvent(
        event, ItemTransferEvent.Type.PICKUP, event.getPlayer(),
        Optional.empty(),
        Optional.of(new InventorySlot<>(event.getPlayer().getInventory())),
        event.getItem().getItemStack(), event.getItem(),
        initialQuantity, event.getPlayer().getOpenInventory().getCursor()
    );

    this.callEvent(transferEvent);

    int quantity = Math.min(transferEvent.getQuantity(), initialQuantity);

    if(!event.isCancelled() && quantity < initialQuantity) {
        event.setCancelled(true);
        if(quantity > 0) {
            ItemStack stack = event.getItem().getItemStack().clone();
            stack.setAmount(stack.getAmount() - quantity);
            event.getItem().setItemStack(stack);

            stack = stack.clone();
            stack.setAmount(quantity);
            event.getPlayer().getInventory().addItem(stack);
            event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 1, 1);
        }
    }
}
项目:OpenUHC    文件:BenchBlitz.java   
/**
 * Limits the player to one workbench in their inventory at a time, by means of picking up an item.
 *
 * @param event The event
 */
@EventHandler(ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
  Item item = event.getItem();
  Player player = event.getPlayer();
  if (item.getItemStack().getType().equals(Material.WORKBENCH)
      && player.getInventory().contains(Material.WORKBENCH)) {
    event.setCancelled(true);
    item.setPickupDelay(20);

    player.sendMessage(ChatColor.RED + "You may not pick up another workbench!");
  }
}
项目:OpenUHC    文件:Bowless.java   
/**
 * Prevents a player from picking up a bow.
 *
 * @param event The event
 */
@EventHandler(ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
  Item item = event.getItem();
  if (item.getItemStack().getType().equals(Material.BOW)) {
    event.setCancelled(true);
    item.setPickupDelay(20);

    event.getPlayer().sendMessage(ChatColor.RED + "You may not pick up a bow!");
  }
}
项目:kaosEssentials    文件:Core.java   
@EventHandler
public void getEmerald(PlayerPickupItemEvent e){
    Player p = e.getPlayer();
    String uuid = p.getUniqueId().toString();
    if(e.getItem().getItemStack().getType().equals(Material.EMERALD)){
        e.setCancelled(true);
        int amount = e.getItem().getItemStack().getAmount();
        e.getItem().remove();
        setEmeralds(uuid, getEmeralds(uuid)+amount);
        p.playNote(p.getLocation(), Instrument.PIANO, Note.natural(1, Tone.A));
    }
}
项目:mczone    文件:GeneralEvents.java   
@EventHandler
public void onPlayerDropItem(PlayerPickupItemEvent event) {
    Gamer g = Gamer.get(event.getPlayer());
    event.setCancelled(true);
    if (g.getVariable("edit") != null) {
        if ((boolean) g.getVariable("edit"))
            event.setCancelled(false);
    }
}
项目:mczone    文件:GeneralEvents.java   
@EventHandler
public void onPlayerDropItem(PlayerPickupItemEvent event) {
    Gamer g = Gamer.get(event.getPlayer());
    event.setCancelled(true);
    if (g.getVariable("edit") != null) {
        if ((boolean) g.getVariable("edit"))
            event.setCancelled(false);
    }
}