Solved PlayerDeathEvent not working

  • After careful consideration and due to limited usage, we’ve made the decision to discontinue the PaperMC forums. Moving forward, we recommend using Hangar for plugin uploads, and for all other community discussions and support, please join us on Discord.

mmmjjkx

New member
Aug 16, 2022
3
0
1
The PlayerDeathEvent is not working.
Here's my code:
Code:
@EventHandler
private void Item(PlayerDeathEvent e){
    if(PlayerDeathPenalty.config.getBoolean("item.enabled")) {
        if(e.getEntity().hasPermission("playerdeathpenalty.bypass")) {
            return;
        }
        Player p = e.getEntity();
        World w = p.getLocation().getWorld();
        if(PlayerDeathPenalty.config.getStringList("item.worlds").contains(w.getName())) {
            List<Integer> slots = PlayerDeathPenalty.getSlots(PermManager.getItemGroup(p));
            Location loc = p.getLocation();
            PlayerInventory pl = p.getInventory();
            int s = slots.size();
            for (int slot : slots) {
                ItemStack is = pl.getItem(slot);
                if (is == null) {
                    s = s - 1;
                    continue;
                }
                pl.setItem(slot, new ItemStack(Material.AIR));
                w.dropItem(loc, is);
            }
            CommandRunner.runCommand("item",p);
            p.sendMessage(ChatColor.translateAlternateColorCodes('&',
                    Objects.requireNonNull(PlayerDeathPenalty.config.getString("item.message"))
                            .replaceAll("%num%", String.valueOf(s))));
        }
    }
}
Who can help me?
 

Tacklezaza

New member
Aug 14, 2022
15
0
1
You mean event is not being called?
What is not working?

Did you register event listener onEnable()?