java类org.bukkit.event.player.PlayerPickupItemEvent的实例源码

ActivePowerup.java 文件源码 项目:SamaGamesAPI 阅读 29 收藏 0 点赞 0 评论 0
@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());
        }
    }
}
BasicFeatures.java 文件源码 项目:UltimateSpawn 阅读 30 收藏 0 点赞 0 评论 0
@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);
            }
        }
    }
}
InventoryListener.java 文件源码 项目:RPGInventory 阅读 21 收藏 0 点赞 0 评论 0
@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);
        }
    }
}
CapturableObjective.java 文件源码 项目:GamePlate 阅读 20 收藏 0 点赞 0 评论 0
@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()));
            }
        }
    }
}
PAEventHandler.java 文件源码 项目:PhantomAdmin 阅读 24 收藏 0 点赞 0 评论 0
@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;
 }
}
MinetraceListener.java 文件源码 项目:Minetrace 阅读 27 收藏 0 点赞 0 评论 0
@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);
}
AIEventHandler.java 文件源码 项目:AutomaticInventory 阅读 23 收藏 0 点赞 0 评论 0
@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.java 文件源码 项目:QuestManager 阅读 25 收藏 0 点赞 0 评论 0
@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();

        }
    }

}
DeliverRequirement.java 文件源码 项目:QuestManager 阅读 20 收藏 0 点赞 0 评论 0
@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);
            }
        }

    }
}
ItemsPickedUpListener.java 文件源码 项目:Statz 阅读 22 收藏 0 点赞 0 评论 0
@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()));

}
EntityNewArrow.java 文件源码 项目:Carbon-2 阅读 21 收藏 0 点赞 0 评论 0
@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();
        }
    }
}
PlayerListener.java 文件源码 项目:BedwarsRel 阅读 25 收藏 0 点赞 0 评论 0
@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);
}
MainListener.java 文件源码 项目:PickupMoney 阅读 31 收藏 0 点赞 0 评论 0
@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"));
                }
            }
//      }
        }
    }
EntityNewArrow.java 文件源码 项目:Carbon-2 阅读 21 收藏 0 点赞 0 评论 0
@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();
        }
    }
}
PlayerListener.java 文件源码 项目:civcraft 阅读 25 收藏 0 点赞 0 评论 0
@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);
    }
}
BonusGoodieManager.java 文件源码 项目:civcraft 阅读 28 收藏 0 点赞 0 评论 0
@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();
    }
}
PlayerEvents2.java 文件源码 项目:acidisland 阅读 23 收藏 0 点赞 0 评论 0
@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);
}
PlayerEvents2.java 文件源码 项目:askyblock 阅读 17 收藏 0 点赞 0 评论 0
@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);
}
DirectionBook.java 文件源码 项目:DDCustomPlugin 阅读 25 收藏 0 点赞 0 评论 0
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);
                }
            }
        }
    }
ItemPickup.java 文件源码 项目:AntiBuild 阅读 19 收藏 0 点赞 0 评论 0
/**
     * 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.
//            }
//        }
    }
ToolRepair.java 文件源码 项目:CardinalPGM 阅读 62 收藏 0 点赞 0 评论 0
@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;
                }
            }
        }
    }
}
PlayerListener.java 文件源码 项目:TNE-Bukkit 阅读 19 收藏 0 点赞 0 评论 0
@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);
    });
  }
}
ItemListener.java 文件源码 项目:NPlugins 阅读 24 收藏 0 点赞 0 评论 0
@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");
}
PlayerListener.java 文件源码 项目:UltimateArena 阅读 20 收藏 0 点赞 0 评论 0
@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);
            }
        }
    }
}
SSGPlayerListener.java 文件源码 项目:simple-survival-games 阅读 30 收藏 0 点赞 0 评论 0
@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);
    }
}
EssentialsAntiBuildListener.java 文件源码 项目:Essentials 阅读 23 收藏 0 点赞 0 评论 0
@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);
        }
    }
}
NewEventListeners.java 文件源码 项目:BedwarsXP 阅读 25 收藏 0 点赞 0 评论 0
@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();
}
OldEventListeners.java 文件源码 项目:BedwarsXP 阅读 30 收藏 0 点赞 0 评论 0
@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();
}
DropManager.java 文件源码 项目:ZentrelaRPG 阅读 24 收藏 0 点赞 0 评论 0
@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);
        }
    }
}
DropManager.java 文件源码 项目:ZentrelaRPG 阅读 19 收藏 0 点赞 0 评论 0
@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());
}


问题


面经


文章

微信
公众号

扫码关注公众号