forked from SteamWar/SteamWar
Update Region.inBuildRegion and Region.inTestblockRegion
This commit is contained in:
@@ -31,6 +31,10 @@ import java.util.Optional;
|
||||
|
||||
public interface Region {
|
||||
|
||||
static Region getRegion(Location location) {
|
||||
return RegionSystem.REGION_SYSTEM.get(location);
|
||||
}
|
||||
|
||||
RegionType getType();
|
||||
|
||||
<T extends Enum<T> & Flag.Value<T>> RegionFlagPolicy hasFlag(@NonNull Flag<T> flag);
|
||||
@@ -49,13 +53,13 @@ public interface Region {
|
||||
|
||||
Optional<Point> getBuildMaxPoint(boolean extension);
|
||||
|
||||
boolean inBuildRegion(boolean extension);
|
||||
boolean inBuildRegion(Location location, boolean extension);
|
||||
|
||||
Optional<Point> getTestblockMinPoint(boolean extension);
|
||||
|
||||
Optional<Point> getTestblockMaxPoint(boolean extension);
|
||||
|
||||
boolean inTestblockRegion(boolean extension);
|
||||
boolean inTestblockRegion(Location location, boolean extension);
|
||||
|
||||
// TODO: Add forEachChunk and getChunkOutsidePredicate
|
||||
|
||||
|
||||
@@ -21,11 +21,14 @@ package de.steamwar.bausystem.regionnew;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public interface RegionSystem {
|
||||
|
||||
RegionSystem REGION_SYSTEM = init();
|
||||
|
||||
void load();
|
||||
void save();
|
||||
|
||||
@@ -37,4 +40,48 @@ public interface RegionSystem {
|
||||
Stream<Region> getRegions();
|
||||
|
||||
boolean isModular();
|
||||
|
||||
private static RegionSystem init() {
|
||||
try {
|
||||
return (RegionSystem) Class.forName("de.steamwar.bausystem.regionnew.FixedRegionSystem").getConstructor().newInstance();
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException |
|
||||
InvocationTargetException e) {
|
||||
return new RegionSystem() {
|
||||
@Override
|
||||
public void load() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region getGlobalRegion() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region get(Location location) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Region> getRegion(String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Region> getRegions() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModular() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -93,7 +93,7 @@ public final class FixedGlobalRegion implements Region {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inBuildRegion(boolean extension) {
|
||||
public boolean inBuildRegion(Location location, boolean extension) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public final class FixedGlobalRegion implements Region {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inTestblockRegion(boolean extension) {
|
||||
public boolean inTestblockRegion(Location location, boolean extension) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -77,7 +77,7 @@ public class FixedRegion implements Region { // TODO: Implement!
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inBuildRegion(boolean extension) {
|
||||
public boolean inBuildRegion(Location location, boolean extension) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class FixedRegion implements Region { // TODO: Implement!
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inTestblockRegion(boolean extension) {
|
||||
public boolean inTestblockRegion(Location location, boolean extension) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user