Dieser Commit ist enthalten in:
Ursprung
a8aa431210
Commit
5cb7cccbcd
@ -20,6 +20,7 @@
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.EditSessionFactory;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
@ -190,25 +191,36 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean backup(Point minPoint, Point maxPoint, File file) {
|
||||
public Clipboard copy(Point minPoint, Point maxPoint, Point copyPoint) {
|
||||
BukkitWorld bukkitWorld = new BukkitWorld(Bukkit.getWorlds().get(0));
|
||||
CuboidRegion region = new CuboidRegion(bukkitWorld, toBlockVector3(minPoint), toBlockVector3(maxPoint));
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
|
||||
Clipboard clipboard = new BlockArrayClipboard(region);
|
||||
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(bukkitWorld, -1)) {
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(
|
||||
e, region, clipboard, region.getMinimumPoint()
|
||||
e, region, toBlockVector3(copyPoint), clipboard, toBlockVector3(copyPoint)
|
||||
);
|
||||
|
||||
copy.setCopyingEntities(false);
|
||||
copy.setCopyingBiomes(false);
|
||||
|
||||
Operations.complete(copy);
|
||||
return clipboard;
|
||||
} catch (WorldEditException e) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
try (ClipboardWriter writer = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(new FileOutputStream(file))) {
|
||||
writer.write(clipboard);
|
||||
}
|
||||
@Override
|
||||
public boolean backup(Point minPoint, Point maxPoint, File file) {
|
||||
Clipboard clipboard = copy(minPoint, maxPoint, minPoint);
|
||||
if (clipboard == null) {
|
||||
return false;
|
||||
}
|
||||
try (ClipboardWriter writer = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(new FileOutputStream(file))) {
|
||||
writer.write(clipboard);
|
||||
return true;
|
||||
} catch (WorldEditException | IOException e) {
|
||||
} catch (IOException e) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
|
@ -0,0 +1,62 @@
|
||||
package de.steamwar.bausystem.features.region;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.util.SelectCommand;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.core.WorldEditWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import de.steamwar.sql.NoClipboardException;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
// Command
|
||||
@Linked // Annotation, zur compile time, erzeugt Instance des RegionCopy commands
|
||||
public class RegionCopyCommand extends SWCommand {
|
||||
@LinkedInstance
|
||||
public SelectCommand selectCommand;
|
||||
public RegionCopyCommand() {
|
||||
super("rgc");
|
||||
}
|
||||
|
||||
// Entry Point
|
||||
@Register
|
||||
public void genericCommand(Player executer) {
|
||||
Region region = Region.getRegion(executer.getLocation());
|
||||
|
||||
if (region.isGlobal()) {
|
||||
BauSystem.MESSAGE.send("SELECT_GLOBAL_REGION", executer);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!region.hasType(RegionType.BUILD)) {
|
||||
BauSystem.MESSAGE.send("SELECT_NO_TYPE", executer, BauSystem.MESSAGE.parse(RegionType.BUILD.getChatValue(), executer));
|
||||
return;
|
||||
}
|
||||
Clipboard clipboard = FlatteningWrapper.impl.copy(region.getMinPoint(RegionType.BUILD, RegionExtensionType.NORMAL), region.getMaxPoint(RegionType.BUILD, RegionExtensionType.NORMAL), region.getCopyPoint());
|
||||
if (clipboard == null) {
|
||||
throw new NoClipboardException();
|
||||
}
|
||||
// actor = jmd der was ausführt
|
||||
Actor actor = WorldEditWrapper.getWorldEditPlugin().wrapCommandSender(executer);
|
||||
// Setze das Spielerclipboard zum aktuell kopierten clipboard
|
||||
WorldEditWrapper.getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard(new ClipboardHolder(clipboard));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// rgc -aso
|
||||
// rgp -aso
|
||||
// tbc -aso
|
@ -46,6 +46,7 @@ public interface FlatteningWrapper {
|
||||
Clipboard loadSchematic(File file);
|
||||
EditSession paste(PasteBuilder pasteBuilder);
|
||||
|
||||
Clipboard copy(Point minPoint, Point maxPoint, Point copyPoint);
|
||||
boolean backup(Point minPoint, Point maxPoint, File file);
|
||||
|
||||
boolean inWater(World world, Vector tntPosition);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren