Advertisement
Guest User

Untitled

a guest
May 10th, 2021
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.39 KB | None | 0 0
  1. private Clipboard loadSchematic(String schematicName) {
  2.         File schematic = new File(plugin.getDataFolder() + File.separator + "/schematics/" + schematicName + ".schem");
  3.         ClipboardFormat format = ClipboardFormats.findByFile(schematic);
  4.         ClipboardReader reader = null;
  5.  
  6.         try {
  7.             reader = format.getReader(new FileInputStream(schematic));
  8.         } catch (IOException e) {
  9.             e.printStackTrace();
  10.         }
  11.         Clipboard clipboard = null;
  12.         try {
  13.             clipboard = reader.read();
  14.         } catch (IOException e) {
  15.             e.printStackTrace();
  16.         }
  17.  
  18.         return clipboard;
  19.     }
  20.  
  21.  
  22. public BuildTask(Clipboard initialClipboard, Location zeroLocation) {
  23.         clipboard = initialClipboard;
  24.         location = zeroLocation;
  25.         iterator = clipboard.iterator();
  26.     }
  27.  
  28.     @Override
  29.     public void run() {
  30.         BlockVector3 userBlock = BlockVector3.at(location.getX(), location.getY(), location.getZ());
  31.  
  32.         if (iterator.hasNext()) {
  33.             BlockVector3 block = (BlockVector3) iterator.next();
  34.             BlockVector3 blockVectorNew = userBlock.add(block);
  35.             BlockState blockState = clipboard.getBlock(block);
  36.  
  37.             if(BukkitAdapter.adapt(blockState.getBlockType()).equals(Material.AIR)) {
  38.                 return;
  39.             }
  40.  
  41.             Block block1 = location.getWorld().getBlockAt(blockVectorNew.getX(), blockVectorNew.getY(), blockVectorNew.getZ());
  42.  
  43.             block1.setType(BukkitAdapter.adapt(blockState.getBlockType()));
  44.             block1.setBlockData(BukkitAdapter.adapt(blockState));
  45.         }
  46.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement