SHARE
TWEET

Untitled

a guest Aug 20th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package de.pyario.system.commands;
  2.  
  3. import com.sk89q.worldedit.EditSession;
  4. import com.sk89q.worldedit.WorldEdit;
  5. import com.sk89q.worldedit.WorldEditException;
  6. import com.sk89q.worldedit.bukkit.BukkitAdapter;
  7. import com.sk89q.worldedit.extent.clipboard.Clipboard;
  8. import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
  9. import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
  10. import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
  11. import com.sk89q.worldedit.function.operation.Operation;
  12. import com.sk89q.worldedit.function.operation.Operations;
  13. import com.sk89q.worldedit.math.BlockVector3;
  14. import com.sk89q.worldedit.session.ClipboardHolder;
  15. import de.pyario.system.main.Main;
  16. import org.bukkit.Bukkit;
  17. import org.bukkit.ChatColor;
  18. import org.bukkit.command.Command;
  19. import org.bukkit.command.CommandExecutor;
  20. import org.bukkit.command.CommandSender;
  21. import org.bukkit.entity.Player;
  22. import org.bukkit.event.Listener;
  23.  
  24. import java.io.FileInputStream;
  25. import java.io.FileNotFoundException;
  26. import java.io.IOException;
  27.  
  28. public class CMD_PASTEFARMWELT implements CommandExecutor {
  29.  
  30.     //So ist mein File Path^^::
  31.    
  32.     // public static File schem = new File(Bukkit.getPluginManager().getPlugin("System").getDataFolder().getAbsolutePath() + "/schematics/farmwelt.schem");
  33.    
  34.     @Override
  35.     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  36.         if(args.length == 0){
  37.             Player p = (Player) sender;
  38.             com.sk89q.worldedit.world.World adaptedWorld = BukkitAdapter.adapt(Bukkit.getWorld("farmwelt")); //<<<- Weltname
  39.             ClipboardFormat format = ClipboardFormats.findByFile(Main.schem); // <<- Pfad für die Schematic ^^
  40.             try (ClipboardReader reader = format.getReader(new FileInputStream(Main.schem))) { // <<- Pfad für die Schematic ^^
  41.                 Clipboard clipboard = reader.read();
  42.                 try (EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(adaptedWorld, -1)) {
  43.                     Operation operation = new ClipboardHolder(clipboard).createPaste(editSession)
  44.                             .to(BlockVector3.at(0, 120, 0)).ignoreAirBlocks(true).build();
  45.                     try {
  46.                         Operations.complete(operation);
  47.                         editSession.flushSession();
  48.                         p.sendMessage("Successfully!"); // <<< Hier wenn es erfolgreich war. aber muss nicht zwingend die nachricht sein
  49.                     } catch (WorldEditException e) {
  50.                         p.sendMessage(ChatColor.RED + "OOPS! Something went wrong, please contact an administrator");
  51.                         e.printStackTrace();
  52.                     }
  53.                 }
  54.             } catch (FileNotFoundException e) {
  55.                 e.printStackTrace();
  56.             } catch (IOException e) {
  57.                 e.printStackTrace();
  58.             }
  59.  
  60.         }
  61.         return false;
  62.     }
  63. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top