mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-01 00:10:40 +01:00
Minor refactor to remove continue from for loop
This commit is contained in:
parent
ad2541963e
commit
2d8b3074a9
@ -338,13 +338,11 @@ public class YamlDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
|||||||
// Null check
|
// Null check
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
plugin.logError("YAML database request to store a null.");
|
plugin.logError("YAML database request to store a null.");
|
||||||
completableFuture.complete(false);
|
return CompletableFuture.completedFuture(false);
|
||||||
return completableFuture;
|
|
||||||
}
|
}
|
||||||
if (!(instance instanceof DataObject)) {
|
if (!(instance instanceof DataObject)) {
|
||||||
plugin.logError("This class is not a DataObject: " + instance.getClass().getName());
|
plugin.logError("This class is not a DataObject: " + instance.getClass().getName());
|
||||||
completableFuture.complete(false);
|
return CompletableFuture.completedFuture(false);
|
||||||
return completableFuture;
|
|
||||||
}
|
}
|
||||||
// This is the Yaml Configuration that will be used and saved at the end
|
// This is the Yaml Configuration that will be used and saved at the end
|
||||||
YamlConfiguration config = new YamlConfiguration();
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
@ -396,9 +394,7 @@ public class YamlDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
|||||||
handleConfigEntryComments(configEntry, config, yamlComments, parent);
|
handleConfigEntryComments(configEntry, config, yamlComments, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkAdapter(field, config, storageLocation, value)) {
|
if (!checkAdapter(field, config, storageLocation, value)) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Set the filename if it has not be set already
|
// Set the filename if it has not be set already
|
||||||
if (filename.isEmpty() && method.getName().equals("getUniqueId")) {
|
if (filename.isEmpty() && method.getName().equals("getUniqueId")) {
|
||||||
// Save the name for when the file is saved
|
// Save the name for when the file is saved
|
||||||
@ -414,6 +410,7 @@ public class YamlDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
|||||||
config.set(storageLocation, serialize(value));
|
config.set(storageLocation, serialize(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// If the filename has not been set by now then we have a problem
|
// If the filename has not been set by now then we have a problem
|
||||||
if (filename.isEmpty()) {
|
if (filename.isEmpty()) {
|
||||||
throw new IllegalArgumentException("No uniqueId in class");
|
throw new IllegalArgumentException("No uniqueId in class");
|
||||||
@ -469,6 +466,16 @@ public class YamlDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if an adapter is to be used. If so, it is used and true returned, if not, fase is returned
|
||||||
|
* @param field Field
|
||||||
|
* @param config Yaml Config
|
||||||
|
* @param storageLocation Storage location
|
||||||
|
* @param value Value
|
||||||
|
* @return true if adapater used
|
||||||
|
* @throws IllegalAccessException exception
|
||||||
|
* @throws InvocationTargetException exception
|
||||||
|
*/
|
||||||
private boolean checkAdapter(Field field, YamlConfiguration config, String storageLocation, Object value) throws IllegalAccessException, InvocationTargetException {
|
private boolean checkAdapter(Field field, YamlConfiguration config, String storageLocation, Object value) throws IllegalAccessException, InvocationTargetException {
|
||||||
Adapter adapterNotation = field.getAnnotation(Adapter.class);
|
Adapter adapterNotation = field.getAnnotation(Adapter.class);
|
||||||
if (adapterNotation != null && AdapterInterface.class.isAssignableFrom(adapterNotation.value())) {
|
if (adapterNotation != null && AdapterInterface.class.isAssignableFrom(adapterNotation.value())) {
|
||||||
|
Loading…
Reference in New Issue
Block a user