Add MicroWarGear21Region
Add MiniWarGear21Region Add WarGear21Region Add WarShip21Region
This commit is contained in:
@@ -171,9 +171,9 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
||||
ClipboardHolder ch = new ClipboardHolder(clipboard);
|
||||
BlockVector3 dimensions = clipboard.getDimensions();
|
||||
BlockVector3 v;
|
||||
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
||||
if (pasteBuilder.getPastPoint() != null) {
|
||||
v = pasteBuilder.getPastPoint().toBlockVector3();
|
||||
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
||||
if (pasteBuilder.isRotate()) {
|
||||
ch.setTransform(new AffineTransform().rotateY(180));
|
||||
v = v.add(dimensions.getX() / 2, 0, dimensions.getZ() / 2).subtract(offset.multiply(-1, 1, -1)).subtract(0, 0, 1);
|
||||
@@ -181,8 +181,7 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
||||
v = v.subtract(dimensions.getX() / 2, 0, dimensions.getZ() / 2).subtract(offset);
|
||||
}
|
||||
} else {
|
||||
v = pasteBuilder.getMinPoint().toBlockVector3();
|
||||
clipboard.setOrigin(v);
|
||||
v = pasteBuilder.getMinPoint().toBlockVector3().subtract(offset);
|
||||
}
|
||||
pastePoint.set(v);
|
||||
|
||||
|
||||
@@ -21,9 +21,11 @@ package de.steamwar.bausystem.features.region;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.config.BauServer;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.TestblockMode;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
@@ -173,6 +175,17 @@ public class TestblockCommand extends SWCommand {
|
||||
|
||||
private Region regionCheck(Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region.getFlags().has(Flag.TESTBLOCK).isWritable() && region.getFlags().get(Flag.TESTBLOCK).isWithDefault(TestblockMode.NO_VALUE)) {
|
||||
Point minPoint = region.getArea().getMinPoint(false);
|
||||
Point maxPoint = region.getArea().getMaxPoint(false);
|
||||
// TODO: Check if empty!
|
||||
int half = minPoint.getZ() + (maxPoint.getZ() - minPoint.getZ()) / 2;
|
||||
if (player.getLocation().getBlockZ() <= half) {
|
||||
region.getFlags().set(Flag.TESTBLOCK, TestblockMode.SOUTH);
|
||||
} else {
|
||||
region.getFlags().set(Flag.TESTBLOCK, TestblockMode.NORTH);
|
||||
}
|
||||
}
|
||||
if (region.getTestblockArea().isEmpty()) {
|
||||
BauSystem.MESSAGE.send("REGION_TB_NO_REGION", player);
|
||||
return null;
|
||||
|
||||
@@ -121,8 +121,8 @@ public class BauScoreboard implements Listener {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region.getType().isGlobal()) return "§eSteam§8War";
|
||||
String colorCode = "§e";
|
||||
if (region.getRegionData().has(Flag.COLOR).isReadable()) {
|
||||
colorCode = "§" + region.getRegionData().get(Flag.COLOR).orElse(ColorMode.PINK).getColorCode();
|
||||
if (region.getFlags().has(Flag.COLOR).isReadable()) {
|
||||
colorCode = "§" + region.getFlags().get(Flag.COLOR).getWithDefault().getColorCode();
|
||||
}
|
||||
return colorCode + "■ §eSteam§8War " + colorCode + "■"; // ■
|
||||
}
|
||||
|
||||
@@ -27,12 +27,19 @@ import lombok.RequiredArgsConstructor;
|
||||
public enum RegionType {
|
||||
|
||||
GLOBAL(true, false, true, ConnectionType.Global),
|
||||
/**
|
||||
* This should not be used by the DynamicRegionSystem
|
||||
*/
|
||||
NORMAL(false, true, false, ConnectionType.Closed),
|
||||
|
||||
SPAWN(false, false, true, ConnectionType.Closed),
|
||||
SPAWN_PATH(false, false, true, ConnectionType.Path),
|
||||
SPAWN_EXTENSION(false, false, false, ConnectionType.Closed),
|
||||
PATH(false, false, false, ConnectionType.Path),
|
||||
DRY(false, true, false, ConnectionType.Closed),
|
||||
DRY_SPECIAL(false, false, false, ConnectionType.Closed),
|
||||
WET(false, true, false, ConnectionType.Water),
|
||||
WET_SPECIAL(false, false, false, ConnectionType.Water),
|
||||
;
|
||||
|
||||
private final boolean global;
|
||||
|
||||
@@ -22,12 +22,20 @@ package de.steamwar.bausystem.region;
|
||||
import de.steamwar.bausystem.features.region.RegionCommand;
|
||||
import de.steamwar.bausystem.region.dynamic.DynamicRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.TileUtils;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.work.MicroWarGear21Region;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.work.MiniWarGear21Region;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.work.WarGear21Region;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.work.WarShip21Region;
|
||||
import de.steamwar.bausystem.region.dynamic.path.PathRegion;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.command.AbstractSWCommand;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@AbstractSWCommand.PartOf(RegionCommand.class)
|
||||
@@ -38,15 +46,68 @@ public class DynamicRegionCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register({"dynamic", "place"})
|
||||
public void placeRegion(Player player) {
|
||||
public void placeRegion(Player player, Placement placement) {
|
||||
Region region = DynamicRegionSystem.INSTANCE.get(player.getLocation());
|
||||
if (!region.getType().isGlobal()) return;
|
||||
Pair<Integer, Integer> tile = TileUtils.fromLocation(player.getLocation());
|
||||
Pair<Integer, Integer> min = TileUtils.toMinLocation(tile);
|
||||
PathRegion pathRegion = new PathRegion(min.getKey(), min.getValue());
|
||||
pathRegion.getArea().reset(null, false);
|
||||
DynamicRegionSystem.INSTANCE.getNeighbours(pathRegion).collect(Collectors.toList())
|
||||
.forEach(r -> r.update(pathRegion));
|
||||
Pair<Integer, Integer> placePosition = placePosition(tile, placement);
|
||||
if (placePosition == null) return;
|
||||
Pair<Integer, Integer> min = TileUtils.toMinLocation(placePosition);
|
||||
|
||||
DynamicRegion dynamicRegion = placement.constructor.apply(min.getKey(), min.getValue());
|
||||
dynamicRegion.getArea().reset(new PasteBuilder(new PasteBuilder.FileProvider(dynamicRegion.getArea().getResetFile())), false);
|
||||
DynamicRegionSystem.INSTANCE.getNeighbours(dynamicRegion).collect(Collectors.toList())
|
||||
.forEach(r -> r.update(dynamicRegion));
|
||||
}
|
||||
|
||||
private Pair<Integer, Integer> placePosition(Pair<Integer, Integer> sourceTile, Placement placement) {
|
||||
Map<Pair<Integer, Integer>, Region> regionCache = new HashMap<>();
|
||||
Set<Pair<Integer, Integer>> seen = new HashSet<>();
|
||||
LinkedHashSet<Pair<Integer, Integer>> currentTile = new LinkedHashSet<>();
|
||||
currentTile.add(sourceTile);
|
||||
while (!currentTile.isEmpty() && currentTile.size() < (placement.widthX * 2 / 19) * (placement.widthZ * 2 / 19)) {
|
||||
Pair<Integer, Integer> tile = currentTile.removeFirst();
|
||||
if (!seen.add(tile)) continue;
|
||||
if (canPlace(tile, placement, regionCache)) {
|
||||
return tile;
|
||||
}
|
||||
|
||||
for (int dx = -1; dx <= 1; dx++) {
|
||||
for (int dz = -1; dz <= 1; dz++) {
|
||||
if (dx == 0 && dz == 0) continue;
|
||||
Pair<Integer, Integer> nextTile = new Pair<>(tile.getKey() + dx, tile.getValue() + dz);
|
||||
Region region = regionCache.computeIfAbsent(nextTile, tilePair -> Region.getRegion(TileUtils.toMinLocation(tilePair.getKey(), tilePair.getValue())));
|
||||
if (region.getType().isGlobal()) currentTile.add(nextTile);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean canPlace(Pair<Integer, Integer> tile, Placement placement, Map<Pair<Integer, Integer>, Region> regionCache) {
|
||||
for (int x = tile.getKey(); x < tile.getKey() + placement.widthX / TileUtils.tileSize; x++) {
|
||||
for (int z = tile.getValue(); z < tile.getValue() + placement.widthZ / TileUtils.tileSize; z++) {
|
||||
Region region = regionCache.computeIfAbsent(new Pair<>(x, z), tilePair -> Region.getRegion(TileUtils.toMinLocation(tilePair.getKey(), tilePair.getValue())));
|
||||
if (region.getType().isGlobal()) continue;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public enum Placement {
|
||||
Path(PathRegion::new, 19, 19),
|
||||
WarGear21(WarGear21Region::new, WarGear21Region.widthX, WarGear21Region.widthZ),
|
||||
MiniWarGear21(MiniWarGear21Region::new, MiniWarGear21Region.widthX, MiniWarGear21Region.widthZ),
|
||||
WarShip21(WarShip21Region::new, WarShip21Region.widthX, WarShip21Region.widthZ),
|
||||
MicroWarGear21(MicroWarGear21Region::new, MicroWarGear21Region.widthX, MicroWarGear21Region.widthZ),
|
||||
;
|
||||
|
||||
private final BiFunction<Integer, Integer, DynamicRegion> constructor;
|
||||
private final int widthX;
|
||||
private final int widthZ;
|
||||
}
|
||||
|
||||
@Register({"dynamic", "delete"})
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import de.steamwar.bausystem.region.*;
|
||||
import lombok.NonNull;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -33,14 +33,16 @@ import java.util.stream.Collectors;
|
||||
|
||||
public abstract class DynamicRegion implements Region {
|
||||
|
||||
protected final UUID id;
|
||||
@Getter
|
||||
protected final UUID ID;
|
||||
protected final int minX;
|
||||
protected final int minZ;
|
||||
|
||||
@Getter
|
||||
protected final RegionBackups backups;
|
||||
|
||||
protected DynamicRegion(int minX, int minZ) {
|
||||
this.id = UUID.randomUUID();
|
||||
this.ID = UUID.randomUUID();
|
||||
this.minX = minX;
|
||||
this.minZ = minZ;
|
||||
backups = RegionDataRepository.getBackups(this);
|
||||
@@ -49,7 +51,7 @@ public abstract class DynamicRegion implements Region {
|
||||
}
|
||||
|
||||
protected DynamicRegion(RegionConstructorData regionConstructorData) {
|
||||
this.id = regionConstructorData.uuid;
|
||||
this.ID = regionConstructorData.uuid;
|
||||
this.minX = regionConstructorData.minX;
|
||||
this.minZ = regionConstructorData.minZ;
|
||||
backups = RegionDataRepository.getBackups(this);
|
||||
@@ -59,17 +61,12 @@ public abstract class DynamicRegion implements Region {
|
||||
public RegionConstructorData getRegionConstructorData() {
|
||||
return new RegionConstructorData.RegionConstructorDataBuilder()
|
||||
.regionClass(this.getClass().getSimpleName())
|
||||
.uuid(id)
|
||||
.uuid(ID)
|
||||
.minX(minX)
|
||||
.minZ(minZ)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull UUID getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public abstract void update(DynamicRegion updateFrom);
|
||||
|
||||
public abstract void setFlags(FlagStorage flags);
|
||||
@@ -96,9 +93,4 @@ public abstract class DynamicRegion implements Region {
|
||||
DynamicRegionSystem.INSTANCE.getNeighbours(this).collect(Collectors.toList())
|
||||
.forEach(region -> region.update(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull RegionBackups getBackups() {
|
||||
return backups;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,10 @@ import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionBackups;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.NormalFlagStorage;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.work.MicroWarGear21Region;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.work.MiniWarGear21Region;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.work.WarGear21Region;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.work.WarShip21Region;
|
||||
import de.steamwar.bausystem.region.dynamic.path.PathRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.spawn.SpawnPathRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.spawn.SpawnRegion;
|
||||
@@ -68,6 +72,10 @@ public class RegionDataRepository {
|
||||
regionCreators.put(SpawnRegion.class.getSimpleName(), SpawnRegion::new);
|
||||
regionCreators.put(SpawnPathRegion.class.getSimpleName(), SpawnPathRegion::new);
|
||||
regionCreators.put(PathRegion.class.getSimpleName(), PathRegion::new);
|
||||
regionCreators.put(WarGear21Region.class.getSimpleName(), WarGear21Region::new);
|
||||
regionCreators.put(MiniWarGear21Region.class.getSimpleName(), MiniWarGear21Region::new);
|
||||
regionCreators.put(WarShip21Region.class.getSimpleName(), WarShip21Region::new);
|
||||
regionCreators.put(MicroWarGear21Region.class.getSimpleName(), MicroWarGear21Region::new);
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
@@ -26,9 +26,9 @@ import org.bukkit.Location;
|
||||
@UtilityClass
|
||||
public class TileUtils {
|
||||
|
||||
private static final int tileSize = 19;
|
||||
private static final int minTile = -1023;
|
||||
private static final int maxTile = 1023;
|
||||
public static final int tileSize = 19;
|
||||
public static final int minTile = -1023;
|
||||
public static final int maxTile = 1023;
|
||||
|
||||
public Pair<Integer, Integer> fromLocation(Location location) {
|
||||
int x = (int) Math.floor((location.getBlockX() + 9) / (double) tileSize);
|
||||
@@ -41,4 +41,8 @@ public class TileUtils {
|
||||
public Pair<Integer, Integer> toMinLocation(Pair<Integer, Integer> tile) {
|
||||
return new Pair<>(tile.getKey() * tileSize - 9, tile.getValue() * tileSize - 9);
|
||||
}
|
||||
|
||||
public Location toMinLocation(int tileX, int tileZ) {
|
||||
return new Location(null, tileX * tileSize - 9, 0, tileZ * tileSize - 9);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.normal;
|
||||
|
||||
public class DisplayRegion {
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.normal;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public abstract class NormalArea implements Region.Area {
|
||||
|
||||
public abstract NormalArea setResetFile(File resetFile);
|
||||
|
||||
public static final NormalArea EMPTY = new NormalArea() {
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getMinPoint(boolean extension) {
|
||||
return Point.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getMaxPoint(boolean extension) {
|
||||
return Point.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getCopyPoint() {
|
||||
return Point.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inRegion(Location location, boolean extension) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Clipboard copy(boolean extension) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NormalArea setResetFile(File resetFile) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getResetFile() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(PasteBuilder pasteBuilder, boolean extension) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachChunk(BiConsumer<Integer, Integer> executor) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunkOutside(int chunkX, int chunkZ) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.normal;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import lombok.NonNull;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
|
||||
public class WorkArea extends NormalArea {
|
||||
|
||||
private final int minX;
|
||||
private final int minY;
|
||||
private final int minZ;
|
||||
private final int widthX;
|
||||
private final int widthY;
|
||||
private final int widthZ;
|
||||
private File resetFile;
|
||||
private final Point minPoint;
|
||||
private final Point maxPoint;
|
||||
private final Point copyPoint;
|
||||
private final boolean rotate;
|
||||
private final Region region;
|
||||
|
||||
public WorkArea(int minX, int minY, int minZ, int widthX, int widthY, int widthZ, File resetFile, boolean rotate, Region region) {
|
||||
this.minX = minX;
|
||||
this.minY = minY;
|
||||
this.minZ = minZ;
|
||||
this.widthX = widthX;
|
||||
this.widthY = widthY;
|
||||
this.widthZ = widthZ;
|
||||
this.resetFile = resetFile;
|
||||
this.rotate = rotate;
|
||||
this.region = region;
|
||||
|
||||
minPoint = new Point(minX, minY, minZ);
|
||||
maxPoint = new Point(minX + widthX - 1, minY + widthY - 1, minZ + widthZ - 1);
|
||||
copyPoint = minPoint.add(widthX / 2, widthY, widthZ / 2);
|
||||
}
|
||||
|
||||
@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 NormalArea setResetFile(File resetFile) {
|
||||
this.resetFile = resetFile;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public File getResetFile() {
|
||||
return resetFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(PasteBuilder pasteBuilder, boolean extension) {
|
||||
EditSession editSession = pasteBuilder.minPoint(minPoint)
|
||||
.maxPoint(maxPoint)
|
||||
.rotate(rotate)
|
||||
.run();
|
||||
region.getHistory().remember(editSession);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.normal;
|
||||
|
||||
import de.steamwar.bausystem.region.FlagOptional;
|
||||
import de.steamwar.bausystem.region.FlagStorage;
|
||||
import de.steamwar.bausystem.region.RegionHistory;
|
||||
import de.steamwar.bausystem.region.dynamic.DynamicRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionConstructorData;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionDataRepository;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.TestblockMode;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public abstract class WorkRegion extends DynamicRegion {
|
||||
|
||||
@Getter
|
||||
private FlagStorage flags = new NormalFlagStorage();
|
||||
|
||||
@Getter
|
||||
protected NormalArea area = NormalArea.EMPTY;
|
||||
protected NormalArea northArea = NormalArea.EMPTY;
|
||||
protected NormalArea southArea = NormalArea.EMPTY;
|
||||
|
||||
protected File frame;
|
||||
protected File testblock;
|
||||
|
||||
@Getter
|
||||
private final RegionHistory history = new RegionHistory.Impl(20);
|
||||
|
||||
protected WorkRegion(int minX, int minZ) {
|
||||
super(minX, minZ);
|
||||
RegionDataRepository.loadFlagStorage(this, flags);
|
||||
}
|
||||
|
||||
protected WorkRegion(RegionConstructorData regionConstructorData) {
|
||||
super(regionConstructorData);
|
||||
RegionDataRepository.loadFlagStorage(this, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(DynamicRegion updateFrom) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlags(FlagStorage flags) {
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Area getBuildArea() {
|
||||
FlagOptional<TestblockMode> testblock = flags.get(Flag.TESTBLOCK);
|
||||
if (testblock.isWithDefault(TestblockMode.NO_VALUE)) {
|
||||
return Area.EMPTY;
|
||||
}
|
||||
if (testblock.isWithDefault(TestblockMode.SOUTH)) {
|
||||
return northArea.setResetFile(this.frame);
|
||||
} else {
|
||||
return southArea.setResetFile(this.frame);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Area getTestblockArea() {
|
||||
FlagOptional<TestblockMode> testblock = flags.get(Flag.TESTBLOCK);
|
||||
if (testblock.isWithDefault(TestblockMode.NO_VALUE)) {
|
||||
return Area.EMPTY;
|
||||
}
|
||||
if (testblock.isWithDefault(TestblockMode.SOUTH)) {
|
||||
return southArea.setResetFile(this.testblock);
|
||||
} else {
|
||||
return northArea.setResetFile(this.testblock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.normal.work;
|
||||
|
||||
import de.steamwar.bausystem.region.RegionConfig;
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionConstructorData;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.WorkArea;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.WorkRegion;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class MicroWarGear21Region extends WorkRegion {
|
||||
|
||||
public static final int widthX = 57;
|
||||
public static final int widthZ = 114;
|
||||
|
||||
private static final File MODE_DIR = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/regions/microwargear21/");
|
||||
private static final File REGION_FILE = new File(MODE_DIR, "Region.schem");
|
||||
private static final File FRAME_FILE = new File(MODE_DIR, "Frame.schem");
|
||||
private static final File TESTBLOCK_FILE = new File(MODE_DIR, "Testblock.schem");
|
||||
|
||||
@Getter
|
||||
private final RegionConfig gameModeConfig = new RegionConfig(null); // TODO: Implement
|
||||
|
||||
public MicroWarGear21Region(int minX, int minZ) {
|
||||
super(minX, minZ);
|
||||
area = new WorkArea(minX, 0, minZ, widthX, 255, widthZ, REGION_FILE, false, this);
|
||||
northArea = new WorkArea(minX + 25, 32, minZ + 25, 7, 7, 7, null, false, this);
|
||||
southArea = new WorkArea(minX + 25, 32, minZ + 82, 7, 7, 7, null, true, this);
|
||||
frame = FRAME_FILE;
|
||||
testblock = TESTBLOCK_FILE;
|
||||
}
|
||||
|
||||
public MicroWarGear21Region(RegionConstructorData regionConstructorData) {
|
||||
super(regionConstructorData);
|
||||
area = new WorkArea(minX, 0, minZ, widthX, 255, widthZ, REGION_FILE, false, this);
|
||||
northArea = new WorkArea(minX + 25, 32, minZ + 25, 7, 7, 7, null, false, this);
|
||||
southArea = new WorkArea(minX + 25, 32, minZ + 82, 7, 7, 7, null, true, this);
|
||||
frame = FRAME_FILE;
|
||||
testblock = TESTBLOCK_FILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull RegionType getType() {
|
||||
return RegionType.DRY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.normal.work;
|
||||
|
||||
import de.steamwar.bausystem.region.RegionConfig;
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionConstructorData;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.WorkArea;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.WorkRegion;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class MiniWarGear21Region extends WorkRegion {
|
||||
|
||||
public static final int widthX = 95;
|
||||
public static final int widthZ = 152;
|
||||
|
||||
private static final File MODE_DIR = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/regions/miniwargear21/");
|
||||
private static final File REGION_FILE = new File(MODE_DIR, "Region.schem");
|
||||
private static final File FRAME_FILE = new File(MODE_DIR, "Frame.schem");
|
||||
private static final File TESTBLOCK_FILE = new File(MODE_DIR, "Testblock.schem");
|
||||
|
||||
@Getter
|
||||
private final RegionConfig gameModeConfig = new RegionConfig(null); // TODO: Implement
|
||||
|
||||
public MiniWarGear21Region(int minX, int minZ) {
|
||||
super(minX, minZ);
|
||||
area = new WorkArea(minX, 0, minZ, widthX, 255, widthZ, REGION_FILE, false, this);
|
||||
northArea = new WorkArea(minX + 29, 32, minZ + 29, 37, 26, 22, null, false, this);
|
||||
southArea = new WorkArea(minX + 29, 32, minZ + 101, 37, 26, 22, null, true, this);
|
||||
frame = FRAME_FILE;
|
||||
testblock = TESTBLOCK_FILE;
|
||||
}
|
||||
|
||||
public MiniWarGear21Region(RegionConstructorData regionConstructorData) {
|
||||
super(regionConstructorData);
|
||||
area = new WorkArea(minX, 0, minZ, widthX, 255, widthZ, REGION_FILE, false, this);
|
||||
northArea = new WorkArea(minX + 29, 32, minZ + 29, 37, 26, 22, null, false, this);
|
||||
southArea = new WorkArea(minX + 29, 32, minZ + 101, 37, 26, 22, null, true, this);
|
||||
frame = FRAME_FILE;
|
||||
testblock = TESTBLOCK_FILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull RegionType getType() {
|
||||
return RegionType.DRY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.normal.work;
|
||||
|
||||
import de.steamwar.bausystem.region.RegionConfig;
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionConstructorData;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.WorkArea;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.WorkRegion;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class WarGear21Region extends WorkRegion {
|
||||
|
||||
public static final int widthX = 133;
|
||||
public static final int widthZ = 228;
|
||||
|
||||
private static final File MODE_DIR = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/regions/wargear21/");
|
||||
private static final File REGION_FILE = new File(MODE_DIR, "Region.schem");
|
||||
private static final File FRAME_FILE = new File(MODE_DIR, "Frame.schem");
|
||||
private static final File TESTBLOCK_FILE = new File(MODE_DIR, "Testblock.schem");
|
||||
|
||||
@Getter
|
||||
private final RegionConfig gameModeConfig = new RegionConfig(null); // TODO: Implement
|
||||
|
||||
public WarGear21Region(int minX, int minZ) {
|
||||
super(minX, minZ);
|
||||
area = new WorkArea(minX, 0, minZ, widthX, 255, widthZ, REGION_FILE, false, this);
|
||||
northArea = new WorkArea(minX + 33, 32, minZ + 42, 67, 41, 47, null, false, this);
|
||||
southArea = new WorkArea(minX + 33, 32, minZ + 139, 67, 41, 47, null, true, this);
|
||||
frame = FRAME_FILE;
|
||||
testblock = TESTBLOCK_FILE;
|
||||
}
|
||||
|
||||
public WarGear21Region(RegionConstructorData regionConstructorData) {
|
||||
super(regionConstructorData);
|
||||
area = new WorkArea(minX, 0, minZ, widthX, 255, widthZ, REGION_FILE, false, this);
|
||||
northArea = new WorkArea(minX + 33, 32, minZ + 42, 67, 41, 47, null, false, this);
|
||||
southArea = new WorkArea(minX + 33, 32, minZ + 139, 67, 41, 47, null, true, this);
|
||||
frame = FRAME_FILE;
|
||||
testblock = TESTBLOCK_FILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull RegionType getType() {
|
||||
return RegionType.DRY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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.normal.work;
|
||||
|
||||
import de.steamwar.bausystem.region.RegionConfig;
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionConstructorData;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.WorkArea;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.WorkRegion;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class WarShip21Region extends WorkRegion {
|
||||
|
||||
public static final int widthX = 285;
|
||||
public static final int widthZ = 228;
|
||||
|
||||
private static final File MODE_DIR = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/regions/warship21/");
|
||||
private static final File REGION_FILE = new File(MODE_DIR, "Region.schem");
|
||||
private static final File FRAME_FILE = new File(MODE_DIR, "Frame.schem");
|
||||
private static final File TESTBLOCK_FILE = new File(MODE_DIR, "Testblock.schem");
|
||||
|
||||
@Getter
|
||||
private final RegionConfig gameModeConfig = new RegionConfig(null); // TODO: Implement
|
||||
|
||||
public WarShip21Region(int minX, int minZ) {
|
||||
super(minX, minZ);
|
||||
area = new WorkArea(minX, 0, minZ, widthX, 255, widthZ, REGION_FILE, false, this);
|
||||
// northArea = new WorkArea(minX + 33, 32, minZ + 42, 67, 41, 47, null, false, this);
|
||||
// southArea = new WorkArea(minX + 33, 32, minZ + 139, 67, 41, 47, null, true, this);
|
||||
frame = FRAME_FILE;
|
||||
testblock = TESTBLOCK_FILE;
|
||||
}
|
||||
|
||||
public WarShip21Region(RegionConstructorData regionConstructorData) {
|
||||
super(regionConstructorData);
|
||||
area = new WorkArea(minX, 0, minZ, widthX, 255, widthZ, REGION_FILE, false, this);
|
||||
// northArea = new WorkArea(minX + 33, 32, minZ + 42, 67, 41, 47, null, false, this);
|
||||
// southArea = new WorkArea(minX + 33, 32, minZ + 139, 67, 41, 47, null, true, this);
|
||||
frame = FRAME_FILE;
|
||||
testblock = TESTBLOCK_FILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull RegionType getType() {
|
||||
return RegionType.WET;
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ import java.util.function.Function;
|
||||
|
||||
public class PathAreaTile implements Region.Area {
|
||||
|
||||
private static final File PATH_DIR = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/path_actual");
|
||||
private static final File PATH_DIR = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/path");
|
||||
private static final File PATH_CENTER = new File(PATH_DIR, "PathCenter.schem");
|
||||
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@@ -28,7 +28,6 @@ import de.steamwar.bausystem.region.dynamic.NonNormalFlagStorage;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionConstructorData;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionDataRepository;
|
||||
import de.steamwar.bausystem.region.dynamic.spawn.SpawnAreaTile;
|
||||
import de.steamwar.bausystem.region.dynamic.spawn.SpawnResetter;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user