forked from SteamWar/SteamWar
Pot impl a FixedGlobalRegion
This commit is contained in:
+6
-4
@@ -19,16 +19,18 @@
|
||||
|
||||
package de.steamwar.bausystem.region;
|
||||
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class FixedRegionSystem implements RegionSystem {
|
||||
|
||||
private static final Map<String, Region> REGION_MAP = new HashMap<>();
|
||||
private static final Map<UUID, Region> REGION_MAP = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
@@ -48,14 +50,14 @@ public class FixedRegionSystem implements RegionSystem {
|
||||
@Override
|
||||
public Region get(Location location) {
|
||||
return REGION_MAP.values().stream()
|
||||
.filter(region -> region.inRegion(location))
|
||||
.filter(region -> region.getArea().inRegion(location, false))
|
||||
.findFirst()
|
||||
.orElse(FixedGlobalRegion.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Region> getRegion(String name) {
|
||||
return Optional.ofNullable(REGION_MAP.get(name));
|
||||
public Optional<Region> getRegion(@NonNull UUID id) {
|
||||
return Optional.ofNullable(REGION_MAP.get(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user