Skip to content

Commit

Permalink
feat: Improved plugin messages sending to backend server
Browse files Browse the repository at this point in the history
  • Loading branch information
4drian3d committed Aug 27, 2024
1 parent ca84147 commit 195b29d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group = io.github.4drian3d
version = 4.1.1
version = 4.1.2-SHAPSHOT
description = AuthMeReloaded Support for Velocity
url = https://modrinth.com/plugin/authmevelocity
id = authmevelocity
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

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.velocitypowered.api.event.EventManager;
import com.velocitypowered.api.event.EventTask;
Expand Down Expand Up @@ -61,13 +59,13 @@ public EventTask executeAsync(final ServerPostConnectEvent event) {
}

plugin.logDebug("ServerPostConnectEvent | Already logged player and connected to an Auth server");
final ByteArrayDataOutput buf = ByteStreams.newDataOutput();
buf.writeUTF("LOGIN");
buf.writeUTF(player.getUsername());

final byte[] byteArray = buf.toByteArray();
plugin.logDebug(() -> "ServerPostConnectEvent | " + player.getUsername() + " | Sending LOGIN data");
if (server.sendPluginMessage(AuthMeVelocityPlugin.MODERN_CHANNEL, byteArray)) {
final boolean messageResult = server.sendPluginMessage(AuthMeVelocityPlugin.MODERN_CHANNEL, (encoder) -> {
plugin.logDebug(() -> "ServerPostConnectEvent | " + player.getUsername() + " | Encoding LOGIN data");
encoder.writeUTF("LOGIN");
encoder.writeUTF(player.getUsername());
plugin.logDebug(() -> "ServerPostConnectEvent | " + player.getUsername() + " | Sending LOGIN data");
});
if (messageResult) {
plugin.logDebug(() -> "ServerPostConnectEvent | " + player.getUsername() + " | Correctly send data");
} else {
plugin.logDebug("ServerPostConnectEvent | Failed to send data");
Expand Down

0 comments on commit 195b29d

Please sign in to comment.