Java 类org.bukkit.event.entity.EntityPickupItemEvent 实例源码

项目:bskyblock    文件:VisitorGuard.java   
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onVisitorPickup(final EntityPickupItemEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (e.getEntity() instanceof Player) {
        Player player = (Player)e.getEntity();
        if (!Util.inWorld(player)) {
            return;
        }
        Island island = plugin.getIslands().getIslandAt(e.getItem().getLocation());
        if ((island != null && island.getFlag(SettingsFlag.ITEM_PICKUP)) 
                || player.isOp() || VaultHelper.hasPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")
                || plugin.getIslands().locationIsOnIsland(player, e.getItem().getLocation())) {
            return;
        }
        e.setCancelled(true);
    }
}
项目:Damocles    文件:EventCanceller.java   
@EventHandler
public void pickupItemEvent(EntityPickupItemEvent event){
    if(event.getItem().getItemStack().getType().equals(Material.EMERALD)){
        if(event.getItem().getItemStack().getItemMeta().hasDisplayName()){
            if(event.getItem().getItemStack().getItemMeta().getDisplayName().contains("$")){
                if(event.getEntity() instanceof Player){
                    String name = event.getItem().getItemStack().getItemMeta().getDisplayName();
                    name = name.replace("$", "");
                    new Treasury(new Account((Player)event.getEntity()).getLoadedCharacter()).deposit(Integer.valueOf(name));
                    ((Player)event.getEntity()).sendMessage(ChatColor.YELLOW+"You have picked up $"+ Integer.valueOf(name)+" Dollars!");
                }
                event.setCancelled(true);
                event.getItem().remove();
            }
        }
    }
}
项目:acidisland    文件:PlayerEvents3.java   
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onVisitorPickup(final EntityPickupItemEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (e.getEntity() instanceof Player) {
        Player player = (Player)e.getEntity();
        if (!IslandGuard.inWorld(player)) {
            return;
        }
        Island island = plugin.getGrid().getIslandAt(e.getItem().getLocation());
        if ((island != null && island.getIgsFlag(SettingsFlag.VISITOR_ITEM_PICKUP)) 
                || player.isOp() || VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")
                || plugin.getGrid().locationIsOnIsland(player, e.getItem().getLocation())) {
            return;
        }
        e.setCancelled(true);
    }
}
项目:askyblock    文件:PlayerEvents3.java   
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onVisitorPickup(final EntityPickupItemEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (e.getEntity() instanceof Player) {
        Player player = (Player)e.getEntity();
        if (!IslandGuard.inWorld(player)) {
            return;
        }
        Island island = plugin.getGrid().getIslandAt(e.getItem().getLocation());
        if ((island != null && island.getIgsFlag(SettingsFlag.VISITOR_ITEM_PICKUP)) 
                || player.isOp() || VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")
                || plugin.getGrid().locationIsOnIsland(player, e.getItem().getLocation())) {
            return;
        }
        e.setCancelled(true);
    }
}
项目:PlotSquared    文件:PlotPlusListener_1_12.java   
@EventHandler
public void onItemPickup(EntityPickupItemEvent event) {
    LivingEntity ent = event.getEntity();
    if (ent instanceof Player) {
        Player player = (Player) ent;
        PlotPlayer pp = BukkitUtil.getPlayer(player);
        Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
        if (plot == null) {
            return;
        }
        UUID uuid = pp.getUUID();
        if (!plot.isAdded(uuid) && Flags.DROP_PROTECTION.isTrue(plot)) {
            event.setCancelled(true);
        }
    }
}
项目:CraftyProfessions    文件:CoreListener.java   
/**
 * THIS METHOD IS FOR TESTING ONLY AND WILL NOT BE USED IN THE FINAL PRODUCTION
 */
