Saving CuboidSelections

Discussion in 'Plugin Development' started by Link_Awesomesause, May 12, 2016.

Thread Status:
Not open for further replies.
  1. Do any of you guys/girls know the best way to save an array list of cuboid selections?

    Btw, cuboid selections is from world edit.
     
  2. Offline

    Zombie_Striker

    @Link_Awesomesause
    (This is assuming you mean saving the sections to a config)
    1. Create a for int loop that loops through the cuboid selections collection as an array
    2. Save each cuboid selection at index "I" to the address "path.to.cuboids.I"
     
  3. Offline

    Zombie_Striker

  4. @Zombie_Striker
    As to my knowledge, there is know way to convert a string(?) to a cuboid selection
     
  5. Offline

    I Al Istannen

    @Link_Awesomesause
    Then make one ;) It depends on what you want to do: Save everything INSIDE the selection to later restore it (use Fishey's approach) or just the selection [e.g. from (1|1|1) to (2|2|2)]. If it is the latter, Zombie_Striker provided the solution.

    For the latter:
    You will need to convert the two locations of the selection to a String and then later restore it.

    (Since 1.8, I think, Location implements ConfigurationSerializable, so you can directly save the Location. This way you can save it at "path.to.cuboid.loc1" and "path.to.cuboid.loc2" and then just use the #get(path) method to get the Locations at the given path. Cast them to Location and recreate the Cuboid selection.).
     
  6. Omg.. thank u sooo much.. although this is a little late, as I wrote a huge chunk of code to get x,y and z of every location and save them under path.to.cuboid.loc1.x and so on...

    this is gonna save soo many lines.. xD

    @I Al Istannen
     
    I Al Istannen likes this.
Thread Status:
Not open for further replies.

Share This Page