feat: Improved plugin messages sending to backend server

This commit is contained in:
Adrian 2024-08-26 22:48:15 -05:00
parent ca8414763f
commit 195b29d003
No known key found for this signature in database
GPG Key ID: FB8EF84DCE1BE452
2 changed files with 8 additions and 10 deletions

View File

@ -1,5 +1,5 @@
group = io.github.4drian3d group = io.github.4drian3d
version = 4.1.1 version = 4.1.2-SHAPSHOT
description = AuthMeReloaded Support for Velocity description = AuthMeReloaded Support for Velocity
url = https://modrinth.com/plugin/authmevelocity url = https://modrinth.com/plugin/authmevelocity
id = authmevelocity id = authmevelocity

View File

@ -17,8 +17,6 @@
package io.github._4drian3d.authmevelocity.velocity.listener.connection; package io.github._4drian3d.authmevelocity.velocity.listener.connection;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.velocitypowered.api.event.EventManager; import com.velocitypowered.api.event.EventManager;
import com.velocitypowered.api.event.EventTask; import com.velocitypowered.api.event.EventTask;
@ -61,13 +59,13 @@ public final class PostConnectListener implements Listener<ServerPostConnectEven
} }
plugin.logDebug("ServerPostConnectEvent | Already logged player and connected to an Auth server"); plugin.logDebug("ServerPostConnectEvent | Already logged player and connected to an Auth server");
final ByteArrayDataOutput buf = ByteStreams.newDataOutput(); final boolean messageResult = server.sendPluginMessage(AuthMeVelocityPlugin.MODERN_CHANNEL, (encoder) -> {
buf.writeUTF("LOGIN"); plugin.logDebug(() -> "ServerPostConnectEvent | " + player.getUsername() + " | Encoding LOGIN data");
buf.writeUTF(player.getUsername()); encoder.writeUTF("LOGIN");
encoder.writeUTF(player.getUsername());
final byte[] byteArray = buf.toByteArray(); plugin.logDebug(() -> "ServerPostConnectEvent | " + player.getUsername() + " | Sending LOGIN data");
plugin.logDebug(() -> "ServerPostConnectEvent | " + player.getUsername() + " | Sending LOGIN data"); });
if (server.sendPluginMessage(AuthMeVelocityPlugin.MODERN_CHANNEL, byteArray)) { if (messageResult) {
plugin.logDebug(() -> "ServerPostConnectEvent | " + player.getUsername() + " | Correctly send data"); plugin.logDebug(() -> "ServerPostConnectEvent | " + player.getUsername() + " | Correctly send data");
} else { } else {
plugin.logDebug("ServerPostConnectEvent | Failed to send data"); plugin.logDebug("ServerPostConnectEvent | Failed to send data");