loc.getworld().playsound(_ code example

Example: loc.getworld().playsound(_

@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);
        }
    }
}

Tags:

Java Example