~/paste/18915
~/paste/18915
~/paste/18915

  1. @SuppressWarnings("deprecation")
  2. public void paste(Player player, String schematic) {
  3.         try {
  4.                 File schematicFile = new File(Bukkit.getServer().getPluginManager().getPlugin("WorldEdit").getDataFolder(), "/schematics/" + schematic);
  5.                 SchematicFormat schematicFormat = SchematicFormat.getFormat(schematicFile);
  6.                 CuboidClipboard cuboidClipboard = schematicFormat.load(schematicFile);
  7.                 cuboidClipboard.paste(new EditSession(new BukkitWorld(player.getLocation().getWorld()), 999999999), BukkitUtil.toVector(player.getLocation()), false);
  8.         } catch (IOException e) {
  9.                 e.printStackTrace();
  10.         } catch (DataException e) {
  11.                 e.printStackTrace();
  12.         } catch (MaxChangedBlocksException e) {
  13.                 e.printStackTrace();
  14.         }
  15. }
  16.  
  17. @SuppressWarnings("deprecation")
  18. public void paste(Location coordinates, String schematic) {
  19.         try {
  20.                 File schematicFile = new File(Bukkit.getServer().getPluginManager().getPlugin("WorldEdit").getDataFolder(), "/schematics/" + schematic);
  21.                 SchematicFormat schematicFormat = SchematicFormat.getFormat(schematicFile);
  22.                 CuboidClipboard cuboidClipboard = schematicFormat.load(schematicFile);
  23.                 cuboidClipboard.paste(new EditSession(new BukkitWorld(coordinates.getWorld()), 999999999), BukkitUtil.toVector(coordinates), false);
  24.         } catch (IOException e) {
  25.                 e.printStackTrace();
  26.         } catch (DataException e) {
  27.                 e.printStackTrace();
  28.         } catch (MaxChangedBlocksException e) {
  29.                 e.printStackTrace();
  30.         }
  31. }
  32.  
  33. public boolean onCommand(CommandSender sender, Command command, String label, String[] arguments) {
  34.         if(command.getName().equalsIgnoreCase("wepaste")) {
  35.                 paste(new Location(Bukkit.getServer().getWorld("world"), 0.0, 5.0, 0.0), "casa");
  36.         }
  37.         return false;
  38. }
Language: java
Posted by Anonymous at 11 Dec 2015, 03:17:18 UTC