Useless casting and elses.

This commit is contained in:
GJ 2013-07-11 12:49:01 -04:00
parent d07b67b5bf
commit 68727496ad
3 changed files with 13 additions and 26 deletions

View File

@ -17,22 +17,16 @@ public class MmoshowdbCommand implements TabExecutor {
if (args.length != 0) { if (args.length != 0) {
return false; return false;
} }
else {
Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass(); Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass();
if (clazz != null) {
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName())); if (clazz != null) {
return true; sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName()));
} return true;
else {
if (Config.getInstance().getUseMySQL()) {
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", "sql"));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", "flatfile"));
}
return true;
}
} }
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (Config.getInstance().getUseMySQL() ? "sql" : "flatfile")));
return true;
} }
@Override @Override

View File

@ -47,7 +47,7 @@ public class MmoupdateCommand implements TabExecutor {
else try { else try {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Class<? extends DatabaseManager> clazz = (Class<? extends DatabaseManager>) Class.forName(oldType); Class<? extends DatabaseManager> clazz = (Class<? extends DatabaseManager>) Class.forName(oldType);
oldDb = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz); oldDb = DatabaseManagerFactory.createCustomDatabaseManager(clazz);
oldType = clazz.getSimpleName(); // For pretty-printing; we have the database now oldType = clazz.getSimpleName(); // For pretty-printing; we have the database now
} }
@ -119,12 +119,7 @@ public class MmoupdateCommand implements TabExecutor {
return DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName(); return DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName();
} }
if (Config.getInstance().getUseMySQL()) { return Config.getInstance().getUseMySQL() ? "sql" : "flatfile";
return "sql";
}
else {
return "flatfile";
}
} }
@Override @Override

View File

@ -379,11 +379,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
// There is no such user // There is no such user
if (create) { if (create) {
newUser(playerName); newUser(playerName);
return new PlayerProfile(playerName, true);
}
else {
return new PlayerProfile(playerName, false);
} }
return new PlayerProfile(playerName, create);
} }
// There is such a user // There is such a user
writeMissingRows(id); writeMissingRows(id);