Custom Class Serialization random output

Discussion in 'Plugin Development' started by dark navi, Jul 18, 2012.

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

    dark navi

    Hey guys, here is the method I am implementing into my class:
    Code:
    @Override
        public Map<String, Object> serialize() {
            Map<String, Object> info = new HashMap<String, Object>();
           
            // Global Boolean
            info.put("enabled", Thirst.oceanDrinkingEnabled);
            info.put("thirstRegened", this.getThirstRegened());
            info.put("healthDamage", this.getHealthDamage());
            info.put("hungerDamage", this.getHungerDamage());
           
            return info;
        }
    And here is where I am saving it:
    Code:
    this.config.set("oceanDrinking", Thirst.oceanDrinkingSettings);
    So this is working pretty well, except I an getting a weird line in my config.YML:
    Code:
    oceanDrinking:
      ==: net.hungercraft.thirst.OceanDrinkingSettings
      enabled: 'true'
      hungerDamage: 0
      healthDamage: 5
      thirstRegened: 2
    As you can see, there is '==: net.hungercraft.thirst.OceanDrinkingSettings'. Any ideas why this is being printed out?
     
  2. Offline

    Sagacious_Zed Bukkit Docs

    dark navi
    that is how you denote the following section belongs to a java class in yaml.
     
  3. Offline

    dark navi

    Is there a way to actually use this to create an object and/or is there a way to hide this line? I am reading the values in by hand, so I don't need the line denoting which class it is.
     
  4. Offline

    Sagacious_Zed Bukkit Docs

    Bukkit has already constructed them, if you did everything the interface specifies.

    Code:
    OceanDrinkingSettings o = (OceanDrinkingSettings) plugin.getConfig().get("oceanDrinking");
    where plugin is an instance of your plugin.

    You can't hide it, but you can change what it actually writes, by using an alias.
     
Thread Status:
Not open for further replies.

Share This Page