Help with PlayerExpChangeEvent

Discussion in 'Plugin Development' started by AviraManager, Oct 25, 2021.

Thread Status:
Not open for further replies.
  1. Offline

    AviraManager

    Hey, can someone tell me why this piece of code isn't working? I want the experience level of all online players to always be the same.
    Changing the experience level of all players using a command worked, but as soon as I tried changing the xp using the PlayerExpChangeEvent, it didn't work anymore

    Code:
    vpublic void onExpChange(PlayerExpChangeEvent event) {
           
           
            Player player = event.getPlayer();
            for(Player all : Bukkit.getServer().getOnlinePlayers())
            {
                all.setLevel(player.getLevel());
                all.setExp(player.getExp());
            }
        }
    }
    (Please also tell me common and easy to spot mistakes, I'm really new to scripting)
     
  2. Online

    timtower Administrator Administrator Moderator

    @AviraManager Did you add the @EventHandler? Did you register the event?
     
Thread Status:
Not open for further replies.

Share This Page