forked from SteamWar/SteamWar
Add PathRegion
This commit is contained in:
+14
-6
@@ -24,6 +24,7 @@ import de.steamwar.bausystem.region.dynamic.DynamicRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.MovementListener;
|
||||
import de.steamwar.bausystem.region.dynamic.RegionDataRepository;
|
||||
import de.steamwar.bausystem.region.dynamic.global.GlobalRegion;
|
||||
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 lombok.NonNull;
|
||||
@@ -44,15 +45,21 @@ public class DynamicRegionSystem implements RegionSystem {
|
||||
@Override
|
||||
public void load() {
|
||||
INSTANCE = this;
|
||||
new DynamicRegionCommand();
|
||||
RegionDataRepository.loadRegions();
|
||||
Bukkit.getPluginManager().registerEvents(new MovementListener(), BauSystem.getInstance());
|
||||
|
||||
if (regionMap.isEmpty()) {
|
||||
new SpawnRegion(-9, -9);
|
||||
new SpawnPathRegion(-9, -27);
|
||||
new SpawnPathRegion(-9, -28);
|
||||
new SpawnPathRegion(-9, 10);
|
||||
new SpawnPathRegion(-27, -9);
|
||||
new SpawnPathRegion(-28, -9);
|
||||
new SpawnPathRegion(10, -9);
|
||||
|
||||
new PathRegion(-28, -28);
|
||||
new PathRegion(-28, 10);
|
||||
new PathRegion(10, -28);
|
||||
new PathRegion(10, 10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,9 +103,10 @@ public class DynamicRegionSystem implements RegionSystem {
|
||||
return regionMap.values().stream();
|
||||
}
|
||||
|
||||
public Stream<Region> getNeighbours(Region region) {
|
||||
Point minPoint = region.getArea().getMinPoint(false).subtract(19, 0, 19);
|
||||
public Stream<DynamicRegion> getNeighbours(Region region) {
|
||||
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) {
|
||||
int minZ = minPoint.getZ();
|
||||
@@ -106,14 +114,14 @@ public class DynamicRegionSystem implements RegionSystem {
|
||||
neighbours.add(get(new Location(WORLD, x, 0, minZ)));
|
||||
neighbours.add(get(new Location(WORLD, x, 0, maxZ)));
|
||||
}
|
||||
for (int z = minPoint.getZ() + 19; z <= maxPoint.getZ() - 19; z += 19) {
|
||||
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.remove(GlobalRegion.INSTANCE);
|
||||
return neighbours.stream();
|
||||
return ((Set<DynamicRegion>)(Set) neighbours).stream();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user