Bungeecord Plugin to Bukkit Plugin communication

Discussion in 'BungeeCord Plugin Development' started by robbietjuh, Jul 12, 2013.

  1. Hey guys,

    I've been trying to tackle this problem for a day now so I decided to go ask here, on the forums. I'm trying to send information from a Bungeecord Plugin to a Bukkit Plugin. Both use channel BSBungee, whereas the Bungeecord plugin sends information and the Bukkit plugin has registered to listen for that channel and receive the information sent.

    This is the code I'm using in the Bungeecord plugin:
    Code (Text):
        // Called from within onEnable()
        private void registerChannels() {
        public static void sendMessage(Server server, String... message) {
            ByteArrayOutputStream b = new ByteArrayOutputStream();
            DataOutputStream o = new DataOutputStream(b);
            try {
                for(String m : message) {
            catch(IOException ignored) {}
            server.sendData("BSBungee", b.toByteArray());
    From the Bukkit side of things, this is the code I'm using to receive the message:
    Code (Text):
      // Called from within onEnable()
      private void registerChannels() {
            Bukkit.getMessenger().registerIncomingPluginChannel(this, "BSBungee", new PluginMessengerListener());
            Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BSFramework");
    Code (Text):
    // PluginMessengerListener.java
    public class PluginMessengerListener implements PluginMessageListener {
        public void onPluginMessageReceived(String channel, Player s, byte[] message) {
            Main.plugin.getLogger().info("Received data from channel " + channel);
    However, it seems like no data is sent or received cause the Bukkit plugin never logs that it received data, even though I'm very sure the sendMessage() method has been called (at the Bungeecord plugin side of things).

    Am I missing something? Do I need to register and/or listen for channels and data being sent another way?

    I'm running...
    • BungeeCord: version git-BungeeCord-Proxy-1.6.1-SNAPSHOT-"fb1cab4"-595
    • Spigot: version git-Spigot-1030 (MC: 1.6.2) (Implementing API version 1.6.2-R0.1-SNAPSHOT)
  2. Bump? :/ We kinda need to get this running within a timeframe which is getting smaller and smaller by the minute and I could really use some help :)
  3. From what little experience I have with Bungee coding, I think you're doing something wrong on the bukkit side. BungeeCord always uses the channel "BungeeCord" to send plugin messages. When you define a channel, it is simply one of Bungee's "sub channels"
    Hope this helped
  4. Thanks! I'll have an extra look at the Bukkit docs.. Plugin communications aren't really a much used feature and there's not too much information on it.. Oh well, we'll have to get along with the tools and docs we have.
  5. 200% wrong. Data sent with server.send data(String, byte[]) will be sent via the channel defined.

    Most likely, the problem is that nobody is connected to the server when the call is made. Either that, or you aren't registering the channels correctly