Ignore island initial level if island levels are not zeroed.

Set BEDROCK to value 0 by default.
This commit is contained in:
tastybento 2020-08-15 10:16:56 -07:00
parent 000463e10c
commit 6c168731d8
4 changed files with 20 additions and 6 deletions

View File

@ -190,7 +190,9 @@ public class Level extends Addon implements Listener {
new AdminLevelCommand(this, adminCommand);
new AdminTopCommand(this, adminCommand);
new AdminLevelStatusCommand(this, adminCommand);
new AdminSetInitialLevelCommand(this, adminCommand);
if (getSettings().isZeroNewIslandLevels()) {
new AdminSetInitialLevelCommand(this, adminCommand);
}
});
gm.getPlayerCommand().ifPresent(playerCmd -> {
new IslandLevelCommand(this, playerCmd);

View File

@ -266,7 +266,7 @@ public class LevelsManager {
}
panel.build();
}
private void addSelf(World world, User user, PanelBuilder panel) {
if (addon.getIslands().hasIsland(world, user) || addon.getIslands().inTeam(world, user.getUniqueId())) {
PanelItem head = getHead(0, this.getIslandLevel(world, user.getUniqueId()), user.getUniqueId(), user, world);
@ -496,7 +496,9 @@ public class LevelsManager {
String id = island.getUniqueId();
IslandLevels il = levelsCache.computeIfAbsent(id, IslandLevels::new);
// Remove the initial level
il.setLevel(lv - il.getInitialLevel());
if (addon.getSettings().isZeroNewIslandLevels()) {
il.setLevel(lv - il.getInitialLevel());
}
handler.saveObjectAsync(levelsCache.get(id));
// Update TopTen
addToTopTen(world, targetPlayer, levelsCache.get(id).getLevel());
@ -515,7 +517,10 @@ public class LevelsManager {
Island island = addon.getIslands().getIsland(world, owner);
if (island == null) return;
IslandLevels ld = levelsCache.computeIfAbsent(island.getUniqueId(), IslandLevels::new);
ld.setLevel(r.getLevel() - ld.getInitialLevel());
// Remove the initial level
if (addon.getSettings().isZeroNewIslandLevels()) {
ld.setLevel(r.getLevel() - ld.getInitialLevel());
}
ld.setUwCount(Maps.asMap(r.getUwCount().elementSet(), elem -> r.getUwCount().count(elem)));
ld.setMdCount(Maps.asMap(r.getMdCount().elementSet(), elem -> r.getMdCount().count(elem)));
ld.setPointsToNextLevel(r.getPointsToNextLevel());

View File

@ -238,9 +238,15 @@ public class IslandLevelCalculator {
reportLines.add("Formula to calculate island level: " + addon.getSettings().getLevelCalc());
reportLines.add("Level cost = " + addon.getSettings().getLevelCost());
reportLines.add("Deaths handicap = " + results.deathHandicap.get());
reportLines.add("Initial island level = " + (0L - addon.getManager().getInitialLevel(island)));
if (addon.getSettings().isZeroNewIslandLevels()) {
reportLines.add("Initial island level = " + (0L - addon.getManager().getInitialLevel(island)));
}
reportLines.add("Previous level = " + addon.getManager().getIslandLevel(island.getWorld(), island.getOwner()));
reportLines.add("New level = " + (results.getLevel() - addon.getManager().getInitialLevel(island)));
if (addon.getSettings().isZeroNewIslandLevels()) {
reportLines.add("New level = " + (results.getLevel() - addon.getManager().getInitialLevel(island)));
} else {
reportLines.add("New level = " + results.getLevel());
}
reportLines.add(LINE_BREAK);
int total = 0;
if (!results.uwCount.isEmpty()) {

View File

@ -47,6 +47,7 @@ blocks:
BLACKSTONE_SLAB: 0
BLACKSTONE_STAIRS: 1
BLACKSTONE_WALL: 1
BEDROCK: 0
BEETROOTS: 1
BELL: 100
BIRCH_BUTTON: 1