misc(debug): Improved Plugin Messaging Listener debug mode
This commit is contained in:
parent
2df0a8b8a4
commit
52b0dca96a
@ -239,13 +239,13 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
|
|||||||
return config.get().authServers().contains(server);
|
return config.get().authServers().contains(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logDebug(String msg) {
|
public void logDebug(final String msg) {
|
||||||
if (config.get().advanced().debug()) {
|
if (config.get().advanced().debug()) {
|
||||||
logger.info("[DEBUG] {}", msg);
|
logger.info("[DEBUG] {}", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logDebug(Supplier<String> msg) {
|
public void logDebug(final Supplier<String> msg) {
|
||||||
if (config.get().advanced().debug()) {
|
if (config.get().advanced().debug()) {
|
||||||
logger.info("[DEBUG] {}", msg.get());
|
logger.info("[DEBUG] {}", msg.get());
|
||||||
}
|
}
|
||||||
|
@ -57,11 +57,7 @@ public final class PluginMessageListener implements Listener<PluginMessageEvent>
|
|||||||
@Override
|
@Override
|
||||||
public EventTask executeAsync(final PluginMessageEvent event) {
|
public EventTask executeAsync(final PluginMessageEvent event) {
|
||||||
return EventTask.async(() -> {
|
return EventTask.async(() -> {
|
||||||
final boolean cancelled = !event.getResult().isAllowed()
|
if (notAllowedEvent(event)) {
|
||||||
|| !(event.getSource() instanceof ServerConnection)
|
|
||||||
|| !(event.getIdentifier().equals(AuthMeVelocityPlugin.MODERN_CHANNEL)
|
|
||||||
|| event.getIdentifier().equals(AuthMeVelocityPlugin.LEGACY_CHANNEL));
|
|
||||||
if (cancelled) {
|
|
||||||
plugin.logDebug("PluginMessageEvent | Not allowed");
|
plugin.logDebug("PluginMessageEvent | Not allowed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -117,6 +113,24 @@ public final class PluginMessageListener implements Listener<PluginMessageEvent>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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){
|
private void createServerConnectionRequest(final Player player, final ServerConnection connection){
|
||||||
final RegisteredServer loginServer = player.getCurrentServer().orElse(connection).getServer();
|
final RegisteredServer loginServer = player.getCurrentServer().orElse(connection).getServer();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user