SteamWar/BauSystem2.0
Archiviert
12
0

Revert ShrinkingOuterPointsState

Add LaufbauUtils.identifier

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-02-07 18:38:26 +01:00
Ursprung 3a24d27ee4
Commit 5095decb37
5 geänderte Dateien mit 123 neuen und 33 gelöschten Zeilen

Datei anzeigen

@ -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) {

Datei anzeigen

@ -38,6 +38,7 @@ public class LaufbauSettings {
list.add(new SWListInv.SWListEntry<>(LaufbauUtils.translateItem(bb.getSwItem(), p), bb));
}
SWListInv<BlockBoundingBox> inv = new SWListInv<>(p, BauSystem.MESSAGE.parse("LAUFBAU_SETTING_GUI_NAME", p), false, list, (clickType, blockBoundingBox) -> {
p.sendMessage(LaufbauUtils.identifier(blockBoundingBox.getSwItem()));
});
inv.open();
}

Datei anzeigen

@ -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<String> 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) + "]";
}
}

Datei anzeigen

@ -42,15 +42,13 @@ public class CreatingOuterBlocksState implements LaufbauState {
}
private List<Point> outerBlocks;
private List<Point> innerPoints;
private int index = 0;
private World world;
private EditSession editSession;
public CreatingOuterBlocksState(List<Point> outerBlocks, List<Point> innerPoints, World world, EditSession editSession) {
public CreatingOuterBlocksState(List<Point> 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;

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<Point> outerPoints;
private List<Point> innerPoints;
private int index = 0;
@Getter
private List<Point> shrunkOuterPoints = new ArrayList<>();
public ShrinkingOuterPointsState(List<Point> outerPoints, List<Point> 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;
}
}
}