From f9f6eeb055391bd1287ebb4756777d7a38048ade Mon Sep 17 00:00:00 2001 From: nickreesdev Date: Fri, 19 Feb 2021 14:57:28 -0600 Subject: [PATCH] Changed negated isPresent() to isEmpty(). --- .../zone/themcgamer/arcade/scoreboard/ArcadeScoreboard.java | 2 +- .../themcgamer/buildServer/listener/PlayerListener.java | 2 +- .../core/account/command/rank/arguments/SetArgument.java | 4 ++-- .../java/zone/themcgamer/core/account/menu/ProfileMenu.java | 2 +- .../zone/themcgamer/core/badSportSystem/BadSportSystem.java | 6 +++--- .../core/badSportSystem/command/BadSportCommand.java | 2 +- .../themcgamer/core/badSportSystem/menu/BadSportMenu.java | 4 ++-- .../java/zone/themcgamer/core/command/CommandManager.java | 2 +- .../main/java/zone/themcgamer/core/game/kit/KitManager.java | 2 +- .../java/zone/themcgamer/core/kingdom/KingdomManager.java | 2 +- .../main/java/zone/themcgamer/core/plugin/MGZPlugin.java | 4 ++-- .../zone/themcgamer/core/server/command/ServerCommand.java | 2 +- .../main/java/zone/themcgamer/core/task/TaskManager.java | 2 +- .../java/zone/themcgamer/core/update/ServerUpdater.java | 2 +- .../main/java/zone/themcgamer/hub/menu/GameKitsMenu.java | 2 +- .../main/java/zone/themcgamer/proxy/hub/HubBalancer.java | 2 +- .../src/main/java/zone/themcgamer/data/jedis/data/Node.java | 2 +- .../java/zone/themcgamer/data/jedis/data/ServerGroup.java | 2 +- 18 files changed, 23 insertions(+), 23 deletions(-) diff --git a/arcade/src/main/java/zone/themcgamer/arcade/scoreboard/ArcadeScoreboard.java b/arcade/src/main/java/zone/themcgamer/arcade/scoreboard/ArcadeScoreboard.java index e3a8917..fa428d9 100644 --- a/arcade/src/main/java/zone/themcgamer/arcade/scoreboard/ArcadeScoreboard.java +++ b/arcade/src/main/java/zone/themcgamer/arcade/scoreboard/ArcadeScoreboard.java @@ -47,7 +47,7 @@ public class ArcadeScoreboard extends WritableScoreboard { @Override public void writeLines() { Optional optionalAccount = AccountManager.fromCache(player.getUniqueId()); - if (!optionalAccount.isPresent()) { + if (optionalAccount.isEmpty()) { writeBlank(); return; } diff --git a/buildserver/src/main/java/zone/themcgamer/buildServer/listener/PlayerListener.java b/buildserver/src/main/java/zone/themcgamer/buildServer/listener/PlayerListener.java index 988e536..119fba6 100644 --- a/buildserver/src/main/java/zone/themcgamer/buildServer/listener/PlayerListener.java +++ b/buildserver/src/main/java/zone/themcgamer/buildServer/listener/PlayerListener.java @@ -78,7 +78,7 @@ public class PlayerListener implements Listener { private void onChat(AsyncPlayerChatEvent event) { Player player = event.getPlayer(); Optional optionalAccount = AccountManager.fromCache(player.getUniqueId()); - if (!optionalAccount.isPresent()) { + if (optionalAccount.isEmpty()) { player.sendMessage(Style.error("Chat", "§cCannot send chat message")); return; } diff --git a/core/src/main/java/zone/themcgamer/core/account/command/rank/arguments/SetArgument.java b/core/src/main/java/zone/themcgamer/core/account/command/rank/arguments/SetArgument.java index 8a39536..e4061a5 100644 --- a/core/src/main/java/zone/themcgamer/core/account/command/rank/arguments/SetArgument.java +++ b/core/src/main/java/zone/themcgamer/core/account/command/rank/arguments/SetArgument.java @@ -29,7 +29,7 @@ public class SetArgument { return; } Optional optionalRank = Rank.lookup(args[1]); - if (!optionalRank.isPresent()) { + if (optionalRank.isEmpty()) { sender.sendMessage(Style.error("Rank", "§cThat rank does not exist.")); return; } @@ -40,7 +40,7 @@ public class SetArgument { } if (command.isPlayer()) { Optional optionalAccount = AccountManager.fromCache(((Player) sender).getUniqueId()); - if (!optionalAccount.isPresent()) { + if (optionalAccount.isEmpty()) { sender.sendMessage(Style.error("Rank", "§cError whilst fetching account, please try again later...")); return; } diff --git a/core/src/main/java/zone/themcgamer/core/account/menu/ProfileMenu.java b/core/src/main/java/zone/themcgamer/core/account/menu/ProfileMenu.java index e48a0d7..f7b603a 100644 --- a/core/src/main/java/zone/themcgamer/core/account/menu/ProfileMenu.java +++ b/core/src/main/java/zone/themcgamer/core/account/menu/ProfileMenu.java @@ -20,7 +20,7 @@ public class ProfileMenu extends Menu { @Override protected void onOpen() { Optional optionalAccount = AccountManager.fromCache(player.getUniqueId()); - if (!optionalAccount.isPresent()) + if (optionalAccount.isEmpty()) return; Account account = optionalAccount.get(); set(1, 1, new Button(new ItemBuilder(XMaterial.PLAYER_HEAD) diff --git a/core/src/main/java/zone/themcgamer/core/badSportSystem/BadSportSystem.java b/core/src/main/java/zone/themcgamer/core/badSportSystem/BadSportSystem.java index fe3b167..758347b 100644 --- a/core/src/main/java/zone/themcgamer/core/badSportSystem/BadSportSystem.java +++ b/core/src/main/java/zone/themcgamer/core/badSportSystem/BadSportSystem.java @@ -54,7 +54,7 @@ public class BadSportSystem extends Module { if (jedisCommand instanceof PunishmentsUpdateCommand) { PunishmentsUpdateCommand punishmentsUpdateCommand = (PunishmentsUpdateCommand) jedisCommand; Optional optionalBadSportClient = lookup(punishmentsUpdateCommand.getUuid()); - if (!optionalBadSportClient.isPresent()) + if (optionalBadSportClient.isEmpty()) return; try { Set punishments = GSON.fromJson(punishmentsUpdateCommand.getJson(), new TypeToken>() {}.getType()); @@ -75,10 +75,10 @@ public class BadSportSystem extends Module { @EventHandler(priority = EventPriority.HIGHEST) private void onLogin(PlayerLoginEvent event) { Optional optionalClient = lookup(event.getPlayer().getUniqueId()); - if (!optionalClient.isPresent()) + if (optionalClient.isEmpty()) return; Optional optionalPunishment = optionalClient.get().getBan(); - if (!optionalPunishment.isPresent()) + if (optionalPunishment.isEmpty()) return; Punishment punishment = optionalPunishment.get(); event.disallow(PlayerLoginEvent.Result.KICK_BANNED, PunishmentCategory.format(punishment)); diff --git a/core/src/main/java/zone/themcgamer/core/badSportSystem/command/BadSportCommand.java b/core/src/main/java/zone/themcgamer/core/badSportSystem/command/BadSportCommand.java index 9f8b6aa..473deef 100644 --- a/core/src/main/java/zone/themcgamer/core/badSportSystem/command/BadSportCommand.java +++ b/core/src/main/java/zone/themcgamer/core/badSportSystem/command/BadSportCommand.java @@ -30,7 +30,7 @@ public class BadSportCommand { return; } Optional optionalExecutorAccount = AccountManager.fromCache(player.getUniqueId()); - if (!optionalExecutorAccount.isPresent()) + if (optionalExecutorAccount.isEmpty()) return; if (player.getName().equalsIgnoreCase(args[0]) && !optionalExecutorAccount.get().hasRank(Rank.JR_DEVELOPER) && args.length >= 2) { command.getSender().sendMessage(Style.error("Bad Sport","You cannot punish yourself!")); diff --git a/core/src/main/java/zone/themcgamer/core/badSportSystem/menu/BadSportMenu.java b/core/src/main/java/zone/themcgamer/core/badSportSystem/menu/BadSportMenu.java index 197a8da..83f70bd 100644 --- a/core/src/main/java/zone/themcgamer/core/badSportSystem/menu/BadSportMenu.java +++ b/core/src/main/java/zone/themcgamer/core/badSportSystem/menu/BadSportMenu.java @@ -46,7 +46,7 @@ public class BadSportMenu extends Menu { if (badSportSystem == null) return; Optional optionalBadSportClient = badSportSystem.lookup(target.getUuid()); - if (!optionalBadSportClient.isPresent()) + if (optionalBadSportClient.isEmpty()) return; BadSportClient badSportClient = optionalBadSportClient.get(); @@ -71,7 +71,7 @@ public class BadSportMenu extends Menu { return; } Optional optionalAccount = AccountManager.fromCache(player.getUniqueId()); - if (!optionalAccount.isPresent()) + if (optionalAccount.isEmpty()) return; Account staffAccount = optionalAccount.get(); diff --git a/core/src/main/java/zone/themcgamer/core/command/CommandManager.java b/core/src/main/java/zone/themcgamer/core/command/CommandManager.java index 1944b49..608dc45 100644 --- a/core/src/main/java/zone/themcgamer/core/command/CommandManager.java +++ b/core/src/main/java/zone/themcgamer/core/command/CommandManager.java @@ -279,7 +279,7 @@ public class CommandManager extends Module implements CommandExecutor { else { if (sender instanceof Player) { Optional optionalAccount = AccountManager.fromCache(((Player) sender).getUniqueId()); - if (!optionalAccount.isPresent()) { + if (optionalAccount.isEmpty()) { sender.sendMessage(Style.error("Account","&cCannot fetch account")); return true; } diff --git a/core/src/main/java/zone/themcgamer/core/game/kit/KitManager.java b/core/src/main/java/zone/themcgamer/core/game/kit/KitManager.java index 62186ac..4d021d8 100644 --- a/core/src/main/java/zone/themcgamer/core/game/kit/KitManager.java +++ b/core/src/main/java/zone/themcgamer/core/game/kit/KitManager.java @@ -33,7 +33,7 @@ public class KitManager extends MiniAccount { @Override public void loadAccount(int accountId, UUID uuid, String name, String ip, String encryptedIp, ResultSet resultSet) throws SQLException { Optional client = lookup(uuid); - if (!client.isPresent()) + if (client.isEmpty()) return; while (resultSet.next()) { MGZGame game = EnumUtils.fromString(MGZGame.class, resultSet.getString("game")); diff --git a/core/src/main/java/zone/themcgamer/core/kingdom/KingdomManager.java b/core/src/main/java/zone/themcgamer/core/kingdom/KingdomManager.java index aaedbc2..7fe7836 100644 --- a/core/src/main/java/zone/themcgamer/core/kingdom/KingdomManager.java +++ b/core/src/main/java/zone/themcgamer/core/kingdom/KingdomManager.java @@ -61,7 +61,7 @@ public class KingdomManager extends Module { return false; } Optional optionalAccount = AccountManager.fromCache(player.getUniqueId()); - if (!optionalAccount.isPresent()) { + if (optionalAccount.isEmpty()) { player.sendMessage(Style.error("Kingdom", "§cThere was an error whilst creating your Kingdom!")); return false; } diff --git a/core/src/main/java/zone/themcgamer/core/plugin/MGZPlugin.java b/core/src/main/java/zone/themcgamer/core/plugin/MGZPlugin.java index f9ad880..1b193f7 100644 --- a/core/src/main/java/zone/themcgamer/core/plugin/MGZPlugin.java +++ b/core/src/main/java/zone/themcgamer/core/plugin/MGZPlugin.java @@ -62,7 +62,7 @@ public abstract class MGZPlugin extends JavaPlugin { getLogger().info("Setting up Minecraft server..."); Optional optionalMinecraftServerRepository = RedisRepository.getRepository(MinecraftServerRepository.class); - if (!optionalMinecraftServerRepository.isPresent()) { + if (optionalMinecraftServerRepository.isEmpty()) { getLogger().severe("Cannot find Minecraft server repository, stopping..."); getServer().shutdown(); return; @@ -83,7 +83,7 @@ public abstract class MGZPlugin extends JavaPlugin { }).findFirst(); // If there is no MinecraftServer found with this server ip and port or the server found is not // in a starting state, we wanna attempt to load the MinecraftServer information from a local file - if (!optionalMinecraftServer.isPresent() || (optionalMinecraftServer.get().getState() != ServerState.STARTING)) { + if (optionalMinecraftServer.isEmpty() || (optionalMinecraftServer.get().getState() != ServerState.STARTING)) { File detailsFile = new File(getDataFolder(), "details.yml"); if (detailsFile.exists()) { // If the details file exists, try and load the MinecraftServer from it try { diff --git a/core/src/main/java/zone/themcgamer/core/server/command/ServerCommand.java b/core/src/main/java/zone/themcgamer/core/server/command/ServerCommand.java index 4a7f62b..104af4c 100644 --- a/core/src/main/java/zone/themcgamer/core/server/command/ServerCommand.java +++ b/core/src/main/java/zone/themcgamer/core/server/command/ServerCommand.java @@ -39,7 +39,7 @@ public class ServerCommand { } Optional optionalServer = minecraftServerRepository .lookup(minecraftServer -> minecraftServer.getName().equalsIgnoreCase(args[0])); - if (!optionalServer.isPresent()) { + if (optionalServer.isEmpty()) { player.sendMessage(Style.error("Server", "&7A server with that name doesn't exist!")); return; } diff --git a/core/src/main/java/zone/themcgamer/core/task/TaskManager.java b/core/src/main/java/zone/themcgamer/core/task/TaskManager.java index 103e4ed..c09074a 100644 --- a/core/src/main/java/zone/themcgamer/core/task/TaskManager.java +++ b/core/src/main/java/zone/themcgamer/core/task/TaskManager.java @@ -31,7 +31,7 @@ public class TaskManager extends MiniAccount { @Override public void loadAccount(int accountId, UUID uuid, String name, String ip, String encryptedIp, ResultSet resultSet) throws SQLException { Optional client = lookup(uuid); - if (!client.isPresent()) + if (client.isEmpty()) return; while (resultSet.next()) { Task task = Task.match(resultSet.getString("task")); diff --git a/core/src/main/java/zone/themcgamer/core/update/ServerUpdater.java b/core/src/main/java/zone/themcgamer/core/update/ServerUpdater.java index 2ab3e6b..9be42dc 100644 --- a/core/src/main/java/zone/themcgamer/core/update/ServerUpdater.java +++ b/core/src/main/java/zone/themcgamer/core/update/ServerUpdater.java @@ -118,7 +118,7 @@ public class ServerUpdater extends Module { if (split.length < 1 || (!split[split.length - 1].equalsIgnoreCase("jar"))) continue; Optional optionalChecksum = getChecksum(file); - if (!optionalChecksum.isPresent()) { + if (optionalChecksum.isEmpty()) { log("Failed to retrieve checksum for file '" + file.getAbsolutePath() + "' in directory '" + directory.getAbsolutePath() + "', continuing..."); continue; diff --git a/hub/src/main/java/zone/themcgamer/hub/menu/GameKitsMenu.java b/hub/src/main/java/zone/themcgamer/hub/menu/GameKitsMenu.java index 73d06d9..651593a 100644 --- a/hub/src/main/java/zone/themcgamer/hub/menu/GameKitsMenu.java +++ b/hub/src/main/java/zone/themcgamer/hub/menu/GameKitsMenu.java @@ -44,7 +44,7 @@ public class GameKitsMenu extends Menu { if (kitManager == null) return; Optional optionalKitClient = kitManager.lookup(player.getUniqueId()); - if (!optionalKitClient.isPresent()) + if (optionalKitClient.isEmpty()) return; KitClient kitClient = optionalKitClient.get(); diff --git a/proxy/src/main/java/zone/themcgamer/proxy/hub/HubBalancer.java b/proxy/src/main/java/zone/themcgamer/proxy/hub/HubBalancer.java index fb37ab5..daa4f84 100644 --- a/proxy/src/main/java/zone/themcgamer/proxy/hub/HubBalancer.java +++ b/proxy/src/main/java/zone/themcgamer/proxy/hub/HubBalancer.java @@ -139,7 +139,7 @@ public class HubBalancer implements Runnable, Listener { Optional optionalMinecraftServer = minecraftServerRepository.getCached().stream() .filter(server -> server.getId().equals(key)) .findFirst(); - if (!optionalMinecraftServer.isPresent()) { + if (optionalMinecraftServer.isEmpty()) { hubs.remove(key); return true; } diff --git a/serverdata/src/main/java/zone/themcgamer/data/jedis/data/Node.java b/serverdata/src/main/java/zone/themcgamer/data/jedis/data/Node.java index 020adf9..f012c09 100644 --- a/serverdata/src/main/java/zone/themcgamer/data/jedis/data/Node.java +++ b/serverdata/src/main/java/zone/themcgamer/data/jedis/data/Node.java @@ -58,7 +58,7 @@ public class Node { public Collection getServers() { Set servers = new HashSet<>(); Optional minecraftServerRepository = RedisRepository.getRepository(MinecraftServerRepository.class); - if (!minecraftServerRepository.isPresent()) + if (minecraftServerRepository.isEmpty()) return servers; servers.addAll(new ArrayList<>(minecraftServerRepository.get().getCached()).parallelStream() .filter(minecraftServer -> minecraftServer.getNode() != null && (minecraftServer.getNode().equals(this))) diff --git a/serverdata/src/main/java/zone/themcgamer/data/jedis/data/ServerGroup.java b/serverdata/src/main/java/zone/themcgamer/data/jedis/data/ServerGroup.java index 00f4642..8f36879 100644 --- a/serverdata/src/main/java/zone/themcgamer/data/jedis/data/ServerGroup.java +++ b/serverdata/src/main/java/zone/themcgamer/data/jedis/data/ServerGroup.java @@ -32,7 +32,7 @@ public class ServerGroup { public Collection getServers() { Set servers = new HashSet<>(); Optional minecraftServerRepository = RedisRepository.getRepository(MinecraftServerRepository.class); - if (!minecraftServerRepository.isPresent()) + if (minecraftServerRepository.isEmpty()) return servers; servers.addAll(new ArrayList<>(minecraftServerRepository.get().getCached()).parallelStream() .filter(minecraftServer -> minecraftServer.getGroup().equals(this))