From 8bdc9c69d8431a9b6939f20b203259fc26f87b35 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 9 Sep 2022 17:10:43 +0200 Subject: [PATCH] Move WorldEditUtils Signed-off-by: yoyosource --- .../features/slaves/laufbau/Laufbau.java | 4 +--- .../features/slaves/laufbau/LaufbauCommand.java | 2 +- .../features/slaves/panzern/Panzern.java | 2 +- .../features/slaves/panzern/PanzernCommand.java | 2 +- .../slaves => utils}/WorldEditUtils.java | 16 ++++++++++++++-- 5 files changed, 18 insertions(+), 8 deletions(-) rename BauSystem_Main/src/de/steamwar/bausystem/{features/slaves => utils}/WorldEditUtils.java (82%) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/Laufbau.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/Laufbau.java index 471d58d4..5a535c4c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/Laufbau.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/Laufbau.java @@ -20,7 +20,7 @@ package de.steamwar.bausystem.features.slaves.laufbau; import com.sk89q.worldedit.EditSession; -import de.steamwar.bausystem.features.slaves.WorldEditUtils; +import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.bausystem.features.slaves.laufbau.states.*; import lombok.Getter; import org.bukkit.Location; @@ -28,8 +28,6 @@ import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -import java.util.ArrayList; -import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java index f19cfe98..3de73826 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java @@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.slaves.laufbau; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.features.slaves.WorldEditUtils; +import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.shared.Pair; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java index 8f7900e7..ca667a8b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java @@ -23,7 +23,7 @@ import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockTypes; -import de.steamwar.bausystem.features.slaves.WorldEditUtils; +import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageUtils; import lombok.Getter; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/PanzernCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/PanzernCommand.java index 216e6c38..83d93f13 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/PanzernCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/PanzernCommand.java @@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.slaves.panzern; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.features.slaves.WorldEditUtils; +import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.shared.Pair; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/WorldEditUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/utils/WorldEditUtils.java similarity index 82% rename from BauSystem_Main/src/de/steamwar/bausystem/features/slaves/WorldEditUtils.java rename to BauSystem_Main/src/de/steamwar/bausystem/utils/WorldEditUtils.java index 43748537..057628d7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/WorldEditUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/utils/WorldEditUtils.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 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 @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.slaves; +package de.steamwar.bausystem.utils; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.IncompleteRegionException; @@ -26,11 +26,14 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.RegionSelector; import de.steamwar.bausystem.shared.Pair; +import lombok.SneakyThrows; import lombok.experimental.UtilityClass; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; +import java.util.Iterator; + @UtilityClass public class WorldEditUtils { @@ -42,6 +45,15 @@ public class WorldEditUtils { WorldEdit.getInstance().getSessionManager().get(BukkitAdapter.adapt(player)).remember(editSession); } + @SneakyThrows + public Iterator getSelectionIterator(Player player) { + RegionSelector regionSelector = WorldEdit.getInstance() + .getSessionManager() + .get(BukkitAdapter.adapt(player)) + .getRegionSelector(BukkitAdapter.adapt(player.getWorld())); + return regionSelector.getRegion().iterator(); + } + public Pair getSelection(Player player) { RegionSelector regionSelector = WorldEdit.getInstance() .getSessionManager()