Replaces 'if' statements with && or || where possible

This commit is contained in:
Fuzzlemann 2017-07-23 14:10:41 +02:00
parent f1ae1c3f8f
commit b091e13ad5
6 changed files with 8 additions and 31 deletions

View File

@ -1,10 +1,11 @@
package main.java.com.djrapitops.plan.command;
import com.djrapitops.plugin.utilities.Verify;
import java.util.UUID;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings;
import java.util.UUID;
/**
* This class contains methods used by commands
*
@ -32,9 +33,6 @@ public class ConditionUtils {
* @return has the player played before, false if uuid is null.
*/
public static boolean playerHasPlayed(UUID uuid) {
if (!Verify.notNull(uuid)) {
return false;
}
return Plan.getInstance().fetch().hasPlayedBefore(uuid);
return Verify.notNull(uuid) && Plan.getInstance().fetch().hasPlayedBefore(uuid);
}
}

View File

@ -54,10 +54,7 @@ public class DataCacheGetQueue extends Queue<Map<UUID, List<DBCallableProcessor>
}
public boolean containsUUIDtoBeCached(UUID uuid) {
if (uuid == null) {
return false;
}
return new ArrayList<>(queue).stream().anyMatch((map) -> (map.get(uuid) != null && map.get(uuid).size() >= 2)); // Map has 2 processors if being cached
return uuid != null && new ArrayList<>(queue).stream().anyMatch((map) -> (map.get(uuid) != null && map.get(uuid).size() >= 2));
}
}

View File

@ -65,10 +65,7 @@ public class DataCacheProcessQueue extends Queue<HandlingInfo> {
* @return true/false
*/
public boolean containsUUID(UUID uuid) {
if (uuid == null) {
return false;
}
return new ArrayList<>(queue).stream().anyMatch(info -> info.getUuid().equals(uuid));
return uuid != null && new ArrayList<>(queue).stream().anyMatch(info -> info.getUuid().equals(uuid));
}
}

View File

@ -84,10 +84,7 @@ public class DataCacheSaveQueue extends Queue<UserData> {
* @return true/false
*/
public boolean containsUUID(UUID uuid) {
if (uuid == null) {
return false;
}
return new ArrayList<>(queue).stream().anyMatch(d -> d.getUuid().equals(uuid));
return uuid != null && new ArrayList<>(queue).stream().anyMatch(d -> d.getUuid().equals(uuid));
}
}

View File

@ -21,10 +21,7 @@ public class ImportUtils {
* @return true/false
*/
public static boolean isPluginEnabled(String pluginName) {
if ("offline".equals(pluginName)) {
return true;
}
return getPluginManager().isPluginEnabled(pluginName);
return "offline".equals(pluginName) || getPluginManager().isPluginEnabled(pluginName);
}
/**

View File

@ -272,16 +272,7 @@ public abstract class SQLDB extends Database {
return false;
}
int userId = usersTable.getUserId(uuid);
if (userId == -1) {
return false;
}
return locationsTable.removeUserLocations(userId)
&& ipsTable.removeUserIps(userId)
&& nicknamesTable.removeUserNicknames(userId)
&& gmTimesTable.removeUserGMTimes(userId)
&& sessionsTable.removeUserSessions(userId)
&& killsTable.removeUserKillsAndVictims(userId)
&& usersTable.removeUser(uuid);
return userId != -1 && locationsTable.removeUserLocations(userId) && ipsTable.removeUserIps(userId) && nicknamesTable.removeUserNicknames(userId) && gmTimesTable.removeUserGMTimes(userId) && sessionsTable.removeUserSessions(userId) && killsTable.removeUserKillsAndVictims(userId) && usersTable.removeUser(uuid);
} finally {
Benchmark.stop("Database: Remove Account");
setAvailable();