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