From 5f1aef6a1ee52861a259d7084481caf66b520664 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Thu, 19 Feb 2026 21:01:20 +0100 Subject: [PATCH] Fix RegionSystem.GLOBAL_REGION_ID Improve RegionUtils.forEachInRegion --- .../de/steamwar/bausystem/region/RegionSystem.java | 4 ++-- .../de/steamwar/bausystem/region/RegionUtils.java | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java index 9718af01..1dbea107 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionSystem.java @@ -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. */ diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionUtils.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionUtils.java index 55203dc8..3cb9fce3 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionUtils.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionUtils.java @@ -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 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 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); } }