diff --git a/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthMeVelocityPlugin.java b/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthMeVelocityPlugin.java index 2f2c9fe..58fcedc 100644 --- a/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthMeVelocityPlugin.java +++ b/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthMeVelocityPlugin.java @@ -44,7 +44,7 @@ public class AuthMeVelocityPlugin { @Subscribe public void onProxyInitialization(ProxyInitializeEvent event) { Toml toml = this.loadConfig(pluginDirectory); - if(toml == null){ + if (toml == null) { logger.warn("Failed to load config.toml. Shutting down."); return; } diff --git a/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthmePlaceholders.java b/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthmePlaceholders.java index 876c21b..47d63fa 100644 --- a/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthmePlaceholders.java +++ b/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthmePlaceholders.java @@ -13,14 +13,26 @@ final class AuthmePlaceholders { static Expansion getExpansion(AuthMeVelocityPlugin plugin){ return Expansion.builder("authme") .filter(Player.class) + // Logged Placeholders .audiencePlaceholder("is_logged", (aud, queue, ctx) -> Tag.selfClosingInserting(plugin.getAPI().isLogged((Player)aud) ? TRUE_COMPONENT : FALSE_COMPONENT)) .globalPlaceholder("is_player_logged", (queue, ctx) -> { String playerName = queue.popOr(() -> "you need to provide a player").value(); return Tag.selfClosingInserting( - plugin.getProxy().getPlayer(playerName).map(pl -> plugin.getAPI().isLogged(pl)).isPresent() - ? TRUE_COMPONENT - : FALSE_COMPONENT + plugin.getProxy().getPlayer(playerName) + .map(plugin.getAPI()::isLogged) + .orElse(false) ? TRUE_COMPONENT : FALSE_COMPONENT + ); + }) + // In Auth Server placeholders + .audiencePlaceholder("in_auth_server", (aud, queue, ctx) -> + Tag.selfClosingInserting(plugin.getAPI().isInAuthServer((Player)aud) ? TRUE_COMPONENT : FALSE_COMPONENT)) + .globalPlaceholder("player_in_auth_server", (queue, ctx) -> { + String playerName = queue.popOr(() -> "you need to provide a player").value(); + return Tag.selfClosingInserting( + plugin.getProxy().getPlayer(playerName) + .map(plugin.getAPI()::isInAuthServer) + .orElse(false) ? TRUE_COMPONENT : FALSE_COMPONENT ); }) .build();