Fixed code smells.

This commit is contained in:
tastybento 2018-08-03 21:30:06 -07:00
parent 683aca7043
commit 5c46265771
4 changed files with 9 additions and 23 deletions

View File

@ -28,7 +28,7 @@ public class IslandSettingsCommand extends CompositeCommand {
public boolean execute(User user, String label, List<String> args) {
// Settings are only shown if you are in the right world
if (Util.getWorld(user.getWorld()).equals(getWorld())) {
SettingsPanel.openPanel(getPlugin(), user, Flag.Type.PROTECTION, getWorld()); //TODO keep track of history?
SettingsPanel.openPanel(getPlugin(), user, Flag.Type.PROTECTION, getWorld());
return true;
} else {
user.sendMessage("general.errors.wrong-world");

View File

@ -121,11 +121,8 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
// Check if there is an annotation on the field
ConfigEntry configEntry = field.getAnnotation(ConfigEntry.class);
// If there is a config annotation then do something
if (configEntry != null) {
if (!configEntry.path().isEmpty()) {
storageLocation = configEntry.path();
}
// TODO: Add handling of other ConfigEntry elements
if (configEntry != null && !configEntry.path().isEmpty()) {
storageLocation = configEntry.path();
}
Adapter adapterNotation = field.getAnnotation(Adapter.class);
if (adapterNotation != null && AdapterInterface.class.isAssignableFrom(adapterNotation.value())) {
@ -279,12 +276,8 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
// Check if there is an annotation on the field
ConfigEntry configEntry = field.getAnnotation(ConfigEntry.class);
// If there is a config path annotation then do something
if (configEntry != null) {
if (!configEntry.path().isEmpty()) {
storageLocation = configEntry.path();
}
// TODO: add in game-specific saving
if (configEntry != null && !configEntry.path().isEmpty()) {
storageLocation = configEntry.path();
}
// Get path for comments

View File

@ -98,13 +98,10 @@ public class MongoDBDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
@Override
public T loadObject(String uniqueId) {
Document doc = collection.find(new Document(MONGO_ID, uniqueId)).limit(1).first();
if (doc != null) {
Gson gson = getGSON();
String json = JSON.serialize(doc).replaceFirst(MONGO_ID, UNIQUEID);
// load single object
return gson.fromJson(json, dataObject);
}
return null;
Gson gson = getGSON();
String json = JSON.serialize(doc).replaceFirst(MONGO_ID, UNIQUEID);
// load single object
return gson.fromJson(json, dataObject);
}
@Override

View File

@ -66,10 +66,6 @@ public class ItemParser {
if (result == null) {
return null;
}
/*
if (StringUtils.isNumeric(part[1])) {
result.setDurability((short) Integer.parseInt(part[1]));
}*/
return result;
}