mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-01-19 16:59:36 +01:00
WorldEdit schematics
This commit is contained in:
parent
0e5f29ef2a
commit
86a1acdd83
@ -264,6 +264,7 @@ public class SchematicCmd extends SubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainUtil.sendMessage(plr, "&aFinished export");
|
MainUtil.sendMessage(plr, "&aFinished export");
|
||||||
|
SchematicCmd.this.running = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
@ -61,7 +61,6 @@ public abstract class SchematicHandler {
|
|||||||
Iterator<Plot> i = plots.iterator();
|
Iterator<Plot> i = plots.iterator();
|
||||||
final Plot plot = i.next();
|
final Plot plot = i.next();
|
||||||
i.remove();
|
i.remove();
|
||||||
final CompoundTag sch = SchematicHandler.manager.getCompoundTag(plot.world, plot.id);
|
|
||||||
String o = UUIDHandler.getName(plot.owner);
|
String o = UUIDHandler.getName(plot.owner);
|
||||||
if (o == null) {
|
if (o == null) {
|
||||||
o = "unknown";
|
o = "unknown";
|
||||||
@ -80,6 +79,11 @@ public abstract class SchematicHandler {
|
|||||||
else {
|
else {
|
||||||
directory = outputDir.getPath();
|
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) {
|
if (sch == null) {
|
||||||
MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id);
|
MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id);
|
||||||
} else {
|
} else {
|
||||||
@ -97,6 +101,7 @@ public abstract class SchematicHandler {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, 20);
|
}, 20);
|
||||||
TaskManager.tasks.put(currentIndex, task);
|
TaskManager.tasks.put(currentIndex, task);
|
||||||
return true;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user