Save Arraylists of UUIDs in Config

Discussion in 'Plugin Development' started by Blablablub100, Jun 2, 2015.

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

    Blablablub100

    Hey,

    like I said in the title I want to save an Arraylist of UUIDs of Players in the Config File.
    Here how I try to save them:
    Code:
    String t = "";
    ArrayList<UUID> pt = new ArrayList<UUID>();
    public void save() {
            t.getConfig().set("one", t);
            t.getConfig().set("two", pt);
    }
    I keep getting this error:
    Error (open)

    [05:39:29 ERROR]: Cannot load plugins\Towns\config.yml
    org.bukkit.configuration.InvalidConfigurationException: could not determine a co
    nstructor for the tag tag:yaml.org,2002:java.util.UUID
    in 'string', line 3, column 3:
    - !!java.util.UUID {}

    I save the config at onDisable() and Load ist an OnEnable(), this error occurs when I am trying to reload the server.

    Does somebody have an idea how to fix this? I googled but I got even more confused.
     
  2. Offline

    xTigerRebornx

    @Blablablub100 Don't believe there is proper serialization for a UUID, Use a List<String> instead and add/remove the UUID in a String form
     
  3. Offline

    caderape

    @Blablablub100
    save UUID.toString and load UUID.fromString(String uuid);
     
  4. Offline

    DuskFireHD

  5. Offline

    Blablablub100

    Thank you, this worked for my UUIDs, but now I want to save Blocks in the configs. I can convert them to Strings but I can not make the String to a Block
    The ArrayList:
    Code:
    ArrayList<Block> protectedChests = new ArrayList<Block>();
    How I save the Arraylist:
    Code:
    t.getConfig().set("eight", protectedChests1.toString());
    How I get the ArrayList:
    Code:
    stringlist = (ArrayList<String>) t.getConfig().getStringList("six");
    Now my question is how to convert this stringlist into a blocklist.
     
  6. Offline

    Ricecutter0

    @Blablablub100

    Are you trying to save the acutal block it's self or just the type. In that case you could just save the Blocks's Name or Id type.
     
Thread Status:
Not open for further replies.

Share This Page