How to save cuboid to schematic? And other questions!

Discussion in 'Plugin Development' started by TGF, Oct 18, 2012.

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

    TGF

    Hello there!

    I'm looking for idea how to automatically save cuboid to schematics files.
    But later I need to restore(automatically) this schematics files to the world.
    It must be restored to the exacly location how was before!

    Quick definitions:
    automatically means after amount of time(for example 7 days) and after executing command
    schematics files its a file type which save every block data in selected area(WorldEdit and WG)
     
  2. Offline

    LukeSFT

    get all the blocks in this cuboid and save them in a threedimensional array
     
  3. Offline

    TGF

    But how?

    Ok then it is my idea for now:
    x,y,z are first coordinates of cuboid and xx,yy,zz are the second cords

    Code:
    long int x,y,z,xx,yy,zz,a=x,b=y,c=z;
    string data[][][][]; 
    //loading x,xx,y,yy,z,zz from cuboid file but i don't know how;/
    for(a;a<xx+1;a++)
    for(b;b<yy+1;b++)
    for(c;c<zz+1;c++)
    int l = getTypeId(a,b,c)
    data[][][][] = data[x][y][z][l];
    One. How u see its too much strings^^
    Two. I don't know how to load data from cuboid file
    Three. Help me please!
     
  4. Offline

    LukeSFT

    do this:
    PHP:
    public void save(data[x][y][z][ldata String path)
    {
        try
        {
            
    ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(path));
            
    oos.writeObject(data);
            
    oos.flush();
            
    oos.close();
            
    //Handle I/O exceptions
        
    }
        catch(
    Exception e)
        {
            
    e.printStackTrace();
        }
    }
    to save
    and this:
    PHP:
    public data[x][y][z][lload(String path)
    {
        try
        {
            
    ObjectInputStream ois = new ObjectInputStream(new FileInputStream(path));
            
    Object result ois.readObject();
            
    //you can feel free to cast result to HashMap<String, Integer> if you know there's that HashMap in the file
            
    return (data[x][y][z][l])result;
        }
        catch(
    Exception e)
        {
            
    e.printStackTrace();
        }
    }
    to load it
     
Thread Status:
Not open for further replies.

Share This Page