[Solved]Bungeecord Plugin <-> Spigot/Bukkit Plugin [PluginMessages]

Discussion in 'BungeeCord Plugin Development' started by _Cory_, Jan 21, 2014.

  1. Bungeecord Plugin <-> Spigot/Bukkit Plugin [PluginMessages]

    This isn't documented on the wiki, and I have run into a bit of trouble with it.
    Please help :D
     
  2. YoFuzzy3

    Supporter

  3. I cant find it ... :(
    Could you show me an example pleasE?
     
    • Disagree Disagree x 1
  4. YoFuzzy3

    Supporter

    In your Bukkit plugin's onEnable():
    Code (Text):
    getServer().getMessenger().registerIncomingPluginChannel(this, "ChannelName", new MessageListener(this));
    getServer().getMessenger().registerOutgoingPluginChannel(this, "ChannelName");
    Also have a class that implements PluginMessageListener to receive stuff:
    Code (Text):
    public class MessageListener implements PluginMessageListener {

        public void onPluginMessageReceived(String channel, Player player, byte[] data) {
            DataInputStream in = new DataInputStream(new ByteArrayInputStream(data));
        }

    }
     
    To send stuff from Bukkit use this:
    Code (Text):
    // this = plugin's main class
    Bukkit.getServer().sendPluginMessage(this, "ChannelName", ByteArrayOutputStream.toByteArray());
    In your Bungee plugin's onEnable():
    Code (Text):
    getProxy().registerChannel("ChannelName");
    Also have a class that implements Listener to receive stuff:
    Code (Text):
    package com.fuzzoland.CommandSyncBungee;

    import java.io.ByteArrayInputStream;
    import java.io.DataInputStream;
    import java.io.IOException;

    import net.md_5.bungee.api.event.PluginMessageEvent;
    import net.md_5.bungee.api.plugin.Listener;
    import net.md_5.bungee.event.EventHandler;

    public class EventListener implements Listener {

        @EventHandler
        public void onPluginMessage(PluginMessageEvent event) throws IOException {
            if(event.getTag().equals("ChannelName")) {
                DataInputStream in = new DataInputStream(new ByteArrayInputStream(event.getData()));
           
            }
        }
    }
     
    To send stuff from Bungee use this:
    Code (Text):
    ServerInfo.sendData("ChannelName", ByteArrayOutputStream.toByteArray());
    Try work out the rest from there. ;)
     
    #8 YoFuzzy3, Jan 21, 2014
    Last edited: Jan 21, 2014
    • Useful Useful x 4
    • Like Like x 1
  5. So in using a BUNGEECORD plugin... I can send a message to a bukkit plugin using
     
  6. How do i send stuff from a bungeecord plugin, to a bukkit plugin?
     
  7. No. You cannot send a Message using Bukkit.getServer().etc() in a bungee plugin.. they are 2 different things.

    As for how to do it, read the wiki, if there is nothing you can use, then you will need to find another way, which, there are plenty.
     
  8. So how do I?
     
  9. GOOGLE IT! If you can't figure this out, you really should NOT be making any plugins, find something better to do.
     
    • Agree Agree x 2
    • Disagree Disagree x 1
  10. YoFuzzy3

    Supporter

    I edited my post with how to send stuff from Bungee to Bukkit.
     
    • Winner Winner x 1
  11. Why thankyou! :D <3
     
  12. @Rmarmorstein I've done what I've been told is impossible... You should never discourage anyone from anything harmless, it really has an effect on people and their confidence. Considering that I use forums as a last resort I did google the questions I had, I found that page. NO WHERE ON IT DID IT HAVE HOW TO SEND FROM BUNGEE PLUGIN...

    lol, 15. What I thought.

    Can I just say, I think my signature fits in really well here!!
    VVVVVVVVVVVVVVVVVVV
     
    #16 _Cory_, Jan 23, 2014
    Last edited: Jan 23, 2014
  13. I don't want to get into this argument here, but you laughing at me about my age just reinforces my point, after all, you're the one with your profile picture a 'Selfie' with a 'Duck-Face' (If im not mistaken, I dont know these things all too well). I personally don't see how age effects anything, let me tell you, that I'm probably a lot more mature than you, 3 years is not a big difference at all, and I dont see why your making a huge deal out of it, like honestly move on, find something better to do with your time. I dont see why your just trying to start an argument from something that happened a few days ago and tagging me. I was letting it go, you made something.. good for you I guess, I really could care less if you did or did not.

    I told you to google it, after I linked you to a Wiki page that clearly explained it. Not sure how your ignorance puts me at fault in this situation.

    tl;dr: please stop tagging me and trying to start an argument.
     
  14. Judging someone on their image, try judging me on it now @Rmarmorstein ...
    And please do point out on the wiki, where it says how to send a plugin message from a BungeeCord.

    Its not about being mature, its about being respectful.
     
    #18 _Cory_, Jan 23, 2014
    Last edited: Jan 23, 2014
  15. Jeez, just leave me alone. Get a life and stop trolling.