From 68727496adc9f51a19aebcd2025a8da7ff7c8b45 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 11 Jul 2013 12:49:01 -0400 Subject: [PATCH] Useless casting and elses. --- .../commands/database/MmoshowdbCommand.java | 24 +++++++------------ .../commands/database/MmoupdateCommand.java | 9 ++----- .../nossr50/database/SQLDatabaseManager.java | 6 ++--- 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/database/MmoshowdbCommand.java b/src/main/java/com/gmail/nossr50/commands/database/MmoshowdbCommand.java index 4f5f6c6cb..ea128838a 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/MmoshowdbCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/MmoshowdbCommand.java @@ -17,22 +17,16 @@ public class MmoshowdbCommand implements TabExecutor { if (args.length != 0) { return false; } - else { - Class clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass(); - if (clazz != null) { - 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; - } + + Class clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass(); + + if (clazz != null) { + sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName())); + return true; } + + sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (Config.getInstance().getUseMySQL() ? "sql" : "flatfile"))); + return true; } @Override diff --git a/src/main/java/com/gmail/nossr50/commands/database/MmoupdateCommand.java b/src/main/java/com/gmail/nossr50/commands/database/MmoupdateCommand.java index 38c89d475..a3eb4e939 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/MmoupdateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/MmoupdateCommand.java @@ -47,7 +47,7 @@ public class MmoupdateCommand implements TabExecutor { else try { @SuppressWarnings("unchecked") Class clazz = (Class) Class.forName(oldType); - oldDb = DatabaseManagerFactory.createCustomDatabaseManager((Class) clazz); + oldDb = DatabaseManagerFactory.createCustomDatabaseManager(clazz); oldType = clazz.getSimpleName(); // For pretty-printing; we have the database now } @@ -119,12 +119,7 @@ public class MmoupdateCommand implements TabExecutor { return DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName(); } - if (Config.getInstance().getUseMySQL()) { - return "sql"; - } - else { - return "flatfile"; - } + return Config.getInstance().getUseMySQL() ? "sql" : "flatfile"; } @Override diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java index 3c126e78a..51813ca09 100644 --- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java @@ -379,11 +379,9 @@ public final class SQLDatabaseManager implements DatabaseManager { // There is no such user if (create) { newUser(playerName); - return new PlayerProfile(playerName, true); - } - else { - return new PlayerProfile(playerName, false); } + + return new PlayerProfile(playerName, create); } // There is such a user writeMissingRows(id);