WorldEdit API Questions

Discussion in 'Spigot Plugin Development' started by ReadySetPawn, Sep 19, 2015.

  1. - How do I convert a normal Bukkit player to a WorldEdit player? SOLVED
    - Is it possible to get a LocalSession without referencing a player? Sort of like a generic LocalSession.
    - How do I edit a player's clipboard?
    - How do I make a player paste a schematic without giving them permission?
     
    #1 ReadySetPawn, Sep 19, 2015
    Last edited: Sep 20, 2015
  2. 1) Wrap the Player to obtain a BukkitPlayer. BukkitPlayer is a LocalPlayer. http://docs.sk89q.com/worldedit/api...gin.html#wrapPlayer(org.bukkit.entity.Player)

    2) No. A Session is strictly tied to a LocalPlayer. See #1 for how to get a LocalPlayer object from a Player.

    3) Please elaborate this question. Do you want to change the blocks in the clipboard? Are you trying to load a schematic into a clipboard? Something else?

    4) What do you mean not giving them permission? Do you mean the WorldEdit permission? If so, you need to implement your own schematic pasting method. You can make your own permission node for this, or leave one out completely.

    Links with more information:

    WorldEdit API: http://docs.sk89q.com/worldedit/apidocs/

    Basic code showing how to load/save schematics: https://www.spigotmc.org/threads/lib-save-paste-schematics-via-worldedit-6.75421/

    Google: http://www.google.com
     
  3. Thanks! :)
    Also for #3, I mean how would I load a schematic into a clipboard.

    And for #4, I mean like having me do
    Code (Java):
    player.performCommand("/paste");
    even though a player doesn't have permission but the command still executes.
     
  4. This is pretty simple.

    Code (Text):

    SchematicFormat schematic = SchematicFormat.getFormat(file);
    CuboidClipboard clipboard = schematic.load(file);
     
    From there you just have to paste the clipboard to the world, which brings us to your #4 question.

    You arent going to be telling WorldEdit to paste the schematic. You already loaded the schematic into a clipboard inside of your plugin. WorldEdit doesnt truly know its there, only your plugin does. This is where I said you have to implement your own pasting method.

    Code (Text):

    clipboard.paste(editSession, BukkitUtil.toVector(pasteLoc), true);
     
    Take a look at the links I gave you above. The second one (Basic code showing how to load/save schematics) show a basic implementation that loads and saves schematics. It is in the form of a lib, but you dont have to use that lib. Just learn from it's code and make your own implementation. There's really not much to it at all. ;)
     
    • Informative Informative x 1
  5. Excellent explanation :)
    Now I just have one more little question xD

    Is it possible to get a schematic's placement position without referencing a LocalSession?
     
  6. I dont understand the question. You are the one who specifies the base location of the schematic when you are pasting the clipboard. Schematics are "locationless" in the fact that all locations stored in it are relative to the base location.
     
  7. In the paste method in WorldEdit, there's an option to either paste the schematic at the player's location or have it paste to where the player is standing when he first copied it.
    It's
    Code (Java):
    localSession.getPlacementPosition(player);
    I believe but I don't want to get the placement position using my own pasting method (no LocalSession).
     
  8. I have many problems to adapt the code to the new minecraft version 1.13, I am using the latest worledit plugins but the functions do not exist:
    SchematicFormat.getFormat
    CuboidClipboard cc = new CuboidClipboard (size, origin, offset);
    etc .. I tried to use the FAWE but there are PLUGINS that DO NOT ACCEPT IT WELL! and it gives many problems so I force myself to use the normal worldedit. could someone please put CODES of example of how to use these functions with the new worledit 7.00 for minecraft 1.13? Thank you
     
  9. hmm, do plugins work in 1.13?
     
  10. Also does 1.13 work for like 1.8.9
     
    • Please TELL ME, I need help