diff --git a/BauSystem_15/src/de/steamwar/bausystem/region/Region_15.java b/BauSystem_15/src/de/steamwar/bausystem/region/Region_15.java index a915ed4a..f9a1e19e 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/region/Region_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/region/Region_15.java @@ -44,7 +44,7 @@ import org.bukkit.Bukkit; @UtilityClass public class Region_15 { - EditSession paste(File file, int x, int y, int z, PasteOptions pasteOptions) { + EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions) { Clipboard clipboard; try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) { clipboard = reader.read(); @@ -52,16 +52,16 @@ public class Region_15 { throw new SecurityException("Bausystem schematic not found", e); } - return paste(clipboard, x, y, z, pasteOptions); + return paste(clipboard, pastePoint, pasteOptions); } - EditSession paste(Clipboard clipboard, int x, int y, int z, PasteOptions pasteOptions) { + EditSession paste(Clipboard clipboard, Point pastePoint, PasteOptions pasteOptions) { try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) { changeColor(clipboard, pasteOptions.getColor()); ClipboardHolder ch = new ClipboardHolder(clipboard); BlockVector3 dimensions = clipboard.getDimensions(); - BlockVector3 v = BlockVector3.at(x, y, z); + BlockVector3 v = BlockVector3.at(pastePoint.getX(), pastePoint.getY(), pastePoint.getZ()); BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); if (pasteOptions.isRotate()) { ch.setTransform(new AffineTransform().rotateY(180)); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java index 3d0cfe34..7e8dc5a1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -20,12 +20,15 @@ package de.steamwar.bausystem.region; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.bausystem.region.flags.Flag; +import de.steamwar.bausystem.region.flags.flagvalues.ColorMode; import de.steamwar.bausystem.region.flags.flagvalues.TNTMode; import de.steamwar.bausystem.region.loader.RegionLoader; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.shared.SizedStack; +import de.steamwar.core.VersionedCallable; import de.steamwar.sql.Schematic; import lombok.AccessLevel; import lombok.Getter; @@ -35,6 +38,7 @@ import yapion.hierarchy.types.YAPIONObject; import yapion.hierarchy.types.YAPIONType; import yapion.hierarchy.types.YAPIONValue; +import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; @@ -340,34 +344,60 @@ public class Region { } public void reset(Schematic schematic, RegionType regionType) throws IOException { - reset(schematic, regionType, RegionExtensionType.NORMAL); + reset(schematic, regionType, RegionExtensionType.NORMAL, false); } public void reset(RegionType regionType, RegionExtensionType regionExtensionType) throws IOException { - reset(null, regionType, regionExtensionType); + reset(null, regionType, regionExtensionType, false); } - public void reset(Schematic schematic, RegionType regionType, RegionExtensionType regionExtensionType) throws IOException { + public void reset(Schematic schematic, RegionType regionType, RegionExtensionType regionExtensionType, boolean ignoreAir) throws IOException { if (!hasReset(regionType)) { return; } if (regionExtensionType == RegionExtensionType.EXTENSION && !hasExtensionType(regionType)) { regionExtensionType = RegionExtensionType.NORMAL; } + + PasteOptions pasteOptions = new PasteOptions((schematic != null && (schematic.getSchemType().fightType() || schematic.getSchemType().check())), ignoreAir, getPlain(Flag.COLOR, ColorMode.class).getColor(), regionExtensionType == RegionExtensionType.EXTENSION, getMinPoint(regionType, regionExtensionType), getMaxPoint(regionType, regionExtensionType), waterLevel); + switch (regionType) { case BUILD: - System.out.println(schematic + " " + regionType + " " + regionExtensionType + " " + minPointBuild); + System.out.println(schematic + " " + prototype.getBuild().getSchematicFile() + " " + regionType + " " + regionExtensionType + " " + minPointBuild); + if (schematic != null) { + paste(schematic.load(), minPointBuild, pasteOptions); + } else { + paste(prototype.getBuild().getSchematicFile(), minPointBuild, pasteOptions); + } break; case TESTBLOCK: - System.out.println(schematic + " " + regionType + " " + regionExtensionType + " " + minPointTestblock); + System.out.println(schematic + " " + prototype.getBuild().getSchematicFile() + " " + regionType + " " + regionExtensionType + " " + minPointTestblock); + if (schematic != null) { + paste(schematic.load(), minPointTestblock, pasteOptions); + } else { + paste(prototype.getTestblock().getSchematicFile(), minPointTestblock, pasteOptions); + } break; default: case NORMAL: - System.out.println(schematic + " " + regionType + " " + regionExtensionType + " " + minPoint); + System.out.println(schematic + " " + prototype.getBuild().getSchematicFile() + " " + regionType + " " + regionExtensionType + " " + minPoint); + if (schematic != null) { + paste(schematic.load(), minPoint, pasteOptions); + } else { + paste(prototype.getSchematicFile(), minPoint, pasteOptions); + } break; } } + private static EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions) { + return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.paste(file, pastePoint, pasteOptions), 15)); + } + + private static EditSession paste(Clipboard clipboard, Point pastePoint, PasteOptions pasteOptions) { + return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.paste(clipboard, pastePoint, pasteOptions), 15)); + } + public boolean isGlobal() { return this == GlobalRegion.getInstance(); }