API improvements

This commit is contained in:
4drian3d 2022-03-30 18:04:53 -05:00
parent c4b0d7dbd6
commit 6f40766d75

View File

@ -1,7 +1,5 @@
package com.glyart.authmevelocity.proxy; package com.glyart.authmevelocity.proxy;
import java.util.Optional;
import java.util.UUID;
import java.util.function.Predicate; import java.util.function.Predicate;
import com.glyart.authmevelocity.proxy.config.AuthMeConfig; import com.glyart.authmevelocity.proxy.config.AuthMeConfig;
@ -27,8 +25,7 @@ public final class AuthmeVelocityAPI {
* @return if the player is logged in or not * @return if the player is logged in or not
*/ */
public boolean isLogged(@NotNull Player player){ public boolean isLogged(@NotNull Player player){
final UUID playerUUID = player.getUniqueId(); return plugin.loggedPlayers.contains(player.getUniqueId());
return plugin.loggedPlayers.contains(playerUUID);
} }
/** /**
@ -37,8 +34,7 @@ public final class AuthmeVelocityAPI {
* @return if the player was succesfully added * @return if the player was succesfully added
*/ */
public boolean addPlayer(@NotNull Player player){ public boolean addPlayer(@NotNull Player player){
final UUID playerUUID = player.getUniqueId(); return plugin.loggedPlayers.add(player.getUniqueId());
return plugin.loggedPlayers.add(playerUUID);
} }
/** /**
@ -47,8 +43,7 @@ public final class AuthmeVelocityAPI {
* @return if the player was succesfully removed * @return if the player was succesfully removed
*/ */
public boolean removePlayer(@NotNull Player player){ public boolean removePlayer(@NotNull Player player){
final UUID playerUUID = player.getUniqueId(); return plugin.loggedPlayers.remove(player.getUniqueId());
return plugin.loggedPlayers.remove(playerUUID);
} }
/** /**
@ -65,8 +60,7 @@ public final class AuthmeVelocityAPI {
* @return if the player is on a login server * @return if the player is on a login server
*/ */
public boolean isInAuthServer(@NotNull Player player){ public boolean isInAuthServer(@NotNull Player player){
Optional<ServerConnection> connection = player.getCurrentServer(); return player.getCurrentServer().map(this::isAuthServer).orElse(false);
return connection.isPresent() && isAuthServer(connection.get());
} }
/** /**