level goes up if experience go up
This commit is contained in:
parent
ea28a9ce69
commit
9fdb944f94
1 changed files with 9 additions and 0 deletions
|
@ -22,6 +22,9 @@ import org.jetbrains.annotations.Nullable;
|
|||
|
||||
public class SRPlayer {
|
||||
|
||||
private static final List<Long> levelRequirements =
|
||||
List.of(100L, 200L, 400L, 800L, 1600L, 3200L, 6400L, 12800L, 25600L, 51200L);
|
||||
|
||||
@Expose private UUID uuid = null;
|
||||
@Expose private int level = 1;
|
||||
@Expose private Long experience = 0L;
|
||||
|
@ -242,6 +245,12 @@ public class SRPlayer {
|
|||
}
|
||||
|
||||
public void setExperience(Long experience) {
|
||||
// checks if experience is above next level requirements
|
||||
if (experience >= levelRequirements.get(level - 1)) {
|
||||
PlayerManager pm = PlayerManager.getInstance(PlayerManager.class);
|
||||
setLevel(level + 1);
|
||||
pm.levelUp(this, level - 1);
|
||||
}
|
||||
this.experience = experience;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue