From 7b22c9af63466ffba212849bfffd466e69c4caec Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 21 Mar 2026 18:05:47 +0100 Subject: [PATCH] Implement WG45PlotRegion Implement WS175PlotRegion --- .../bausystem/region/DynamicRegionSystem.java | 2 +- .../region/dynamic/modes/AreaBlock.java | 2 +- .../modes/wargear_45/WG45PlotRegion.java | 28 +++++++++--------- .../modes/warship_175/WS175PlotRegion.java | 29 +++++++++---------- 4 files changed, 30 insertions(+), 31 deletions(-) diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionSystem.java b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionSystem.java index 767fd125..16393b68 100644 --- a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionSystem.java +++ b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionSystem.java @@ -155,7 +155,7 @@ public class DynamicRegionSystem implements RegionSystem { } public @NonNull Stream getRegionsByType(RegionType type) { - return regionTypeMap.get(type).stream(); + return regionTypeMap.getOrDefault(type, Collections.emptySet()).stream(); } private Stream> getNeighbours(Region region, boolean noCorners, boolean fastCache, Collection regions) { diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/AreaBlock.java b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/AreaBlock.java index 53c32c95..93febf5b 100644 --- a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/AreaBlock.java +++ b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/AreaBlock.java @@ -58,7 +58,7 @@ public class AreaBlock implements Region.Area { int tempSizeZ = switch (copyLocation) { case CENTER -> size.getZ() * 2 + distance; - case SIDE -> size.getZ() + distance; + case SIDE -> size.getZ() + distance - 1; }; // Calculate Offset Region to North diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/wargear_45/WG45PlotRegion.java b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/wargear_45/WG45PlotRegion.java index d67023d4..da663d7e 100644 --- a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/wargear_45/WG45PlotRegion.java +++ b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/wargear_45/WG45PlotRegion.java @@ -19,17 +19,16 @@ package de.steamwar.bausystem.region.dynamic.modes.wargear_45; -import de.steamwar.bausystem.region.RegionBackups; -import de.steamwar.bausystem.region.RegionData; -import de.steamwar.bausystem.region.RegionHistory; -import de.steamwar.bausystem.region.RegionType; +import de.steamwar.bausystem.region.*; import de.steamwar.bausystem.region.dynamic.*; +import de.steamwar.bausystem.region.dynamic.modes.AreaBlock; import de.steamwar.bausystem.region.dynamic.modes.AreaTile; import de.steamwar.bausystem.region.dynamic.modes.PlotRegionBackups; import de.steamwar.bausystem.region.dynamic.modes.PlotRegionData; import de.steamwar.bausystem.region.dynamic.modes.miniwargear.MWGUtils; import de.steamwar.bausystem.region.dynamic.modes.warship_230.WS230Utils; import de.steamwar.bausystem.region.flags.Flag; +import de.steamwar.bausystem.shared.Pair; import de.steamwar.sql.GameModeConfig; import lombok.NonNull; import org.bukkit.Bukkit; @@ -56,8 +55,8 @@ public class WG45PlotRegion extends DynamicRegion { private static final VariantSelector WIREFRAME = VariantSelector.Get(new File(DIRECTORY, "wireframe")); private final AreaTile area; - private final Area northArea; - private final Area southArea; + private final AreaBlock northArea; + private final AreaBlock southArea; private final RegionHistory history; private final RegionBackups backups; @@ -65,10 +64,11 @@ public class WG45PlotRegion extends DynamicRegion { super(id, minX, minZ); Tile tile = Tile.fromXZ(minX, minZ).orElseThrow(); area = new AreaTile(tile, TILE_X, TILE_Z, this, REGION); - // northArea = new AreaBlock(); - // southArea = new AreaBlock(); - northArea = Area.EMPTY; // TODO: Replace! - southArea = Area.EMPTY; // TODO: Replace! + + Pair pair = AreaBlock.create(this, 36, new Point(67, 41, 47), new Point(16, 0, 16), new Point(16, 16, 16), AreaBlock.CopyLocation.CENTER, 50); + northArea = pair.getKey(); + southArea = pair.getValue(); + regionData = new PlotRegionData(this); history = new RegionHistory.Impl(10); backups = new PlotRegionBackups(this, PlotRegionData::new); @@ -89,8 +89,8 @@ public class WG45PlotRegion extends DynamicRegion { public @NonNull Area getBuildArea() { return switch (regionData.get(Flag.TESTBLOCK).getWithDefault()) { case NO_VALUE -> Area.EMPTY; - case NORTH -> northArea;//.withSelector(WIREFRAME); - case SOUTH -> southArea;//.withSelector(WIREFRAME); + case NORTH -> southArea.withSelector(WIREFRAME); + case SOUTH -> northArea.withSelector(WIREFRAME); }; } @@ -98,8 +98,8 @@ public class WG45PlotRegion extends DynamicRegion { public @NonNull Area getTestblockArea() { return switch (regionData.get(Flag.TESTBLOCK).getWithDefault()) { case NO_VALUE -> Area.EMPTY; - case NORTH -> southArea;//.withSelector(TESTBLOCK); - case SOUTH -> northArea;//.withSelector(TESTBLOCK); + case NORTH -> northArea.withSelector(TESTBLOCK); + case SOUTH -> southArea.withSelector(TESTBLOCK); }; } diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/warship_175/WS175PlotRegion.java b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/warship_175/WS175PlotRegion.java index a30e97f5..9cf41ed1 100644 --- a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/warship_175/WS175PlotRegion.java +++ b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/warship_175/WS175PlotRegion.java @@ -19,16 +19,14 @@ package de.steamwar.bausystem.region.dynamic.modes.warship_175; -import de.steamwar.bausystem.region.RegionBackups; -import de.steamwar.bausystem.region.RegionData; -import de.steamwar.bausystem.region.RegionHistory; -import de.steamwar.bausystem.region.RegionType; +import de.steamwar.bausystem.region.*; import de.steamwar.bausystem.region.dynamic.*; +import de.steamwar.bausystem.region.dynamic.modes.AreaBlock; import de.steamwar.bausystem.region.dynamic.modes.AreaTile; import de.steamwar.bausystem.region.dynamic.modes.PlotRegionBackups; import de.steamwar.bausystem.region.dynamic.modes.PlotRegionData; -import de.steamwar.bausystem.region.dynamic.modes.miniwargear.MWGUtils; import de.steamwar.bausystem.region.flags.Flag; +import de.steamwar.bausystem.shared.Pair; import de.steamwar.sql.GameModeConfig; import lombok.NonNull; import org.bukkit.Bukkit; @@ -55,8 +53,8 @@ public class WS175PlotRegion extends DynamicRegion { private static final VariantSelector WIREFRAME = VariantSelector.Get(new File(DIRECTORY, "wireframe")); private final AreaTile area; - private final Area northArea; - private final Area southArea; + private final AreaBlock northArea; + private final AreaBlock southArea; private final RegionHistory history; private final RegionBackups backups; @@ -64,10 +62,11 @@ public class WS175PlotRegion extends DynamicRegion { super(id, minX, minZ); Tile tile = Tile.fromXZ(minX, minZ).orElseThrow(); area = new AreaTile(tile, TILE_X, TILE_Z, this, REGION); - // northArea = new AreaBlock(); - // southArea = new AreaBlock(); - northArea = Area.EMPTY; // TODO: Replace! - southArea = Area.EMPTY; // TODO: Replace! + + Pair pair = AreaBlock.create(this, 36, new Point(175, 58, 39), new Point(0, 0, 0), new Point(0, 0, 0), AreaBlock.CopyLocation.SIDE, 132); + northArea = pair.getKey(); + southArea = pair.getValue(); + regionData = new PlotRegionData(this); history = new RegionHistory.Impl(10); backups = new PlotRegionBackups(this, PlotRegionData::new); @@ -88,8 +87,8 @@ public class WS175PlotRegion extends DynamicRegion { public @NonNull Area getBuildArea() { return switch (regionData.get(Flag.TESTBLOCK).getWithDefault()) { case NO_VALUE -> Area.EMPTY; - case NORTH -> northArea;//.withSelector(WIREFRAME); - case SOUTH -> southArea;//.withSelector(WIREFRAME); + case NORTH -> southArea.withSelector(WIREFRAME); + case SOUTH -> northArea.withSelector(WIREFRAME); }; } @@ -97,8 +96,8 @@ public class WS175PlotRegion extends DynamicRegion { public @NonNull Area getTestblockArea() { return switch (regionData.get(Flag.TESTBLOCK).getWithDefault()) { case NO_VALUE -> Area.EMPTY; - case NORTH -> southArea;//.withSelector(TESTBLOCK); - case SOUTH -> northArea;//.withSelector(TESTBLOCK); + case NORTH -> northArea.withSelector(TESTBLOCK); + case SOUTH -> southArea.withSelector(TESTBLOCK); }; }