Changed negated isPresent() to isEmpty().

This commit is contained in:
nickreesdev 2021-02-19 14:57:28 -06:00
parent 7c9b72c23a
commit f9f6eeb055
18 changed files with 23 additions and 23 deletions

@ -47,7 +47,7 @@ public class ArcadeScoreboard extends WritableScoreboard {
@Override
public void writeLines() {
Optional<Account> optionalAccount = AccountManager.fromCache(player.getUniqueId());
if (!optionalAccount.isPresent()) {
if (optionalAccount.isEmpty()) {
writeBlank();
return;
}

@ -78,7 +78,7 @@ public class PlayerListener implements Listener {
private void onChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
Optional<Account> optionalAccount = AccountManager.fromCache(player.getUniqueId());
if (!optionalAccount.isPresent()) {
if (optionalAccount.isEmpty()) {
player.sendMessage(Style.error("Chat", "§cCannot send chat message"));
return;
}

@ -29,7 +29,7 @@ public class SetArgument {
return;
}
Optional<Rank> 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<Account> 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;
}

@ -20,7 +20,7 @@ public class ProfileMenu extends Menu {
@Override
protected void onOpen() {
Optional<Account> 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)

@ -54,7 +54,7 @@ public class BadSportSystem extends Module {
if (jedisCommand instanceof PunishmentsUpdateCommand) {
PunishmentsUpdateCommand punishmentsUpdateCommand = (PunishmentsUpdateCommand) jedisCommand;
Optional<BadSportClient> optionalBadSportClient = lookup(punishmentsUpdateCommand.getUuid());
if (!optionalBadSportClient.isPresent())
if (optionalBadSportClient.isEmpty())
return;
try {
Set<Punishment> punishments = GSON.fromJson(punishmentsUpdateCommand.getJson(), new TypeToken<Set<Punishment>>() {}.getType());
@ -75,10 +75,10 @@ public class BadSportSystem extends Module {
@EventHandler(priority = EventPriority.HIGHEST)
private void onLogin(PlayerLoginEvent event) {
Optional<BadSportClient> optionalClient = lookup(event.getPlayer().getUniqueId());
if (!optionalClient.isPresent())
if (optionalClient.isEmpty())
return;
Optional<Punishment> optionalPunishment = optionalClient.get().getBan();
if (!optionalPunishment.isPresent())
if (optionalPunishment.isEmpty())
return;
Punishment punishment = optionalPunishment.get();
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, PunishmentCategory.format(punishment));

@ -30,7 +30,7 @@ public class BadSportCommand {
return;
}
Optional<Account> 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!"));

@ -46,7 +46,7 @@ public class BadSportMenu extends Menu {
if (badSportSystem == null)
return;
Optional<BadSportClient> 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<Account> optionalAccount = AccountManager.fromCache(player.getUniqueId());
if (!optionalAccount.isPresent())
if (optionalAccount.isEmpty())
return;
Account staffAccount = optionalAccount.get();

@ -279,7 +279,7 @@ public class CommandManager extends Module implements CommandExecutor {
else {
if (sender instanceof Player) {
Optional<Account> optionalAccount = AccountManager.fromCache(((Player) sender).getUniqueId());
if (!optionalAccount.isPresent()) {
if (optionalAccount.isEmpty()) {
sender.sendMessage(Style.error("Account","&cCannot fetch account"));
return true;
}

@ -33,7 +33,7 @@ public class KitManager extends MiniAccount<KitClient> {
@Override
public void loadAccount(int accountId, UUID uuid, String name, String ip, String encryptedIp, ResultSet resultSet) throws SQLException {
Optional<KitClient> client = lookup(uuid);
if (!client.isPresent())
if (client.isEmpty())
return;
while (resultSet.next()) {
MGZGame game = EnumUtils.fromString(MGZGame.class, resultSet.getString("game"));

@ -61,7 +61,7 @@ public class KingdomManager extends Module {
return false;
}
Optional<Account> 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;
}

@ -62,7 +62,7 @@ public abstract class MGZPlugin extends JavaPlugin {
getLogger().info("Setting up Minecraft server...");
Optional<MinecraftServerRepository> 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 {

@ -39,7 +39,7 @@ public class ServerCommand {
}
Optional<MinecraftServer> 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;
}

@ -31,7 +31,7 @@ public class TaskManager extends MiniAccount<TaskClient> {
@Override
public void loadAccount(int accountId, UUID uuid, String name, String ip, String encryptedIp, ResultSet resultSet) throws SQLException {
Optional<TaskClient> client = lookup(uuid);
if (!client.isPresent())
if (client.isEmpty())
return;
while (resultSet.next()) {
Task task = Task.match(resultSet.getString("task"));

@ -118,7 +118,7 @@ public class ServerUpdater extends Module {
if (split.length < 1 || (!split[split.length - 1].equalsIgnoreCase("jar")))
continue;
Optional<String> optionalChecksum = getChecksum(file);
if (!optionalChecksum.isPresent()) {
if (optionalChecksum.isEmpty()) {
log("Failed to retrieve checksum for file '" + file.getAbsolutePath() + "' in directory '" +
directory.getAbsolutePath() + "', continuing...");
continue;

@ -44,7 +44,7 @@ public class GameKitsMenu extends Menu {
if (kitManager == null)
return;
Optional<KitClient> optionalKitClient = kitManager.lookup(player.getUniqueId());
if (!optionalKitClient.isPresent())
if (optionalKitClient.isEmpty())
return;
KitClient kitClient = optionalKitClient.get();

@ -139,7 +139,7 @@ public class HubBalancer implements Runnable, Listener {
Optional<MinecraftServer> optionalMinecraftServer = minecraftServerRepository.getCached().stream()
.filter(server -> server.getId().equals(key))
.findFirst();
if (!optionalMinecraftServer.isPresent()) {
if (optionalMinecraftServer.isEmpty()) {
hubs.remove(key);
return true;
}

@ -58,7 +58,7 @@ public class Node {
public Collection<MinecraftServer> getServers() {
Set<MinecraftServer> servers = new HashSet<>();
Optional<MinecraftServerRepository> 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)))

@ -32,7 +32,7 @@ public class ServerGroup {
public Collection<MinecraftServer> getServers() {
Set<MinecraftServer> servers = new HashSet<>();
Optional<MinecraftServerRepository> 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))