Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,14 @@ public IslandLevelCalculator(Level addon, Island island, CompletableFuture<Resul
*/
private long calculateLevel(final long rawPoints) {
String calcString = addon.getSettings().getLevelCalc();
// Reduce count by initial count, if zeroing is done
// Reduce count by initial count, if zeroing is done. In donations-only
// mode the initial count is ignored — it was recorded from a one-off
// scan of the starter island and would push the level wildly negative
// when subtracted from donation-only points (e.g. when an admin enables
// this mode mid-game on islands that already have an initial count).
long modifiedPoints = rawPoints
- (addon.getSettings().isZeroNewIslandLevels() ? results.initialCount.get() : 0);
- (addon.getSettings().isZeroNewIslandLevels() && !addon.getSettings().isDonationsOnly()
? results.initialCount.get() : 0);
// Paste in the values to the formula
// Use Math.max(1, ...) to prevent division by zero if island_members is used in the formula
int memberCount = Math.max(1, this.island.getMemberSet().size());
Expand Down Expand Up @@ -262,7 +267,7 @@ private List<String> getReport() {
if (addon.getSettings().isZeroNewIslandLevels()) {
reportLines.add("Initial island level = " + (0L - addon.getManager().getInitialLevel(island)));
}*/
if (addon.getSettings().isZeroNewIslandLevels()) {
if (addon.getSettings().isZeroNewIslandLevels() && !addon.getSettings().isDonationsOnly()) {
reportLines.add("Initial island count = " + (0L - addon.getManager().getInitialCount(island)));
}
reportLines.add("Previous level = " + addon.getManager().getIslandLevel(island.getWorld(), island.getOwner()));
Expand Down Expand Up @@ -766,7 +771,9 @@ public void tidyUp() {

// Binary search for points accumulated within the current level.
// Floor at initialCount when zeroing new islands to avoid negative/NaN in non-linear formulas.
long minBlocks = addon.getSettings().isZeroNewIslandLevels() ? results.initialCount.get() : 0;
// In donations-only mode, the initial count is ignored (see calculateLevel).
long minBlocks = addon.getSettings().isZeroNewIslandLevels() && !addon.getSettings().isDonationsOnly()
? results.initialCount.get() : 0;
lo = Math.max(minBlocks, blockAndDeathPoints - MAX_AMOUNT);
hi = blockAndDeathPoints;
while (lo < hi) {
Expand Down Expand Up @@ -794,9 +801,14 @@ boolean isNotZeroIsland() {
}

public void scanIsland(Pipeliner pipeliner) {
// In donations-only mode, skip the chunk scan entirely. tidyUp() will add
// the donated points and compute the level from those alone.
if (addon.getSettings().isDonationsOnly()) {
// In donations-only mode, skip the chunk scan for regular level calcs:
// tidyUp() will add the donated points and compute the level from those
// alone. Zero-island scans (run on island create/reset when
// zero-new-island-levels is true) still run the full scan so the
// initial-count handicap is recorded — this lets an admin later
// disable donations-only without losing the handicap that would
// otherwise need to be subtracted from the scanned block total.
if (addon.getSettings().isDonationsOnly() && !zeroIsland) {
pipeliner.getInProcessQueue().remove(this);
this.tidyUp();
this.getR().complete(getResults());
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/world/bentobox/level/panels/TopLevelPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ private PanelItem createIslandIcon(ItemTemplateRecord template, IslandTopRecord
|| !this.addon.getVisitHook().getAddonManager().preprocessTeleportation(this.user, island, true);
}
case "VIEW" -> {
return island.getOwner() == null
// In donations-only mode there is no detail panel to view, so this
// action is filtered out — that also drops the "click to view"
// tooltip from the rendered button.
return this.addon.getSettings().isDonationsOnly()
|| island.getOwner() == null
|| !island.getMemberSet(RanksManager.MEMBER_RANK).contains(this.user.getUniqueId());
}
default -> {
Expand Down
Loading