This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package de.steamwar.bausystem.features.region;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.ProtectMode;
|
||||
@@ -23,9 +22,7 @@ public class ProtectListener implements Listener, ScoreboardElement {
|
||||
private void explode(List<Block> blockList, Location location) {
|
||||
Region region = Region.getRegion(location);
|
||||
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.INACTIVE)) return;
|
||||
Point p1 = region.getBuildArea().getMinPoint(true);
|
||||
Point p2 = region.getTestblockArea().getMinPoint(true);
|
||||
int floorLevel = Math.min(p1.getY(), p2.getY());
|
||||
int floorLevel = region.getFloorLevel();
|
||||
blockList.removeIf(block -> block.getY() < floorLevel);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import de.steamwar.bausystem.region.flags.Flag;
|
||||
import lombok.NonNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface FlagStorage {
|
||||
|
||||
@@ -40,7 +39,4 @@ public interface FlagStorage {
|
||||
}
|
||||
|
||||
Map<Flag<?>, Flag.Value<?>> getBackedMap();
|
||||
|
||||
default void setSaveOperation(Consumer<FlagStorage> operation) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,12 @@ public interface Region {
|
||||
@NonNull
|
||||
Area getTestblockArea();
|
||||
|
||||
default int getFloorLevel() {
|
||||
Point p1 = getBuildArea().getMinPoint(true);
|
||||
Point p2 = getTestblockArea().getMinPoint(true);
|
||||
return Math.min(p1.getY(), p2.getY());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
GameModeConfig getGameModeConfig();
|
||||
|
||||
|
||||
@@ -22,11 +22,17 @@ 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.display.MicroWarGear21DisplayRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.display.MiniWarGear21DisplayRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.display.WarGear21DisplayRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.display.WarShip21DisplayRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.work.MicroWarGear21WorkRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.work.MiniWarGear21WorkRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.work.WarGear21WorkRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.work.WarShip21WorkRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.path.PathRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.special.DrySpecialRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.special.WetSpecialRegion;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.command.AbstractSWCommand;
|
||||
@@ -99,10 +105,16 @@ public class DynamicRegionCommand extends SWCommand {
|
||||
@RequiredArgsConstructor
|
||||
public enum Placement {
|
||||
Path(PathRegion::new, 19, 19),
|
||||
WarGear21(WarGear21WorkRegion::new, WarGear21WorkRegion.widthX, WarGear21WorkRegion.widthZ),
|
||||
MiniWarGear21(MiniWarGear21WorkRegion::new, MiniWarGear21WorkRegion.widthX, MiniWarGear21WorkRegion.widthZ),
|
||||
WarShip21(WarShip21WorkRegion::new, WarShip21WorkRegion.widthX, WarShip21WorkRegion.widthZ),
|
||||
MicroWarGear21(MicroWarGear21WorkRegion::new, MicroWarGear21WorkRegion.widthX, MicroWarGear21WorkRegion.widthZ),
|
||||
WetSpecial(WetSpecialRegion::new, 19, 19),
|
||||
DrySpecial(DrySpecialRegion::new, 19, 19),
|
||||
WarGearWork21(WarGear21WorkRegion::new, WarGear21WorkRegion.widthX, WarGear21WorkRegion.widthZ),
|
||||
WarGearDisplay21(WarGear21DisplayRegion::new, WarGear21DisplayRegion.widthX, WarGear21DisplayRegion.widthZ),
|
||||
MiniWarGearWork21(MiniWarGear21WorkRegion::new, MiniWarGear21WorkRegion.widthX, MiniWarGear21WorkRegion.widthZ),
|
||||
MiniWarGearDisplay21(MiniWarGear21DisplayRegion::new, MiniWarGear21DisplayRegion.widthX, MiniWarGear21DisplayRegion.widthZ),
|
||||
WarShipWork21(WarShip21WorkRegion::new, WarShip21WorkRegion.widthX, WarShip21WorkRegion.widthZ),
|
||||
WarShipDisplay21(WarShip21DisplayRegion::new, WarShip21DisplayRegion.widthX, WarShip21DisplayRegion.widthZ),
|
||||
MicroWarGearWork21(MicroWarGear21WorkRegion::new, MicroWarGear21WorkRegion.widthX, MicroWarGear21WorkRegion.widthZ),
|
||||
MicroWarGearDisplay21(MicroWarGear21DisplayRegion::new, MicroWarGear21DisplayRegion.widthX, MicroWarGear21DisplayRegion.widthZ),
|
||||
;
|
||||
|
||||
private final BiFunction<Integer, Integer, DynamicRegion> constructor;
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class DynamicRegionSystem implements RegionSystem {
|
||||
@@ -90,14 +91,18 @@ public class DynamicRegionSystem implements RegionSystem {
|
||||
return GlobalRegion.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Region get(@NonNull Location location) {
|
||||
return regionMap.values().stream()
|
||||
private Region get(Location location, Collection<Region> regions) {
|
||||
return regions.stream()
|
||||
.filter(region -> region.getArea().inRegion(location, false))
|
||||
.findFirst()
|
||||
.orElse(GlobalRegion.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Region get(@NonNull Location location) {
|
||||
return get(location, regionMap.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Region> getRegion(@NonNull UUID id) {
|
||||
return Optional.ofNullable(regionMap.get(id));
|
||||
@@ -108,24 +113,44 @@ public class DynamicRegionSystem implements RegionSystem {
|
||||
return regionMap.values().stream();
|
||||
}
|
||||
|
||||
public Stream<DynamicRegion> getNeighbours(Region region) {
|
||||
private Stream<DynamicRegion> getNeighbours(Region region, boolean noCorners, Collection<Region> regions) {
|
||||
Point minPoint = region.getArea().getMinPoint(false).subtract(18, 0, 18);
|
||||
Point maxPoint = region.getArea().getMaxPoint(false).add(19, 0, 19);
|
||||
// TODO: Optimize Set away!
|
||||
Set<Region> neighbours = new HashSet<>();
|
||||
for (int x = minPoint.getX(); x <= maxPoint.getX(); x += 19) {
|
||||
for (int x = minPoint.getX() + (noCorners ? 18 : 0); x <= maxPoint.getX() - (noCorners ? 19 : 0); x += 19) {
|
||||
int minZ = minPoint.getZ();
|
||||
int maxZ = maxPoint.getZ();
|
||||
neighbours.add(get(new Location(WORLD, x, 0, minZ)));
|
||||
neighbours.add(get(new Location(WORLD, x, 0, maxZ)));
|
||||
neighbours.add(get(new Location(WORLD, x, 0, minZ), regions));
|
||||
neighbours.add(get(new Location(WORLD, x, 0, maxZ), regions));
|
||||
}
|
||||
for (int z = minPoint.getZ() + 18; z <= maxPoint.getZ() - 19; z += 19) {
|
||||
int minX = minPoint.getX();
|
||||
int maxX = maxPoint.getX();
|
||||
neighbours.add(get(new Location(WORLD, minX, 0, z)));
|
||||
neighbours.add(get(new Location(WORLD, maxX, 0, z)));
|
||||
neighbours.add(get(new Location(WORLD, minX, 0, z), regions));
|
||||
neighbours.add(get(new Location(WORLD, maxX, 0, z), regions));
|
||||
}
|
||||
neighbours.remove(GlobalRegion.INSTANCE);
|
||||
return ((Set<DynamicRegion>)(Set) neighbours).stream();
|
||||
}
|
||||
|
||||
public Stream<DynamicRegion> getNeighbours(Region region) {
|
||||
return getNeighbours(region, false, regionMap.values());
|
||||
}
|
||||
|
||||
public Stream<DynamicRegion> getConnectedRegions(DynamicRegion region) {
|
||||
Set<Region> regions = regionMap.values()
|
||||
.stream()
|
||||
.filter(r -> r.getType() == region.getType())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Set<DynamicRegion> connectedRegions = new HashSet<>();
|
||||
LinkedHashSet<DynamicRegion> current = new LinkedHashSet<>();
|
||||
current.add(region);
|
||||
while (!current.isEmpty()) {
|
||||
DynamicRegion r = current.removeFirst();
|
||||
if (!connectedRegions.add(r)) continue;
|
||||
getNeighbours(r, true, regions).forEach(current::add);
|
||||
}
|
||||
return connectedRegions.stream();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,8 +56,11 @@ public abstract class DefaultFlagStorage implements FlagStorage {
|
||||
return flagMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSaveOperation(Consumer<FlagStorage> operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
operation.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,12 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
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 de.steamwar.bausystem.region.DynamicRegionSystem;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionBackups;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -70,7 +74,10 @@ public abstract class DynamicRegion implements Region {
|
||||
|
||||
public abstract void update(DynamicRegion updateFrom);
|
||||
|
||||
public abstract void setFlags(FlagStorage flags);
|
||||
public abstract void setFlags(DefaultFlagStorage flags);
|
||||
|
||||
@Override
|
||||
public abstract @NonNull DefaultFlagStorage getFlags();
|
||||
|
||||
public void delete() {
|
||||
if (getType().isCannotDelete()) return;
|
||||
|
||||
@@ -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.display.MicroWarGear21DisplayRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.display.MiniWarGear21DisplayRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.display.WarGear21DisplayRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.display.WarShip21DisplayRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.work.MicroWarGear21WorkRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.work.MiniWarGear21WorkRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.work.WarGear21WorkRegion;
|
||||
@@ -35,6 +39,8 @@ import de.steamwar.bausystem.region.dynamic.normal.work.WarShip21WorkRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.path.PathRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.spawn.SpawnPathRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.spawn.SpawnRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.special.DrySpecialRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.special.WetSpecialRegion;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
@@ -72,13 +78,19 @@ 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(DrySpecialRegion.class.getSimpleName(), DrySpecialRegion::new);
|
||||
regionCreators.put(WetSpecialRegion.class.getSimpleName(), WetSpecialRegion::new);
|
||||
regionCreators.put(WarGear21WorkRegion.class.getSimpleName(), WarGear21WorkRegion::new);
|
||||
regionCreators.put(WarGear21DisplayRegion.class.getSimpleName(), WarGear21DisplayRegion::new);
|
||||
regionCreators.put("WarGear21Region", WarGear21WorkRegion::new); // TODO: Legacy because of rename
|
||||
regionCreators.put(MiniWarGear21WorkRegion.class.getSimpleName(), MiniWarGear21WorkRegion::new);
|
||||
regionCreators.put(MiniWarGear21DisplayRegion.class.getSimpleName(), MiniWarGear21DisplayRegion::new);
|
||||
regionCreators.put("MiniWarGear21Region", MiniWarGear21WorkRegion::new); // TODO: Legacy because of rename
|
||||
regionCreators.put(WarShip21WorkRegion.class.getSimpleName(), WarShip21WorkRegion::new);
|
||||
regionCreators.put(WarShip21DisplayRegion.class.getSimpleName(), WarShip21WorkRegion::new);
|
||||
regionCreators.put("WarShip21Region", WarShip21WorkRegion::new); // TODO: Legacy because of rename
|
||||
regionCreators.put(MicroWarGear21WorkRegion.class.getSimpleName(), MicroWarGear21WorkRegion::new);
|
||||
regionCreators.put(MicroWarGear21DisplayRegion.class.getSimpleName(), MicroWarGear21DisplayRegion::new);
|
||||
regionCreators.put("MicroWarGear21Region", MicroWarGear21WorkRegion::new); // TODO: Legacy because of rename
|
||||
}
|
||||
|
||||
@@ -119,7 +131,7 @@ public class RegionDataRepository {
|
||||
deleteDir(getRegionDirectory(region));
|
||||
}
|
||||
|
||||
public void loadFlagStorage(Region region, FlagStorage storage) {
|
||||
public void loadFlagStorage(Region region, DefaultFlagStorage storage) {
|
||||
File file = getRegionDirectory(region);
|
||||
file = new File(file, FLAGS_FILE_NAME);
|
||||
loadFlagStorage(file, storage);
|
||||
@@ -274,7 +286,7 @@ public class RegionDataRepository {
|
||||
.run();
|
||||
region.getHistory().remember(editSession);
|
||||
region.getFlags().setSaveOperation(null);
|
||||
region.setFlags(getFlags());
|
||||
region.setFlags((DefaultFlagStorage) getFlags());
|
||||
region.getFlags().setSaveOperation(storage -> saveFlagStorage(region, storage));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package de.steamwar.bausystem.region.dynamic.global;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.bausystem.region.*;
|
||||
import de.steamwar.bausystem.region.dynamic.DefaultFlagStorage;
|
||||
import de.steamwar.bausystem.region.dynamic.NonNormalFlagStorage;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionDataRepository;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
@@ -90,7 +91,7 @@ public class GlobalRegion implements Region {
|
||||
|
||||
private static final GameModeConfig GLOBAL_CONFIG = new GameModeConfig(null);
|
||||
|
||||
private static FlagStorage FLAG_STORAGE = new NonNormalFlagStorage();
|
||||
private static DefaultFlagStorage FLAG_STORAGE = new NonNormalFlagStorage();
|
||||
static {
|
||||
RegionDataRepository.loadFlagStorage(INSTANCE, FLAG_STORAGE);
|
||||
}
|
||||
|
||||
@@ -19,5 +19,51 @@
|
||||
|
||||
package de.steamwar.bausystem.region.dynamic.normal;
|
||||
|
||||
public class DisplayRegion {
|
||||
import de.steamwar.bausystem.region.RegionHistory;
|
||||
import de.steamwar.bausystem.region.dynamic.DefaultFlagStorage;
|
||||
import de.steamwar.bausystem.region.dynamic.DynamicRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionConstructorData;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionDataRepository;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
|
||||
public abstract class DisplayRegion extends DynamicRegion {
|
||||
|
||||
@Getter
|
||||
private DefaultFlagStorage flags = new NormalFlagStorage();
|
||||
|
||||
@Getter
|
||||
protected NormalArea area = NormalArea.EMPTY;
|
||||
|
||||
@Getter
|
||||
private final RegionHistory history = new RegionHistory.Impl(20);
|
||||
|
||||
protected DisplayRegion(int minX, int minZ) {
|
||||
super(minX, minZ);
|
||||
RegionDataRepository.loadFlagStorage(this, flags);
|
||||
}
|
||||
|
||||
protected DisplayRegion(RegionConstructorData regionConstructorData) {
|
||||
super(regionConstructorData);
|
||||
RegionDataRepository.loadFlagStorage(this, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(DynamicRegion updateFrom) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlags(DefaultFlagStorage flags) {
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Area getBuildArea() {
|
||||
return Area.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Area getTestblockArea() {
|
||||
return Area.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,72 +19,108 @@
|
||||
|
||||
package de.steamwar.bausystem.region.dynamic.normal;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public abstract class NormalArea implements Region.Area {
|
||||
public class NormalArea implements Region.Area {
|
||||
|
||||
public abstract NormalArea setResetFile(VariantSelector variantSelector);
|
||||
public static final NormalArea EMPTY = new NormalArea(0, 0, 0, 0, 0, 0, null, false, null) {
|
||||
@Override
|
||||
public void reset(PasteBuilder pasteBuilder, boolean extension) {
|
||||
}
|
||||
|
||||
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(VariantSelector variantSelector) {
|
||||
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;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
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 VariantSelector variantSelector;
|
||||
private final Point minPoint;
|
||||
private final Point maxPoint;
|
||||
private final Point copyPoint;
|
||||
private final boolean rotate;
|
||||
private final Region region;
|
||||
|
||||
public NormalArea(int minX, int minY, int minZ, int widthX, int widthY, int widthZ, VariantSelector variantSelector, boolean rotate, Region region) {
|
||||
this.minX = minX;
|
||||
this.minY = minY;
|
||||
this.minZ = minZ;
|
||||
this.widthX = widthX;
|
||||
this.widthY = widthY;
|
||||
this.widthZ = widthZ;
|
||||
this.variantSelector = variantSelector;
|
||||
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;
|
||||
}
|
||||
|
||||
public NormalArea setResetFile(VariantSelector variantSelector) {
|
||||
this.variantSelector = variantSelector;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public File getResetFile() {
|
||||
return variantSelector.selectVariant(minX, minZ).orElseThrow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(PasteBuilder pasteBuilder, boolean extension) {
|
||||
EditSession editSession = pasteBuilder.minPoint(minPoint)
|
||||
.maxPoint(maxPoint)
|
||||
.rotate(rotate)
|
||||
.color(region.getFlags().get(Flag.COLOR).getWithDefault())
|
||||
.run();
|
||||
region.getHistory().remember(editSession);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* 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.FlagStorage;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
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 VariantSelector variantSelector;
|
||||
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, VariantSelector variantSelector, boolean rotate, Region region) {
|
||||
this.minX = minX;
|
||||
this.minY = minY;
|
||||
this.minZ = minZ;
|
||||
this.widthX = widthX;
|
||||
this.widthY = widthY;
|
||||
this.widthZ = widthZ;
|
||||
this.variantSelector = variantSelector;
|
||||
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(VariantSelector variantSelector) {
|
||||
this.variantSelector = variantSelector;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public File getResetFile() {
|
||||
return variantSelector.selectVariant(minX, minZ).orElseThrow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(PasteBuilder pasteBuilder, boolean extension) {
|
||||
EditSession editSession = pasteBuilder.minPoint(minPoint)
|
||||
.maxPoint(maxPoint)
|
||||
.rotate(rotate)
|
||||
.color(region.getFlags().get(Flag.COLOR).getWithDefault())
|
||||
.run();
|
||||
region.getHistory().remember(editSession);
|
||||
}
|
||||
}
|
||||
@@ -20,12 +20,8 @@
|
||||
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.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.region.dynamic.*;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.TestblockMode;
|
||||
import lombok.Getter;
|
||||
@@ -34,7 +30,7 @@ import lombok.NonNull;
|
||||
public abstract class WorkRegion extends DynamicRegion {
|
||||
|
||||
@Getter
|
||||
private FlagStorage flags = new NormalFlagStorage();
|
||||
private DefaultFlagStorage flags = new NormalFlagStorage();
|
||||
|
||||
@Getter
|
||||
protected NormalArea area = NormalArea.EMPTY;
|
||||
@@ -62,7 +58,7 @@ public abstract class WorkRegion extends DynamicRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlags(FlagStorage flags) {
|
||||
public void setFlags(DefaultFlagStorage flags) {
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.display;
|
||||
|
||||
import de.steamwar.bausystem.region.GameModeConfig;
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionConstructorData;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.DisplayRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.NormalArea;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class MicroWarGear21DisplayRegion extends DisplayRegion {
|
||||
|
||||
public static final int widthX = 57;
|
||||
public static final int widthZ = 57;
|
||||
|
||||
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, "Display.schem");
|
||||
|
||||
@Getter
|
||||
private final GameModeConfig gameModeConfig = new GameModeConfig(null); // TODO: Implement
|
||||
|
||||
public MicroWarGear21DisplayRegion(int minX, int minZ) {
|
||||
super(minX, minZ);
|
||||
area = new NormalArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(REGION_FILE), false, this);
|
||||
}
|
||||
|
||||
public MicroWarGear21DisplayRegion(RegionConstructorData regionConstructorData) {
|
||||
super(regionConstructorData);
|
||||
area = new NormalArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(REGION_FILE), false, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull RegionType getType() {
|
||||
return RegionType.DRY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.display;
|
||||
|
||||
import de.steamwar.bausystem.region.GameModeConfig;
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionConstructorData;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.DisplayRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.NormalArea;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class MiniWarGear21DisplayRegion extends DisplayRegion {
|
||||
|
||||
public static final int widthX = 57;
|
||||
public static final int widthZ = 38;
|
||||
|
||||
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, "Display.schem");
|
||||
|
||||
@Getter
|
||||
private final GameModeConfig gameModeConfig = new GameModeConfig(null); // TODO: Implement
|
||||
|
||||
public MiniWarGear21DisplayRegion(int minX, int minZ) {
|
||||
super(minX, minZ);
|
||||
area = new NormalArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(REGION_FILE), false, this);
|
||||
}
|
||||
|
||||
public MiniWarGear21DisplayRegion(RegionConstructorData regionConstructorData) {
|
||||
super(regionConstructorData);
|
||||
area = new NormalArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(REGION_FILE), false, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull RegionType getType() {
|
||||
return RegionType.DRY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.display;
|
||||
|
||||
import de.steamwar.bausystem.region.GameModeConfig;
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionConstructorData;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.DisplayRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.NormalArea;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class WarGear21DisplayRegion extends DisplayRegion {
|
||||
|
||||
public static final int widthX = 133;
|
||||
public static final int widthZ = 95;
|
||||
|
||||
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, "Display.schem");
|
||||
|
||||
@Getter
|
||||
private final GameModeConfig gameModeConfig = new GameModeConfig(null); // TODO: Implement
|
||||
|
||||
public WarGear21DisplayRegion(int minX, int minZ) {
|
||||
super(minX, minZ);
|
||||
area = new NormalArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(REGION_FILE), false, this);
|
||||
}
|
||||
|
||||
public WarGear21DisplayRegion(RegionConstructorData regionConstructorData) {
|
||||
super(regionConstructorData);
|
||||
area = new NormalArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(REGION_FILE), false, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull RegionType getType() {
|
||||
return RegionType.DRY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.display;
|
||||
|
||||
import de.steamwar.bausystem.region.GameModeConfig;
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionConstructorData;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.DisplayRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.NormalArea;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class WarShip21DisplayRegion extends DisplayRegion {
|
||||
|
||||
public static final int widthX = 266;
|
||||
public static final int widthZ = 95;
|
||||
|
||||
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, "Display.schem");
|
||||
|
||||
@Getter
|
||||
private final GameModeConfig gameModeConfig = new GameModeConfig(null); // TODO: Implement
|
||||
|
||||
public WarShip21DisplayRegion(int minX, int minZ) {
|
||||
super(minX, minZ);
|
||||
area = new NormalArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(REGION_FILE), false, this);
|
||||
}
|
||||
|
||||
public WarShip21DisplayRegion(RegionConstructorData regionConstructorData) {
|
||||
super(regionConstructorData);
|
||||
area = new NormalArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(REGION_FILE), false, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull RegionType getType() {
|
||||
return RegionType.DRY;
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import de.steamwar.bausystem.region.GameModeConfig;
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionConstructorData;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.WorkArea;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.NormalArea;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.WorkRegion;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
@@ -37,7 +37,7 @@ public class MicroWarGear21WorkRegion extends WorkRegion {
|
||||
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 REGION_FILE = new File(MODE_DIR, "Work.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");
|
||||
|
||||
@@ -46,18 +46,18 @@ public class MicroWarGear21WorkRegion extends WorkRegion {
|
||||
|
||||
public MicroWarGear21WorkRegion(int minX, int minZ) {
|
||||
super(minX, minZ);
|
||||
area = new WorkArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(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);
|
||||
area = new NormalArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(REGION_FILE), false, this);
|
||||
northArea = new NormalArea(minX + 25, 32, minZ + 25, 7, 7, 7, null, false, this);
|
||||
southArea = new NormalArea(minX + 25, 32, minZ + 82, 7, 7, 7, null, true, this);
|
||||
frame = VariantSelector.File(FRAME_FILE);
|
||||
testblock = VariantSelector.File(TESTBLOCK_FILE);
|
||||
}
|
||||
|
||||
public MicroWarGear21WorkRegion(RegionConstructorData regionConstructorData) {
|
||||
super(regionConstructorData);
|
||||
area = new WorkArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(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);
|
||||
area = new NormalArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(REGION_FILE), false, this);
|
||||
northArea = new NormalArea(minX + 25, 32, minZ + 25, 7, 7, 7, null, false, this);
|
||||
southArea = new NormalArea(minX + 25, 32, minZ + 82, 7, 7, 7, null, true, this);
|
||||
frame = VariantSelector.File(FRAME_FILE);
|
||||
testblock = VariantSelector.File(TESTBLOCK_FILE);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import de.steamwar.bausystem.region.GameModeConfig;
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionConstructorData;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.WorkArea;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.NormalArea;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.WorkRegion;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
@@ -37,7 +37,7 @@ public class MiniWarGear21WorkRegion extends WorkRegion {
|
||||
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 REGION_FILE = new File(MODE_DIR, "Work.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");
|
||||
|
||||
@@ -46,18 +46,18 @@ public class MiniWarGear21WorkRegion extends WorkRegion {
|
||||
|
||||
public MiniWarGear21WorkRegion(int minX, int minZ) {
|
||||
super(minX, minZ);
|
||||
area = new WorkArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(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);
|
||||
area = new NormalArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(REGION_FILE), false, this);
|
||||
northArea = new NormalArea(minX + 29, 32, minZ + 29, 37, 26, 22, null, false, this);
|
||||
southArea = new NormalArea(minX + 29, 32, minZ + 101, 37, 26, 22, null, true, this);
|
||||
frame = VariantSelector.File(FRAME_FILE);
|
||||
testblock = VariantSelector.File(TESTBLOCK_FILE);
|
||||
}
|
||||
|
||||
public MiniWarGear21WorkRegion(RegionConstructorData regionConstructorData) {
|
||||
super(regionConstructorData);
|
||||
area = new WorkArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(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);
|
||||
area = new NormalArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(REGION_FILE), false, this);
|
||||
northArea = new NormalArea(minX + 29, 32, minZ + 29, 37, 26, 22, null, false, this);
|
||||
southArea = new NormalArea(minX + 29, 32, minZ + 101, 37, 26, 22, null, true, this);
|
||||
frame = VariantSelector.File(FRAME_FILE);
|
||||
testblock = VariantSelector.File(TESTBLOCK_FILE);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import de.steamwar.bausystem.region.GameModeConfig;
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionConstructorData;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.WorkArea;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.NormalArea;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.WorkRegion;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
@@ -37,7 +37,7 @@ public class WarGear21WorkRegion extends WorkRegion {
|
||||
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 REGION_FILE = new File(MODE_DIR, "Work.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");
|
||||
|
||||
@@ -46,18 +46,18 @@ public class WarGear21WorkRegion extends WorkRegion {
|
||||
|
||||
public WarGear21WorkRegion(int minX, int minZ) {
|
||||
super(minX, minZ);
|
||||
area = new WorkArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(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);
|
||||
area = new NormalArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(REGION_FILE), false, this);
|
||||
northArea = new NormalArea(minX + 33, 32, minZ + 42, 67, 41, 47, null, false, this);
|
||||
southArea = new NormalArea(minX + 33, 32, minZ + 139, 67, 41, 47, null, true, this);
|
||||
frame = VariantSelector.File(FRAME_FILE);
|
||||
testblock = VariantSelector.File(TESTBLOCK_FILE);
|
||||
}
|
||||
|
||||
public WarGear21WorkRegion(RegionConstructorData regionConstructorData) {
|
||||
super(regionConstructorData);
|
||||
area = new WorkArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(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);
|
||||
area = new NormalArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(REGION_FILE), false, this);
|
||||
northArea = new NormalArea(minX + 33, 32, minZ + 42, 67, 41, 47, null, false, this);
|
||||
southArea = new NormalArea(minX + 33, 32, minZ + 139, 67, 41, 47, null, true, this);
|
||||
frame = VariantSelector.File(FRAME_FILE);
|
||||
testblock = VariantSelector.File(TESTBLOCK_FILE);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import de.steamwar.bausystem.region.GameModeConfig;
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionConstructorData;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.WorkArea;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.NormalArea;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.WorkRegion;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
@@ -37,7 +37,7 @@ public class WarShip21WorkRegion extends WorkRegion {
|
||||
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 REGION_FILE = new File(MODE_DIR, "Work.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");
|
||||
|
||||
@@ -46,18 +46,18 @@ public class WarShip21WorkRegion extends WorkRegion {
|
||||
|
||||
public WarShip21WorkRegion(int minX, int minZ) {
|
||||
super(minX, minZ);
|
||||
area = new WorkArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(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);
|
||||
area = new NormalArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(REGION_FILE), false, this);
|
||||
northArea = new NormalArea(minX + 28, 19, minZ + 25, 230, 58, 43, null, false, this);
|
||||
southArea = new NormalArea(minX + 28, 19, minZ + 160, 230, 58, 43, null, true, this);
|
||||
frame = VariantSelector.File(FRAME_FILE);
|
||||
testblock = VariantSelector.File(TESTBLOCK_FILE);
|
||||
}
|
||||
|
||||
public WarShip21WorkRegion(RegionConstructorData regionConstructorData) {
|
||||
super(regionConstructorData);
|
||||
area = new WorkArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(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);
|
||||
area = new NormalArea(minX, 0, minZ, widthX, 255, widthZ, VariantSelector.File(REGION_FILE), false, this);
|
||||
northArea = new NormalArea(minX + 28, 19, minZ + 25, 230, 58, 43, null, false, this);
|
||||
southArea = new NormalArea(minX + 28, 19, minZ + 160, 230, 58, 43, null, true, this);
|
||||
frame = VariantSelector.File(FRAME_FILE);
|
||||
testblock = VariantSelector.File(TESTBLOCK_FILE);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package de.steamwar.bausystem.region.dynamic.path;
|
||||
|
||||
import de.steamwar.bausystem.region.FlagStorage;
|
||||
import de.steamwar.bausystem.region.GameModeConfig;
|
||||
import de.steamwar.bausystem.region.RegionHistory;
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
@@ -35,7 +34,7 @@ public class PathRegion extends DynamicRegion {
|
||||
private static final File SECTIONS_DIR = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections");
|
||||
private static final File RESET_FILE = new File(SECTIONS_DIR, "path/Path.schem"); // Temp
|
||||
|
||||
private FlagStorage flagStorage = new NonNormalFlagStorage();
|
||||
private DefaultFlagStorage flagStorage = new NonNormalFlagStorage();
|
||||
private final Area area;
|
||||
private final GameModeConfig config = new GameModeConfig(null);
|
||||
|
||||
@@ -67,7 +66,7 @@ public class PathRegion extends DynamicRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlags(FlagStorage flags) {
|
||||
public void setFlags(DefaultFlagStorage flags) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,7 +79,7 @@ public class PathRegion extends DynamicRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull FlagStorage getFlags() {
|
||||
public @NonNull DefaultFlagStorage getFlags() {
|
||||
return flagStorage;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package de.steamwar.bausystem.region.dynamic.spawn;
|
||||
|
||||
import de.steamwar.bausystem.region.FlagStorage;
|
||||
import de.steamwar.bausystem.region.GameModeConfig;
|
||||
import de.steamwar.bausystem.region.RegionHistory;
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
@@ -37,7 +36,7 @@ public class SpawnPathRegion extends DynamicRegion {
|
||||
private static final File RESET_FILE_WEST = new File(SECTIONS_DIR, "spawn/SpawnWest.schem");
|
||||
private static final File RESET_FILE_EAST = new File(SECTIONS_DIR, "spawn/SpawnEast.schem");
|
||||
|
||||
private FlagStorage flagStorage = new NonNormalFlagStorage();
|
||||
private DefaultFlagStorage flagStorage = new NonNormalFlagStorage();
|
||||
private final Area area;
|
||||
private final GameModeConfig config = new GameModeConfig(null);
|
||||
|
||||
@@ -72,7 +71,7 @@ public class SpawnPathRegion extends DynamicRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlags(FlagStorage flags) {
|
||||
public void setFlags(DefaultFlagStorage flags) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,7 +80,7 @@ public class SpawnPathRegion extends DynamicRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull FlagStorage getFlags() {
|
||||
public @NonNull DefaultFlagStorage getFlags() {
|
||||
return flagStorage;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package de.steamwar.bausystem.region.dynamic.spawn;
|
||||
|
||||
import de.steamwar.bausystem.region.FlagStorage;
|
||||
import de.steamwar.bausystem.region.GameModeConfig;
|
||||
import de.steamwar.bausystem.region.RegionHistory;
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
@@ -34,7 +33,7 @@ public class SpawnRegion extends DynamicRegion {
|
||||
private static final File SECTIONS_DIR = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections");
|
||||
private static final File RESET_FILE = new File(SECTIONS_DIR, "spawn/SpawnMiddle.schem");
|
||||
|
||||
private FlagStorage flagStorage = new NonNormalFlagStorage();
|
||||
private DefaultFlagStorage flagStorage = new NonNormalFlagStorage();
|
||||
private final Area area;
|
||||
private final GameModeConfig config = new GameModeConfig(null);
|
||||
|
||||
@@ -56,7 +55,7 @@ public class SpawnRegion extends DynamicRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlags(FlagStorage flags) {
|
||||
public void setFlags(DefaultFlagStorage flags) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,7 +64,7 @@ public class SpawnRegion extends DynamicRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull FlagStorage getFlags() {
|
||||
public @NonNull DefaultFlagStorage getFlags() {
|
||||
return flagStorage;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,5 +19,36 @@
|
||||
|
||||
package de.steamwar.bausystem.region.dynamic.special;
|
||||
|
||||
public class DrySpecialRegion {
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionConstructorData;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class DrySpecialRegion extends SpecialRegion {
|
||||
|
||||
private static final File SECTIONS_DIR = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections");
|
||||
private static final File RESET_FILE = new File(SECTIONS_DIR, "special/DryRegion.schem");
|
||||
|
||||
public DrySpecialRegion(int minX, int minZ) {
|
||||
super(minX, minZ);
|
||||
area = new SpecialAreaTile(minX, minZ, VariantSelector.File(RESET_FILE));
|
||||
}
|
||||
|
||||
public DrySpecialRegion(RegionConstructorData regionConstructorData) {
|
||||
super(regionConstructorData);
|
||||
area = new SpecialAreaTile(minX, minZ, VariantSelector.File(RESET_FILE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull RegionType getType() {
|
||||
return RegionType.DRY_SPECIAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFloorLevel() {
|
||||
return 32;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,5 +19,60 @@
|
||||
|
||||
package de.steamwar.bausystem.region.dynamic.special;
|
||||
|
||||
public class SpecialAreaTile {
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import lombok.NonNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
|
||||
public class SpecialAreaTile implements Region.Area {
|
||||
|
||||
private final int minX;
|
||||
private final int minZ;
|
||||
private final VariantSelector variantSelector;
|
||||
|
||||
private final Point minPoint;
|
||||
private final Point maxPoint;
|
||||
private final Point copyPoint;
|
||||
|
||||
public SpecialAreaTile(int minX, int minZ, VariantSelector variantSelector) {
|
||||
this.minX = minX;
|
||||
this.minZ = minZ;
|
||||
this.variantSelector = variantSelector;
|
||||
|
||||
minPoint = new Point(minX, 0, minZ);
|
||||
maxPoint = new Point(minX + 18, 255, minZ + 18);
|
||||
copyPoint = new Point(minX + 9, 0, minZ + 9);
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public File getResetFile() {
|
||||
return variantSelector.selectVariant(minX, minZ).orElseThrow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(PasteBuilder pasteBuilder, boolean extension) {
|
||||
pasteBuilder.minPoint(minPoint)
|
||||
.maxPoint(maxPoint)
|
||||
.run();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.special;
|
||||
|
||||
import de.steamwar.bausystem.region.DynamicRegionSystem;
|
||||
import de.steamwar.bausystem.region.dynamic.DynamicRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.normal.NormalFlagStorage;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.TNTMode;
|
||||
import lombok.NonNull;
|
||||
|
||||
public class SpecialFlagStorage extends NormalFlagStorage {
|
||||
|
||||
private DynamicRegion region;
|
||||
|
||||
public SpecialFlagStorage(DynamicRegion region) {
|
||||
this.region = region;
|
||||
flagMap.put(Flag.TNT, TNTMode.DENY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Enum<T> & Flag.Value<T>> boolean set(@NonNull Flag<T> flag, @NonNull T value) {
|
||||
boolean result = super.set(flag, value);
|
||||
DynamicRegionSystem.INSTANCE.getConnectedRegions(region).forEach(other -> {
|
||||
other.getFlags().getBackedMap().put(flag, value);
|
||||
other.getFlags().save();
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -19,5 +19,61 @@
|
||||
|
||||
package de.steamwar.bausystem.region.dynamic.special;
|
||||
|
||||
public class SpecialRegion {
|
||||
import de.steamwar.bausystem.region.GameModeConfig;
|
||||
import de.steamwar.bausystem.region.RegionHistory;
|
||||
import de.steamwar.bausystem.region.dynamic.DefaultFlagStorage;
|
||||
import de.steamwar.bausystem.region.dynamic.DynamicRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionConstructorData;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionDataRepository;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
|
||||
public abstract class SpecialRegion extends DynamicRegion {
|
||||
|
||||
@Getter
|
||||
private DefaultFlagStorage flags = new SpecialFlagStorage(this);
|
||||
|
||||
@Getter
|
||||
protected SpecialAreaTile area;
|
||||
|
||||
private final GameModeConfig config = new GameModeConfig(null);
|
||||
|
||||
protected SpecialRegion(int minX, int minZ) {
|
||||
super(minX, minZ);
|
||||
RegionDataRepository.loadFlagStorage(this, flags);
|
||||
}
|
||||
|
||||
protected SpecialRegion(RegionConstructorData regionConstructorData) {
|
||||
super(regionConstructorData);
|
||||
RegionDataRepository.loadFlagStorage(this, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(DynamicRegion updateFrom) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlags(DefaultFlagStorage flags) {
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Area getBuildArea() {
|
||||
return Area.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Area getTestblockArea() {
|
||||
return Area.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull GameModeConfig getGameModeConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull RegionHistory getHistory() {
|
||||
return RegionHistory.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,5 +19,31 @@
|
||||
|
||||
package de.steamwar.bausystem.region.dynamic.special;
|
||||
|
||||
public class WetSpecialRegion {
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionConstructorData;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class WetSpecialRegion extends SpecialRegion {
|
||||
|
||||
private static final File SECTIONS_DIR = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections");
|
||||
private static final File RESET_FILE = new File(SECTIONS_DIR, "special/WetRegion.schem");
|
||||
|
||||
public WetSpecialRegion(int minX, int minZ) {
|
||||
super(minX, minZ);
|
||||
area = new SpecialAreaTile(minX, minZ, VariantSelector.File(RESET_FILE));
|
||||
}
|
||||
|
||||
public WetSpecialRegion(RegionConstructorData regionConstructorData) {
|
||||
super(regionConstructorData);
|
||||
area = new SpecialAreaTile(minX, minZ, VariantSelector.File(RESET_FILE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull RegionType getType() {
|
||||
return RegionType.WET_SPECIAL;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user