WorldEdit save and load Schematic from Clipboard

Discussion in 'Plugin Development' started by Weasel_Squeezer, May 19, 2013.

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

    Weasel_Squeezer

    ok so I am trying to create a schematic of what the player has selected and I am having problems with the WorldEdit API because it is not documented very well. I know that in order to create a schematic, you must do:
    Code:
    CuboidClipboard.saveSchematic(path);
    so I need to turn the players selection into the CuboidClipboard object. However, in the WorldEdit documentation, the given constructors are:
    CuboidClipboard(Vector size)
    Constructs the clipboard.
    CuboidClipboard(Vector size, Vector origin)
    Constructs the clipboard.
    CuboidClipboard(Vector size, Vector origin, Vector offset)
    Constructs the clipboard.

    the above does not say much about the parameters for the CuboidClipboard object. I have no idea what "size" or "origin" are, so it is kinda hard for me to know how to construct this object.
    I start out with the players selection:
    Code:java
    1. WorldEditPlugin we = getWorldEdit();
    2. if (we != null) {
    3. Selection selection = we.getSelection(player);
    4.  
    5. }

    then with the selection, I can get the maximum and minimum locations and create vectors for the max and min locations of the selection. Or I can get the vectors of the max and min by doing:
    Code:java
    1. selection.getNativeMaximumPoint();
    2. selection.getNativeMinimumPoint();

    But with this, I have a vector for the max and min, and the constructor for CuboidClipboard takes one vector parameter for the "size" or two vector parameters for the "size" and "origin"

    My question is:
    Does anyone know how to get the CuboidClipboard object given the players selection so that I can create a schematic from it?
    Or at least enlighten me on what the parameters for CuboidClipboard mean? and how I would get them?

    Thanks for your help for whoever helps me on this! :)

    can anyone help with this?

    has nobody used the WorldEdit API before??

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  2. Offline

    Weasel_Squeezer

    I can load schematics fine now, but does anyone know how I would be able to save them? I can use the worldEdit save method, but it takes CuboidClipboard as a parameter and I cannot figure out how to properly construct that object.
     
  3. Offline

    GeekWithAChick

    I know it's a bit late, but I found the solution

    Code:java
    1. try {
    2. LocalSession session = we.getWorldEdit().getSession(player.getName());
    3. CuboidClipboard clibboard = session.getClipboard();
    4. File file = new File("./plugins/WorldEdit/schematics/test.schematic");
    5. clibboard.saveSchematic(file);
    6. player.sendMessage("Saved!");
    7. }
    8. catch (EmptyClipboardException e) {
    9. e.printStackTrace();
    10. player.sendMessage("Your clipboard is empty");
    11. }
    12. catch (IOException | DataException e) {
    13. e.printStackTrace();
    14. player.sendMessage("Something went wrong");
    15. }
     
    Ultracrepadarian likes this.
Thread Status:
Not open for further replies.

Share This Page