public void setLevel(int level) { this.level = level; int totalExp = 0; for (int i = 0; i < level; i++) { totalExp += ExperienceHolderUtils.getExpBetweenLevels(i); } this.totalExp = totalExp; this.expSinceLevel = 0; this.expBetweenLevels = ExperienceHolderUtils.getExpBetweenLevels(level); }
public void setTotalExp(int totalExp) { this.totalExp = totalExp; int level = 0; for (int i = totalExp; i > 0; i -= ExperienceHolderUtils.getExpBetweenLevels(level)) { level++; if (i - ExperienceHolderUtils.getExpBetweenLevels(level) <= 0) { this.expSinceLevel = i; this.expBetweenLevels = ExperienceHolderUtils.getExpBetweenLevels(level); this.level = level; break; } } }
public SpongeExperienceHolderData(int level, int totalExp, int expSinceLevel) { super(ExperienceHolderData.class); this.level = level; this.expBetweenLevels = ExperienceHolderUtils.getExpBetweenLevels(level); this.totalExp = totalExp; this.expSinceLevel = expSinceLevel; registerGettersAndSetters(); }