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 6c80e3fc..2ce9c527 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 @@ -29,6 +29,7 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; public class Laufbau { @@ -43,6 +44,7 @@ public class Laufbau { private ProcessingTracesState processingTracesState = null; private ExpandingTracesState expandingTracesState = null; private SplittingPointsState splittingPointsState = null; + private ShrinkingOuterPointsState shrinkingOuterPointsState = null; private CreatingInnerBlocksState creatingInnerBlocksState = null; private CreatingOuterBlocksState creatingOuterBlocksState = null; @@ -80,6 +82,9 @@ public class Laufbau { if (creatingInnerBlocksState != null) { return creatingInnerBlocksState; } + if (shrinkingOuterPointsState != null) { + return shrinkingOuterPointsState; + } if (splittingPointsState != null) { return splittingPointsState; } @@ -97,11 +102,15 @@ public class Laufbau { return; } if (creatingInnerBlocksState != null) { - creatingOuterBlocksState = new CreatingOuterBlocksState(splittingPointsState.getOuterPoints(), splittingPointsState.getInnerPoints(), world, editSession); + creatingOuterBlocksState = new CreatingOuterBlocksState(shrinkingOuterPointsState.getShrunkOuterPoints(), world, editSession); + return; + } + if (shrinkingOuterPointsState != null) { + creatingInnerBlocksState = new CreatingInnerBlocksState(splittingPointsState.getInnerPoints(), world, processingTracesState.getCuboidList(), splittingPointsState.getIntersectedCuboid(), editSession, elements, preferingBlastResistance); return; } if (splittingPointsState != null) { - creatingInnerBlocksState = new CreatingInnerBlocksState(splittingPointsState.getInnerPoints(), world, processingTracesState.getCuboidList(), splittingPointsState.getIntersectedCuboid(), editSession, elements, preferingBlastResistance); + shrinkingOuterPointsState = new ShrinkingOuterPointsState(splittingPointsState.getOuterPoints(), splittingPointsState.getInnerPoints()); return; } if (expandingTracesState != null) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauSettings.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauSettings.java index 88ecce34..b2215e77 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauSettings.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauSettings.java @@ -38,6 +38,7 @@ public class LaufbauSettings { list.add(new SWListInv.SWListEntry<>(LaufbauUtils.translateItem(bb.getSwItem(), p), bb)); } SWListInv inv = new SWListInv<>(p, BauSystem.MESSAGE.parse("LAUFBAU_SETTING_GUI_NAME", p), false, list, (clickType, blockBoundingBox) -> { + p.sendMessage(LaufbauUtils.identifier(blockBoundingBox.getSwItem())); }); inv.open(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauUtils.java index d1a718ea..6c06d2d3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauUtils.java @@ -56,4 +56,24 @@ public class LaufbauUtils { return new SWItem(item.getItemStack().getType(), BauSystem.MESSAGE.parse(itemMeta.getDisplayName(), p), lore, false, clickType -> { }); } + + public static String identifier(SWItem item) { + ItemMeta itemMeta = item.getItemMeta(); + List lore = new ArrayList<>(); + if (itemMeta.getLore() != null) { + lore = itemMeta.getLore() + .stream() + .map(s -> s.substring(8)) + .map(s -> { + return s.replace("ATTACHMENT", "*") + .replace("CONNECTION", "CON") + .replace("FACING", "*") + .replace("LAYERS", "*") + .replace("SHAPE", "*"); + }) + .collect(Collectors.toList()); + } + String name = itemMeta.getDisplayName().substring(14); + return name + "[" + String.join(",", lore) + "]"; + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingOuterBlocksState.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingOuterBlocksState.java index 0ff7693f..6c97b5f8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingOuterBlocksState.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingOuterBlocksState.java @@ -42,15 +42,13 @@ public class CreatingOuterBlocksState implements LaufbauState { } private List outerBlocks; - private List innerPoints; private int index = 0; private World world; private EditSession editSession; - public CreatingOuterBlocksState(List outerBlocks, List innerPoints, World world, EditSession editSession) { + public CreatingOuterBlocksState(List outerBlocks, World world, EditSession editSession) { this.outerBlocks = outerBlocks; - this.innerPoints = innerPoints; this.world = world; this.editSession = editSession; } @@ -70,34 +68,6 @@ public class CreatingOuterBlocksState implements LaufbauState { Point point = outerBlocks.get(index); index++; - boolean isRim = false; - Point p1 = new Point(point.getX() - 1, point.getY(), point.getZ()); - if (innerPoints.contains(p1)) isRim = true; - if (!isRim) { - Point p2 = new Point(point.getX() + 1, point.getY(), point.getZ()); - if (innerPoints.contains(p2)) isRim = true; - } - if (!isRim) { - Point p3 = new Point(point.getX(), point.getY() - 1, point.getZ()); - if (innerPoints.contains(p3)) isRim = true; - } - if (!isRim) { - Point p4 = new Point(point.getX(), point.getY() + 1, point.getZ()); - if (innerPoints.contains(p4)) isRim = true; - } - if (!isRim) { - Point p5 = new Point(point.getX(), point.getY(), point.getZ() - 1); - if (innerPoints.contains(p5)) isRim = true; - } - if (!isRim) { - Point p6 = new Point(point.getX(), point.getY(), point.getZ() + 1); - if (innerPoints.contains(p6)) isRim = true; - } - - if (!isRim) { - return; - } - Location location = new Location(world, point.getX(), point.getY(), point.getZ()); if (!location.getBlock().getType().isAir()) { return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ShrinkingOuterPointsState.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ShrinkingOuterPointsState.java new file mode 100644 index 00000000..8ee9ed0a --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ShrinkingOuterPointsState.java @@ -0,0 +1,90 @@ +/* + * This file is a part of the SteamWar software. + * + * 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 + * 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.features.slaves.laufbau.states; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.region.Point; +import lombok.Getter; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; + +public class ShrinkingOuterPointsState implements LaufbauState { + + private List outerPoints; + private List innerPoints; + private int index = 0; + + @Getter + private List shrunkOuterPoints = new ArrayList<>(); + + public ShrinkingOuterPointsState(List outerPoints, List innerPoints) { + this.outerPoints = outerPoints; + this.innerPoints = innerPoints; + } + + @Override + public String actionBarMessage(Player p) { + return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_SHRINKING_POINTS", p), index, outerPoints.size()); + } + + @Override + public boolean hasNext() { + return index < outerPoints.size(); + } + + @Override + public void next() { + Point point = outerPoints.get(index); + index++; + + Point p1 = new Point(point.getX() - 1, point.getY(), point.getZ()); + if (innerPoints.contains(p1)) { + shrunkOuterPoints.add(point); + return; + } + Point p2 = new Point(point.getX() + 1, point.getY(), point.getZ()); + if (innerPoints.contains(p2)) { + shrunkOuterPoints.add(point); + return; + } + Point p3 = new Point(point.getX(), point.getY() - 1, point.getZ()); + if (innerPoints.contains(p3)) { + shrunkOuterPoints.add(point); + return; + } + Point p4 = new Point(point.getX(), point.getY() + 1, point.getZ()); + if (innerPoints.contains(p4)) { + shrunkOuterPoints.add(point); + return; + } + Point p5 = new Point(point.getX(), point.getY(), point.getZ() - 1); + if (innerPoints.contains(p5)) { + shrunkOuterPoints.add(point); + return; + } + Point p6 = new Point(point.getX(), point.getY(), point.getZ() + 1); + if (innerPoints.contains(p6)) { + shrunkOuterPoints.add(point); + return; + } + } +}