Skip to content

Commit

Permalink
update name used for maxCommandLevel #25
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume-Lebegue committed Nov 13, 2020
1 parent 4103ec5 commit 1a647a7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/main/java/world/bentobox/upgrades/config/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,17 @@ private Map<String, Map<String, CommandUpgradeTier>> loadCommand(ConfigurationSe
CommandUpgradeTier newUpgrade = addCommandUpgradeSection(cmdSection, key);

if (gamemode == null) {
if (this.maxCommandUpgrade.get(name) == null || this.maxCommandUpgrade.get(name) < newUpgrade.getMaxLevel()) {
this.maxCommandUpgrade.put(name, newUpgrade.getMaxLevel());
if (this.maxCommandUpgrade.get(commandId) == null || this.maxCommandUpgrade.get(commandId) < newUpgrade.getMaxLevel()) {
this.maxCommandUpgrade.put(commandId, newUpgrade.getMaxLevel());
}
} else {
if (this.customMaxCommandUpgrade.get(gamemode) == null) {
Map<String, Integer> newMap = new HashMap<>();
newMap.put(name, newUpgrade.getMaxLevel());
newMap.put(commandId, newUpgrade.getMaxLevel());
this.customMaxCommandUpgrade.put(gamemode, newMap);
} else {
if (this.customMaxCommandUpgrade.get(gamemode).get(name) == null || this.customMaxCommandUpgrade.get(gamemode).get(name) < newUpgrade.getMaxLevel())
this.customMaxCommandUpgrade.get(gamemode).put(name, newUpgrade.getMaxLevel());
if (this.customMaxCommandUpgrade.get(gamemode).get(commandId) == null || this.customMaxCommandUpgrade.get(gamemode).get(commandId) < newUpgrade.getMaxLevel())
this.customMaxCommandUpgrade.get(gamemode).put(commandId, newUpgrade.getMaxLevel());
}
}

Expand Down Expand Up @@ -464,7 +464,12 @@ private EntityType getEntityType(String key) {
}

public int getMaxCommandUpgrade(String commandUpgrade, String addon) {
return this.customMaxCommandUpgrade.getOrDefault(addon, this.maxCommandUpgrade).getOrDefault(commandUpgrade, 0);
if (this.customMaxCommandUpgrade.containsKey(addon)) {
if (this.customMaxCommandUpgrade.get(addon).containsKey(commandUpgrade)) {
return this.customMaxCommandUpgrade.get(addon).get(commandUpgrade);
}
}
return this.maxCommandUpgrade.getOrDefault(commandUpgrade, 0);
}

public Map<String, Map<String, CommandUpgradeTier>> getDefaultCommandUpgradeTierMap() {
Expand Down

0 comments on commit 1a647a7

Please sign in to comment.