mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-11-04 03:03:43 +01:00 
			
		
		
		
	WorldEdit schematics
This commit is contained in:
		@@ -264,6 +264,7 @@ public class SchematicCmd extends SubCommand {
 | 
			
		||||
					@Override
 | 
			
		||||
					public void run() {
 | 
			
		||||
						MainUtil.sendMessage(plr, "&aFinished export");
 | 
			
		||||
						SchematicCmd.this.running = false;
 | 
			
		||||
					}
 | 
			
		||||
				});
 | 
			
		||||
                if (!result) {
 | 
			
		||||
 
 | 
			
		||||
@@ -61,7 +61,6 @@ public abstract class SchematicHandler {
 | 
			
		||||
            	Iterator<Plot> i = plots.iterator();
 | 
			
		||||
            	final Plot plot = i.next();
 | 
			
		||||
            	i.remove();
 | 
			
		||||
                final CompoundTag sch = SchematicHandler.manager.getCompoundTag(plot.world, plot.id);
 | 
			
		||||
                String o = UUIDHandler.getName(plot.owner);
 | 
			
		||||
                if (o == null) {
 | 
			
		||||
                	o = "unknown";
 | 
			
		||||
@@ -80,6 +79,11 @@ public abstract class SchematicHandler {
 | 
			
		||||
                else {
 | 
			
		||||
                	directory = outputDir.getPath();
 | 
			
		||||
                }
 | 
			
		||||
                if (PlotSquared.worldEdit != null) {
 | 
			
		||||
                    new WorldEditSchematic().saveSchematic(directory + File.separator + name + ".schematic", plot.world, plot.id);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    final CompoundTag sch = SchematicHandler.manager.getCompoundTag(plot.world, plot.id);
 | 
			
		||||
                    if (sch == null) {
 | 
			
		||||
                        MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id);
 | 
			
		||||
                    } else {
 | 
			
		||||
@@ -97,6 +101,7 @@ public abstract class SchematicHandler {
 | 
			
		||||
                        });
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }, 20);
 | 
			
		||||
        TaskManager.tasks.put(currentIndex, task);
 | 
			
		||||
    	return true;
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,42 @@
 | 
			
		||||
package com.intellectualcrafters.plot.util;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.Bukkit;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PlotSquared;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Location;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotId;
 | 
			
		||||
import com.sk89q.worldedit.CuboidClipboard;
 | 
			
		||||
import com.sk89q.worldedit.EditSession;
 | 
			
		||||
import com.sk89q.worldedit.Vector;
 | 
			
		||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
 | 
			
		||||
import com.sk89q.worldedit.data.DataException;
 | 
			
		||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
 | 
			
		||||
import com.sk89q.worldedit.regions.CuboidRegion;
 | 
			
		||||
import com.sk89q.worldedit.schematic.MCEditSchematicFormat;
 | 
			
		||||
import com.sk89q.worldedit.schematic.SchematicFormat;
 | 
			
		||||
 | 
			
		||||
public class WorldEditSchematic {
 | 
			
		||||
    public void saveSchematic(String file, final String world, final PlotId id) {
 | 
			
		||||
        System.out.print("SAVCING SCHSAKJHDJKAS HDKAS");
 | 
			
		||||
        Location bot = MainUtil.getPlotBottomLoc(world, id).add(1, 0, 1);
 | 
			
		||||
        Location top = MainUtil.getPlotTopLoc(world, id);
 | 
			
		||||
        Vector size = new Vector(top.getX() - bot.getX() + 1, top.getY() - bot.getY() - 1, top.getZ() - bot.getZ() + 1);
 | 
			
		||||
        Vector origin = new Vector(bot.getX(), bot.getY(), bot.getZ());
 | 
			
		||||
        CuboidClipboard clipboard = new CuboidClipboard(size, origin);
 | 
			
		||||
        Vector pos1 = new Vector(bot.getX(), bot.getY(), bot.getZ());
 | 
			
		||||
        Vector pos2 = new Vector(top.getX(), top.getY(), top.getZ());
 | 
			
		||||
        CuboidRegion region = new CuboidRegion(pos1, pos2);
 | 
			
		||||
        EditSession session = PlotSquared.worldEdit.getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorld(world)), 999999999);
 | 
			
		||||
        clipboard.copy(session);
 | 
			
		||||
        try {
 | 
			
		||||
            clipboard.saveSchematic(new File(file));
 | 
			
		||||
            MainUtil.sendMessage(null, "&7 - &a  success: " + id);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
            MainUtil.sendMessage(null, "&7 - Failed to save &c" + id);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user