Getting WorldEdit Schematics and assigning them to a map

Discussion in 'Plugin Development' started by jordanzilla02, Jan 11, 2014.

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

    jordanzilla02

    I am trying to make a plugin that gets a worldedit schematic and then it gives you a map that when you right click it will spawn that schematic. How would I use the worldedit api to get the schematic and then assign the command to a map?
     
  2. Offline

    Gopaintman

    Code:java
    1. public class WorldEditHandler {
    2. public static WorldEditPlugin getWorldEdit(){
    3. if(Main.getMainInstance().getServer().getPluginManager().getPlugin("WorldEdit") != null){
    4. if(!(Main.getMainInstance().getServer().getPluginManager().getPlugin("WorldEdit") instanceof WorldEditPlugin)){
    5. return (WorldEditPlugin) Main.getMainInstance().getServer().getPluginManager().getPlugin("WorldEdit");
    6. }else{
    7. return null;
    8. }
    9.  
    10. }else{
    11. return null;
    12. }
    13.  
    14. }
    15. public static boolean loadSchematic(File schemFile, World world, Location location) throws MaxChangedBlocksException, IOException, DataException {
    16.  
    17. Vector v = new Vector(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    18. SchematicFormat format = SchematicFormat.getFormat(schemFile);
    19. if (format == null)
    20. {
    21. return false;
    22. }
    23. EditSession es = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(world), 0x3b9ac9ff);
    24.  
    25. CuboidClipboard cc = format.load(schemFile);
    26. cc.paste(es, v, false);
    27. return true;
    28. }
    29.  
    30.  
    31. }


    Should fit your needs, just do WorldEditHandler.loadSchematic(args) to load your schematic. Use the getWorldEdit() method if you ever need to do something with WorldEdit specificially.
     
    CraftBang likes this.
  3. Offline

    CraftBang

    Gopaintman is there anyway I could use like SafeEdit also with this?
    So it's not laggy?

    And can you maybe give me the Imports, since there are multiple possibiltys? And I get an error on Main.getMainInstance() (Error = The method getMainInstance() is undefined for the type Main)

    Thanks in advance!
     
  4. Offline

    Gopaintman

    Main.getMainInstance() is a reference to the Main JavaPlugin class. You can replace with the way you get instances of your JavaPlugin class.
     
Thread Status:
Not open for further replies.

Share This Page