Skip to content

Commit 4399087

Browse files
tastybentoclaude
andcommitted
Address Copilot review on the 1.8.0 release PR (#421)
- ChallengesAddon.allLoaded(): reset levelProvided=false when the Level add-on is absent, so isLevelProvided() can't be stale-true and TryToComplete.rewardIslandLevel() can't NPE on a null level add-on. - EditChallengePanel: sort the required-biome list before rendering so the admin GUI description is stable (the backing set is unordered). - ChallengesPanel.createToggleUndeployedButton(): guard the template description with !isBlank() to avoid inserting empty lore lines, matching the other button builders. - ChallengesAddonTest: verify placeholder registration with atLeastOnce() instead of times(13) so the tests don't break whenever a placeholder is added or removed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DfEq1X2sy57G8nq2Cd23ba
1 parent 152ef0c commit 4399087

4 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/main/java/world/bentobox/challenges/ChallengesAddon.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ public void allLoaded()
234234
this.log("Challenges Addon hooked into Level addon.");
235235
}, () -> {
236236
this.levelAddon = null;
237+
this.levelProvided = false;
237238
this.logWarning("Level add-on not found so level challenges will not work!");
238239
});
239240

src/main/java/world/bentobox/challenges/panel/admin/EditChallengePanel.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -962,8 +962,11 @@ private PanelItem createBiomeRequirementButton() {
962962
description.add(this.user.getTranslation(reference + "none"));
963963
} else {
964964
description.add(this.user.getTranslation(reference + Constants.TITLE_KEY));
965-
requirements.getRequiredBiomes().forEach(biomeKey -> description.add(
966-
this.user.getTranslation(reference + "list", "[biome]", Utils.prettifyBiome(biomeKey))));
965+
// Sort so the biome list renders in a stable order (the underlying set is unordered).
966+
requirements.getRequiredBiomes().stream()
967+
.sorted(Comparator.comparing(Utils::prettifyBiome))
968+
.forEach(biomeKey -> description.add(
969+
this.user.getTranslation(reference + "list", "[biome]", Utils.prettifyBiome(biomeKey))));
967970
}
968971

969972
description.add("");

src/main/java/world/bentobox/challenges/panel/user/ChallengesPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ private PanelItem createToggleUndeployedButton(@NonNull ItemTemplateRecord templ
714714
builder.name(this.user.getTranslation(this.world, template.title()));
715715
}
716716

717-
if (template.description() != null)
717+
if (template.description() != null && !template.description().isBlank())
718718
{
719719
builder.description(this.user.getTranslation(this.world, template.description()));
720720
}

src/test/java/world/bentobox/challenges/ChallengesAddonTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,10 @@ void testPlaceholderCompletedPercentRegistered() {
377377

378378
addon.onEnable();
379379

380-
// Verify that the completed_percent placeholder was registered
380+
// Capture every registered placeholder name; assert the one under test is present without
381+
// pinning the exact total (which changes whenever any placeholder is added or removed).
381382
ArgumentCaptor<String> nameCaptor = ArgumentCaptor.forClass(String.class);
382-
verify(phm, org.mockito.Mockito.times(13)).registerPlaceholder(any(GameModeAddon.class), nameCaptor.capture(), any());
383+
verify(phm, org.mockito.Mockito.atLeastOnce()).registerPlaceholder(any(GameModeAddon.class), nameCaptor.capture(), any());
383384

384385
List<String> names = nameCaptor.getAllValues();
385386
assertTrue(names.contains("challenges_completed_percent"),
@@ -398,9 +399,10 @@ void testPlaceholderLatestLevelCompletedPercentRegistered() {
398399

399400
addon.onEnable();
400401

401-
// Verify that the latest_level_completed_percent placeholder was registered
402+
// Capture every registered placeholder name; assert the one under test is present without
403+
// pinning the exact total (which changes whenever any placeholder is added or removed).
402404
ArgumentCaptor<String> nameCaptor = ArgumentCaptor.forClass(String.class);
403-
verify(phm, org.mockito.Mockito.times(13)).registerPlaceholder(any(GameModeAddon.class), nameCaptor.capture(), any());
405+
verify(phm, org.mockito.Mockito.atLeastOnce()).registerPlaceholder(any(GameModeAddon.class), nameCaptor.capture(), any());
404406

405407
List<String> names = nameCaptor.getAllValues();
406408
assertTrue(names.contains("challenges_latest_level_completed_percent"),

0 commit comments

Comments
 (0)