Add PanzernAlgorithmLazyInit
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
5a32b90499
Commit
c464a57828
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren