From 594707637a8bf632077334912552df35ae707d28 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 7 Sep 2026 15:10:44 +0200 Subject: [PATCH] Update initial RegionVisualizer and Editor --- .../region/DynamicRegionCommand.java | 9 ++- .../region/DynamicRegionEditor2.java | 43 ---------- .../region/DynamicRegionVisualizer2.java | 80 +++++++++++++++++++ 3 files changed, 86 insertions(+), 46 deletions(-) create mode 100644 BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionVisualizer2.java diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionCommand.java b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionCommand.java index b1837b36..10c131c9 100644 --- a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionCommand.java +++ b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionCommand.java @@ -21,7 +21,6 @@ package de.steamwar.bausystem.region; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.region.RegionCommand; -import de.steamwar.bausystem.region.dynamic.Tile; import de.steamwar.command.AbstractSWCommand; import de.steamwar.command.SWCommand; import de.steamwar.core.SWPlayer; @@ -37,10 +36,14 @@ public class DynamicRegionCommand extends SWCommand { @Register({"dynamic"}) public void visualizeRegions(Player player) { SWPlayer swPlayer = SWPlayer.of(player); - if (swPlayer.hasComponent(DynamicRegionEditor2.class)) { + if (swPlayer.hasComponent(DynamicRegionVisualizer2.class)) { + swPlayer.removeComponent(DynamicRegionVisualizer2.class); swPlayer.removeComponent(DynamicRegionEditor2.class); } else { - swPlayer.setComponent(new DynamicRegionEditor2()); + swPlayer.setComponent(DynamicRegionVisualizer2.INSTANCE); + if (Permission.SUPERVISOR.hasPermission(player)) { + swPlayer.setComponent(new DynamicRegionEditor2()); + } } if (true) return; if (swPlayer.hasComponent(DynamicRegionVisualizer.class)) { diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionEditor2.java b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionEditor2.java index 68ebf987..75051b6d 100644 --- a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionEditor2.java +++ b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionEditor2.java @@ -19,58 +19,15 @@ package de.steamwar.bausystem.region; -import de.steamwar.bausystem.region.dynamic.RegionConstructorData; -import de.steamwar.bausystem.region.dynamic.Tile; -import de.steamwar.bausystem.region.dynamic.path.PathRegion; import de.steamwar.core.SWPlayer; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; public class DynamicRegionEditor2 implements SWPlayer.Component { - private static final World WORLD = Bukkit.getWorlds().get(0); - - private static final int ORIGIN_X = 10000; - private static final int ORIGIN_Z = 10000; - - public DynamicRegionEditor2() { - DynamicRegionSystem.INSTANCE.getRegions().forEach(region -> { - RegionConstructorData data = DynamicRegionSystem.constructorDataMap.get(region.getClass()); - if (data == null) return; - int widthX = data.widthX(); - int widthZ = data.widthZ(); - - Material material = data.material(); - if (region instanceof PathRegion pathRegion && pathRegion.isGarden()) { - material = Material.GRASS_BLOCK; - } - - Tile tile = Tile.fromPoint(region.getArea().getMinPoint(false)).orElseThrow(); - for (int x = 0; x < widthX; x++) { - for (int z = 0; z < widthZ; z++) { - int cx = x + tile.getTileX() + ORIGIN_X; - int cz = z + tile.getTileZ() + ORIGIN_Z; - WORLD.getBlockAt(cx, 1, cz).setType(material, false); - } - } - }); - } - @Override public void onMount(SWPlayer player) { - Location location = player.getPlayer().getLocation().clone().multiply(1.0 / Tile.tileSize).add(ORIGIN_X + 0.5, 0, ORIGIN_Z + 0.5); - location.setY(10); - player.getPlayer().teleport(location); - // TODO: Add anything that is needed for setup } @Override public void onUnmount(SWPlayer player) { - Location location = player.getPlayer().getLocation().clone().subtract(ORIGIN_X + 0.5, 0, ORIGIN_Z + 0.5).multiply(Tile.tileSize); - location.setY(50); - player.getPlayer().teleport(location.add(0.5, 0, 0.5)); - // TODO: Add anything that is needed for shutdown } } diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionVisualizer2.java b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionVisualizer2.java new file mode 100644 index 00000000..c9322d74 --- /dev/null +++ b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/DynamicRegionVisualizer2.java @@ -0,0 +1,80 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2026 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.region; + +import de.steamwar.bausystem.region.dynamic.RegionConstructorData; +import de.steamwar.bausystem.region.dynamic.Tile; +import de.steamwar.bausystem.region.dynamic.path.PathRegion; +import de.steamwar.core.SWPlayer; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; + +public class DynamicRegionVisualizer2 implements SWPlayer.Component { + + public static final DynamicRegionVisualizer2 INSTANCE = new DynamicRegionVisualizer2(); + + private static final World WORLD = Bukkit.getWorlds().get(0); + + private static final int ORIGIN_X = 10000; + private static final int ORIGIN_Z = 10000; + + public DynamicRegionVisualizer2() { + if (true) return; + // TODO: This is only needed once on startup with a clear beforehand to make the region visualization up to date with the Region Data + DynamicRegionSystem.INSTANCE.getRegions().forEach(region -> { + RegionConstructorData data = DynamicRegionSystem.constructorDataMap.get(region.getClass()); + if (data == null) return; + int widthX = data.widthX(); + int widthZ = data.widthZ(); + + Material material = data.material(); + if (region instanceof PathRegion pathRegion && pathRegion.isGarden()) { + material = Material.GRASS_BLOCK; + } + + Tile tile = Tile.fromPoint(region.getArea().getMinPoint(false)).orElseThrow(); + for (int x = 0; x < widthX; x++) { + for (int z = 0; z < widthZ; z++) { + int cx = x + tile.getTileX() + ORIGIN_X; + int cz = z + tile.getTileZ() + ORIGIN_Z; + WORLD.getBlockAt(cx, 1, cz).setType(material, false); + } + } + }); + } + + @Override + public void onMount(SWPlayer player) { + Location location = player.getPlayer().getLocation().clone().multiply(1.0 / Tile.tileSize).add(ORIGIN_X + 0.5, 0, ORIGIN_Z + 0.5); + location.setY(10); + player.getPlayer().teleport(location); + // TODO: Add anything that is needed for setup + } + + @Override + public void onUnmount(SWPlayer player) { + Location location = player.getPlayer().getLocation().clone().subtract(ORIGIN_X + 0.5, 0, ORIGIN_Z + 0.5).multiply(Tile.tileSize); + location.setY(50); + player.getPlayer().teleport(location.add(0.5, 0, 0.5)); + // TODO: Add anything that is needed for shutdown + } +}