Adds a default box change setting for unknown advancements.

Makes adding custom advancement datapacks easier because the default
advancement reward will be to increase the box by 1.
This commit is contained in:
tastybento 2021-03-20 09:49:34 -07:00
parent cac0c64654
commit c7473785df
2 changed files with 6 additions and 1 deletions

View File

@ -32,6 +32,7 @@ public class AdvancementsManager {
// A cache of island levels.
private final Map<String, IslandAdvancements> cache;
private final YamlConfiguration advConfig;
private int unknownAdvChange;
/**
* @param addon
@ -53,6 +54,7 @@ public class AdvancementsManager {
} else {
try {
advConfig.load(advFile);
unknownAdvChange = advConfig.getInt("settings.unknown-advancement-increase", 0);
} catch (IOException | InvalidConfigurationException e) {
addon.logError("advancements.yml cannot be found! " + e.getLocalizedMessage());
}
@ -152,7 +154,7 @@ public class AdvancementsManager {
return 0;
}
// Check score of advancement
int score = advConfig.getInt("advancements." + advancement.getKey().toString());
int score = advConfig.getInt("advancements." + advancement.getKey().toString(), this.unknownAdvChange);
if (score == 0) {
return 0;
}

View File

@ -1,3 +1,6 @@
# Lists how many blocks the box will increase when advancement occurs
settings:
unknown-advancement-increase: 1
advancements:
'minecraft:adventure/adventuring_time': 1
'minecraft:adventure/arbalistic': 1