lelesape

Untitled

Oct 20th, 2020
971
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private void loadSchematic() {
  2.  
  3.  
  4.         File schematicFile = new File(Main.getInstance().getDataFolder() + File.separator + "arena schematics" + File.separator + name + ".schematic");
  5.         if(!schematicFile.exists()) {
  6.             Bukkit.getConsoleSender().sendMessage("NO EXISTE");
  7.             return;
  8.         }
  9.  
  10.  
  11.         ClipboardFormat format = ClipboardFormats.findByFile(schematicFile);
  12.         try {
  13.             ClipboardReader reader = format.getReader(new FileInputStream(schematicFile));
  14.             Clipboard clipboard = reader.read();
  15.  
  16.             EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(BukkitAdapter.adapt(location.getWorld()), -1);
  17.             Operation operation = new ClipboardHolder(clipboard)
  18.                     .createPaste(editSession)
  19.                     .to(BlockVector3.at(location.getX(), location.getY(), location.getZ()))
  20.                     .ignoreAirBlocks(false)
  21.                     .build();
  22.             Operations.complete(operation);
  23.             editSession.flushSession();
  24.  
  25.         } catch (IOException | WorldEditException e) {
  26.             e.printStackTrace();
  27.             Bukkit.getConsoleSender().sendMessage("ERROR1 o 2");
  28.         }
  29.  
  30.     }
RAW Paste Data