Solved WorldEdit schematic pasting.

Discussion in 'Plugin Development' started by Shadow_tingBRO, Mar 14, 2019.

Thread Status:
Not open for further replies.
  1. When I run this, yet again, a null pointer.

    Code:
    public static void loadSchematic(String fileName, Player player) {
            Location loc = player.getLocation();
            WorldEditPlugin worldEditPlugin =  (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
            EditSession session = worldEditPlugin.getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(loc.getWorld()), 30000000);
            File schematic = new File(PixelCraftX.getIntsance().getDataFolder() + File.separator + "/schematics/" + fileName + ".schematic");
            try {
             
                CuboidClipboard clipboard = MCEditSchematicFormat.getFormat(schematic).load(schematic);
                clipboard.rotate2D(90);
                clipboard.paste(session, new Vector(loc.getX(), loc.getY(), loc.getZ()), false);
            }catch(MaxChangedBlocksException |  DataException | IOException | NullPointerException e) {
                e.printStackTrace();
            }
        }
    I get it on the line where is says CubiodClipboard clipboard etc... Other bukkit forumns and websites dont have the answer so im back here...
     
    Last edited: Mar 14, 2019
  2. Offline

    timtower Administrator Administrator Moderator

    @Shadow_tingBRO
    MCEditSchematicFormat.getFormat(schematic)
    What does that return?
     
  3. It returns a SchematicFormat, and the .load (obviously) returns a CuboidClipboard
     
  4. Offline

    timtower Administrator Administrator Moderator

  5. :( So.... Its solved. I put the schematics in the folder. Then they somehow got removed. I was searching around and found they where gone so I treid on the server... .and it worked. Thanks timtower (still my fave) for this. I need to stop with these stupid mistakes!
     
    Last edited: Mar 14, 2019
Thread Status:
Not open for further replies.

Share This Page