Convert current data to UUIDs

Discussion in 'Plugin Development' started by MacDev, Feb 6, 2015.

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

    MacDev

    I have a plugin that stores playernames in the configuration file everytime they do /test

    I've managed to make it so future data is stored as the UUID of the command sender instead of the username, but i've been having one issue that's been bugging me all day:

    How can I convert the current usernames in that file to UUIDs?

    So, here's an example:

    Current file content:
    Code:
    claimed:
    - Creeper_King310
    - Notch
    (Yes, there's a list in the config named "claimed")

    What I want it to be converted to when the plugin is enabled:
    Code:
    claimed:
    - 50ecc314-4b15-4118-852d-1b7620ea11df
    - 069a79f4-44e9-4726-a5be-fca90e38aaf5
    So, how would I go about doing this?
     
  2. Offline

    timtower Administrator Administrator Moderator

    @MacDev for(string){
    uuid = bukkit.getofflineplayer(string);
    list.add(uuid);
    }
     
  3. Offline

    MacDev

    I tried doing this using UUIDFetcher:
    Code:
        public void convertToUUID() {
        for (String name : getConfig().getStringList("claimed")) {
            UUIDFetcher fetcher = new UUIDFetcher(Arrays.asList(name));
            getConfig().getStringList("claimed").add(fetcher);
            }
        }
    (I made it a void so I can just call convertToUUID(); onEnable).

    But, i'm getting this error and a red line under "add": The method add(String) in the type List<String> is not applicable for the arguments (UUIDFetcher)
     
  4. Offline

    timtower Administrator Administrator Moderator

    @MacDev Probably because you are trying to add an UUIDFetcher to a string list.
    Why does it take a list argument anyways?
     
  5. Offline

    teej107

    @MacDev You can use the OfflinePlayer getUniqueId method to get the true UUID (server must be in online mode but that's not a problem) of a Player if they have played before.

    • Get the List
    • Get the username
    • Remove the username
    • Add the UUID
     
Thread Status:
Not open for further replies.

Share This Page