Changed negated isPresent() to isEmpty().
This commit is contained in:
parent
7c9b72c23a
commit
f9f6eeb055
@ -47,7 +47,7 @@ public class ArcadeScoreboard extends WritableScoreboard {
|
|||||||
@Override
|
@Override
|
||||||
public void writeLines() {
|
public void writeLines() {
|
||||||
Optional<Account> optionalAccount = AccountManager.fromCache(player.getUniqueId());
|
Optional<Account> optionalAccount = AccountManager.fromCache(player.getUniqueId());
|
||||||
if (!optionalAccount.isPresent()) {
|
if (optionalAccount.isEmpty()) {
|
||||||
writeBlank();
|
writeBlank();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ public class PlayerListener implements Listener {
|
|||||||
private void onChat(AsyncPlayerChatEvent event) {
|
private void onChat(AsyncPlayerChatEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Optional<Account> optionalAccount = AccountManager.fromCache(player.getUniqueId());
|
Optional<Account> optionalAccount = AccountManager.fromCache(player.getUniqueId());
|
||||||
if (!optionalAccount.isPresent()) {
|
if (optionalAccount.isEmpty()) {
|
||||||
player.sendMessage(Style.error("Chat", "§cCannot send chat message"));
|
player.sendMessage(Style.error("Chat", "§cCannot send chat message"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public class SetArgument {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Optional<Rank> optionalRank = Rank.lookup(args[1]);
|
Optional<Rank> optionalRank = Rank.lookup(args[1]);
|
||||||
if (!optionalRank.isPresent()) {
|
if (optionalRank.isEmpty()) {
|
||||||
sender.sendMessage(Style.error("Rank", "§cThat rank does not exist."));
|
sender.sendMessage(Style.error("Rank", "§cThat rank does not exist."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ public class SetArgument {
|
|||||||
}
|
}
|
||||||
if (command.isPlayer()) {
|
if (command.isPlayer()) {
|
||||||
Optional<Account> optionalAccount = AccountManager.fromCache(((Player) sender).getUniqueId());
|
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..."));
|
sender.sendMessage(Style.error("Rank", "§cError whilst fetching account, please try again later..."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public class ProfileMenu extends Menu {
|
|||||||
@Override
|
@Override
|
||||||
protected void onOpen() {
|
protected void onOpen() {
|
||||||
Optional<Account> optionalAccount = AccountManager.fromCache(player.getUniqueId());
|
Optional<Account> optionalAccount = AccountManager.fromCache(player.getUniqueId());
|
||||||
if (!optionalAccount.isPresent())
|
if (optionalAccount.isEmpty())
|
||||||
return;
|
return;
|
||||||
Account account = optionalAccount.get();
|
Account account = optionalAccount.get();
|
||||||
set(1, 1, new Button(new ItemBuilder(XMaterial.PLAYER_HEAD)
|
set(1, 1, new Button(new ItemBuilder(XMaterial.PLAYER_HEAD)
|
||||||
|
@ -54,7 +54,7 @@ public class BadSportSystem extends Module {
|
|||||||
if (jedisCommand instanceof PunishmentsUpdateCommand) {
|
if (jedisCommand instanceof PunishmentsUpdateCommand) {
|
||||||
PunishmentsUpdateCommand punishmentsUpdateCommand = (PunishmentsUpdateCommand) jedisCommand;
|
PunishmentsUpdateCommand punishmentsUpdateCommand = (PunishmentsUpdateCommand) jedisCommand;
|
||||||
Optional<BadSportClient> optionalBadSportClient = lookup(punishmentsUpdateCommand.getUuid());
|
Optional<BadSportClient> optionalBadSportClient = lookup(punishmentsUpdateCommand.getUuid());
|
||||||
if (!optionalBadSportClient.isPresent())
|
if (optionalBadSportClient.isEmpty())
|
||||||
return;
|
return;
|
||||||
try {
|
try {
|
||||||
Set<Punishment> punishments = GSON.fromJson(punishmentsUpdateCommand.getJson(), new TypeToken<Set<Punishment>>() {}.getType());
|
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)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
private void onLogin(PlayerLoginEvent event) {
|
private void onLogin(PlayerLoginEvent event) {
|
||||||
Optional<BadSportClient> optionalClient = lookup(event.getPlayer().getUniqueId());
|
Optional<BadSportClient> optionalClient = lookup(event.getPlayer().getUniqueId());
|
||||||
if (!optionalClient.isPresent())
|
if (optionalClient.isEmpty())
|
||||||
return;
|
return;
|
||||||
Optional<Punishment> optionalPunishment = optionalClient.get().getBan();
|
Optional<Punishment> optionalPunishment = optionalClient.get().getBan();
|
||||||
if (!optionalPunishment.isPresent())
|
if (optionalPunishment.isEmpty())
|
||||||
return;
|
return;
|
||||||
Punishment punishment = optionalPunishment.get();
|
Punishment punishment = optionalPunishment.get();
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, PunishmentCategory.format(punishment));
|
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, PunishmentCategory.format(punishment));
|
||||||
|
@ -30,7 +30,7 @@ public class BadSportCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Optional<Account> optionalExecutorAccount = AccountManager.fromCache(player.getUniqueId());
|
Optional<Account> optionalExecutorAccount = AccountManager.fromCache(player.getUniqueId());
|
||||||
if (!optionalExecutorAccount.isPresent())
|
if (optionalExecutorAccount.isEmpty())
|
||||||
return;
|
return;
|
||||||
if (player.getName().equalsIgnoreCase(args[0]) && !optionalExecutorAccount.get().hasRank(Rank.JR_DEVELOPER) && args.length >= 2) {
|
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!"));
|
command.getSender().sendMessage(Style.error("Bad Sport","You cannot punish yourself!"));
|
||||||
|
@ -46,7 +46,7 @@ public class BadSportMenu extends Menu {
|
|||||||
if (badSportSystem == null)
|
if (badSportSystem == null)
|
||||||
return;
|
return;
|
||||||
Optional<BadSportClient> optionalBadSportClient = badSportSystem.lookup(target.getUuid());
|
Optional<BadSportClient> optionalBadSportClient = badSportSystem.lookup(target.getUuid());
|
||||||
if (!optionalBadSportClient.isPresent())
|
if (optionalBadSportClient.isEmpty())
|
||||||
return;
|
return;
|
||||||
BadSportClient badSportClient = optionalBadSportClient.get();
|
BadSportClient badSportClient = optionalBadSportClient.get();
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ public class BadSportMenu extends Menu {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Optional<Account> optionalAccount = AccountManager.fromCache(player.getUniqueId());
|
Optional<Account> optionalAccount = AccountManager.fromCache(player.getUniqueId());
|
||||||
if (!optionalAccount.isPresent())
|
if (optionalAccount.isEmpty())
|
||||||
return;
|
return;
|
||||||
Account staffAccount = optionalAccount.get();
|
Account staffAccount = optionalAccount.get();
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ public class CommandManager extends Module implements CommandExecutor {
|
|||||||
else {
|
else {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Optional<Account> optionalAccount = AccountManager.fromCache(((Player) sender).getUniqueId());
|
Optional<Account> optionalAccount = AccountManager.fromCache(((Player) sender).getUniqueId());
|
||||||
if (!optionalAccount.isPresent()) {
|
if (optionalAccount.isEmpty()) {
|
||||||
sender.sendMessage(Style.error("Account","&cCannot fetch account"));
|
sender.sendMessage(Style.error("Account","&cCannot fetch account"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public class KitManager extends MiniAccount<KitClient> {
|
|||||||
@Override
|
@Override
|
||||||
public void loadAccount(int accountId, UUID uuid, String name, String ip, String encryptedIp, ResultSet resultSet) throws SQLException {
|
public void loadAccount(int accountId, UUID uuid, String name, String ip, String encryptedIp, ResultSet resultSet) throws SQLException {
|
||||||
Optional<KitClient> client = lookup(uuid);
|
Optional<KitClient> client = lookup(uuid);
|
||||||
if (!client.isPresent())
|
if (client.isEmpty())
|
||||||
return;
|
return;
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
MGZGame game = EnumUtils.fromString(MGZGame.class, resultSet.getString("game"));
|
MGZGame game = EnumUtils.fromString(MGZGame.class, resultSet.getString("game"));
|
||||||
|
@ -61,7 +61,7 @@ public class KingdomManager extends Module {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Optional<Account> optionalAccount = AccountManager.fromCache(player.getUniqueId());
|
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!"));
|
player.sendMessage(Style.error("Kingdom", "§cThere was an error whilst creating your Kingdom!"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public abstract class MGZPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
getLogger().info("Setting up Minecraft server...");
|
getLogger().info("Setting up Minecraft server...");
|
||||||
Optional<MinecraftServerRepository> optionalMinecraftServerRepository = RedisRepository.getRepository(MinecraftServerRepository.class);
|
Optional<MinecraftServerRepository> optionalMinecraftServerRepository = RedisRepository.getRepository(MinecraftServerRepository.class);
|
||||||
if (!optionalMinecraftServerRepository.isPresent()) {
|
if (optionalMinecraftServerRepository.isEmpty()) {
|
||||||
getLogger().severe("Cannot find Minecraft server repository, stopping...");
|
getLogger().severe("Cannot find Minecraft server repository, stopping...");
|
||||||
getServer().shutdown();
|
getServer().shutdown();
|
||||||
return;
|
return;
|
||||||
@ -83,7 +83,7 @@ public abstract class MGZPlugin extends JavaPlugin {
|
|||||||
}).findFirst();
|
}).findFirst();
|
||||||
// If there is no MinecraftServer found with this server ip and port or the server found is not
|
// 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
|
// 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");
|
File detailsFile = new File(getDataFolder(), "details.yml");
|
||||||
if (detailsFile.exists()) { // If the details file exists, try and load the MinecraftServer from it
|
if (detailsFile.exists()) { // If the details file exists, try and load the MinecraftServer from it
|
||||||
try {
|
try {
|
||||||
|
@ -39,7 +39,7 @@ public class ServerCommand {
|
|||||||
}
|
}
|
||||||
Optional<MinecraftServer> optionalServer = minecraftServerRepository
|
Optional<MinecraftServer> optionalServer = minecraftServerRepository
|
||||||
.lookup(minecraftServer -> minecraftServer.getName().equalsIgnoreCase(args[0]));
|
.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!"));
|
player.sendMessage(Style.error("Server", "&7A server with that name doesn't exist!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class TaskManager extends MiniAccount<TaskClient> {
|
|||||||
@Override
|
@Override
|
||||||
public void loadAccount(int accountId, UUID uuid, String name, String ip, String encryptedIp, ResultSet resultSet) throws SQLException {
|
public void loadAccount(int accountId, UUID uuid, String name, String ip, String encryptedIp, ResultSet resultSet) throws SQLException {
|
||||||
Optional<TaskClient> client = lookup(uuid);
|
Optional<TaskClient> client = lookup(uuid);
|
||||||
if (!client.isPresent())
|
if (client.isEmpty())
|
||||||
return;
|
return;
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
Task task = Task.match(resultSet.getString("task"));
|
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")))
|
if (split.length < 1 || (!split[split.length - 1].equalsIgnoreCase("jar")))
|
||||||
continue;
|
continue;
|
||||||
Optional<String> optionalChecksum = getChecksum(file);
|
Optional<String> optionalChecksum = getChecksum(file);
|
||||||
if (!optionalChecksum.isPresent()) {
|
if (optionalChecksum.isEmpty()) {
|
||||||
log("Failed to retrieve checksum for file '" + file.getAbsolutePath() + "' in directory '" +
|
log("Failed to retrieve checksum for file '" + file.getAbsolutePath() + "' in directory '" +
|
||||||
directory.getAbsolutePath() + "', continuing...");
|
directory.getAbsolutePath() + "', continuing...");
|
||||||
continue;
|
continue;
|
||||||
|
@ -44,7 +44,7 @@ public class GameKitsMenu extends Menu {
|
|||||||
if (kitManager == null)
|
if (kitManager == null)
|
||||||
return;
|
return;
|
||||||
Optional<KitClient> optionalKitClient = kitManager.lookup(player.getUniqueId());
|
Optional<KitClient> optionalKitClient = kitManager.lookup(player.getUniqueId());
|
||||||
if (!optionalKitClient.isPresent())
|
if (optionalKitClient.isEmpty())
|
||||||
return;
|
return;
|
||||||
KitClient kitClient = optionalKitClient.get();
|
KitClient kitClient = optionalKitClient.get();
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ public class HubBalancer implements Runnable, Listener {
|
|||||||
Optional<MinecraftServer> optionalMinecraftServer = minecraftServerRepository.getCached().stream()
|
Optional<MinecraftServer> optionalMinecraftServer = minecraftServerRepository.getCached().stream()
|
||||||
.filter(server -> server.getId().equals(key))
|
.filter(server -> server.getId().equals(key))
|
||||||
.findFirst();
|
.findFirst();
|
||||||
if (!optionalMinecraftServer.isPresent()) {
|
if (optionalMinecraftServer.isEmpty()) {
|
||||||
hubs.remove(key);
|
hubs.remove(key);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ public class Node {
|
|||||||
public Collection<MinecraftServer> getServers() {
|
public Collection<MinecraftServer> getServers() {
|
||||||
Set<MinecraftServer> servers = new HashSet<>();
|
Set<MinecraftServer> servers = new HashSet<>();
|
||||||
Optional<MinecraftServerRepository> minecraftServerRepository = RedisRepository.getRepository(MinecraftServerRepository.class);
|
Optional<MinecraftServerRepository> minecraftServerRepository = RedisRepository.getRepository(MinecraftServerRepository.class);
|
||||||
if (!minecraftServerRepository.isPresent())
|
if (minecraftServerRepository.isEmpty())
|
||||||
return servers;
|
return servers;
|
||||||
servers.addAll(new ArrayList<>(minecraftServerRepository.get().getCached()).parallelStream()
|
servers.addAll(new ArrayList<>(minecraftServerRepository.get().getCached()).parallelStream()
|
||||||
.filter(minecraftServer -> minecraftServer.getNode() != null && (minecraftServer.getNode().equals(this)))
|
.filter(minecraftServer -> minecraftServer.getNode() != null && (minecraftServer.getNode().equals(this)))
|
||||||
|
@ -32,7 +32,7 @@ public class ServerGroup {
|
|||||||
public Collection<MinecraftServer> getServers() {
|
public Collection<MinecraftServer> getServers() {
|
||||||
Set<MinecraftServer> servers = new HashSet<>();
|
Set<MinecraftServer> servers = new HashSet<>();
|
||||||
Optional<MinecraftServerRepository> minecraftServerRepository = RedisRepository.getRepository(MinecraftServerRepository.class);
|
Optional<MinecraftServerRepository> minecraftServerRepository = RedisRepository.getRepository(MinecraftServerRepository.class);
|
||||||
if (!minecraftServerRepository.isPresent())
|
if (minecraftServerRepository.isEmpty())
|
||||||
return servers;
|
return servers;
|
||||||
servers.addAll(new ArrayList<>(minecraftServerRepository.get().getCached()).parallelStream()
|
servers.addAll(new ArrayList<>(minecraftServerRepository.get().getCached()).parallelStream()
|
||||||
.filter(minecraftServer -> minecraftServer.getGroup().equals(this))
|
.filter(minecraftServer -> minecraftServer.getGroup().equals(this))
|
||||||
|
Reference in New Issue
Block a user