forked from SteamWar/SteamWar
Fix RegionSystem.GLOBAL_REGION_ID
Improve RegionUtils.forEachInRegion
This commit is contained in:
@@ -31,10 +31,10 @@ import java.util.stream.Stream;
|
||||
|
||||
public interface RegionSystem {
|
||||
|
||||
RegionSystem INSTANCE = init();
|
||||
|
||||
UUID GLOBAL_REGION_ID = new UUID(0, 0);
|
||||
|
||||
RegionSystem INSTANCE = init();
|
||||
|
||||
/**
|
||||
* Loads and initializes the Regions and anything that should be loaded on startup.
|
||||
*/
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@UtilityClass
|
||||
public class RegionUtils {
|
||||
@@ -58,10 +59,12 @@ public class RegionUtils {
|
||||
}
|
||||
|
||||
public void forEachInRegion(Region region, Consumer<Player> consumer) {
|
||||
Bukkit.getOnlinePlayers()
|
||||
.stream()
|
||||
.filter(player -> region.getArea().inRegion(player.getLocation(), false))
|
||||
.filter(player -> !region.getType().isGlobal() || Region.getRegion(player.getLocation()).getType().isGlobal())
|
||||
.forEach(consumer);
|
||||
Stream<? extends Player> players = Bukkit.getOnlinePlayers().stream();
|
||||
if (region.getType().isGlobal()) {
|
||||
players = players.filter(player -> Region.getRegion(player.getLocation()).getType().isGlobal());
|
||||
} else {
|
||||
players = players.filter(player -> region.getArea().inRegion(player.getLocation(), false));
|
||||
}
|
||||
players.forEach(consumer);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user