Skip to content
This repository has been archived by the owner on Nov 2, 2021. It is now read-only.

Commit

Permalink
Fix AllAchievementsReceivedRewards option (#1088)
Browse files Browse the repository at this point in the history
  • Loading branch information
PyvesB committed Oct 26, 2021
1 parent bb7ff6b commit 01ef298
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ private void parseAchievement(Category category, String subcategory, long thresh
throw new PluginLoadError(
"Achievement with path (" + path + ") is missing its Message parameter in config.yml.");
}
String rewardPath = mainConfig.isConfigurationSection(path + ".Reward") ? path + ".Reward" : path + ".Rewards";

Achievement achievement = new AchievementBuilder()
.name(section.getString("Name"))
Expand All @@ -316,7 +317,7 @@ private void parseAchievement(Category category, String subcategory, long thresh
.threshold(threshold)
.category(category)
.subcategory(subcategory)
.rewards(rewardParser.parseRewards(path))
.rewards(rewardParser.parseRewards(rewardPath))
.build();
achievementMap.put(achievement);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ public Economy getEconomy() {
}

public List<Reward> parseRewards(String path) {
ConfigurationSection configSection = mainConfig.getConfigurationSection(path + ".Reward");
if (configSection == null) {
configSection = mainConfig.getConfigurationSection(path + ".Rewards");
}
ConfigurationSection configSection = mainConfig.getConfigurationSection(path);
List<Reward> rewards = new ArrayList<>();
if (configSection != null) {
if (economy != null && configSection.contains("Money")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void shouldParseMoneyRewardSingular() throws Exception {
mainConfig.load(Paths.get(getClass().getClassLoader().getResource("reward-parser/money-1.yml").toURI()).toFile());
when(economy.currencyNameSingular()).thenReturn("coin");

List<Reward> rewards = underTest.parseRewards("");
List<Reward> rewards = underTest.parseRewards("Reward");

assertEquals(1, rewards.size());
Reward reward = rewards.get(0);
Expand All @@ -79,7 +79,7 @@ void shouldParseMoneyRewardPlural() throws Exception {
mainConfig.load(Paths.get(getClass().getClassLoader().getResource("reward-parser/money-2.yml").toURI()).toFile());
when(economy.currencyNamePlural()).thenReturn("coins");

List<Reward> rewards = underTest.parseRewards("");
List<Reward> rewards = underTest.parseRewards("Reward");

assertEquals(1, rewards.size());
Reward reward = rewards.get(0);
Expand All @@ -93,7 +93,7 @@ void shouldParseMoneyRewardPlural() throws Exception {
void shouldParseItemReward() throws Exception {
mainConfig.load(Paths.get(getClass().getClassLoader().getResource("reward-parser/item.yml").toURI()).toFile());

List<Reward> rewards = underTest.parseRewards("");
List<Reward> rewards = underTest.parseRewards("Reward");

assertEquals(1, rewards.size());
Reward reward = rewards.get(0);
Expand All @@ -113,7 +113,7 @@ void shouldParseSingleCommandReward() throws Exception {
when(player.getWorld()).thenReturn(world);
when(world.getName()).thenReturn("Nether");

List<Reward> rewards = underTest.parseRewards("");
List<Reward> rewards = underTest.parseRewards("Reward");

assertEquals(1, rewards.size());
Reward reward = rewards.get(0);
Expand All @@ -132,7 +132,7 @@ void shouldParseMultipleCommandRewards() throws Exception {
when(player.getWorld()).thenReturn(world);
when(world.getName()).thenReturn("Nether");

List<Reward> rewards = underTest.parseRewards("");
List<Reward> rewards = underTest.parseRewards("Reward");

assertEquals(1, rewards.size());
Reward reward = rewards.get(0);
Expand All @@ -148,7 +148,7 @@ void shouldParseMultipleCommandRewards() throws Exception {
void shouldParseExperienceReward() throws Exception {
mainConfig.load(Paths.get(getClass().getClassLoader().getResource("reward-parser/experience.yml").toURI()).toFile());

List<Reward> rewards = underTest.parseRewards("");
List<Reward> rewards = underTest.parseRewards("Reward");

assertEquals(1, rewards.size());
Reward reward = rewards.get(0);
Expand All @@ -165,7 +165,7 @@ void shouldParseMaxHealthReward() throws Exception {
when(player.getAttribute(any())).thenReturn(healthAttribute);
when(healthAttribute.getBaseValue()).thenReturn(1.0);

List<Reward> rewards = underTest.parseRewards("");
List<Reward> rewards = underTest.parseRewards("Reward");

assertEquals(1, rewards.size());
Reward reward = rewards.get(0);
Expand All @@ -181,7 +181,7 @@ void shouldParseMaxOxygenReward() throws Exception {
mainConfig.load(Paths.get(getClass().getClassLoader().getResource("reward-parser/max-oxygen.yml").toURI()).toFile());
when(player.getMaximumAir()).thenReturn(5);

List<Reward> rewards = underTest.parseRewards("");
List<Reward> rewards = underTest.parseRewards("Reward");

assertEquals(1, rewards.size());
Reward reward = rewards.get(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Rewards:
Reward:
Commands:
Display:
- 'display 1'
Expand Down

0 comments on commit 01ef298

Please sign in to comment.