Fixes points to next level bug.

https://github.com/BentoBoxWorld/addon-level/issues/17
This commit is contained in:
tastybento 2018-08-23 12:05:28 -07:00
parent c8e753af16
commit 4c7a6a710c
3 changed files with 3 additions and 5 deletions

View File

@ -70,7 +70,7 @@
<dependency>
<groupId>world.bentobox</groupId>
<artifactId>bentobox</artifactId>
<version>FC-1</version>
<version>0.9.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -207,9 +207,7 @@ public class CalcIslandLevel {
// Set final score
result.level = (result.rawBlockCount / addon.getSettings().getLevelCost()) - result.deathHandicap - island.getLevelHandicap();
// Calculate how many points are required to get to the next level
result.pointsToNextLevel = (addon.getSettings().getLevelCost() * (result.level + 1 + island.getLevelHandicap())) - (result.rawBlockCount - (result.deathHandicap * addon.getSettings().getDeathPenalty()));
// Sometimes it will return 0, so calculate again to make sure it will display a good value
if(result.pointsToNextLevel == 0) result.pointsToNextLevel = (addon.getSettings().getLevelCost() * (result.level + 2 + island.getLevelHandicap()) - (result.rawBlockCount - (result.deathHandicap * addon.getSettings().getDeathPenalty())));
result.pointsToNextLevel = addon.getSettings().getLevelCost() - (result.rawBlockCount % addon.getSettings().getLevelCost());
// Report
result.report = getReport();
// All done.

View File

@ -71,7 +71,7 @@ public class PlayerLevel {
}
// Send player how many points are required to reach next island level
if (results.getPointsToNextLevel() >= 0) {
asker.sendMessage("island.level.required-points-to-next-level", "[points]", String.valueOf(addon.getIslandLevel(world, targetPlayer)));
asker.sendMessage("island.level.required-points-to-next-level", "[points]", String.valueOf(results.getPointsToNextLevel()));
}
// Tell other team members
if (addon.getIslandLevel(world, targetPlayer) != oldLevel) {