Skip to content

Commit

Permalink
Fixed bug with ConfigMap not working properly with saveDefaults
Browse files Browse the repository at this point in the history
  • Loading branch information
boxbeam committed Jun 11, 2020
1 parent e1289c6 commit e994236
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/redempt/redlib/configmanager/ConfigField.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public void load(Object object, ConfigurationSection config) {
}
ConfigMap<?> map = (ConfigMap<?>) obj;
map.section = section;
map.manager = manager;
map.init();
map.init(manager);
map.load();
return;
}
Expand Down Expand Up @@ -80,6 +79,7 @@ public void save(Object object, ConfigurationSection config) {
try {
if (path.endsWith(".*")) {
ConfigMap<?> map = (ConfigMap<?>) field.get(object);
map.init(manager);
map.save();
return;
}
Expand Down Expand Up @@ -117,6 +117,7 @@ public void saveIfAbsent(Object object, ConfigurationSection config) {
if (section == null) {
section = config.createSection(name);
map.section = section;
map.init(manager);
map.save();
}
return;
Expand Down
5 changes: 3 additions & 2 deletions src/redempt/redlib/configmanager/ConfigMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ class ConfigMap<T> extends HashMap<String, T> {

private Class<T> clazz;
protected ConfigurationSection section;
protected ConfigManager manager;
private ConfigManager manager;
private List<ConfigField> fields = new ArrayList<>();

public ConfigMap(Class<T> clazz) {
this.clazz = clazz;
}

public void init() {
public void init(ConfigManager manager) {
if (fields.size() > 0) {
return;
}
this.manager = manager;
for (Field field : clazz.getDeclaredFields()) {
ConfigHook hook = field.getAnnotation(ConfigHook.class);
if (hook == null) {
Expand Down

0 comments on commit e994236

Please sign in to comment.