How to make a proper string

Discussion in 'Plugin Development' started by mydeblob, Dec 6, 2013.

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

    mydeblob

    I was making a config with a customizable string today and ran into a problem. In game the ' show up. For example
    [​IMG]
    The ' signs
    It use to not do this but now it does. This is how I'm imputting my string
    config.yml
    Code:
    # This is the message sent to a player when he types /test
    message: ‘&bNotice the signs’
    This is how I'm sending the code
    Code:java
    1. p.sendMessage(this.getConfig().getString("message").replaceAll("&", "\u00A7"));

    When I have no signs at all it cuts the message in half. How do I fix this?
     
  2. Offline

    ZeusAllMighty11

    The ampersand (&) symbol does not require apostrophes around the string iirc
     
  3. Offline

    sgavster

    mydeblob Hmm, that's weird.. :eek:

    Try this:

    (might not fix it..)
    Code:java
    1. p.sendMessage(ChatColor.translateAlternateColorCodes('&', this.getConfig().getString("message")));
     
  4. Offline

    Gater12

    mydeblob
    My method to getting a string and translating the Color Codes:
    Code:java
    1. player.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("path.to.whatever")));
     
  5. Offline

    Puharesource

    You're simply using the wrong apostrophe symbol e.g. ` and ´ are used for something like è or é whole ' is used for something like "he's" or "she's" or in your case for code.

    Also, you rather than replacing & with "\u00A7" I'd recommend replacing it with § but that is just personal preference, I guess :), hope this helped.
     
  6. Offline

    mydeblob

    ZeusAllMighty11 sgavster Gater12
    The color codes are not causing it. I even removed color code capability completely and it still happened
    It does the same thing without the color codes
    [​IMG]
    Puharesource
    I tryed replacing the ' with a " but it did the exact same thing, but with the quotation mark.
     
Thread Status:
Not open for further replies.

Share This Page