Solved UUID problem in ConfigurationSerializable?

Discussion in 'Plugin Development' started by Gonmarte, Apr 14, 2016.

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

    Gonmarte

    Hello,
    I solved that problem by converting the list of uuids into a list of strings, but not im getting another error.
    If i do /dog , it will create and save my dog in the config, then if i do /reload it will work without errors, and then if i do again /reload it will throw an error. This is bad because, if i try to add a dog to my list of dogs using /add-dog it wont be saved into the config unless i do this before the first /relaod, cuz then it will keep throwing me an error on console and i wont be able to store any more data (Problem is with serialize).

    Dog
    Code:
    package me.gonmarte;
    
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.UUID;
    
    import org.bukkit.configuration.serialization.ConfigurationSerializable;
    
    public class Dog implements ConfigurationSerializable{
      
        public int age;
        public String name;
        public ArrayList<UUID> dogs;
      
        public Dog(String name, int age){
            this.dogs = new ArrayList<>();
            this.name=name;
            this.age = age;
            dogs.add(UUID.randomUUID());
        }
      
        @SuppressWarnings("unchecked")
        public Dog(Map<String, Object> map){
            this.age = (int) map.get("age");
            this.name = (String) map.get("name");
            this.dogs = (ArrayList<UUID>) map.get("dogs");
        }
    
        @Override
        public Map<String, Object> serialize() {
            Map<String, Object> map = new HashMap<>();
            map.put("age", this.age);
            map.put("name", this.name);
            map.put("dogs", toStringList());
            return map;
        }
      
        public ArrayList<String> toStringList(){
            ArrayList<String> list = new ArrayList<>();
            for(UUID uuid : dogs){
                list.add(uuid.toString());
            }
            return list;
        }
    }
    
    Main
    Code:
    package me.gonmarte;
    
    import java.io.*;
    import java.util.UUID;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.InvalidConfigurationException;
    import org.bukkit.configuration.file.YamlConfiguration;
    import org.bukkit.configuration.serialization.ConfigurationSerialization;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Main extends JavaPlugin{
            
        public File ClansData = new File("plugins/" + File.separator + "Clans", "ClansData.yml");
        public YamlConfiguration cd;
        @Override
        public void onEnable() {
            ConfigurationSerialization.registerClass(Dog.class);
            cd = YamlConfiguration.loadConfiguration(ClansData);
            loadFiles();
        }
      
        @Override
        public void onDisable() {
            saveFiles();
        }
      
      
        @Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if(command.getName().equalsIgnoreCase("dog")){
                Dog myDog = new Dog("Billy" , 15);
                cd.set("dog", myDog);
                return true;
    }else if(command.getName().equalsIgnoreCase("add-dog")){
        Dog dog = (Dog) cd.get("dog");
        dog.dogs.add(UUID.randomUUID());
        return true;
          
        }else if(command.getName().equalsIgnoreCase("mydog")){
        Dog dog = (Dog) cd.get("dog");
        sender.sendMessage(dog.name + dog.age + dog.dogs);
    }
            return false;
    }
      
      public void saveFiles() {
      try {
        this.cd.save(this.ClansData);
      } catch (IOException e) {
        e.printStackTrace();
      
      }
    }
    
    public void loadFiles() {
      if (this.ClansData.exists())
        try {
          
          this.cd.load(this.ClansData);
        
        }catch(IOException e){
           e.printStackTrace();
        
        } catch (InvalidConfigurationException e) {
            e.printStackTrace();
        }else{
      
           try {
        
               this.cd.save(this.ClansData);
      
           } catch (IOException e) {
        
               e.printStackTrace();
        }
        }
    
    }
    }
    
    
    Error:
    Code:
    java.lang.ClassCastException : java.lang.String cannot be cast to java.util.UUID
        at me.gonmarte.Dog.toStringList(Dog.java:41)
        at me.gonmarte.Dog.serialize(Dog.java:35)
    @I Al Istannen
     
    Last edited: Apr 15, 2016
  2. Offline

    CeramicTitan

    A few things here;
    1. Where do you call this serialize and deserialize code?
    2. Are any errors being produced?
    3. How do you deserialize the data?
     
  3. Offline

    WolfMage1

    Thats what he wants to know xD
     
  4. Offline

    CeramicTitan

    OP made that super unclear lol
     
  5. Offline

    Gonmarte

    Exactly xD
    I solved it, but now im getting another problem :eek:
     
    Last edited: Apr 15, 2016
    I Al Istannen likes this.
  6. Offline

    I Al Istannen

    @Gonmarte
    Well, for saving I would create a new List<String> and save all the UUIDs in there and save the List<String>. For deserializing cast it to a List<String> again and do it backwards. So you create a List<UUID> and then add all the UUID.fromString() to it. You can use your "dogs" list instad of creating a new List<UUID> if you want.

    Code:
    Create List<String> stringList
    For UUID in uuidList
      add to stringList
    End for
    save stringList
    
    Code:
    List<String> stringList = savedList
    For String in stringList
      add UUID.fromString(String) to dogs list
    End for
    
     
    Gonmarte likes this.
  7. Offline

    Gonmarte

    Very smart you are xD I had the same idea and i did, but i get an error, take a look at the main post, i will be adding the console error.
    Thanks.
    EDIT: @I Al Istannen You have everything that you need in main post. Ty
     
  8. Offline

    I Al Istannen

    @Gonmarte
    Are you sure the code for the Dog class is right? It says the error is here:
    Code:
            for(UUID uuid : dogs){
                list.add(uuid.toString());
            }
    
    but you never cast there and any error should be pointed out by your IDE, as they won't just occur at runtime.
     
  9. Offline

    Gonmarte

    Yes, and also it points me.gonmarte.saveFiles(line 50)
    me.gonmarte.onDisable(line 26)

    Code:
    >reload
    16:00:06 [INFO] [Test] Disabling Test v1.0
    16:00:06 [INFO] 229 recipes
    16:00:06 [INFO] [Test] Loading Test v1.0
    16:00:06 [INFO] [Test] Enabling Test v1.0
    16:00:06 [INFO] Server permissions file permissions.yml is empty, ignoring it
    16:00:06 [INFO] CONSOLE: Reload complete.
    >reload
    16:00:08 [INFO] [Test] Disabling Test v1.0
    16:00:08 [SEVERE] Error occurred while disabling Test v1.0 (Is it up to date?)
    java.lang.ClassCastException: java.lang.String cannot be cast to java.util.UUID
            at me.gonmarte.Dog.toStringList(Dog.java:46)
            at me.gonmarte.Dog.serialize(Dog.java:35)
            at org.bukkit.configuration.file.YamlRepresenter$RepresentConfigurationS
    erializable.representData(YamlRepresenter.java:33)
            at org.yaml.snakeyaml.representer.BaseRepresenter.representData(BaseRepr
    esenter.java:96)
            at org.yaml.snakeyaml.representer.BaseRepresenter.representMapping(BaseR
    epresenter.java:164)
            at org.yaml.snakeyaml.representer.SafeRepresenter$RepresentMap.represent
    Data(SafeRepresenter.java:201)
            at org.yaml.snakeyaml.representer.BaseRepresenter.representData(BaseRepr
    esenter.java:96)
            at org.yaml.snakeyaml.representer.BaseRepresenter.represent(BaseRepresen
    ter.java:66)
            at org.yaml.snakeyaml.Yaml.dumpAll(Yaml.java:270)
            at org.yaml.snakeyaml.Yaml.dumpAll(Yaml.java:261)
            at org.yaml.snakeyaml.Yaml.dumpAll(Yaml.java:233)
            at org.yaml.snakeyaml.Yaml.dump(Yaml.java:209)
            at org.bukkit.configuration.file.YamlConfiguration.saveToString(YamlConf
    iguration.java:38)
            at org.bukkit.configuration.file.FileConfiguration.save(FileConfiguratio
    n.java:54)
            at me.gonmarte.Main.saveFiles(Main.java:50)
            at me.gonmarte.Main.onDisable(Main.java:26)
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:219)
            at org.bukkit.plugin.java.JavaPluginLoader.disablePlugin(JavaPluginLoade
    r.java:481)
            at org.bukkit.plugin.SimplePluginManager.disablePlugin(SimplePluginManag
    er.java:400)
            at org.bukkit.plugin.SimplePluginManager.disablePlugins(SimplePluginMana
    ger.java:393)
            at org.bukkit.plugin.SimplePluginManager.clearPlugins(SimplePluginManage
    r.java:434)
            at org.bukkit.craftbukkit.v1_5_R3.CraftServer.reload(CraftServer.java:57
    5)
            at org.bukkit.Bukkit.reload(Bukkit.java:185)
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:
    23)
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:18
    9)
            at org.bukkit.craftbukkit.v1_5_R3.CraftServer.dispatchCommand(CraftServe
    r.java:523)
            at org.bukkit.craftbukkit.v1_5_R3.CraftServer.dispatchServerCommand(Craf
    tServer.java:512)
            at net.minecraft.server.v1_5_R3.DedicatedServer.an(DedicatedServer.java:
    262)
            at net.minecraft.server.v1_5_R3.DedicatedServer.r(DedicatedServer.java:2
    27)
            at net.minecraft.server.v1_5_R3.MinecraftServer.q(MinecraftServer.java:4
    77)
            at net.minecraft.server.v1_5_R3.MinecraftServer.run(MinecraftServer.java
    :410)
            at net.minecraft.server.v1_5_R3.ThreadServerApplication.run(SourceFile:5
    73)
    16:00:08 [INFO] 229 recipes
    
    @I Al Istannen
     
  10. Offline

    I Al Istannen

    @Gonmarte
    I copy-pasted your Dog class and it worked. Which is slightly strange. Have you tried stopping the server, deleting the whole config file and then restarting?
     
  11. Offline

    Gonmarte

    Ik it works, but if you do /reload two times, at the second time and it will throw that error.
    Code:
    >reload
    16:00:06 [INFO] [Test] Disabling Test v1.0
    16:00:06 [INFO] 229 recipes
    16:00:06 [INFO] [Test] Loading Test v1.0
    16:00:06 [INFO] [Test] Enabling Test v1.0
    16:00:06 [INFO] Server permissions file permissions.yml is empty, ignoring it
    16:00:06 [INFO] CONSOLE: Reload complete.
    >reload
    16:00:08 [INFO] [Test] Disabling Test v1.0
    16:00:08 [SEVERE] Error occurred while disabling Test v1.0 (Is it up to date?)
    java.lang.ClassCastException: java.lang.String cannot be cast to java.util.UUID
            at me.gonmarte.Dog.toStringList(Dog.java:46)
            at me.gonmarte.Dog.serialize(Dog.java:35)
            at org.bukkit.configuration.file.YamlRepresenter$RepresentConfigurationS
    erializable.representData(YamlRepresenter.java:33)
            at org.yaml.snakeyaml.representer.BaseRepresenter.representData(BaseRepr
    esenter.java:96)
            at org.yaml.snakeyaml.representer.BaseRepresenter.representMapping(BaseR
    epresenter.java:164)
            at org.yaml.snakeyaml.representer.SafeRepresenter$RepresentMap.represent
    Data(SafeRepresenter.java:201)
            at org.yaml.snakeyaml.representer.BaseRepresenter.representData(BaseRepr
    esenter.java:96)
            at org.yaml.snakeyaml.representer.BaseRepresenter.represent(BaseRepresen
    ter.java:66)
            at org.yaml.snakeyaml.Yaml.dumpAll(Yaml.java:270)
            at org.yaml.snakeyaml.Yaml.dumpAll(Yaml.java:261)
            at org.yaml.snakeyaml.Yaml.dumpAll(Yaml.java:233)
            at org.yaml.snakeyaml.Yaml.dump(Yaml.java:209)
            at org.bukkit.configuration.file.YamlConfiguration.saveToString(YamlConf
    iguration.java:38)
            at org.bukkit.configuration.file.FileConfiguration.save(FileConfiguratio
    n.java:54)
            at me.gonmarte.Main.saveFiles(Main.java:50)
            at me.gonmarte.Main.onDisable(Main.java:26)
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:219)
            at org.bukkit.plugin.java.JavaPluginLoader.disablePlugin(JavaPluginLoade
    r.java:481)
            at org.bukkit.plugin.SimplePluginManager.disablePlugin(SimplePluginManag
    er.java:400)
            at org.bukkit.plugin.SimplePluginManager.disablePlugins(SimplePluginMana
    ger.java:393)
            at org.bukkit.plugin.SimplePluginManager.clearPlugins(SimplePluginManage
    r.java:434)
            at org.bukkit.craftbukkit.v1_5_R3.CraftServer.reload(CraftServer.java:57
    5)
            at org.bukkit.Bukkit.reload(Bukkit.java:185)
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:
    23)
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:18
    9)
            at org.bukkit.craftbukkit.v1_5_R3.CraftServer.dispatchCommand(CraftServe
    r.java:523)
            at org.bukkit.craftbukkit.v1_5_R3.CraftServer.dispatchServerCommand(Craf
    tServer.java:512)
            at net.minecraft.server.v1_5_R3.DedicatedServer.an(DedicatedServer.java:
    262)
            at net.minecraft.server.v1_5_R3.DedicatedServer.r(DedicatedServer.java:2
    27)
            at net.minecraft.server.v1_5_R3.MinecraftServer.q(MinecraftServer.java:4
    77)
            at net.minecraft.server.v1_5_R3.MinecraftServer.run(MinecraftServer.java
    :410)
            at net.minecraft.server.v1_5_R3.ThreadServerApplication.run(SourceFile:5
    73)
    16:00:08 [INFO] 229 recipes
     
  12. Offline

    I Al Istannen

    @Gonmarte
    Not for me. But I would have done the deserialization different, as you can see here. Very Surprised the cast works there:
    EDIT: The error is on serializing. This is extremly odd. Are you sure you have the right class file on the server?
     
  13. Offline

    Gonmarte

    What you mean?
    Did you copy and paste both of my classes? Did you do /dog and then /reload two times? Im sure second time you get an error.
     
  14. Offline

    I Al Istannen

    @Gonmarte
    No, I just copied the Dog class. Nothing seems to be wrong with it.

    Again, I really can't see where this error should happen. Are you absolutly sure you exported it again and overwrote the old file?
     
  15. Offline

    Gonmarte

    Yess. Copy both classes and test it and you will see
     
  16. Offline

    I Al Istannen

    @Gonmarte
    Ok, I see it. I will look into it.

    EDIT:
    Easy fix. If you would have listened to what I said and implemented it the way my pseudo code showed, all would be good. Not trying to be mean though ;)
    The error is here:
    "dogs = (ArrayList<UUID>) map.get("dogs");"
    Well that iussed a UncheckedWarning that was totally right in this case. You saved it as a LIST<STRING> and casted it to a LIST<UUID>. Guess, what went wrong. Exactly, the dogs list was a List<String>, despite being declared as <UUID>. The fix is following the pseudocode I wrote.


    Code:
    dogs = new List
    List<String> stringList = map.get("dogs");
    For String in stringList
      dogs.add( UUID.from String)
    End For
     
    Last edited: Apr 15, 2016
    Gonmarte likes this.
  17. Offline

    Gonmarte

    Another error.
    Code:
       
    17:01:56 [SEVERE] Could not call constructor 'public me.gonmarte.Dog(java.util.M
    ap)' of class me.gonmarte.Dog for deserialization
    java.lang.NullPointerException
            at me.gonmarte.Dog.<init>(Dog.java:29)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
    rce)
            at java.lang.reflect.Constructor.newInstance(Unknown Source)
            at org.bukkit.configuration.serialization.ConfigurationSerialization.des
    erializeViaCtor(ConfigurationSerialization.java:92)
            at org.bukkit.configuration.serialization.ConfigurationSerialization.des
    erialize(ConfigurationSerialization.java:129)
            at org.bukkit.configuration.serialization.ConfigurationSerialization.des
    erializeObject(ConfigurationSerialization.java:187)
            at org.bukkit.configuration.file.YamlConstructor$ConstructCustomObject.c
    onstruct(YamlConstructor.java:35)
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseCo
    nstructor.java:183)
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping2ndSte
    p(BaseConstructor.java:326)
            at org.yaml.snakeyaml.constructor.SafeConstructor.constructMapping2ndSte
    p(SafeConstructor.java:143)
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping(BaseC
    onstructor.java:307)
            at org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlMap.const
    ruct(SafeConstructor.java:459)
            at org.bukkit.configuration.file.YamlConstructor$ConstructCustomObject.c
    onstruct(YamlConstructor.java:26)
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseCo
    nstructor.java:183)
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(Base
    Constructor.java:142)
            at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseCons
    tructor.java:128)
            at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:480)
            at org.yaml.snakeyaml.Yaml.load(Yaml.java:399)
            at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlCo
    nfiguration.java:53)
            at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguratio
    n.java:138)
            at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguratio
    n.java:105)
            at org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(Yam
    lConfiguration.java:175)
            at me.gonmarte.Main.onEnable(Main.java:20)
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader
    .java:457)
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManage
    r.java:381)
            at org.bukkit.craftbukkit.v1_5_R3.CraftServer.loadPlugin(CraftServer.jav
    a:282)
            at org.bukkit.craftbukkit.v1_5_R3.CraftServer.enablePlugins(CraftServer.
    java:264)
            at org.bukkit.craftbukkit.v1_5_R3.CraftServer.reload(CraftServer.java:60
    5)
            at org.bukkit.Bukkit.reload(Bukkit.java:185)
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:
    23)
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:18
    9)
            at org.bukkit.craftbukkit.v1_5_R3.CraftServer.dispatchCommand(CraftServe
    r.java:523)
            at net.minecraft.server.v1_5_R3.PlayerConnection.handleCommand(PlayerCon
    nection.java:965)
            at net.minecraft.server.v1_5_R3.PlayerConnection.chat(PlayerConnection.j
    ava:883)
            at net.minecraft.server.v1_5_R3.PlayerConnection.a(PlayerConnection.java
    :840)
            at net.minecraft.server.v1_5_R3.Packet3Chat.handle(Packet3Chat.java:44)
            at net.minecraft.server.v1_5_R3.NetworkManager.b(NetworkManager.java:292
    )
            at net.minecraft.server.v1_5_R3.PlayerConnection.d(PlayerConnection.java
    :109)
            at net.minecraft.server.v1_5_R3.ServerConnection.b(SourceFile:35)
            at net.minecraft.server.v1_5_R3.DedicatedServerConnection.b(SourceFile:3
    0)
            at net.minecraft.server.v1_5_R3.MinecraftServer.r(MinecraftServer.java:5
    81)
            at net.minecraft.server.v1_5_R3.DedicatedServer.r(DedicatedServer.java:2
    26)
            at net.minecraft.server.v1_5_R3.MinecraftServer.q(MinecraftServer.java:4
    77)
            at net.minecraft.server.v1_5_R3.MinecraftServer.run(MinecraftServer.java
    :410)
            at net.minecraft.server.v1_5_R3.ThreadServerApplication.run(SourceFile:5
    73)
    17:01:57 [SEVERE] Could not call constructor 'public me.gonmarte.Dog(java.util.M
    ap)' of class me.gonmarte.Dog for deserialization
    java.lang.NullPointerException
            at me.gonmarte.Dog.<init>(Dog.java:29)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
    rce)
            at java.lang.reflect.Constructor.newInstance(Unknown Source)
            at org.bukkit.configuration.serialization.ConfigurationSerialization.des
    erializeViaCtor(ConfigurationSerialization.java:92)
            at org.bukkit.configuration.serialization.ConfigurationSerialization.des
    erialize(ConfigurationSerialization.java:129)
            at org.bukkit.configuration.serialization.ConfigurationSerialization.des
    erializeObject(ConfigurationSerialization.java:187)
            at org.bukkit.configuration.file.YamlConstructor$ConstructCustomObject.c
    onstruct(YamlConstructor.java:35)
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseCo
    nstructor.java:183)
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping2ndSte
    p(BaseConstructor.java:326)
            at org.yaml.snakeyaml.constructor.SafeConstructor.constructMapping2ndSte
    p(SafeConstructor.java:143)
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping(BaseC
    onstructor.java:307)
            at org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlMap.const
    ruct(SafeConstructor.java:459)
            at org.bukkit.configuration.file.YamlConstructor$ConstructCustomObject.c
    onstruct(YamlConstructor.java:26)
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseCo
    nstructor.java:183)
            at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(Base
    Constructor.java:142)
            at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseCons
    tructor.java:128)
            at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:480)
            at org.yaml.snakeyaml.Yaml.load(Yaml.java:399)
            at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlCo
    nfiguration.java:53)
            at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguratio
    n.java:138)
            at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguratio
    n.java:105)
            at me.gonmarte.Main.loadFiles(Main.java:61)
            at me.gonmarte.Main.onEnable(Main.java:21)
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader
    .java:457)
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManage
    r.java:381)
            at org.bukkit.craftbukkit.v1_5_R3.CraftServer.loadPlugin(CraftServer.jav
    a:282)
            at org.bukkit.craftbukkit.v1_5_R3.CraftServer.enablePlugins(CraftServer.
    java:264)
            at org.bukkit.craftbukkit.v1_5_R3.CraftServer.reload(CraftServer.java:60
    5)
            at org.bukkit.Bukkit.reload(Bukkit.java:185)
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:
    23)
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:18
    9)
            at org.bukkit.craftbukkit.v1_5_R3.CraftServer.dispatchCommand(CraftServe
    r.java:523)
            at net.minecraft.server.v1_5_R3.PlayerConnection.handleCommand(PlayerCon
    nection.java:965)
            at net.minecraft.server.v1_5_R3.PlayerConnection.chat(PlayerConnection.j
    ava:883)
            at net.minecraft.server.v1_5_R3.PlayerConnection.a(PlayerConnection.java
    :840)
            at net.minecraft.server.v1_5_R3.Packet3Chat.handle(Packet3Chat.java:44)
            at net.minecraft.server.v1_5_R3.NetworkManager.b(NetworkManager.java:292
    )
            at net.minecraft.server.v1_5_R3.PlayerConnection.d(PlayerConnection.java
    :109)
            at net.minecraft.server.v1_5_R3.ServerConnection.b(SourceFile:35)
            at net.minecraft.server.v1_5_R3.DedicatedServerConnection.b(SourceFile:3
    0)
            at net.minecraft.server.v1_5_R3.MinecraftServer.r(MinecraftServer.java:5
    81)
            at net.minecraft.server.v1_5_R3.DedicatedServer.r(DedicatedServer.java:2
    26)
            at net.minecraft.server.v1_5_R3.MinecraftServer.q(MinecraftServer.java:4
    77)
            at net.minecraft.server.v1_5_R3.MinecraftServer.run(MinecraftServer.java
    :410)
            at net.minecraft.server.v1_5_R3.ThreadServerApplication.run(SourceFile:5
    73)
    17:01:57 [INFO] Server permissions file permissions.yml is empty, ignoring it
    17:01:57 [INFO] gonmarte0334: Reload complete.
      
    I think solve this :p
    Code:
        public Dog(Map<String, Object> map){
            this.age = (int) map.get("age");
            this.name = (String) map.get("name");
           //ADD THIS
            dogs = new ArrayList<>();
            ArrayList<String> stringList = (ArrayList<String>) map.get("dogs");
            for(String str : stringList){
                dogs.add(UUID.fromString(str));
            }
        }
    
    It is all fine now? :)
    Thank you for all you help!!
    I will test this on my real project and share results with you.
     
    I Al Istannen likes this.
  18. Offline

    I Al Istannen

    @Gonmarte
    Did you create the list "dogs" before?
     
    Gonmarte likes this.
  19. Offline

    Gonmarte

    I just realized that now :p
    I didnt quite undestand why i need to create a new list.... its working, but if you could explain i would apreciate.
     
  20. Offline

    I Al Istannen

    @Gonmarte
    Depends on which one you mean. The "dogs" one? That is quite easy. Normally you created it in your first constructor, but that was never called. This means that the list "dogs" was just declared at the of of the class, but there was never a value assigned to it.

    The other list is just there to be able to loop through it and keep the code a bit more clear.
     
    Gonmarte likes this.
  21. Offline

    Gonmarte

    It was the dogs one. But nvm i understood :p This method deserialize is a constructor that does the same as my other constructor. The difference is that, the other one, i can write the data for the dog, in this one, it will load the data to "create" the dog again with the data.
    Thank you!!
    I will mark this as solved and i will tag you if i find anything weird.
    Thanks :D
     
    I Al Istannen likes this.
Thread Status:
Not open for further replies.

Share This Page