From 830ca93105ddc28efe48697030189cc8c81930da Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 2 Aug 2025 13:53:52 +0200 Subject: [PATCH] Implement Area for FixedRegion --- .../de/steamwar/bausystem/region/Region.java | 9 ++- .../bausystem/region/fixed/FixedRegion.java | 80 ++++++++++++------- 2 files changed, 58 insertions(+), 31 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java index bad3b0ef..609364a1 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -19,7 +19,8 @@ package de.steamwar.bausystem.region; -import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.extent.clipboard.Clipboard; +import de.steamwar.bausystem.utils.FlatteningWrapper; import de.steamwar.bausystem.utils.PasteBuilder; import lombok.NonNull; import org.bukkit.Location; @@ -100,7 +101,7 @@ public interface Region { } @Override - public EditSession copy(boolean extension) { + public Clipboard copy(boolean extension) { return null; } @@ -146,7 +147,9 @@ public interface Region { } @Nullable - EditSession copy(boolean extension); + default Clipboard copy(boolean extension) { + return FlatteningWrapper.impl.copy(getMinPoint(extension), getMaxPoint(extension), getCopyPoint()); + } @Nullable File getResetFile(); diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java index 7409de36..d89095c3 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegion.java @@ -26,6 +26,7 @@ import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.TestblockMode; import de.steamwar.bausystem.utils.PasteBuilder; import de.steamwar.core.Core; +import de.steamwar.sql.SchematicType; import lombok.NonNull; import yapion.hierarchy.types.YAPIONObject; @@ -36,9 +37,10 @@ import java.util.UUID; public class FixedRegion implements Region { - private UUID uuid; - private FixedFlagStorage flagStorage; - private Prototype prototype; + private final UUID uuid; + private final FixedFlagStorage flagStorage; + private final Prototype prototype; + private final String skin; private final Area area; private final Area build; @@ -52,7 +54,7 @@ public class FixedRegion implements Region { uuid = UUID.nameUUIDFromBytes(name.getBytes(StandardCharsets.UTF_8)); this.flagStorage = flagStorage; this.prototype = prototype; - System.out.println(name + " " + prototype + " " + flagStorage); + this.skin = prototype.getDefaultSkin(); Point minPoint; if (regionConfig.containsKey("minX", Integer.class) && regionConfig.containsKey("minY", Integer.class) && regionConfig.containsKey("minZ", Integer.class)) { @@ -78,21 +80,24 @@ public class FixedRegion implements Region { return minPoint; } - @Nullable - @Override - public EditSession copy(boolean extension) { - return null; // TODO: Implement - } - @Nullable @Override public File getResetFile() { - return null; // TODO: Implement + return prototype.getSkinMap().get(skin).getSchematicFile(); } @Override public void reset(PasteBuilder pasteBuilder, boolean extension) { - // TODO: Implement + pasteBuilder.reset(extension) + .minPoint(getMinPoint(extension)) + .maxPoint(getMaxPoint(extension)) + .waterLevel(waterLevel); + if (pasteBuilder.getClipboardProvider().is(PasteBuilder.SchematicProvider.class)) { + SchematicType schematicType = pasteBuilder.getClipboardProvider().as(PasteBuilder.SchematicProvider.class).getSchematic().getSchemtype(); + pasteBuilder.rotate(schematicType.fightType() || schematicType.check()); + } + pasteBuilder.pastePoint(minPoint.add(prototype.getSizeX() / 2, 0, prototype.getSizeY() / 2)); + regionHistory.remember(pasteBuilder.run()); } }; @@ -128,21 +133,24 @@ public class FixedRegion implements Region { return copyPoint; } - @Nullable - @Override - public EditSession copy(boolean extension) { - return null; // TODO: Implement - } - @Nullable @Override public File getResetFile() { - return null; // TODO: Implement + return prototype.getSkinMap().get(skin).getBuildSchematicFile(); } @Override public void reset(PasteBuilder pasteBuilder, boolean extension) { - // TODO: Implement + pasteBuilder.reset(extension) + .minPoint(getMinPoint(extension)) + .maxPoint(getMaxPoint(extension)) + .waterLevel(waterLevel); + if (pasteBuilder.getClipboardProvider().is(PasteBuilder.SchematicProvider.class)) { + SchematicType schematicType = pasteBuilder.getClipboardProvider().as(PasteBuilder.SchematicProvider.class).getSchematic().getSchemtype(); + pasteBuilder.rotate(schematicType.fightType() || schematicType.check()); + } + pasteBuilder.pastePoint(minPointBuild.add(prototype.getBuild().getSizeX() / 2, 0, prototype.getBuild().getSizeZ() / 2)); + regionHistory.remember(pasteBuilder.run()); } }; } else { @@ -181,21 +189,37 @@ public class FixedRegion implements Region { return copyPoint; } - @Nullable - @Override - public EditSession copy(boolean extension) { - return null; // TODO: Implement - } - @Nullable @Override public File getResetFile() { - return null; // TODO: Implement + return prototype.getSkinMap().get(skin).getTestblockSchematicFile(); } @Override public void reset(PasteBuilder pasteBuilder, boolean extension) { - // TODO: Implement + pasteBuilder.reset(extension) + .minPoint(getMinPoint(extension)) + .maxPoint(getMaxPoint(extension)) + .waterLevel(waterLevel); + if (pasteBuilder.getClipboardProvider().is(PasteBuilder.SchematicProvider.class)) { + SchematicType schematicType = pasteBuilder.getClipboardProvider().as(PasteBuilder.SchematicProvider.class).getSchematic().getSchemtype(); + pasteBuilder.rotate(schematicType.fightType() || schematicType.check()); + } + Point pastePoint = minPointTestblock.add(prototype.getTestblock().getSizeX() / 2, 0, prototype.getTestblock().getSizeZ() / 2); + if (pasteBuilder.getClipboardProvider().is(PasteBuilder.SchematicProvider.class)) { + SchematicType schematicType = pasteBuilder.getClipboardProvider().as(PasteBuilder.SchematicProvider.class).getSchematic().getSchemtype(); + if (schematicType.getKuerzel().equalsIgnoreCase("wg")) { + pastePoint = pastePoint.add(0, 0, 1); + } + if (schematicType.getKuerzel().equalsIgnoreCase("ws")) { + pastePoint = pastePoint.add(-1, 0, 1); + } + if (schematicType.getKuerzel().equalsIgnoreCase("as")) { + pastePoint = pastePoint.add(-1, 0, 1); + } + } + pasteBuilder.pastePoint(pastePoint); + regionHistory.remember(pasteBuilder.run()); } }; } else {