diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/microwargear_7/MiWG7Utils.java b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/microwargear_7/MiWG7Utils.java new file mode 100644 index 00000000..b7bbbfa2 --- /dev/null +++ b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/microwargear_7/MiWG7Utils.java @@ -0,0 +1,35 @@ +/* + * 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 . + */ + +package de.steamwar.bausystem.region.dynamic.modes.microwargear_7; + +import de.steamwar.sql.GameModeConfig; +import lombok.experimental.UtilityClass; +import org.bukkit.Material; + +@UtilityClass +public class MiWG7Utils { + + public static final GameModeConfig GAME_MODE_CONFIG; + + static { + GameModeConfig config = GameModeConfig.getByGameName("MicroWarGear"); + GAME_MODE_CONFIG = config != null ? config : GameModeConfig.getDefaults(); + } +} diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/microwargear_7/display/.gitkeep b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/microwargear_7/display/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/microwargear_7/display/MiWG7DisplayArea.java b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/microwargear_7/display/MiWG7DisplayArea.java new file mode 100644 index 00000000..d7abd45e --- /dev/null +++ b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/microwargear_7/display/MiWG7DisplayArea.java @@ -0,0 +1,79 @@ +/* + * 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 . + */ + +package de.steamwar.bausystem.region.dynamic.modes.microwargear_7.display; + +import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.dynamic.PasteUtils; +import de.steamwar.bausystem.region.dynamic.Tile; +import de.steamwar.bausystem.region.dynamic.VariantSelector; +import de.steamwar.bausystem.utils.PasteBuilder; +import lombok.NonNull; +import org.bukkit.Bukkit; +import org.jetbrains.annotations.Nullable; + +import java.io.File; +import java.util.UUID; + +public class MiWG7DisplayArea implements Region.Area { + + private static final File DIRECTORY = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/microwargear_7/display"); + private static final VariantSelector SELECTOR = VariantSelector.Get(DIRECTORY); + + private final UUID regionIdentifier; + private final Point minPoint; + private final Point maxPoint; + private final Point copyPoint; + + public MiWG7DisplayArea(Tile tile, MiWG7DisplayRegion region) { + this.regionIdentifier = region.getID(); + minPoint = Point.fromLocation(tile.getMinLocation()).setY(WORLD_MIN_Y); + maxPoint = Point.fromLocation(tile.getMaxLocation()).setY(WORLD_MAX_Y); + copyPoint = Point.fromLocation(tile.getCenterLocation()); + } + + @Override + public @NonNull Point getMinPoint(boolean extension) { + return minPoint; + } + + @Override + public @NonNull Point getMaxPoint(boolean extension) { + return maxPoint; + } + + @Override + public @NonNull Point getCopyPoint() { + return copyPoint; + } + + @Override + public @Nullable File getResetFile() { + return null; + } + + @Override + public void place(PasteBuilder pasteBuilder, boolean extension) { + File resetFile = SELECTOR.select(regionIdentifier, 0).orElse(null); + if (resetFile != null) { + PasteUtils.paste(resetFile, minPoint, 0); + } + } +} diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/microwargear_7/display/MiWG7DisplayRegion.java b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/microwargear_7/display/MiWG7DisplayRegion.java new file mode 100644 index 00000000..b73c0ce6 --- /dev/null +++ b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/modes/microwargear_7/display/MiWG7DisplayRegion.java @@ -0,0 +1,103 @@ +/* + * 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 . + */ + +package de.steamwar.bausystem.region.dynamic.modes.microwargear_7.display; + +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.dynamic.DynamicRegion; +import de.steamwar.bausystem.region.dynamic.DynamicRegionRepository; +import de.steamwar.bausystem.region.dynamic.RegionConstructorData; +import de.steamwar.bausystem.region.dynamic.Tile; +import de.steamwar.bausystem.region.dynamic.modes.DisplayRegionData; +import de.steamwar.bausystem.region.dynamic.modes.microwargear_7.MiWG7Utils; +import de.steamwar.sql.GameModeConfig; +import lombok.NonNull; +import org.bukkit.Material; + +import java.util.UUID; + +@RegionConstructorData( + identifier = "microwargear_display", + widthX = Tile.tileSize, + widthZ = Tile.tileSize +) +public class MiWG7DisplayRegion extends DynamicRegion { + + private MiWG7DisplayArea area; + private Tile tile; + + public MiWG7DisplayRegion(UUID id, int minX, int minZ) { + super(id, minX, minZ); + } + + @Override + public void init() { + tile = Tile.fromXZ(minX, minZ).orElseThrow(); + area = new MiWG7DisplayArea(tile, this); + regionData = new DisplayRegionData(this); + } + + @Override + public @NonNull RegionType getType() { + return RegionType.DRY; + } + + @Override + public @NonNull Area getArea() { + return area; + } + + @Override + public @NonNull Area getBuildArea() { + return Area.EMPTY; + } + + @Override + public @NonNull Area getTestblockArea() { + return Area.EMPTY; + } + + @Override + public @NonNull GameModeConfig getGameModeConfig() { + return MiWG7Utils.GAME_MODE_CONFIG; + } + + @Override + public @NonNull RegionHistory getHistory() { + return RegionHistory.EMPTY; + } + + @Override + public @NonNull RegionBackups getBackups() { + return RegionBackups.EMPTY; + } + + @Override + public void save() { + DynamicRegionRepository.saveRegion(this); + } + + @Override + public void load(RegionData regionData) { + DynamicRegionRepository.loadRegionData(this, regionData); + } +}