SteamWar/BauSystem2.0
Archiviert
12
0

Add PanzernAlgorithmLazyInit

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-08-26 20:10:03 +02:00
Ursprung 5a32b90499
Commit c464a57828
3 geänderte Dateien mit 38 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.slaves.panzern;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.history.change.BlockChange;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockTypes;
import de.steamwar.bausystem.features.slaves.WorldEditUtils;
@ -38,12 +37,6 @@ import java.util.*;
public class Panzern {
private static List<PanzernAlgorithm> panzernAlgorithmList = new ArrayList<>();
public static void add(PanzernAlgorithm panzernAlgorithm) {
panzernAlgorithmList.add(panzernAlgorithm);
}
private static final BlockFace[] BLOCK_FACES = new BlockFace[]{BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST, BlockFace.UP, BlockFace.DOWN};
private Set<Location> current = new LinkedHashSet<>();
@ -105,7 +98,7 @@ public class Panzern {
Block currentBlock = world.getBlockAt(toCheck);
PanzernResult panzernResult = PanzernResult.DEFAULT;
for (PanzernAlgorithm panzernAlgorithm : panzernAlgorithmList) {
for (PanzernAlgorithm panzernAlgorithm : PanzernAlgorithmLazyInit.panzernAlgorithmList) {
PanzernResult temp = panzernAlgorithm.check(currentBlock, adjacent, adjacentMaterials);
if (temp != null && temp != PanzernResult.DEFAULT) {
panzernResult = temp;

Datei anzeigen

@ -0,0 +1,35 @@
/*
* 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.panzern;
import lombok.experimental.UtilityClass;
import java.util.ArrayList;
import java.util.List;
@UtilityClass
public class PanzernAlgorithmLazyInit {
static List<PanzernAlgorithm> panzernAlgorithmList = new ArrayList<>();
public static void add(PanzernAlgorithm panzernAlgorithm) {
panzernAlgorithmList.add(panzernAlgorithm);
}
}

Datei anzeigen

@ -27,6 +27,7 @@ import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.slaves.panzern.Panzern;
import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm;
import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithmLazyInit;
import de.steamwar.bausystem.features.smartplace.SmartPlaceBehaviour;
import de.steamwar.bausystem.features.smartplace.SmartPlaceListener;
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
@ -60,7 +61,7 @@ public enum LinkageType {
SCRIPT_COMMAND(4, false, SpecialCommand.class::isAssignableFrom, o -> ScriptExecutor.SPECIAL_COMMANDS.add((SpecialCommand) o)),
CONFIG_CONVERTER(5, false, ConfigConverter.class::isAssignableFrom, o -> Config.addConfigConverter((ConfigConverter) o)),
SCOREBOARD(6, false, ScoreboardItem.class::isAssignableFrom, o -> {}),
PANZERN(7, false, PanzernAlgorithm.class::isAssignableFrom, o -> Panzern.add((PanzernAlgorithm) o)),
PANZERN(7, false, PanzernAlgorithm.class::isAssignableFrom, o -> PanzernAlgorithmLazyInit.add((PanzernAlgorithm) o)),
SMART_PLACE(8, false, SmartPlaceBehaviour.class::isAssignableFrom, o -> SmartPlaceListener.add((SmartPlaceBehaviour) o));
private final int order;