Skip to content

Commit 1826b59

Browse files
authored
Merge pull request #425 from BentoBoxWorld/fix/pr421-copilot-review
Address Copilot review on the 1.8.0 release PR (#421)
2 parents 71b8f0e + 4399087 commit 1826b59

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)