Solved Help with configuration file

Discussion in 'Plugin Development' started by SrNicks_, May 31, 2015.

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


    How do I do to set strings in a config and then grabs them and separates them ?

    Player reason temp
    SrNick you are banned 100

    The player will be used to check if it is banned
    The reason will serve as a kick message
    And time will serve to make the count and unban

    It is possible to do this?
  2. Offline


  3. Offline


    This is going to be pretty crude and conceptual, I've had a long day and my ability to speak what I'm trying to say is diminished so I apologize in advance.

    Make a config file.
    Organize the messages like this in the file-

    player reason temp

    list = getconfig.getstringlist(config file name)
    for (string : list) //runs through number of columns you have in the config
    string[] x = string.split(" ") // this will add the items to an array list "player", "reason", "temp", splitting them up by the space in between them

    from there you can just retrieve them by using a for loop

    for (int k : string[].size)
    string p = string[k]
    string reason = string[k+1]
    string temp= string[k+2]

  4. Offline


    @SrNicks_ Personally, I would do [Name] [Time] [Reason], because it will be easier to get an array of strings at the end of it rather than the middle.

    I like to use a separator like a semi-colon or | then use String.split(";") or String.split("|"). It will only split the string up at those "separators", and make it a lot easier for me. You can also check out the configuration api reference page for a lot of config stuff.

    What you want done is very possible and not too difficult. Just test using the String.split() method in a separate project until you get what you want.
  5. Offline


Thread Status:
Not open for further replies.

Share This Page