Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending a PluginMessage from BungeeCord to a SpigotServer

I tried to send a message via the "BungeeCord Plugin Messaging Channel" from the Proxy to a Server. I used the following Code:

In the BungeeCord Plugin:

        ByteArrayOutputStream bb = new ByteArrayOutputStream();
        DataOutputStream outt = new DataOutputStream(bb);
        try {
            outt.writeUTF("Forward");
            outt.writeUTF("lobby");
            outt.writeUTF("anfrage ");
            outt.writeUTF(pp.getDisplayName());
        } catch (IOException e) {
            e.printStackTrace();
        }
        pp.sendData("GlobalSystem", bb.toByteArray());

In the Spigot Plugin:

public class MessageListener implements PluginMessageListener {

public MessageListener(main main) {
    plugin = main;
    plugin.getServer().getMessenger().registerIncomingPluginChannel(plugin, "GlobalSystem", this);
    plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "GlobalSystem");
}

@Override
public void onPluginMessageReceived(String channel, Player p, byte[] args) {
    System.out.println("hi");
}

main plugin = main.getPlugin();
}

What is wrong with it? I read everything on these websites:

PostCrafter.de

Bukkit & Bungee Plugin Message Channel

Sorry for my bad English and thanks for your help :)

like image 729
LeWimbes Avatar asked Nov 25 '25 13:11

LeWimbes


1 Answers

You made another mistake. You are sending your packets to the player and not to the server. You need to do

pp.getServer().sendData("GlobalSystem", bb.toByteArray());
like image 104
gyurix Avatar answered Nov 27 '25 01:11

gyurix



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!