forked from SteamWar/SteamWar
Change Region.Area to abstract class instead of interface
This commit is contained in:
@@ -74,14 +74,14 @@ public interface Region extends RegionDataStore {
|
||||
@NonNull
|
||||
RegionBackups getBackups();
|
||||
|
||||
interface Area {
|
||||
abstract class Area {
|
||||
|
||||
int WORLD_MIN_Y = Bukkit.getWorlds().get(0).getMinHeight();
|
||||
int WORLD_MAX_Y = Bukkit.getWorlds().get(0).getMaxHeight();
|
||||
public static final int WORLD_MIN_Y = Bukkit.getWorlds().get(0).getMinHeight();
|
||||
public static final int WORLD_MAX_Y = Bukkit.getWorlds().get(0).getMaxHeight();
|
||||
|
||||
Area EMPTY = new Area() {
|
||||
public static final Area EMPTY = new Area() {
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
protected boolean isEmptyInternal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -129,20 +129,24 @@ public interface Region extends RegionDataStore {
|
||||
}
|
||||
};
|
||||
|
||||
default boolean isEmpty() {
|
||||
public final boolean isEmpty() {
|
||||
return isEmptyInternal();
|
||||
}
|
||||
|
||||
boolean isEmptyInternal() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
Point getMinPoint(boolean extension);
|
||||
public abstract Point getMinPoint(boolean extension);
|
||||
|
||||
@NonNull
|
||||
Point getMaxPoint(boolean extension);
|
||||
public abstract Point getMaxPoint(boolean extension);
|
||||
|
||||
@NonNull
|
||||
Point getCopyPoint();
|
||||
public abstract Point getCopyPoint();
|
||||
|
||||
default boolean inRegion(Location location, boolean extension) {
|
||||
public boolean inRegion(Location location, boolean extension) {
|
||||
Point minPoint = getMinPoint(extension);
|
||||
Point maxPoint = getMaxPoint(extension);
|
||||
if (location.getBlockX() < minPoint.getX() || location.getBlockX() > maxPoint.getX()) return false;
|
||||
@@ -151,7 +155,7 @@ public interface Region extends RegionDataStore {
|
||||
return true;
|
||||
}
|
||||
|
||||
default boolean inRegion(int x, int z, boolean extension) {
|
||||
public boolean inRegion(int x, int z, boolean extension) {
|
||||
Point minPoint = getMinPoint(extension);
|
||||
Point maxPoint = getMaxPoint(extension);
|
||||
if (x < minPoint.getX() || x > maxPoint.getX()) return false;
|
||||
@@ -160,17 +164,17 @@ public interface Region extends RegionDataStore {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default Clipboard copy(boolean extension) {
|
||||
public Clipboard copy(boolean extension) {
|
||||
return FlatteningWrapper.impl.copy(getMinPoint(extension), getMaxPoint(extension), getCopyPoint());
|
||||
}
|
||||
|
||||
default void reset(PasteBuilder pasteBuilder, boolean extension) {
|
||||
public void reset(PasteBuilder pasteBuilder, boolean extension) {
|
||||
place(pasteBuilder, extension);
|
||||
}
|
||||
|
||||
void place(PasteBuilder pasteBuilder, boolean extension);
|
||||
public abstract void place(PasteBuilder pasteBuilder, boolean extension);
|
||||
|
||||
default void forEachChunk(BiConsumer<Integer, Integer> executor) {
|
||||
public void forEachChunk(BiConsumer<Integer, Integer> executor) {
|
||||
Point minPoint = getMinPoint(false);
|
||||
Point maxPoint = getMaxPoint(false);
|
||||
for (int x = (int) Math.floor(minPoint.getX() / 16.0); x <= (int) Math.ceil(maxPoint.getX() / 16.0); x++) {
|
||||
@@ -180,7 +184,7 @@ public interface Region extends RegionDataStore {
|
||||
}
|
||||
}
|
||||
|
||||
default boolean isChunkOutside(int chunkX, int chunkZ) {
|
||||
public boolean isChunkOutside(int chunkX, int chunkZ) {
|
||||
Point minPoint = getMinPoint(true);
|
||||
Point maxPoint = getMaxPoint(true);
|
||||
return Math.floor(minPoint.getX() / 16.0) > chunkX || chunkX >= Math.ceil(maxPoint.getX() / 16.0) ||
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class AreaBlock implements Region.Area {
|
||||
public class AreaBlock extends Region.Area {
|
||||
|
||||
public enum CopyLocation {
|
||||
/**
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ import lombok.NonNull;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class AreaTile implements Region.Area {
|
||||
public class AreaTile extends Region.Area {
|
||||
|
||||
@Getter
|
||||
private final Tile tile;
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ import java.util.function.BiConsumer;
|
||||
|
||||
import static de.steamwar.bausystem.region.RegionType.ConnectionType.*;
|
||||
|
||||
public class PathArea implements Region.Area {
|
||||
public class PathArea extends Region.Area {
|
||||
|
||||
private static final File PATH_DIR = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/path");
|
||||
private static final File FALLBACK_SCHEM = new File(PATH_DIR, "Fallback.schem");
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import lombok.NonNull;
|
||||
|
||||
public class SpawnArea implements Region.Area {
|
||||
public class SpawnArea extends Region.Area {
|
||||
|
||||
@Override
|
||||
public @NonNull Point getMinPoint(boolean extension) {
|
||||
@@ -44,7 +44,7 @@ public class SpawnArea implements Region.Area {
|
||||
@Override
|
||||
public void reset(PasteBuilder pasteBuilder, boolean extension) {
|
||||
// TODO: Implement!
|
||||
Region.Area.super.reset(pasteBuilder, extension);
|
||||
super.reset(pasteBuilder, extension);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
@@ -27,6 +27,7 @@ import de.steamwar.bausystem.region.RegionType;
|
||||
import de.steamwar.bausystem.region.dynamic.DynamicRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.Tile;
|
||||
import de.steamwar.bausystem.region.dynamic.TileUtils;
|
||||
import de.steamwar.bausystem.region.dynamic.path.PathRegionData;
|
||||
import de.steamwar.sql.GameModeConfig;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Material;
|
||||
@@ -51,6 +52,7 @@ public class SpawnRegion extends DynamicRegion {
|
||||
private SpawnRegion(UUID id, Tile tile) {
|
||||
super(id, null);
|
||||
this.tile = tile;
|
||||
regionData = PathRegionData.INSTANCE;
|
||||
// TODO: Initialize
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class SpecialArea implements Region.Area {
|
||||
public class SpecialArea extends Region.Area {
|
||||
|
||||
public static final File SPECIAL_PATH_DIR = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/special");
|
||||
|
||||
|
||||
-2
@@ -31,7 +31,6 @@ import de.steamwar.sql.GameModeConfig;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import yapion.hierarchy.types.YAPIONObject;
|
||||
|
||||
@@ -39,7 +38,6 @@ import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user