Solved Iron Sword of Slightly More Awesomeness

Discussion in 'Plugin Development' started by Sheepii, Aug 12, 2014.

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

    Sheepii

    This is the bukkit java docs for setDisplayName to an item. However, it doesn't say anything about a limit of characters I can place before it throws something like a ArrayOutOfBoundsException. Does anyone know on the top of their heads the maximum amount of characters I can put in the string. Also, could you tell me if this is too long:

    im.setDisplayName("Iron Sword of Slightly More Awesomeness");

    Thanks!
     
  2. Offline

    _LB

    For Java strings, it will be around 65k (that's sixty-five thousand) depending on the implementation.

    The only limit I know off the top of my head is that inventory titles can't be more than 32 characters, though I have no idea why that restriction is in place or why it has to annoyingly throw an exception for it.
     
    Sheepii likes this.
  3. Offline

    Gerov

    _LB That's a nice little fact, I didn't know that :eek:.
     
    Sheepii likes this.
  4. Offline

    Sheepii

    _LB I just tried with a anvil on a creative server. It seems you can only put 30 characters on an item. Bummer.

    Edit 1: Visually that is..

    Edit 2: I wonder what type of exception it would throw if you had more than 65k characters in a string. o:
     
  5. Offline

    qlimax5000

    Sheepii
    brb
     
  6. Offline

    Sheepii

  7. Offline

    qlimax5000


    Code:
    [10:33:08 INFO]: qlimax5000 lost connection: Internal Exception: net.minecraft.util.io.netty.handler.codec.EncoderException: java.io.UTFDataFormatException: encoded string too long: 66000 bytes
    [10:33:08 WARN]: Failed to save player data for qlimax5000
    [10:33:08 INFO]: qlimax5000 left the game.
    EDIT: Just tried with 65k and that worked, but switching to the sword lags a lot. So you CAN have more than 30 chars in the name
     
    Sheepii likes this.
  8. Offline

    _LB

    Minecraft in general has a lot of ~65k character limits (e.g. in commandblock commands) so keep that in mind.
     
    Sheepii likes this.
Thread Status:
Not open for further replies.

Share This Page