This commit is contained in:
ajgeiss0702
2021-07-21 17:17:58 -05:00
parent cfdadd17ca
commit 5bd770da9c
18 changed files with 725 additions and 30 deletions
@@ -1,8 +1,12 @@
package us.ajg0702.queue.platforms.velocity;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.velocitypowered.api.plugin.PluginContainer;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import net.kyori.adventure.text.Component;
import us.ajg0702.queue.api.PlatformMethods;
@@ -42,6 +46,14 @@ public class PlatformMethodsImpl implements PlatformMethods {
public void sendPluginMessage(AdaptedPlayer player, String channel, String... data) {
if(player == null) return;
Player velocityPlayer = ((VelocityPlayer) player).getHandle();
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF( channel );
out.writeUTF(player.getName());
for(String s : data) {
out.writeUTF( s );
}
velocityPlayer.sendPluginMessage(MinecraftChannelIdentifier.from("ajqueue:tospigot"), out.toByteArray());
}
@Override
@@ -85,6 +85,7 @@ public class VelocityQueue {
@Subscribe
public void onPluginMessage(PluginMessageEvent e) {
System.out.println("Recieved message: "+e.getIdentifier().getId());
if(e.getIdentifier().getId().equals("ajqueue:tospigot")) {
e.setResult(PluginMessageEvent.ForwardResult.handled());
return;