Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class VersionHandler implements VersionInterface {
- public EditSession doWorldEditTask(Player player, Location location, File myfile, boolean wg) {
- World world = player.getWorld();
- int X = location.getBlockX();
- int Y = location.getBlockY();
- int Z = location.getBlockZ();
- location.getDirection();
- com.sk89q.worldedit.world.World AdaptedWorld = BukkitAdapter.adapt(world);
- EditSession playerEditSession = null;
- ClipboardFormat format = ClipboardFormats.findByFile(myfile);
- try (ClipboardReader reader = format.getReader(new FileInputStream(myfile))) {
- Clipboard clipboard = reader.read();
- if (wg == true) {
- String er = "h";
- try {
- er = WorldGuardClass.wgMethod(clipboard, X, Y, Z, player, AdaptedWorld);
- } catch (NoClassDefFoundError e2){
- }
- if (er != null) {
- try (EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(AdaptedWorld,
- -1)) {
- playerEditSession = editSession;
- Operation operation = new ClipboardHolder(clipboard).createPaste(editSession)
- .to(BlockVector3.at(X, Y, Z)).ignoreAirBlocks(true).build();
- try {
- Operations.complete(operation);
- editSession.flushSession();
- } catch (WorldEditException e) {
- player.sendMessage(ChatColor.RED + "OOPS! Something went wrong, please contact an administrator");
- e.printStackTrace();
- }
- }
- return playerEditSession;
- } else {
- return null;
- }
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- player.sendMessage(ChatColor.RED + "This file was not found! Contact an administrator");
- System.out.println("StructurePasteCommand > " + "FileNotFoundException: ");
- System.out.println("StructurePasteCommand > " + "Ensure schematic has extension in the file .schem or .schematic (not supported)");
- System.out.println("StructurePasteCommand > " + "NOTE: .schem files are not the same as .schematic files! ");
- System.out.println("StructurePasteCommand > " + "If you're having issues that you feel to be unresolveable, contact the author. ");
- } catch (IOException e) {
- e.printStackTrace();
- }
- return playerEditSession;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement