Problem with config.

Discussion in 'Plugin Development' started by YTSkaGamerPL, Nov 15, 2019.

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

    YTSkaGamerPL

    Hi,
    Im creating user info module to my plugin, and I have prolem with getting their UUID by name (or discordid, both strings). I need function that will do that I explained in gist below:
    https://gist.github.com/YTSkaGamerPL/51cb59a627fbade4fe1bac2964d33793
    Can someone help?

    EDIT - I want code to be clear, no Lambda expressions or harder functions if possible - it will be easyer for me to understand it
     
  2. Offline

    Strahan

    Well, I don't know a more efficient way but this would work:
    Code:
    String getUserUUID(String value, String index) {
      if (!index.equalsIgnoreCase("nick") && !index.equalsIgnoreCase("discordid")) return null;
    
      ConfigurationSection keys = (plugin_instance).getConfig().getConfigurationSection("users");
      if (keys == null) return null;
    
      for (String uuid : keys.getKeys(false)) {
        String data = (plugin_instance).getConfig().getString("users." + uuid + "." + index);
        if (!data.equalsIgnoreCase(value)) continue;
        return uuid;
      }
      return null;
    }
     
Thread Status:
Not open for further replies.

Share This Page