worldedit api selection to schematic

Discussion in 'Plugin Development' started by noelelias, Oct 14, 2015.

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

    noelelias

    Hey there
    i like to save a WorldEdit Selection to a schematic file . But I dont get it how to..
     
  2. Offline

    mythbusterma

  3. Offline

    Kakarot798

    @noelelias
    Worldedit has a command for this, "//schem"
    I'm not sure if this is what you're looking for, (probably not because this is this Plugin Development section). But hopefully it helped.
     
  4. Offline

    nlthijs48

  5. Offline

    noelelias

    @nlthijs48 thank you for the answer it looks like what im searching for but I get this Error :
    The constructor CuboidRegion(World, Vector, Vector) is undefined
    Code:
    CuboidRegion cuboidRegion = new CuboidRegion(world, selection.getMinimumPoint().toVector(), selection.getMaximumPoint().toVector());

    but if i look at the doc:

    Code:
        /**
         * Construct a new instance of this cuboid using two corners of the cuboid.
         *
         * @param world the world
         * @param pos1  the first position
         * @param pos2  the second position
         */
        public CuboidRegion(World world, Vector pos1, Vector pos2) {
            super(world);
            checkNotNull(pos1);
            checkNotNull(pos2);
            this.pos1 = pos1;
            this.pos2 = pos2;
            recalculate();
        }
    or if I try your example:

    The constructor CuboidRegion(World, Location, Location) is undefined


    any idea why?
     
  6. Offline

    Scimiguy

    @noelelias
    Did you import the wrong world?

    There's 2 World classes in Bukkit
     
  7. Offline

    noelelias

    I used the wrong Vector .... :mad: why does every plugin need it own Vector and World i dont get it
     
  8. Offline

    Scimiguy

    Don't forget to mark the thread as solved if solved
     
  9. Offline

    noelelias

    @nlthijs48 can you tell me what these functions are used for?
    Operations.completeLegacy(copy);
    Closer closer = Closer.create();

    und ich würde nun doch gerne ein CuboidClipboard erhalten
    weisst du wie das geht? Ich komme mit der World Edit API nicht so wirklich zurecht
     
    Last edited: Oct 15, 2015
  10. Offline

    nlthijs48

    @noelelias The completeLegacy thing is to copy the blocks to the clipboard (inspiration from here). Creating the Closer and using the file streams of that is to write the data of the clipboard to a schematic file (inspiration from here). My method is basically a combination of making a selection, then using '//copy' and then using '//schem save <filename>'.

    Although I can understand basic written and spoken German, I cannot really write it properly myself. So communication in Dutch or English is a better idea :) What exactly do you want to do with CuboidClipboard?
     
  11. Offline

    noelelias

  12. Offline

    nlthijs48

    Why exactly are you trying to get a byte stream if you do not want to save it to disk? If you simply want to temporarily (as long as the server is on) save a part of the world then it is a lot simpler to simply save block data.
     
  13. Offline

    noelelias

    I like to save these schematics in one File
    Because the user can create from 1 to 1000 schematics.
    So I would Like to save it in one File per User
     
  14. Offline

    nlthijs48

    Then it might be best to save the schematic to a temporary file, and then read a byte stream from that file. However I don't really see why you would not be able to save the schematics with something like '<player>_<number>' so that you simply have 1 file for each schematic (apart from the file count it would generate).

    An alternative is to give the ClipboardWriter a modified BufferedOutputStream that will keep the bytes written to it instead of feeding it to a file.
     
  15. Offline

    noelelias

    oh How can I do that?

    @nlthijs48 im realy sorry but i dont get it how i should do this.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 1, 2015
  16. Offline

    nlthijs48

    Sorry for the late reply, but which option are you talking about? The first is trivial, simply read a file like you normally do with Java (google has the answers), and then write multiple of them to the same file with some kind of separator to get them separately later.

    The second thing is basically making a class that extends BufferedOutputStream and overwriting the write() methods with code that saves the given bytes to a memory object instead of writing it to an actual file. Then give the WorldEdit API that modified stream and perform the actions, then you should get everything in the custom class because the WorldEdit API calls the write() methods.
     
Thread Status:
Not open for further replies.

Share This Page