From 255c7e83558c80f1316edad6a74e8d85b0124745 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 3 Apr 2021 19:40:47 +0200 Subject: [PATCH] Update Region to new Region.RegionType and Region.RegionExtensionType --- .../de/steamwar/bausystem/commands/CommandTNT.java | 4 ++-- .../de/steamwar/bausystem/commands/RegionUtils.java | 4 +++- .../src/de/steamwar/bausystem/world/Region.java | 12 ++---------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java index 18553db..b57d083 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java @@ -157,11 +157,11 @@ public class CommandTNT extends SWCommand implements Listener { event.blockList().removeIf(block -> { Region region = Region.getRegion(block.getLocation()); if (region.getTntMode() == TNTMode.ON) return false; - if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation(), Region.RegionExtensionType.NORMAL)) { + if (region.hasBuildRegion() && region.inRegion(block.getLocation(), Region.RegionType.BUILD_AREA, Region.RegionExtensionType.NORMAL)) { RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Baubereich zerstört"); return true; } - if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation(), Region.RegionExtensionType.EXTENSION)) { + if (region.hasBuildRegion() && region.inRegion(block.getLocation(), Region.RegionType.BUILD_AREA, Region.RegionExtensionType.EXTENSION)) { RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Ausfahrbereich zerstört"); return true; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java index 49901e0..7c2cc3a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/RegionUtils.java @@ -20,17 +20,19 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.world.Region; +import lombok.experimental.UtilityClass; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; +@UtilityClass public class RegionUtils { public static void actionBar(Region region, String s) { if (Region.GlobalRegion.isGlobalRegion(region)) { Bukkit.getOnlinePlayers().stream().filter(player -> Region.getRegion(player.getLocation()) == null).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s))); } else { - Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), Region.RegionExtensionType.NORMAL)).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s))); + Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), Region.RegionType.NORMAL, Region.RegionExtensionType.NORMAL)).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s))); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java index 53bb16a..5363d9d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Region.java @@ -77,7 +77,7 @@ public class Region { public static Region getRegion(Location location) { for (Region region : regions) { - if (region.inRegion(location, RegionExtensionType.NORMAL)) return region; + if (region.inRegion(location, RegionType.NORMAL, RegionExtensionType.NORMAL)) return region; } return GlobalRegion.getInstance(); } @@ -191,18 +191,10 @@ public class Region { } } - public boolean inRegion(Location l, RegionExtensionType regionExtensionType) { - return prototype.inRegion(this, l, regionExtensionType); - } - public boolean hasBuildRegion() { return prototype.buildArea != null; } - public boolean inBuildRegion(Location l, RegionExtensionType regionExtensionType) { - return prototype.buildArea.inRegion(this, l, regionExtensionType); - } - public void reset() throws IOException { initSessions(); undosessions.push(prototype.reset(this, null)); @@ -297,7 +289,7 @@ public class Region { } @Override - public boolean inRegion(Location l, RegionExtensionType regionExtensionType) { + public boolean inRegion(Location l, RegionType regionType, RegionExtensionType regionExtensionType) { return true; }