@EventHandler
public void onEntityPickup (EntityPickupItemEvent event)
{
    Entity player = event.getEntity ();

    if (player instanceof Player)
    {
        player.sendMessage (event.getItem ().getName ());
        // TODO: Use the below way to retrieve the Material Type from an Item.
        player.sendMessage (event.getItem ().getItemStack ().getType ().toString ());
        player.sendMessage (event.getItem ().getItemStack ().getData ().toString ());
        player.sendMessage (event.getItem ().getItemStack ().getItemMeta ().toString ());
    }
}
项目:Warzone    文件:WoolObjective.java   
@EventHandler
public void onPickup(EntityPickupItemEvent event) {
    if (event.getEntity() instanceof Player) {
        if (event.getItem() != null && event.getItem().getItemStack().getType() == Material.WOOL) {
            if (event.getItem().getItemStack().getData().getData() == color) {
                handleWoolPickup(((Player) event.getEntity()).getPlayer());
            }
        }
    }
}
项目:Slimefun4-Chinese-Version    文件:ItemPickupListener_1_12.java   
@EventHandler
public void onPickup(EntityPickupItemEvent 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();
    }
}
项目:AddGun    文件:Guns.java   
/**
 * This prevents from picking up a gun if you already have one
 * 
 * @param event The pickup event.
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void pickupWeaponEvent(EntityPickupItemEvent event) {
    if (event.getItem() == null) return;
    StandardGun gun = findGun(event.getItem().getItemStack());
    if (gun != null && gun.isLimitToOne() && gun.hasGun(event.getEntity())) {
        event.setCancelled(true);
        gun.optionallyWarn(event.getEntity(), ChatColor.RED + "A " + ChatColor.AQUA + gun.getName() + ChatColor.RED + " is already in inventory, you cannot pick up another.");
    }
}
项目:AddGun    文件:RailGun.java   
/**
 * This prevents from picking up a gun if you already have one
 * 
 * @param event The pickup event.
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void pickupWeaponEvent(EntityPickupItemEvent event) {
    if (!enabled || event.getItem() == null) return;
    if (isGun(event.getItem().getItemStack()) && hasGun(event.getEntity())) {
        event.setCancelled(true);
        if (!warned.contains(event.getEntity().getUniqueId())) {
            event.getEntity().sendMessage(ChatColor.RED + "A " + ChatColor.AQUA + getName() + ChatColor.RED + " is already in inventory, it's too heavy to carry two!");
            warned.add(event.getEntity().getUniqueId());
        }
    }
}
项目:Damocles    文件:AnvilHandler.java   
@EventHandler
public void onItemPickup(EntityPickupItemEvent event){
    for(Anvil anvil : anvils){
        if(anvil.getItem().equals(event.getItem())){
            event.setCancelled(true);
        }
    }
}
项目:HamsterEcoHelper    文件:Events.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onPickupItem(EntityPickupItemEvent e) {
    if (e.getItem() != null && MarketManager.isMarketItem(e.getItem().getItemStack())) {
        e.getItem().setItemStack(new ItemStack(Material.AIR));
        e.setCancelled(true);
    }
}
项目:NyaaUtils    文件:LootProtectListener.java   
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPickup(EntityPickupItemEvent e) {
    if (plugin.cfg.lootProtectMode == LootProtectMode.OFF || !(e.getEntity() instanceof Player))
        return;
    Player p = (Player) e.getEntity();
    if (!p.isSneaking() && bypassVanillaPlayer.get(p.getUniqueId()) == VanillaStrategy.REJECT) {
        ItemStack item = e.getItem().getItemStack();
        if (!(item.hasItemMeta() && item.getItemMeta().hasLore())) {
            e.setCancelled(true);
        }
    }
}
项目:Slimefun4    文件:ItemPickupListener_1_12.java   
@EventHandler
public void onPickup(EntityPickupItemEvent 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();
    }
}
项目:EnchantmentAPI    文件:ItemListener.java   
@EventHandler
public void onPickup(final EntityPickupItemEvent event) {
    if (event.getEntity() instanceof Player) {
        final PlayerEquips equips = Enchantments.getEquipmentData((Player) event.getEntity());
        Tasks.schedule(() -> equips.updateWeapon(((Player) event.getEntity()).getInventory()));
    }
}
项目:Warzone    文件:SpectatorModule.java   
@EventHandler
public void onPickup(EntityPickupItemEvent event) {
    if (event instanceof Player && isSpectating((Player) event.getEntity())) {
        event.setCancelled(true);
    }
}
项目:Kineticraft    文件:FarmLimiter.java   
@EventHandler(ignoreCancelled = true) // Prevent items that entities pickup from being lost on death.
public void onItemPickup(EntityPickupItemEvent evt) {
    addPlayerDamage(evt.getEntity(), 100);
}
项目:NyaaUtils    文件:DropProtectListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onPickup(EntityPickupItemEvent e) {
    if (plugin.cfg.dropProtectMode == DropProtectMode.OFF) return;
    items.invalidate(e.getItem().getEntityId());
}