Skip to content

Commit

Permalink
Revert "Refactor YamlDatabaseHandler to reduce continue statements"
Browse files Browse the repository at this point in the history
This reverts commit fec43ad.
  • Loading branch information
tastybento committed Jul 25, 2023
1 parent 2ad7796 commit 475e67c
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,11 @@ public CompletableFuture<Boolean> saveObject(T instance) throws IllegalAccessExc
// See if there are any top-level comments
handleComments(instance.getClass(), config, yamlComments, "");

// Run through all the fields in the class that is being stored. EVERY field must have a get and set method
for (Field field : dataObject.getDeclaredFields()) {
if (field.isSynthetic()) {
continue;
}

// Get the property descriptor for this field
PropertyDescriptor propertyDescriptor = new PropertyDescriptor(field.getName(), dataObject);
// Get the read method
Expand All @@ -376,7 +376,12 @@ public CompletableFuture<Boolean> saveObject(T instance) throws IllegalAccessExc
ConfigEntry configEntry = field.getAnnotation(ConfigEntry.class);

// If there is a config path annotation or adapter then deal with them
if (configEntry != null && !configEntry.path().isEmpty() && !configEntry.hidden()) {
if (configEntry != null && !configEntry.path().isEmpty()) {
if (configEntry.hidden()) {
// If the annotation tells us to not print the config entry, then we won't.
continue;
}

// Get the storage location
storageLocation = configEntry.path();

Expand All @@ -387,7 +392,9 @@ public CompletableFuture<Boolean> saveObject(T instance) throws IllegalAccessExc
}
handleComments(field, config, yamlComments, parent);
handleConfigEntryComments(configEntry, config, yamlComments, parent);
} else if (!checkAdapter(field, config, storageLocation, value)) {
}

if (!checkAdapter(field, config, storageLocation, value)) {
// Set the filename if it has not be set already
if (filename.isEmpty() && method.getName().equals("getUniqueId")) {
// Save the name for when the file is saved
Expand All @@ -404,7 +411,6 @@ public CompletableFuture<Boolean> saveObject(T instance) throws IllegalAccessExc
}
}
}

// If the filename has not been set by now then we have a problem
if (filename.isEmpty()) {
throw new IllegalArgumentException("No uniqueId in class");
Expand Down

0 comments on commit 475e67c

Please sign in to comment.