title: My final config object does not contain any values
body: <p>So, I have started writing my plugin for my server. I made a method, that should get values from config and store them inside my storing object.
  But as the method <code>serialize()</code> tells, the object is except serialVersionUID empty.
  The output from the <code>serialize()</code> method is at the end.</p>
  <p>Here is the main Plugin class (BetterJavaPlugin &lt;- JavaPlugin)</p>
  <pre class="lang-java prettyprint-override"><code>package me.rorak.blazenoidplugin;
  
  import me.rorak.blazenoidplugin.files.ConfigYml;
  import me.rorak.blazenoidplugin.files.MessagesYml;
  import me.rorak.utils.BetterJavaPlugin;
  import me.rorak.utils.YamlFile;
  import org.bukkit.Bukkit;
  
  import static me.rorak.utils.Serializer.serialize;
  
  public class Plugin extends BetterJavaPlugin {
      public final Commands commands;
      public final Events events;
      public final TabCompleter tabCompleter;
  
      public final YamlFile messagesf;
  
      public ConfigYml config;
      public MessagesYml messages;
  
      public Plugin() {
          super();
          commands = new Commands(this);
          events = new Events(this);
          tabCompleter = new TabCompleter(this);
  
          messagesf = new YamlFile(this, &quot;messages.yml&quot;); // YamlFile is OK, not problem here
  
          config = new ConfigYml();
          messages = new MessagesYml();
      }
      @Override
      public void onEnable() {
          registerCommands(commands);
          registerTabComplete(tabCompleter);
          Bukkit.getPluginManager().registerEvents(events, this);
  
          // file setup
          saveDefaultConfig();
          messagesf.saveDefault(); // this does the same as saveDefaultConfig, but with
                                   // messages.yml file
  
          // load files
          config.load(getConfig()); // THIS LOADS THE CONFIG, i think there is the problem
          messages.load(messagesf.get()); // this also doesn't work, but it's the same problem
  
          debug(&quot;config.yml: &quot;);
          debug(&quot;\n&quot; + serialize(config)); // here the deserilization - output at the end
          debug(&quot;messages.yml: &quot;);
          debug(&quot;\n&quot; + serialize(messages));
  
          getLogger().info(&quot;Loaded!&quot;);
      }
      @Override
      public void onDisable() {
          getLogger().info(&quot;Unloaded!&quot;);
      }
  
      public void debug(String message) {
          Bukkit.getLogger().info(&quot;[Debug] &quot; + message);
      }
  }
  </code></pre>
  <p>Here is my ConfigYml class</p>
  <pre class="lang-java prettyprint-override"><code>package me.rorak.blazenoidplugin.files;
  
  import me.rorak.blazenoidplugin.files.serializables.*;
  import org.bukkit.configuration.ConfigurationSection;
  import org.bukkit.configuration.file.FileConfiguration;
  
  import java.io.Serial;
  import java.io.Serializable;
  import java.util.HashMap;
  import java.util.Map;
  
  public class ConfigYml implements Loadable, Serializable { // loadable contains load()
      @Serial
      private static final long serialVersionUID = 10L;
  
      public Map&lt;String, Permissions&gt; permissions = new HashMap&lt;&gt;();
      public Map&lt;String, Ranks&gt; ranks = new HashMap&lt;&gt;();
      public Map&lt;String, Chats&gt; chats = new HashMap&lt;&gt;();
      public Map&lt;String, Worlds&gt; worlds = new HashMap&lt;&gt;();
      public Famous famous = new Famous();
  
      @Override
      public void load(FileConfiguration config) {
          final ConfigurationSection __permissions = config.getConfigurationSection(&quot;permissions&quot;);
          final ConfigurationSection __ranks = config.getConfigurationSection(&quot;ranks&quot;);
          final ConfigurationSection __chats = config.getConfigurationSection(&quot;chats&quot;);
          final ConfigurationSection __worlds = config.getConfigurationSection(&quot;ranks&quot;);
  
          famous = config.getObject(&quot;famous&quot;, Famous.class, new Famous());
  
          // PERMISSIONS
          if (__permissions != null) {
              __permissions.getKeys(false).forEach((u) -&gt; {
                  Permissions _permissions = __permissions.getObject(u, Permissions.class, new Permissions());
                  permissions.put(u, _permissions);
              });
          }
          // RANKS
          if (__ranks != null) {
              __ranks.getKeys(false).forEach((u) -&gt; {
                  Ranks _ranks = __ranks.getObject(u, Ranks.class, new Ranks());
                  ranks.put(u, _ranks);
              });
          }
          // CHATS
          if (__chats != null) {
              __chats.getKeys(false).forEach((u) -&gt; {
                  Chats _chats = __chats.getObject(u, Chats.class, new Chats());
                  chats.put(u, _chats);
              });
          }
          // WORLDS
          if (__worlds != null) {
              __worlds.getKeys(false).forEach((u) -&gt; {
                  Worlds _worlds = __worlds.getObject(u, Worlds.class, new Worlds());
                  worlds.put(u, _worlds);
              });
          }
      }
  }
  </code></pre>
  <p>The MessagesYml is almost the same.</p>
  <p>And here is my Serializer code. There might be a problem too</p>
  <pre class="lang-java prettyprint-override"><code>package me.rorak.utils;
  
  import java.lang.reflect.Field;
  import java.util.List;
  import java.util.Map;
  
  public class Serializer {
      public static String serializeMap(Map&lt;?, ?&gt; toSer, String prefix) throws IllegalAccessException {
          StringBuilder str = new StringBuilder();
          str.append(prefix).append(&quot;{\n&quot;);
          for (Map.Entry&lt;?, ?&gt; entry : toSer.entrySet()) {
              str.append(prefix).append(&quot;[\n&quot;);
              str.append(serialize(entry.getKey(), prefix + &quot;[] &quot;));
              str.append(prefix).append(&quot;===AND===\n&quot;);
              str.append(serialize(entry.getValue(), prefix + &quot;[] &quot;));
              str.append(prefix).append(&quot;]\n&quot;);
          }
          str.append(prefix).append(&quot;}\n&quot;);
          return str.toString();
      }
      public static String serializeList(List&lt;?&gt; toSer, String prefix) throws IllegalAccessException {
          StringBuilder str = new StringBuilder();
          str.append(prefix).append(&quot;{\n&quot;);
          for (Object o : toSer) {
              str.append(prefix).append(&quot;[\n&quot;);
              str.append(serialize(o, prefix + &quot;[] &quot;));
              str.append(prefix).append(&quot;]\n&quot;);
          }
          str.append(prefix).append(&quot;}\n&quot;);
          return str.toString();
      }
      public static String serialize(Object toSer, String prefix) throws IllegalAccessException {
          StringBuilder str = new StringBuilder();
          for (Field f : toSer.getClass().getDeclaredFields()) {
              boolean acc = f.trySetAccessible();
              if (!acc) {
                  str.append(prefix).append(f.getName());
                  str.append(&quot;: not accessible&quot;);
                  break;
              }
              str.append(prefix).append(f.getName());
              str.append(&quot;: &quot;);
              if (f.getType().isPrimitive()) {
                  str.append(f.get(toSer).toString());
              }
              else if (f.getType().isInstance(String.class)) {
                  str.append((String)f.get(toSer));
              }
              else if (f.getType().isInstance(Map.class)) {
                  str.append(&quot;\n&quot;);
                  str.append(serializeMap((Map&lt;?, ?&gt;)f.get(toSer), prefix + &quot;:: &quot;));
              }
              else if (f.getType().isInstance(List.class)) {
                  str.append(&quot;\n&quot;);
                  str.append(serializeList((List&lt;?&gt;)f.get(toSer), prefix + &quot;:: &quot;));
              }
              else if (f.getType().isArray()) {
                  str.append(serializeList(List.of((Object[])f.get(toSer)), prefix + &quot;:: &quot;));
              }
              else {
                  str.append(&quot;\n&quot;);
                  str.append(serialize(f.get(toSer), prefix + &quot;:: &quot;));
              }
              str.append(&quot;\n&quot;);
          }
          return str.toString();
      }
      public static String serialize(Object toSer) {
          try {
              return serialize(toSer, &quot;&quot;);
          }
          catch (Exception e) {
              e.printStackTrace();
              return &quot;null&quot;;
          }
      }
  }
  </code></pre>
  <p>And here is my output from the <code>serialize()</code> method:</p>
  <pre><code>[INFO] [Debug] config.yml:
  
  [INFO] [Debug]
  
  serialVersionUID: 10
  
  permissions:
  
  :: serialVersionUID: not accessible
  
  ranks:
  
  :: serialVersionUID: not accessible
  
  chats:
  
  :: serialVersionUID: not accessible
  
  worlds:
  
  :: serialVersionUID: not accessible
  
  famous:
  
  :: serialVersionUID: 2
  
  :: names:
  
  :: :: serialVersionUID: not accessible
  
  :: password:
  
  :: :: value: not accessible
  
  [INFO] [Debug] messages.yml:
  
  [INFO] [Debug]
  
  serialVersionUID: 11
  
  commands:
  
  :: serialVersionUID: not accessible
  
  serverinfo:
  
  :: serialVersionUID: not accessible
  
  rules:
  
  :: serialVersionUID: not accessible
  
  noSuchPlayer:
  
  :: value: not accessible
  
  noPermissions:
  
  :: value: not accessible
  
  [INFO] [BlazenoidPlugin] Loaded!
  </code></pre>
  <p>(BlazenoidPlugin is my plugin prefix, defined in plugin.yml)</p>
  <p>I know, there is a lot of code, but I would appreciate an answer.
  If you need any of the other classes, comment down.</p>
  <p>Thanks!</p>