diff --git a/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/AuthMeVelocityPlugin.java b/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/AuthMeVelocityPlugin.java index 91d5954..1f7f2d5 100644 --- a/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/AuthMeVelocityPlugin.java +++ b/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/AuthMeVelocityPlugin.java @@ -239,13 +239,13 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI { return config.get().authServers().contains(server); } - public void logDebug(String msg) { + public void logDebug(final String msg) { if (config.get().advanced().debug()) { logger.info("[DEBUG] {}", msg); } } - public void logDebug(Supplier msg) { + public void logDebug(final Supplier msg) { if (config.get().advanced().debug()) { logger.info("[DEBUG] {}", msg.get()); } diff --git a/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/listener/data/PluginMessageListener.java b/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/listener/data/PluginMessageListener.java index 1e8f948..ecbea2f 100644 --- a/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/listener/data/PluginMessageListener.java +++ b/velocity/src/main/java/io/github/_4drian3d/authmevelocity/velocity/listener/data/PluginMessageListener.java @@ -57,11 +57,7 @@ public final class PluginMessageListener implements Listener @Override public EventTask executeAsync(final PluginMessageEvent event) { return EventTask.async(() -> { - final boolean cancelled = !event.getResult().isAllowed() - || !(event.getSource() instanceof ServerConnection) - || !(event.getIdentifier().equals(AuthMeVelocityPlugin.MODERN_CHANNEL) - || event.getIdentifier().equals(AuthMeVelocityPlugin.LEGACY_CHANNEL)); - if (cancelled) { + if (notAllowedEvent(event)) { plugin.logDebug("PluginMessageEvent | Not allowed"); return; } @@ -117,6 +113,24 @@ public final class PluginMessageListener implements Listener }); } + private boolean notAllowedEvent(PluginMessageEvent event) { + if (!event.getResult().isAllowed()) { + plugin.logDebug("PluginMessageEvent | Result not allowed"); + return true; + } + if (!(event.getSource() instanceof ServerConnection)) { + plugin.logDebug("PluginMessageEvent | Not ServerConnection"); + return true; + } + final var identifier = event.getIdentifier(); + if (!(identifier.equals(AuthMeVelocityPlugin.MODERN_CHANNEL) + || identifier.equals(AuthMeVelocityPlugin.LEGACY_CHANNEL))) { + plugin.logDebug("PluginMessageEvent | Not AuthMeVelocity Identifier"); + return true; + } + return false; + } + private void createServerConnectionRequest(final Player player, final ServerConnection connection){ final RegisteredServer loginServer = player.getCurrentServer().orElse(connection).getServer();