forked from SteamWar/SteamWar
Fix WetRegion -> WetRegionData
Fix DynamicRegionSystem.get Add Fallback.schem for PathArea
This commit is contained in:
+17
-13
@@ -144,21 +144,25 @@ public class DynamicRegionRepository {
|
||||
continue;
|
||||
}
|
||||
Location minTileLocation = tile.getMinLocation();
|
||||
constructRegion(regionClass, regionUUID, minTileLocation.getBlockX(), minTileLocation.getBlockZ());
|
||||
}
|
||||
}
|
||||
|
||||
Constructor<? extends DynamicRegion> regionConstructor;
|
||||
try {
|
||||
regionConstructor = regionClass.getConstructor(UUID.class, int.class, int.class);
|
||||
} catch (NoSuchMethodException e) {
|
||||
RegionSystem.LOGGER.log(Level.SEVERE, "Failed to read region metadata file (region constructor not found)");
|
||||
continue;
|
||||
}
|
||||
public static DynamicRegion constructRegion(Class<? extends DynamicRegion> clazz, UUID uuid, int minX, int minZ) {
|
||||
Constructor<? extends DynamicRegion> regionConstructor;
|
||||
try {
|
||||
regionConstructor = clazz.getConstructor(UUID.class, int.class, int.class);
|
||||
} catch (NoSuchMethodException e) {
|
||||
RegionSystem.LOGGER.log(Level.SEVERE, "Failed to read region metadata file (region constructor not found)");
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
regionConstructor.newInstance(regionUUID, minTileLocation.getBlockX(), minTileLocation.getBlockZ());
|
||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException |
|
||||
InvocationTargetException e) {
|
||||
RegionSystem.LOGGER.log(Level.SEVERE, "Failed to read region metadata file (invalid data)");
|
||||
}
|
||||
try {
|
||||
return regionConstructor.newInstance(uuid, minX, minZ);
|
||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException |
|
||||
InvocationTargetException e) {
|
||||
RegionSystem.LOGGER.log(Level.SEVERE, "Failed to read region metadata file (invalid data)");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
-8
@@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.bausystem.region.dynamic.path;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.DynamicRegionSystem;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
@@ -42,6 +43,7 @@ import static de.steamwar.bausystem.region.RegionType.ConnectionType.*;
|
||||
public class PathArea implements Region.Area {
|
||||
|
||||
private static final File PATH_DIR = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/path");
|
||||
private static final File FALLBACK_SCHEM = new File(PATH_DIR, "Fallback.schem");
|
||||
|
||||
private static final VariantSelector CENTER_NORMAL = VariantSelector.Get(new File(PATH_DIR, "center/normal"));
|
||||
private static final VariantSelector SIDE_GLOBAL = VariantSelector.Get(new File(PATH_DIR, "side/global"));
|
||||
@@ -151,10 +153,11 @@ public class PathArea implements Region.Area {
|
||||
|
||||
for (Side side : Side.values()) {
|
||||
VariantSelector selector = SELECTOR_SIDE.Select(tile, side);
|
||||
if (selector == null) continue;
|
||||
|
||||
resetFile = selector.select(regionIdentifier, side.ordinal() + side.rotate).orElse(null);
|
||||
if (resetFile == null) continue;
|
||||
if (selector != null) resetFile = selector.select(regionIdentifier, side.ordinal() + side.rotate).orElse(null);
|
||||
if (selector == null || resetFile == null) {
|
||||
if (!BauSystem.DEV_SERVER) continue;
|
||||
resetFile = FALLBACK_SCHEM;
|
||||
}
|
||||
|
||||
PasteUtils.paste(resetFile, minPoint.add(side.pasteOffsetX, 0, side.pasteOffsetZ), side.rotate);
|
||||
}
|
||||
@@ -162,11 +165,13 @@ public class PathArea implements Region.Area {
|
||||
for (Corner corner : Corner.values()) {
|
||||
Pair<VariantSelector, RotationCorrection> pair = SELECTOR_CORNER.Select(tile, corner);
|
||||
VariantSelector selector = pair.getKey();
|
||||
if (selector == null) continue;
|
||||
RotationCorrection rotationCorrection = pair.getValue();
|
||||
|
||||
resetFile = selector.select(regionIdentifier, corner.side1.ordinal() * corner.side2.ordinal() + corner.side1.rotate * corner.side2.rotate).orElse(null);
|
||||
if (resetFile == null) continue;
|
||||
if (selector != null) resetFile = selector.select(regionIdentifier, corner.side1.ordinal() * corner.side2.ordinal() + corner.side1.rotate * corner.side2.rotate).orElse(null);
|
||||
if (selector == null || resetFile == null) {
|
||||
if (!BauSystem.DEV_SERVER) continue;
|
||||
resetFile = FALLBACK_SCHEM;
|
||||
rotationCorrection = RotationCorrection.Unchanged;
|
||||
}
|
||||
|
||||
int rotate = corner.rotate;
|
||||
switch (rotationCorrection) {
|
||||
|
||||
+1
-2
@@ -25,7 +25,6 @@ import de.steamwar.bausystem.region.RegionHistory;
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
import de.steamwar.bausystem.region.dynamic.*;
|
||||
import de.steamwar.bausystem.region.dynamic.special.SpecialArea;
|
||||
import de.steamwar.bausystem.region.dynamic.special.SpecialRegionData;
|
||||
import de.steamwar.sql.GameModeConfig;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Material;
|
||||
@@ -53,7 +52,7 @@ public class WetRegion extends DynamicRegion {
|
||||
@Override
|
||||
public void init() {
|
||||
area = new SpecialArea(Tile.fromXZ(minX, minZ).orElseThrow(), this, WET);
|
||||
regionData = new SpecialRegionData(this);
|
||||
regionData = new WetRegionData(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.region.dynamic.special.wet;
|
||||
|
||||
import de.steamwar.bausystem.region.RegionFlagPolicy;
|
||||
import de.steamwar.bausystem.region.dynamic.DynamicRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.special.SpecialRegionData;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.ProtectMode;
|
||||
import lombok.NonNull;
|
||||
|
||||
public class WetRegionData extends SpecialRegionData {
|
||||
|
||||
public WetRegionData(DynamicRegion region) {
|
||||
super(region);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize() {
|
||||
flagMap.put(Flag.PROTECT, ProtectMode.INACTIVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull <T extends Enum<T> & Flag.Value<T>> RegionFlagPolicy has(@NonNull Flag<T> flag) {
|
||||
if (flag.oneOf(Flag.PROTECT)) return RegionFlagPolicy.NOT_APPLICABLE;
|
||||
return super.has(flag);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user