From f3bf5fc1eacad3db8fe5405df2a47cd4766e4f63 Mon Sep 17 00:00:00 2001 From: nicksitnikov Date: Thu, 28 May 2026 23:04:03 -0500 Subject: [PATCH] Apply spotless --- .../structure/IStructureElement.java | 2 +- .../structure/IStructureWalker.java | 14 +-- .../structure/StructureUtility.java | 92 +++++++++++-------- 3 files changed, 62 insertions(+), 46 deletions(-) diff --git a/src/main/java/com/gtnewhorizon/structurelib/structure/IStructureElement.java b/src/main/java/com/gtnewhorizon/structurelib/structure/IStructureElement.java index 6c3d9287..a5390bf3 100644 --- a/src/main/java/com/gtnewhorizon/structurelib/structure/IStructureElement.java +++ b/src/main/java/com/gtnewhorizon/structurelib/structure/IStructureElement.java @@ -30,7 +30,7 @@ import com.gtnewhorizon.structurelib.util.ItemStackPredicate.NBTMode; * represents what a particular element can be and how this particular element should be autoplaced. * * @param Type of the context object. {@link IStructureElement} is contravariant over T, so parameters and fields of - * type {@link IStructureElement} should be declared as {@code IStructureElement} + * type {@link IStructureElement} should be declared as {@code IStructureElement} */ public interface IStructureElement { diff --git a/src/main/java/com/gtnewhorizon/structurelib/structure/IStructureWalker.java b/src/main/java/com/gtnewhorizon/structurelib/structure/IStructureWalker.java index ac958e91..d81ba74a 100644 --- a/src/main/java/com/gtnewhorizon/structurelib/structure/IStructureWalker.java +++ b/src/main/java/com/gtnewhorizon/structurelib/structure/IStructureWalker.java @@ -32,13 +32,14 @@ public interface IStructureWalker { return new IStructureWalker<>() { @Override - public boolean visit(IStructureElement element, World world, int x, int y, int z, int a, int b, int c) { + public boolean visit(IStructureElement element, World world, int x, int y, int z, int a, int b, + int c) { return walker.visit(element, world, x, y, z, a, b, c); } @Override - public boolean blockNotLoaded(IStructureElement element, World world, int x, int y, int z, int a, int b, - int c) { + public boolean blockNotLoaded(IStructureElement element, World world, int x, int y, int z, int a, + int b, int c) { return walker.visit(element, world, x, y, z, a, b, c); } }; @@ -48,13 +49,14 @@ public interface IStructureWalker { return new IStructureWalker<>() { @Override - public boolean visit(IStructureElement element, World world, int x, int y, int z, int a, int b, int c) { + public boolean visit(IStructureElement element, World world, int x, int y, int z, int a, int b, + int c) { return walker.visit(element, world, x, y, z, a, b, c); } @Override - public boolean blockNotLoaded(IStructureElement element, World world, int x, int y, int z, int a, int b, - int c) { + public boolean blockNotLoaded(IStructureElement element, World world, int x, int y, int z, int a, + int b, int c) { return true; } }; diff --git a/src/main/java/com/gtnewhorizon/structurelib/structure/StructureUtility.java b/src/main/java/com/gtnewhorizon/structurelib/structure/StructureUtility.java index 2c37fd57..6228f645 100644 --- a/src/main/java/com/gtnewhorizon/structurelib/structure/StructureUtility.java +++ b/src/main/java/com/gtnewhorizon/structurelib/structure/StructureUtility.java @@ -46,7 +46,6 @@ import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; @@ -577,7 +576,8 @@ public class StructureUtility { * @see #ofBlocksTiered(ITierConverter, Object, BiConsumer, Function) */ public static IStructureElementCheckOnly ofBlocksTiered(ITierConverter tierExtractor, - @Nullable TIER notSet, BiConsumer setter, Function getter) { + @Nullable TIER notSet, BiConsumer setter, + Function getter) { if (tierExtractor == null) throw new IllegalArgumentException(); if (setter == null) throw new IllegalArgumentException(); if (getter == null) throw new IllegalArgumentException(); @@ -700,8 +700,8 @@ public class StructureUtility { * @param setter a function to set the current tier into context object */ public static IStructureElement ofBlocksTiered(ITierConverter tierExtractor, - @Nullable List> allKnownTiers, @Nullable TIER notSet, BiConsumer setter, - Function getter) { + @Nullable List> allKnownTiers, @Nullable TIER notSet, + BiConsumer setter, Function getter) { List descriptions = null; if (allKnownTiers != null) { descriptions = new java.util.ArrayList<>(); @@ -723,8 +723,9 @@ public class StructureUtility { * @see #ofBlocksTiered(ITierConverter, List, Object, BiConsumer, Function) */ public static IStructureElement ofBlocksTiered(ITierConverter tierExtractor, - @Nullable List> allKnownTiers, @Nullable TIER notSet, BiConsumer setter, - Function getter, @Nullable List description) { + @Nullable List> allKnownTiers, @Nullable TIER notSet, + BiConsumer setter, Function getter, + @Nullable List description) { List> hints = allKnownTiers == null ? Collections.emptyList() : allKnownTiers; if (hints.stream().anyMatch(Objects::isNull)) throw new IllegalArgumentException(); IStructureElementCheckOnly check = ofBlocksTiered(tierExtractor, notSet, setter, getter); @@ -1014,7 +1015,7 @@ public class StructureUtility { *

* Does not have autoplace. * - * @param blocksMap Accepted (block, meta) pairs. + * @param blocksMap Accepted (block, meta) pairs. * @param hintBlock hint block to use * @param hintMeta hint meta to use * @see #ofBlocksMapHint(Map, Block, int) @@ -1050,13 +1051,13 @@ public class StructureUtility { *

* Does not have autoplace. * - * @param blocksMap Accepted (block, meta) pairs. + * @param blocksMap Accepted (block, meta) pairs. * @param hintBlock hint block to use * @param hintMeta hint meta to use * @see #ofBlocksFlatHint(Map, Block, int) */ - public static IStructureElementNoPlacement ofBlocksMapHint(Map> blocksMap, - Block hintBlock, int hintMeta) { + public static IStructureElementNoPlacement ofBlocksMapHint( + Map> blocksMap, Block hintBlock, int hintMeta) { if (blocksMap == null || blocksMap.isEmpty() || hintBlock == null) { throw new IllegalArgumentException(); } @@ -1129,8 +1130,8 @@ public class StructureUtility { *

* Useful when your logic is very complex. Does not support autoplace. */ - public static IStructureElementNoPlacement ofBlockAdderHint(IBlockAdder iBlockAdder, Block hintBlock, - int hintMeta) { + public static IStructureElementNoPlacement ofBlockAdderHint(IBlockAdder iBlockAdder, + Block hintBlock, int hintMeta) { if (iBlockAdder == null || hintBlock == null) { throw new IllegalArgumentException(); } @@ -1161,7 +1162,7 @@ public class StructureUtility { * Accept a set of blocks. Less cumbersome to use than {@link #ofBlocksMap(Map, Block, int)} when for any accepted * block type we accept only one meta for each. * - * @param blocksMap Accepted (block, meta) pairs. + * @param blocksMap Accepted (block, meta) pairs. * @param defaultBlock default block to place/spawn hint * @param defaultMeta default meta to place/spawn hint * @see #ofBlocksMapHint(Map, Block, int) @@ -1279,8 +1280,8 @@ public class StructureUtility { * @param defaultMeta default meta to place/spawn hint * @see #ofBlocksMapHint(Map, Block, int) */ - public static IStructureElement ofBlocksMap(Map> blocsMap, Block defaultBlock, - int defaultMeta) { + public static IStructureElement ofBlocksMap(Map> blocsMap, + Block defaultBlock, int defaultMeta) { if (blocsMap == null || blocsMap.isEmpty() || defaultBlock == null) { throw new IllegalArgumentException(); } @@ -1803,8 +1804,8 @@ public class StructureUtility { * Try to add a structure element with a particular type of tile entity. Note that tile adder will not be called at * locations without a tile entity. */ - public static IStructureElementNoPlacement ofSpecificTileAdder(BiPredicate iTileAdder, - Class tileClass, Block hintBlock, int hintMeta) { + public static IStructureElementNoPlacement ofSpecificTileAdder( + BiPredicate iTileAdder, Class tileClass, Block hintBlock, int hintMeta) { if (iTileAdder == null || hintBlock == null || tileClass == null) { throw new IllegalArgumentException(); } @@ -1844,7 +1845,8 @@ public class StructureUtility { * @param onCheckPass side effect * @param element downstream */ - public static IStructureElement onElementPass(Consumer onCheckPass, IStructureElement element) { + public static IStructureElement onElementPass(Consumer onCheckPass, + IStructureElement element) { return new IStructureElement<>() { @Override @@ -1906,7 +1908,8 @@ public class StructureUtility { * @param description the description to use, or null to clear any existing description * @param element the element to wrap */ - public static IStructureElement withDescription(@Nullable List description, IStructureElement element) { + public static IStructureElement withDescription(@Nullable List description, + IStructureElement element) { return new IStructureElement<>() { @Override @@ -1963,7 +1966,8 @@ public class StructureUtility { * @param onFail side effect * @param element downstream */ - public static IStructureElement onElementFail(Consumer onFail, IStructureElement element) { + public static IStructureElement onElementFail(Consumer onFail, + IStructureElement element) { return new IStructureElement<>() { @Override @@ -2035,8 +2039,8 @@ public class StructureUtility { * * @param placeResultWhenDisabled value to return for survival auto place when predicate returns false */ - public static IStructureElement onlyIf(Predicate predicate, IStructureElement downstream, - PlaceResult placeResultWhenDisabled) { + public static IStructureElement onlyIf(Predicate predicate, + IStructureElement downstream, PlaceResult placeResultWhenDisabled) { return new IStructureElement<>() { @Override @@ -2224,7 +2228,8 @@ public class StructureUtility { * * @param to create structure element from the first context object passed in */ - public static IStructureElementDeferred lazy(Function> to) { + public static IStructureElementDeferred lazy( + Function> to) { if (to == null) { throw new IllegalArgumentException(); } @@ -2299,7 +2304,8 @@ public class StructureUtility { * * @param to downstream element supplier */ - public static IStructureElementDeferred defer(Function> to) { + public static IStructureElementDeferred defer( + Function> to) { if (to == null) { throw new IllegalArgumentException(); } @@ -2516,7 +2522,8 @@ public class StructureUtility { * * @param to downstream element supplier */ - public static IStructureElementDeferred defer(BiFunction> to) { + public static IStructureElementDeferred defer( + BiFunction> to) { if (to == null) { throw new IllegalArgumentException(); } @@ -2600,7 +2607,8 @@ public class StructureUtility { * @param keyExtractor extract a key from the context object and trigger item * @param map all possible structure element */ - public static IStructureElementDeferred partitionBy(BiFunction keyExtractor, + public static IStructureElementDeferred partitionBy( + BiFunction keyExtractor, Map> map) { if (keyExtractor == null || map == null) { throw new IllegalArgumentException(); @@ -2647,7 +2655,8 @@ public class StructureUtility { * @param map all possible structure element * @param defaultElem element to use when keyExtractor returns a value not found in given map */ - public static IStructureElementDeferred partitionBy(BiFunction keyExtractor, + public static IStructureElementDeferred partitionBy( + BiFunction keyExtractor, Map> map, IStructureElement defaultElem) { if (keyExtractor == null || map == null) { throw new IllegalArgumentException(); @@ -2712,7 +2721,8 @@ public class StructureUtility { * @param toCheck override the check function with the returned element * @param to create structure element from the context object passed in */ - public static IStructureElementDeferred defer(Function> toCheck, + public static IStructureElementDeferred defer( + Function> toCheck, BiFunction> to) { if (to == null) { throw new IllegalArgumentException(); @@ -2775,7 +2785,8 @@ public class StructureUtility { */ @Deprecated public static IStructureElementDeferred defer(Function keyExtractorCheck, - BiFunction keyExtractor, Map> map) { + BiFunction keyExtractor, + Map> map) { return partitionBy(keyExtractorCheck, keyExtractor, map); } @@ -2799,7 +2810,8 @@ public class StructureUtility { * @param map all possible structure element */ public static IStructureElementDeferred partitionBy(Function keyExtractorCheck, - BiFunction keyExtractor, Map> map) { + BiFunction keyExtractor, + Map> map) { if (keyExtractor == null || map == null) { throw new IllegalArgumentException(); } @@ -2827,8 +2839,8 @@ public class StructureUtility { */ @Deprecated public static IStructureElementDeferred defer(Function keyExtractorCheck, - BiFunction keyExtractor, Map> map, - IStructureElement defaultElem) { + BiFunction keyExtractor, + Map> map, IStructureElement defaultElem) { return partitionBy(keyExtractorCheck, keyExtractor, map, defaultElem); } @@ -2851,8 +2863,8 @@ public class StructureUtility { * @param map all possible structure element */ public static IStructureElementDeferred partitionBy(Function keyExtractorCheck, - BiFunction keyExtractor, Map> map, - IStructureElement defaultElem) { + BiFunction keyExtractor, + Map> map, IStructureElement defaultElem) { if (keyExtractor == null || map == null) { throw new IllegalArgumentException(); } @@ -2934,7 +2946,8 @@ public class StructureUtility { */ @Deprecated public static IStructureElementDeferred defer(Function keyExtractorCheck, - BiFunction keyExtractor, List> array) { + BiFunction keyExtractor, + List> array) { return partitionBy(keyExtractorCheck, keyExtractor, array); } @@ -2956,7 +2969,8 @@ public class StructureUtility { */ @SuppressWarnings("unchecked") public static IStructureElementDeferred partitionBy(Function keyExtractorCheck, - BiFunction keyExtractor, List> array) { + BiFunction keyExtractor, + List> array) { return partitionBy(keyExtractorCheck, keyExtractor, array.toArray(new IStructureElement[0])); } @@ -3070,7 +3084,7 @@ public class StructureUtility { } private static IStructureNavigate stepA(int a, int b, int c) { - return new IStructureNavigate() { + return new IStructureNavigate<>() { @Override public int getStepA() { @@ -3090,7 +3104,7 @@ public class StructureUtility { } private static IStructureNavigate stepB(int a, int b, int c) { - return new IStructureNavigate() { + return new IStructureNavigate<>() { @Override public int getStepA() { @@ -3115,7 +3129,7 @@ public class StructureUtility { } private static IStructureNavigate stepC(int a, int b, int c) { - return new IStructureNavigate() { + return new IStructureNavigate<>() { @Override public int getStepA() {