Removing ' from config.

Discussion in 'Plugin Development' started by Connor2weirdness, Mar 13, 2014.

Thread Status:
Not open for further replies.
  1. When I use a command I have made to change a value in the config, it automatically adds in marks around the changed value. For example: value: value1 when changed it would be value: 'value1'. This is a problem because my plugin cannot read the value properly even though I used replaceAll to replace them all with nothing. Thanks.

    I am using this:
    Code:
        this.getConfig().set("cooldown", args[0].replaceAll("'", ""));
     
  2. Connor2weirdness
    If you're simply trying to set a string, then you don't need to do that. You simply need to do:

    Code:java
    1. getConfig().set("your.path", "put your message here");


    If you're trying to do anything else, like set an integer, then you don't need to worry about that. You just need to do:

    Code:java
    1. getConfig().set("your.path", yourValue);
     
  3. Thank you, but that is what I am using.
     
  4. Yeah, sorry about that.
     
  5. Connor2weirdness
    And... you should probably do that if you want people to help ;)
     
  6. Done c:
     
  7. Connor2weirdness
    You're not doing what I told you above... especially since it seems you're trying to get a numerical value.
     
  8. Uh, I have.
     
  9. Connor2weirdness
    What specifically are you trying to set? A number? A string?
     
  10. I'm trying to create an int which the player defines in an onCommand method. Hence the args[0].
     
  11. Offline

    firecombat4

    'your.path' also needs to already be a path in the config I believe, also perhaps your not saving the config?
     
  12. Offline

    Gater12

    firecombat4
    It would create a path for you. It doesn't need to exist.
     
  13. Connor2weirdness
    args[0] is a string. In order to get the integer value from that and set it properly in the config, you need to do:

    Code:java
    1. try{
    2. int value = Integer.parseInt(args[0]);
    3. //set value in config & save
     
  14. Offline

    firecombat4

    Ahh okay, thanks haha.
     
  15. I can't thank you enough.
     
Thread Status:
Not open for further replies.

Share This Page