Plugin Help What's the best way to go about this(custom configuration)?

Discussion in 'Plugin Help/Development/Requests' started by IEatClocks, May 19, 2016.

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

    IEatClocks

    I'm honestly not good with Bukkit configuration. I want to create code that when a player joins the server their name, ip, uuid, and custom rank(which is a string) is added to a custom configuration file. I will be able to take it from there.

    Example of what the configuration file should look like:

    Code:
    IEATCLOCKS:
    - 127.0.0.1
    - SAD2-DSA3-AD4R-ZZZX-SSS
    - PLAYER
    Notch:
    - 127.0.0.2
    - DWSZ-AWDG-XASR-ASXV-WWWW
    - GLOBAL_ADMIN
    Thank you.
     
    Last edited: May 19, 2016
  2. Offline

    I Al Istannen

    @IEatClocks
    You save a List<String> with their name as path. Just use Config#set(String path, List<String> list). Retrieve it with Config#getStringList(String path). Have a look here. Also quite intersting is the last section there (but I would read the whole page).
     
    timtower likes this.
  3. Offline

    timtower Administrator Administrator Moderator

    @IEatClocks I suggest using a map and not using a list.
    Bad pun: you must be very time consuming.
     
  4. Offline

    I Al Istannen

    @timtower
    In the plugin: sure.
    Afaik you can't serialize a map though, it will save the Map.Entry entries and just blow up if you load the config. So, for saving, a List is better, I think. (I will never grasp of where to place commas in english. Well)
    I wouldn't do it like this though. I would create an object to represent this and then implement ConfigurationSerializable. And then save a list of these object. Which is why I linked to this chapter in the wiki page (the "there" link) ;)

    Clocks is quite a nice song though. (Too uncreative to think of a comment about your pun, so I will just take his username... I am sorry, I swear!)
     
  5. Offline

    timtower Administrator Administrator Moderator

    @I Al Istannen It all depends on how you save the map, as the config is just a recursive map in the end.
     
    I Al Istannen likes this.
Thread Status:
Not open for further replies.

Share This Page