From 0f14efbc46e29a441642bdcfbe8d85accc5f22eb Mon Sep 17 00:00:00 2001 From: Fuzzlemann Date: Sun, 23 Jul 2017 14:04:55 +0200 Subject: [PATCH] Simplifies 'if' statements --- .../com/djrapitops/plan/data/KillData.java | 5 +---- .../com/djrapitops/plan/data/SessionData.java | 5 +---- .../java/com/djrapitops/plan/data/TPS.java | 5 +---- .../com/djrapitops/plan/data/UserData.java | 5 +---- .../plan/data/additional/PluginData.java | 14 ++++--------- .../plan/database/tables/SecurityTable.java | 10 +++++----- .../plan/database/tables/UsersTable.java | 20 +++++++------------ 7 files changed, 20 insertions(+), 44 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/data/KillData.java b/Plan/src/main/java/com/djrapitops/plan/data/KillData.java index 7d75e7ed4..c56944aeb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/KillData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/KillData.java @@ -90,10 +90,7 @@ public class KillData { if (!Objects.equals(this.weapon, other.weapon)) { return false; } - if (!Objects.equals(this.victim, other.victim)) { - return false; - } - return true; + return Objects.equals(this.victim, other.victim); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/data/SessionData.java b/Plan/src/main/java/com/djrapitops/plan/data/SessionData.java index f4267aa56..471c65395 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/SessionData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/SessionData.java @@ -109,10 +109,7 @@ public class SessionData { if (this.sessionStart != other.sessionStart) { return false; } - if (this.sessionEnd != other.sessionEnd) { - return false; - } - return true; + return this.sessionEnd == other.sessionEnd; } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/data/TPS.java b/Plan/src/main/java/com/djrapitops/plan/data/TPS.java index 47a213593..9284f0d83 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/TPS.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/TPS.java @@ -84,10 +84,7 @@ public class TPS { if (Double.doubleToLongBits(this.tps) != Double.doubleToLongBits(other.tps)) { return false; } - if (this.players != other.players) { - return false; - } - return true; + return this.players == other.players; } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/data/UserData.java b/Plan/src/main/java/com/djrapitops/plan/data/UserData.java index 3c7a23039..149543b79 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/UserData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/UserData.java @@ -809,10 +809,7 @@ public class UserData { if (!Objects.equals(this.playerKills, other.playerKills)) { return false; } - if (!Objects.equals(this.sessions, other.sessions)) { - return false; - } - return true; + return Objects.equals(this.sessions, other.sessions); } /** diff --git a/Plan/src/main/java/com/djrapitops/plan/data/additional/PluginData.java b/Plan/src/main/java/com/djrapitops/plan/data/additional/PluginData.java index 0ba357cf0..a94bc0ee6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/additional/PluginData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/additional/PluginData.java @@ -1,13 +1,10 @@ package main.java.com.djrapitops.plan.data.additional; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.UUID; import main.java.com.djrapitops.plan.ui.html.Html; +import java.io.Serializable; +import java.util.*; + /** * This is an abstract class that can be used to add data from a plugin to the * "Plugins"-tab of Analysis and Inspect pages. @@ -306,10 +303,7 @@ public abstract class PluginData { if (!Objects.equals(this.sourcePlugin, other.sourcePlugin)) { return false; } - if (!Objects.equals(this.analysisTypes, other.analysisTypes)) { - return false; - } - return true; + return Objects.equals(this.analysisTypes, other.analysisTypes); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/SecurityTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/SecurityTable.java index da2c65807..824d727a0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/SecurityTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/SecurityTable.java @@ -5,14 +5,15 @@ */ package main.java.com.djrapitops.plan.database.tables; +import main.java.com.djrapitops.plan.Log; +import main.java.com.djrapitops.plan.data.WebUser; +import main.java.com.djrapitops.plan.database.databases.SQLDB; + import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -import main.java.com.djrapitops.plan.Log; -import main.java.com.djrapitops.plan.data.WebUser; -import main.java.com.djrapitops.plan.database.databases.SQLDB; /** * @@ -96,8 +97,7 @@ public class SecurityTable extends Table { while (set.next()) { String saltedPassHash = set.getString(columnSaltedHash); int permissionLevel = set.getInt(columnPermLevel); - WebUser info = new WebUser(user, saltedPassHash, permissionLevel); - return info; + return new WebUser(user, saltedPassHash, permissionLevel); } return null; } finally { diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java index 070efb111..d97b0f5c1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java @@ -1,19 +1,6 @@ package main.java.com.djrapitops.plan.database.tables; import com.djrapitops.plugin.utilities.player.Fetch; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.function.Function; -import java.util.stream.Collectors; import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.database.DBUtils; @@ -22,6 +9,13 @@ import main.java.com.djrapitops.plan.utilities.Benchmark; import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility; import org.bukkit.GameMode; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + /** * * @author Rsl1122