Problem with config.

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

  1. Offline


    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:
    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


    Well, I don't know a more efficient way but this would work:
    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;

Share This Page