BungeeCord Plugin Messaging

Discussion in 'CommandHelper' started by combat_wombat, Jun 3, 2017.

  1. combat_wombat

    combat_wombat New Member

    Not sure if anyone can help with this query, but I've recently run into a bit of an issue.

    I've been using a version of the _writeUTF() procedure that's in one of the learning trail tutorials to perform various plugin messaging actions, which has been really useful for adding another server into the mix using bungee. However, since the 1.10 update extended the chat length well past 128 characters, I've had the problem that as it is writing 8 bits to the array, I can't send messages the full length of the chat window.

    Is there some way this can be extended using the available functions in commandhelper? It's a bit beyond my capability to figure this out. Right now it's very similar to the original:

    Code (Text):
    proc _writeUTF (@ba, @str) {
        @len = length(@str);
        if (@len > 128) {
            die();
        }
        ba_put_byte(@ba, 0);
        ba_put_byte(@ba, @len);
        ba_put_bytes(@ba, string_get_bytes(@str, 'UTF-8'));
    }
    I'd like to be able to send much longer messages, or those at least as long as the chat window length.
  2. PseudoKnight

    PseudoKnight Well-Known Member

    I don't work with bungeecord, but I may still be able to help. But I'm not sure what your problem is. What do you mean "it is writing 8 bits to the array".
  3. PseudoKnight

    PseudoKnight Well-Known Member

    Oh, it's probably the ba_put_byte(@ba, @len); line. Try ba_put_short(@ba, @len);
  4. combat_wombat

    combat_wombat New Member

    Oh, well, in the middle of typing a reply I went and read up the info on the writeUTF java method used on this page. Now, I essentially have no idea how this works, but I've been picking up bits and pieces along the way. I kind of gathered that what I needed to do was drop the writing of the "0" integer, then use short as you recommended. Lo and behold, it works!

    I've tried making it a short before, but not getting rid of the 0. This confirmed that I wasn't doing that wrong, so something else must be incorrect! Thank you :)
    Last edited: Jun 4, 2017