Storing block states and loading from config

Discussion in 'Plugin Development' started by Pik0, Jun 10, 2014.

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

    Pik0

    I want a way to store lists of block states in a config, and a way to load them, so i could save a region and load it after reloading the server
     
  2. Offline

    mine-care

    How about adding them to hashmap and using objecoutputstream to save em, and objwctinputstream to load? Btw where you get tht signature?
     
  3. Offline

    Pik0

  4. Offline

    mine-care

    Ok ill do when I get to a pc :/ iOS...
     
  5. Offline

    Garris0n

    They're not serializable...

    You'll have to do it manually. Save the material/data I suppose, along with any tile entity data you can bother to implement (inventory items, sign lines).
     
  6. Offline

    mine-care

    Code:
    try {
                ObjectOutputStream output = new ObjectOutputStream(
                        new FileOutputStream(red));
                output.writeObject(HASHMAP);
                output.close();
            } catch (IOException e) {
                Main.plugin.getLogger().info("File could not be saved");
            }
     
     
    //and input:
     
            try {
                ObjectInputStream input = new ObjectInputStream(
                        new FileInputStream(HMAP));
                HASHMAP = ((HashMap) input.readObject());
                input.close();
            } catch (IOException | ClassNotFoundException e) {
                Main.plugin.getLogger().info(
                        "Error: Something went wrong reading the file");
            }
    
    i havent used this code since 1.6.X so i dont remember it so well... :p
     
Thread Status:
Not open for further replies.

Share This Page