forked from SteamWar/SteamWar
Add MiWG7DisplayRegion
This commit is contained in:
+35
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<Material, String> GAME_MODE_CONFIG;
|
||||
|
||||
static {
|
||||
GameModeConfig<Material, String> config = GameModeConfig.getByGameName("MicroWarGear");
|
||||
GAME_MODE_CONFIG = config != null ? config : GameModeConfig.getDefaults();
|
||||
}
|
||||
}
|
||||
+79
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+103
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<Material, String> 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user