Skip to content

Commit

Permalink
Ignore island initial level if island levels are not zeroed.
Browse files Browse the repository at this point in the history
Set BEDROCK to value 0 by default.
  • Loading branch information
tastybento committed Aug 15, 2020
1 parent 000463e commit 6c16873
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/main/java/world/bentobox/level/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ private void registerCommands(GameModeAddon gm) {
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);
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/world/bentobox/level/LevelsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public void getGUI(World world, final User user) {
}
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);
Expand Down Expand Up @@ -496,7 +496,9 @@ public void setIslandLevel(@NonNull World world, @NonNull UUID targetPlayer, lon
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());
Expand All @@ -515,7 +517,10 @@ private void setIslandResults(World world, @NonNull UUID owner, Results r) {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,15 @@ private List<String> getReport() {
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()) {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/blockconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ blocks:
BLACKSTONE_SLAB: 0
BLACKSTONE_STAIRS: 1
BLACKSTONE_WALL: 1
BEDROCK: 0
BEETROOTS: 1
BELL: 100
BIRCH_BUTTON: 1
Expand Down

0 comments on commit 6c16873

Please sign in to comment.