Development Assistance BungeeCord Messaging Channel Help

Discussion in 'Plugin Help/Development/Requests' started by Agentleader1, Nov 28, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Agentleader1

    I'm very confused with the BungeeCord Messaging Channel. I'm trying to forward some data from one server to another. I heard players had to be on both the receiver and transmitter server for the Forward channel to work on BungeeCord channel. Is this true?

    I tried looking everywhere, but here are 2 links on the topic. They both give different methods on writing out a forward command:
    In general (shortened version), the code I have right now is:

    Code:java
    1. package YourMamma.YourDaddy.YoBro;
    2.  
    3. import YourMom.YourDad.YourParents;
    4.  
    5. public class Main extends JavaPlugin implements Listener, PluginMessageListener{
    6.  
    7. @Override
    8. public void onEnable(){
    9. this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
    10. this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", this);
    11. }
    12.  
    13. public void YourMomStuff(){
    14. //the code is supposed to be executed here, I just wanted to put the named method that!
    15. String data = "yourmom yourdad yourbrother yoursister yourdog";
    16. try {
    17. out.writeUTF("Foward");
    18. out.writeUTF("KitPVP");
    19. out.writeUTF("Hub");
    20. out.writeShort(data.length()); // The length of the rest of the data.
    21. out.writeUTF(data); // Write out the rest of the data.
    22. } catch (IOException e) {
    23. }
    24. player.sendPluginMessage(this, "BungeeCord", b.toByteArray());
    25. try {
    26. out.close();
    27. } catch (IOException e) {
    28. }
    29. }
    30. }


    And the receiver:

    Code:java
    1. @SuppressWarnings("unused")
    2. @Override
    3. public void onPluginMessageReceived(String channel, Player arg1, byte[] msg) {
    4. String message = msg.toString();
    5. //if(message.contains("giveboltz")){
    6. ByteArrayDataInput in = ByteStreams.newDataInput(msg);
    7. String subChannel = in.readUTF();
    8. short len = in.readShort();
    9. byte[] msgbytes = new byte[len];
    10. in.readFully(msgbytes);
    11. try {
    12. String somedata = msgin.readUTF();
    13. short somenumber = msgin.readShort();
    14. if(somedata.contains("giveboltz")){
    15. KitPVP.getInstance().getServer().broadcastMessage(channel + " " + arg1.getName() + " " + somedata);
    16. }
    17. } catch (IOException e) {
    18. }
    19. if(message.contains("giveboltz")){
    20. KitPVP.getInstance().getServer().broadcastMessage("YO MAMA!");
    21. }
    22. //}
    23. }


    I am currently unsure what to do! If you have a solution, please replace the full code, not state just part of it. I will not understand!

    Thank you for your participation in reading/helping me out!
     
  2. Offline

    Skionz

    Agentleader1 Considering you want us to rewrite your code for you I am going to take a wild guess and say you didn't write this. I suggest just using sockets as they seem easier to use.
     
  3. Online

    timtower Administrator Administrator Moderator

    Moved to Bukkit Alternatives.
     
  4. Offline

    Agentleader1

    I have the full code written already. I just want the "general jist" re-written.
     
  5. Offline

    Agentleader1

    Bump, so inactive
     
Thread Status:
Not open for further replies.

Share This Page