2015-07-26 16:51:12 +02:00
|
|
|
package com.plotsquared.bukkit.util;
|
2015-05-15 19:48:26 +02:00
|
|
|
|
2015-07-30 16:25:16 +02:00
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
|
2015-05-15 19:48:26 +02:00
|
|
|
import com.intellectualcrafters.plot.object.Location;
|
|
|
|
import com.intellectualcrafters.plot.object.PlotId;
|
2015-07-27 19:50:04 +02:00
|
|
|
import com.intellectualcrafters.plot.util.MainUtil;
|
2015-08-02 21:25:41 +02:00
|
|
|
import com.plotsquared.bukkit.BukkitMain;
|
2015-05-15 19:48:26 +02:00
|
|
|
import com.sk89q.worldedit.CuboidClipboard;
|
|
|
|
import com.sk89q.worldedit.EditSession;
|
|
|
|
import com.sk89q.worldedit.Vector;
|
|
|
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
|
|
|
|
|
|
|
public class WorldEditSchematic {
|
|
|
|
public void saveSchematic(String file, final String world, final PlotId id) {
|
|
|
|
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());
|
2015-08-02 21:25:41 +02:00
|
|
|
EditSession session = BukkitMain.worldEdit.getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorld(world)), 999999999);
|
2015-05-15 19:48:26 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|