Replacement for ChangeLevelEvent?


#1

Dear all,

I am currently using the latest version (7.2.0-20190808.184451-25 ) of the API and the ChangeLevelEvent is marked deprecated. The java documentation doesn’t mentioned it is deprecated and inside the code on Github there is no comment, which event I should use now to determine the change of a players level. I tried to use the depreated ChangeLevelEvent but it doesn’t get triggered when a player levels up.

Is this a ongoing change in the latest version of the API or did I miss something and there is a other event or way to recognise or handle player level changes?

Regards
Sascha


#2

Github does say why it is deprecated. Shown on this line.


#3

Oh damn … feel stupid now … I missed that. Thanks for correcting me.

I tried to use the ChangeEntityExperienceEvent but it didn’t get triggered. I opened a case on gitub for that. I will update this topic as soon I get new information.


#4

With the latest build SpongeForge Version: 1.12.2-2838-7.1.7-RC3898 the event gets triggered.

This is how you determine a level change with the event

if (event.getOriginalData().level().get() != event.getFinalData().level().get())