From 7d423fa49dceb7e9e2acbd72dc25b1a7f2c22816 Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Wed, 14 Jul 2021 16:40:20 -0400 Subject: [PATCH] Totally stable optimizations that wont cause any problems at all. --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- src/main/java/com/volmit/iris/Iris.java | 27 +- .../java/com/volmit/iris/IrisSettings.java | 2 + .../iris/generator/IrisWorldManager.java | 2 +- .../generator/actuator/IrisBiomeActuator.java | 6 +- .../decorator/IrisEngineDecorator.java | 2 +- .../decorator/IrisSurfaceDecorator.java | 2 +- .../generator/modifier/IrisPostModifier.java | 1 + .../modifier/IrisRavineModifier.java | 5 +- .../com/volmit/iris/generator/noise/CNG.java | 4 +- .../iris/generator/noise/FastNoiseDouble.java | 411 ++---- .../iris/manager/ConversionManager.java | 76 +- .../volmit/iris/manager/IrisBoardManager.java | 10 +- .../com/volmit/iris/manager/IrisProject.java | 10 +- .../volmit/iris/manager/ProjectManager.java | 30 +- .../volmit/iris/manager/SchemaBuilder.java | 1206 ++++++++--------- .../com/volmit/iris/manager/WandManager.java | 2 +- .../manager/command/CommandIrisDownload.java | 1 + .../object/CommandIrisObjectContract.java | 2 +- .../object/CommandIrisObjectExpand.java | 2 +- .../object/CommandIrisObjectPaste.java | 1 + .../command/object/CommandIrisObjectSave.java | 1 + .../object/CommandIrisObjectShift.java | 2 +- .../command/studio/CommandIrisStudioLoot.java | 2 +- .../studio/CommandIrisStudioPackage.java | 1 + .../studio/CommandIrisStudioProfile.java | 7 +- .../command/what/CommandIrisWhatBiome.java | 2 +- .../command/what/CommandIrisWhatObjects.java | 4 +- .../command/world/CommandIrisCreate.java | 44 +- .../manager/command/world/CommandIrisFix.java | 2 +- .../command/world/CommandIrisPregen.java | 9 +- .../command/world/CommandIrisUpdateWorld.java | 1 + .../manager/command/world/CommandLocate.java | 2 +- .../volmit/iris/manager/edit/BlockSignal.java | 1 + .../iris/manager/edit/BukkitBlockEditor.java | 1 + .../iris/manager/edit/DustRevealer.java | 1 + .../iris/manager/edit/WEBlockEditor.java | 1 - .../volmit/iris/manager/gui/IrisRenderer.java | 1 + .../volmit/iris/manager/gui/IrisVision.java | 67 +- .../iris/manager/gui/NoiseExplorer.java | 14 +- .../com/volmit/iris/manager/link/BKLink.java | 3 +- .../iris/manager/link/CitizensLink.java | 15 +- .../iris/manager/link/MultiverseCoreLink.java | 18 +- .../iris/manager/link/MythicMobsLink.java | 5 +- .../volmit/iris/nms/v17_1/NMSBinding17_1.java | 9 +- .../com/volmit/iris/object/CarvingMode.java | 2 + .../com/volmit/iris/object/IrisBiome.java | 19 +- .../volmit/iris/object/IrisBiomeMutation.java | 30 +- .../com/volmit/iris/object/IrisBlockData.java | 11 +- .../volmit/iris/object/IrisBlockDrops.java | 2 +- .../com/volmit/iris/object/IrisColor.java | 6 +- .../com/volmit/iris/object/IrisCompat.java | 2 - .../com/volmit/iris/object/IrisDecorator.java | 7 +- .../iris/object/IrisDepositGenerator.java | 2 +- .../com/volmit/iris/object/IrisDimension.java | 15 +- .../iris/object/IrisDimensionIndex.java | 1 + .../com/volmit/iris/object/IrisDirection.java | 135 +- .../com/volmit/iris/object/IrisEffect.java | 50 +- .../volmit/iris/object/IrisEnchantment.java | 2 +- .../com/volmit/iris/object/IrisEntity.java | 3 +- .../com/volmit/iris/object/IrisGenerator.java | 3 +- .../iris/object/IrisGeneratorStyle.java | 3 +- .../volmit/iris/object/IrisJigsawPiece.java | 1 + .../iris/object/IrisJigsawPieceConnector.java | 1 + .../volmit/iris/object/IrisJigsawPool.java | 1 + .../iris/object/IrisJigsawStructure.java | 1 + .../object/IrisJigsawStructurePlacement.java | 1 + .../java/com/volmit/iris/object/IrisLoot.java | 10 +- .../com/volmit/iris/object/IrisLootTable.java | 1 + .../iris/object/IrisNoiseGenerator.java | 2 +- .../com/volmit/iris/object/IrisObject.java | 29 +- .../iris/object/IrisObjectPlacement.java | 12 +- .../iris/object/IrisObjectRotation.java | 61 +- .../volmit/iris/object/IrisPotionEffect.java | 2 +- .../volmit/iris/object/IrisRareObject.java | 1 + .../com/volmit/iris/object/IrisRegion.java | 11 +- .../com/volmit/iris/object/IrisSlopeClip.java | 1 + .../volmit/iris/object/tile/TileBanner.java | 48 +- .../com/volmit/iris/object/tile/TileData.java | 7 +- .../com/volmit/iris/object/tile/TileSign.java | 1 + .../volmit/iris/object/tile/TileSpawner.java | 3 +- .../volmit/iris/pregen/DirectWorldWriter.java | 3 +- .../com/volmit/iris/pregen/Pregenerator.java | 82 +- .../com/volmit/iris/scaffold/IrisWorlds.java | 1 + .../iris/scaffold/cache/AtomicCache.java | 2 + .../iris/scaffold/cache/Multicache.java | 2 - .../iris/scaffold/data/DataPalette.java | 4 +- .../iris/scaffold/data/mca/LoadFlags.java | 32 +- .../iris/scaffold/data/mca/MCAFile.java | 11 +- .../iris/scaffold/data/mca/Section.java | 7 +- .../iris/scaffold/data/nbt/io/SNBTWriter.java | 1 + .../scaffold/data/nbt/io/StringPointer.java | 1 + .../iris/scaffold/data/nbt/tag/ArrayTag.java | 2 +- .../scaffold/data/nbt/tag/CompoundTag.java | 1 + .../iris/scaffold/data/nbt/tag/ListTag.java | 3 +- .../data/nbt/tag/NonNullEntrySet.java | 14 +- .../iris/scaffold/data/nbt/tag/Tag.java | 5 +- .../volmit/iris/scaffold/engine/Engine.java | 8 +- .../engine/EngineCompositeGenerator.java | 24 +- .../iris/scaffold/engine/EngineCompound.java | 2 +- .../iris/scaffold/engine/EngineData.java | 2 +- .../iris/scaffold/engine/EngineDecorator.java | 1 + .../engine/EngineParallaxManager.java | 8 +- .../iris/scaffold/engine/EnginePlayer.java | 6 +- .../scaffold/engine/EngineWorldManager.java | 1 + .../iris/scaffold/engine/IrisAccess.java | 1 + .../com/volmit/iris/scaffold/hunk/Hunk.java | 5 +- .../iris/scaffold/hunk/io/HunkRegion.java | 3 +- .../scaffold/hunk/io/HunkRegionSlice.java | 2 +- .../hunk/io/PaletteHunkIOAdapter.java | 2 +- .../iris/scaffold/hunk/storage/ArrayHunk.java | 1 + .../hunk/storage/AtomicDoubleHunk.java | 1 + .../scaffold/hunk/storage/AtomicHunk.java | 3 +- .../hunk/storage/AtomicIntegerHunk.java | 1 + .../scaffold/hunk/storage/AtomicLongHunk.java | 1 + .../scaffold/hunk/storage/MappedHunk.java | 1 + .../hunk/storage/SynchronizedArrayHunk.java | 1 + .../scaffold/hunk/view/BiomeGridHunkView.java | 1 + .../hunk/view/ChunkBiomeHunkView.java | 1 + .../scaffold/hunk/view/ChunkDataHunkView.java | 1 + .../scaffold/hunk/view/ChunkHunkView.java | 1 + .../scaffold/hunk/view/DriftHunkView.java | 1 + .../scaffold/hunk/view/FringedHunkView.java | 1 + .../scaffold/hunk/view/InvertedHunkView.java | 1 + .../scaffold/hunk/view/ListeningHunk.java | 1 + .../iris/scaffold/hunk/view/ReadOnlyHunk.java | 1 + .../scaffold/hunk/view/RotatedXHunkView.java | 8 +- .../scaffold/hunk/view/RotatedYHunkView.java | 8 +- .../scaffold/hunk/view/RotatedZHunkView.java | 8 +- .../hunk/view/SynchronizedHunkView.java | 1 + .../scaffold/hunk/view/WriteTrackHunk.java | 1 + .../iris/scaffold/jigsaw/PlannedPiece.java | 1 + .../scaffold/lighting/FlatRegionInfo.java | 1 - .../scaffold/lighting/FlatRegionInfoMap.java | 13 +- .../scaffold/lighting/LightingAutoClean.java | 2 +- .../scaffold/lighting/LightingCategory.java | 15 - .../iris/scaffold/lighting/LightingChunk.java | 16 +- .../lighting/LightingChunkNeighboring.java | 6 - .../iris/scaffold/lighting/LightingCube.java | 5 +- .../lighting/LightingCubeNeighboring.java | 6 - .../lighting/LightingForcedChunkCache.java | 6 +- .../scaffold/lighting/LightingService.java | 1 + .../scaffold/lighting/LightingTaskBatch.java | 18 +- .../scaffold/lighting/LightingTaskWorld.java | 3 +- .../scaffold/lighting/TimeDurationFormat.java | 2 - .../scaffold/parallax/ParallaxChunkMeta.java | 2 +- .../iris/scaffold/parallax/ParallaxWorld.java | 1 + .../iris/scaffold/parallel/BurstExecutor.java | 4 +- .../iris/scaffold/parallel/MultiBurst.java | 28 +- .../scaffold/stream/ProceduralStream.java | 1 + .../stream/convert/ForceDoubleStream.java | 1 - .../stream/convert/SignificanceStream.java | 6 +- .../stream/interpolation/Interpolated.java | 4 +- .../stream/interpolation/Interpolator.java | 2 +- .../interpolation/InterpolatorFactory.java | 3 +- .../stream/utility/ProfiledStream.java | 7 +- .../com/volmit/iris/util/AtomicAverage.java | 4 +- .../java/com/volmit/iris/util/Average.java | 2 +- src/main/java/com/volmit/iris/util/B.java | 12 +- .../com/volmit/iris/util/BlockPosition.java | 5 +- src/main/java/com/volmit/iris/util/Board.java | 8 +- .../java/com/volmit/iris/util/BoardEntry.java | 1 + .../com/volmit/iris/util/BoardSettings.java | 1 + src/main/java/com/volmit/iris/util/C.java | 157 +-- src/main/java/com/volmit/iris/util/CDou.java | 1 + .../com/volmit/iris/util/CarveResult.java | 3 + .../com/volmit/iris/util/ChunkPosition.java | 3 +- .../java/com/volmit/iris/util/Chunker.java | 4 +- .../com/volmit/iris/util/CompoundTag.java | 4 +- .../java/com/volmit/iris/util/Consumer2.java | 2 +- .../java/com/volmit/iris/util/Consumer3.java | 2 +- .../java/com/volmit/iris/util/Consumer4.java | 1 - .../java/com/volmit/iris/util/Consumer5.java | 1 - .../java/com/volmit/iris/util/Consumer6.java | 1 - .../java/com/volmit/iris/util/Consumer7.java | 1 - .../java/com/volmit/iris/util/Consumer8.java | 1 - .../java/com/volmit/iris/util/Controller.java | 2 +- .../java/com/volmit/iris/util/Converter.java | 1 + .../java/com/volmit/iris/util/Cuboid.java | 148 +- .../com/volmit/iris/util/DataPalette.java | 4 +- .../java/com/volmit/iris/util/Direction.java | 126 +- .../volmit/iris/util/DoubleArrayUtils.java | 4 +- .../java/com/volmit/iris/util/Element.java | 1 + .../java/com/volmit/iris/util/FakeWorld.java | 314 +++-- src/main/java/com/volmit/iris/util/Form.java | 226 +-- .../java/com/volmit/iris/util/Function2.java | 1 - .../java/com/volmit/iris/util/Function3.java | 1 - .../java/com/volmit/iris/util/Function4.java | 1 - .../java/com/volmit/iris/util/GBiset.java | 1 - .../com/volmit/iris/util/GListAdapter.java | 2 +- .../com/volmit/iris/util/GroupedExecutor.java | 15 +- src/main/java/com/volmit/iris/util/HTTP.java | 1 - .../com/volmit/iris/util/HTTPTokener.java | 1 - .../volmit/iris/util/HeightedFakeWorld.java | 315 +++-- .../com/volmit/iris/util/IController.java | 1 + src/main/java/com/volmit/iris/util/IO.java | 34 +- .../volmit/iris/util/InvertedBiomeGrid.java | 7 +- .../volmit/iris/util/IrisInterpolation.java | 2 - .../java/com/volmit/iris/util/IrisLock.java | 2 +- .../com/volmit/iris/util/IrisMathHelper.java | 39 +- src/main/java/com/volmit/iris/util/J.java | 1 + .../java/com/volmit/iris/util/JSONArray.java | 2 + .../java/com/volmit/iris/util/JSONML.java | 13 +- .../java/com/volmit/iris/util/JSONObject.java | 2 + .../com/volmit/iris/util/JSONTokener.java | 1 + .../java/com/volmit/iris/util/JSONWriter.java | 4 +- .../java/com/volmit/iris/util/JarScanner.java | 2 +- src/main/java/com/volmit/iris/util/KList.java | 6 +- src/main/java/com/volmit/iris/util/KMap.java | 2 +- .../volmit/iris/util/LinkedTerrainChunk.java | 16 +- .../java/com/volmit/iris/util/ListTag.java | 4 +- .../java/com/volmit/iris/util/Looper.java | 2 + src/main/java/com/volmit/iris/util/M.java | 6 +- .../java/com/volmit/iris/util/MathHelper.java | 39 +- .../java/com/volmit/iris/util/Metrics.java | 9 +- .../com/volmit/iris/util/MetricsLite.java | 6 +- .../com/volmit/iris/util/MortarCommand.java | 9 +- .../com/volmit/iris/util/MortarSender.java | 26 +- .../com/volmit/iris/util/NBTConstants.java | 4 +- .../com/volmit/iris/util/NBTInputStream.java | 10 +- .../com/volmit/iris/util/NBTOutputStream.java | 60 +- .../java/com/volmit/iris/util/NBTUtils.java | 47 +- .../java/com/volmit/iris/util/NMSVersion.java | 2 +- .../com/volmit/iris/util/NastyFunction.java | 2 +- .../com/volmit/iris/util/NastyFuture.java | 2 +- .../com/volmit/iris/util/NibbleArray.java | 4 +- src/main/java/com/volmit/iris/util/O.java | 3 +- .../iris/util/ObjectResourceLoader.java | 2 +- .../iris/util/ParticleSenderLegacy.java | 8 +- .../com/volmit/iris/util/ParticleType.java | 21 +- src/main/java/com/volmit/iris/util/Queue.java | 1 + .../com/volmit/iris/util/QueueExecutor.java | 2 +- src/main/java/com/volmit/iris/util/RNG.java | 2 +- .../com/volmit/iris/util/ResourceLoader.java | 5 +- .../com/volmit/iris/util/RouterCommand.java | 7 +- .../com/volmit/iris/util/SKConversion.java | 3 - .../com/volmit/iris/util/ShurikenQueue.java | 2 +- .../java/com/volmit/iris/util/Spiraler.java | 1 + .../com/volmit/iris/util/TaskExecutor.java | 17 +- .../com/volmit/iris/util/TerrainChunk.java | 10 +- .../com/volmit/iris/util/ThreadMonitor.java | 1 + .../java/com/volmit/iris/util/Tuple2d.java | 40 +- .../java/com/volmit/iris/util/Tuple2f.java | 40 +- .../java/com/volmit/iris/util/Tuple3d.java | 58 +- .../java/com/volmit/iris/util/Tuple3f.java | 58 +- .../java/com/volmit/iris/util/Tuple4d.java | 70 +- .../java/com/volmit/iris/util/Tuple4f.java | 70 +- .../java/com/volmit/iris/util/UIElement.java | 22 +- .../volmit/iris/util/UIStaticDecorator.java | 1 + .../java/com/volmit/iris/util/UIWindow.java | 81 +- src/main/java/com/volmit/iris/util/V.java | 4 +- .../java/com/volmit/iris/util/VectorMath.java | 27 +- .../java/com/volmit/iris/util/Violator.java | 55 +- .../com/volmit/iris/util/VirtualCommand.java | 7 +- .../volmit/iris/util/VoidOutputStream.java | 3 +- .../com/volmit/iris/util/VolmitPlugin.java | 34 +- .../java/com/volmit/iris/util/WeightMap.java | 2 +- .../java/com/volmit/iris/util/Wrapper.java | 3 +- src/main/java/com/volmit/iris/util/XML.java | 30 +- .../java/com/volmit/iris/util/XMLTokener.java | 15 +- 260 files changed, 2329 insertions(+), 3058 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 9d1799dfd..296c358b9 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -23,7 +23,7 @@ A clear and concise description of what you expected to happen. **Screenshots or Video Recordings** If applicable, add screenshots or video recordings to help explain your problem. -**Server and Plugin Informations** +**Server and Plugin Information** - Installed plugins: - Iris Version: - Server Platform and Version [eg: PaperSpigot 1.16.3 #240]: diff --git a/src/main/java/com/volmit/iris/Iris.java b/src/main/java/com/volmit/iris/Iris.java index 286b3b201..aaebcdf35 100644 --- a/src/main/java/com/volmit/iris/Iris.java +++ b/src/main/java/com/volmit/iris/Iris.java @@ -41,14 +41,15 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.generator.ChunkGenerator; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; import java.io.BufferedInputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.net.URL; -import java.util.concurrent.Callable; +@SuppressWarnings("CanBeFinal") public class Iris extends VolmitPlugin implements Listener { public static KList executors = new KList<>(); public static Iris instance; @@ -142,7 +143,7 @@ public class Iris extends VolmitPlugin implements Listener { if (tc <= 0) { int p = Runtime.getRuntime().availableProcessors(); - return p > 16 ? 16 : p < 4 ? 4 : p; + return p > 16 ? 16 : Math.max(p, 4); } return tc; @@ -153,7 +154,7 @@ public class Iris extends VolmitPlugin implements Listener { int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]); return v >= 15; - } catch (Throwable e) { + } catch (Throwable ignored) { } @@ -165,7 +166,7 @@ public class Iris extends VolmitPlugin implements Listener { int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]); return v >= 14; - } catch (Throwable e) { + } catch (Throwable ignored) { } @@ -177,7 +178,7 @@ public class Iris extends VolmitPlugin implements Listener { int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]); return v >= 15; - } catch (Throwable e) { + } catch (Throwable ignored) { } @@ -287,19 +288,9 @@ public class Iris extends VolmitPlugin implements Listener { J.s(() -> { Metrics m = new Metrics(Iris.instance, 8757); - m.addCustomChart(new Metrics.SingleLineChart("custom_dimensions", new Callable() { - @Override - public Integer call() throws Exception { - return ProjectManager.countUniqueDimensions(); - } - })); + m.addCustomChart(new Metrics.SingleLineChart("custom_dimensions", ProjectManager::countUniqueDimensions)); - m.addCustomChart(new Metrics.SimplePie("using_custom_dimensions", new Callable() { - @Override - public String call() throws Exception { - return ProjectManager.countUniqueDimensions() > 0 ? "Active Projects" : "No Projects"; - } - })); + m.addCustomChart(new Metrics.SimplePie("using_custom_dimensions", () -> ProjectManager.countUniqueDimensions() > 0 ? "Active Projects" : "No Projects")); }); } } @@ -319,7 +310,7 @@ public class Iris extends VolmitPlugin implements Listener { @Override - public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) { + public ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, String id) { String dimension = IrisSettings.get().getGenerator().getDefaultWorldType(); if (id != null && !id.isEmpty()) { diff --git a/src/main/java/com/volmit/iris/IrisSettings.java b/src/main/java/com/volmit/iris/IrisSettings.java index a0b972e17..020c0ef3e 100644 --- a/src/main/java/com/volmit/iris/IrisSettings.java +++ b/src/main/java/com/volmit/iris/IrisSettings.java @@ -25,6 +25,7 @@ import lombok.Data; import java.io.File; import java.io.IOException; +@SuppressWarnings("SynchronizeOnNonFinalField") @Data public class IrisSettings { public static transient IrisSettings settings; @@ -43,6 +44,7 @@ public class IrisSettings { return getStudio().isStudio(); } + @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean isUseServerLaunchedGuis() { return getGui().isUseServerLaunchedGuis(); } diff --git a/src/main/java/com/volmit/iris/generator/IrisWorldManager.java b/src/main/java/com/volmit/iris/generator/IrisWorldManager.java index d34c62e0b..0e4e2107c 100644 --- a/src/main/java/com/volmit/iris/generator/IrisWorldManager.java +++ b/src/main/java/com/volmit/iris/generator/IrisWorldManager.java @@ -127,7 +127,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager { }); } }); - } catch (Throwable xe) { + } catch (Throwable ignored) { } } diff --git a/src/main/java/com/volmit/iris/generator/actuator/IrisBiomeActuator.java b/src/main/java/com/volmit/iris/generator/actuator/IrisBiomeActuator.java index bee612f1c..b8bbbeab5 100644 --- a/src/main/java/com/volmit/iris/generator/actuator/IrisBiomeActuator.java +++ b/src/main/java/com/volmit/iris/generator/actuator/IrisBiomeActuator.java @@ -43,16 +43,14 @@ public class IrisBiomeActuator extends EngineAssignedActuator { private boolean injectBiome(Hunk h, int x, int y, int z, Object bb) { try { - if (h instanceof BiomeGridHunkView) { - BiomeGridHunkView hh = (BiomeGridHunkView) h; + if (h instanceof BiomeGridHunkView hh) { ChunkGenerator.BiomeGrid g = hh.getChunk(); if (g instanceof TerrainChunk) { ((TerrainChunk) g).getBiomeBaseInjector().setBiome(x, y, z, bb); - return true; } else { hh.forceBiomeBaseInto(x, y, z, bb); - return true; } + return true; } } catch (Throwable e) { e.printStackTrace(); diff --git a/src/main/java/com/volmit/iris/generator/decorator/IrisEngineDecorator.java b/src/main/java/com/volmit/iris/generator/decorator/IrisEngineDecorator.java index b1efaab4f..2f37fa5ad 100644 --- a/src/main/java/com/volmit/iris/generator/decorator/IrisEngineDecorator.java +++ b/src/main/java/com/volmit/iris/generator/decorator/IrisEngineDecorator.java @@ -41,7 +41,7 @@ public abstract class IrisEngineDecorator extends EngineAssignedComponent implem public IrisEngineDecorator(Engine engine, String name, DecorationPart part) { super(engine, name + " Decorator"); this.part = part; - this.rng = new RNG(getSeed() + 29356788 - (part.ordinal() * 10439677)); + this.rng = new RNG(getSeed() + 29356788 - (part.ordinal() * 10439677L)); } protected IrisDecorator getDecorator(IrisBiome biome, double realX, double realZ) { diff --git a/src/main/java/com/volmit/iris/generator/decorator/IrisSurfaceDecorator.java b/src/main/java/com/volmit/iris/generator/decorator/IrisSurfaceDecorator.java index 0ef045416..f6ec108d4 100644 --- a/src/main/java/com/volmit/iris/generator/decorator/IrisSurfaceDecorator.java +++ b/src/main/java/com/volmit/iris/generator/decorator/IrisSurfaceDecorator.java @@ -59,7 +59,7 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator { ((Bisected) bd).setHalf(Bisected.Half.TOP); try { data.set(x, height + 2, z, bd); - } catch (Throwable e) { + } catch (Throwable ignored) { } bd = bd.clone(); diff --git a/src/main/java/com/volmit/iris/generator/modifier/IrisPostModifier.java b/src/main/java/com/volmit/iris/generator/modifier/IrisPostModifier.java index 75927bf48..a54d7db89 100644 --- a/src/main/java/com/volmit/iris/generator/modifier/IrisPostModifier.java +++ b/src/main/java/com/volmit/iris/generator/modifier/IrisPostModifier.java @@ -60,6 +60,7 @@ public class IrisPostModifier extends EngineAssignedModifier { getEngine().getMetrics().getPost().put(p.getMilliseconds()); } + @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") private void post(int currentPostX, int currentPostZ, Hunk currentData, int x, int z) { int h = getFramework().getEngineParallax().trueHeight(x, z); diff --git a/src/main/java/com/volmit/iris/generator/modifier/IrisRavineModifier.java b/src/main/java/com/volmit/iris/generator/modifier/IrisRavineModifier.java index a4ed03d58..9ebe280d3 100644 --- a/src/main/java/com/volmit/iris/generator/modifier/IrisRavineModifier.java +++ b/src/main/java/com/volmit/iris/generator/modifier/IrisRavineModifier.java @@ -27,6 +27,7 @@ import com.volmit.iris.util.*; import org.bukkit.Material; import org.bukkit.block.data.BlockData; +@SuppressWarnings("ALL") public class IrisRavineModifier extends EngineAssignedModifier { private static final BlockData CAVE_AIR = B.get("CAVE_AIR"); private static final BlockData LAVA = B.get("LAVA"); @@ -70,7 +71,7 @@ public class IrisRavineModifier extends EngineAssignedModifier { private final float[] ravineCache = new float[1024]; - private void doRavine(long seed, int tx, int tz, ChunkPosition pos, double sx, double sy, double sz, float f, float f2, float f3, int n3, int n4, double d4, RNG bbx, Hunk terrain) { + private void doRavine(long seed, int tx, int tz, ChunkPosition pos, double sx, double sy, double sz, float f, float f2, float f3, @SuppressWarnings("SameParameterValue") int n3, @SuppressWarnings("SameParameterValue") int n4, @SuppressWarnings("SameParameterValue") double d4, RNG bbx, Hunk terrain) { int n5; RNG random = new RNG(seed); double x = tx * 16 + 8; @@ -214,7 +215,7 @@ public class IrisRavineModifier extends EngineAssignedModifier { } } - private BlockPosition cSet(BlockPosition bb, double var0, double var2, double var4) { + private BlockPosition cSet(BlockPosition bb, double var0, @SuppressWarnings("SameParameterValue") double var2, double var4) { bb.setX(MathHelper.floor(var0)); bb.setY(MathHelper.floor(var2)); bb.setZ(MathHelper.floor(var4)); diff --git a/src/main/java/com/volmit/iris/generator/noise/CNG.java b/src/main/java/com/volmit/iris/generator/noise/CNG.java index 296ffba12..521b46700 100644 --- a/src/main/java/com/volmit/iris/generator/noise/CNG.java +++ b/src/main/java/com/volmit/iris/generator/noise/CNG.java @@ -66,7 +66,7 @@ public class CNG { } public ProceduralStream stream(double min, double max) { - return new FittedStream(stream(), min, max); + return new FittedStream<>(stream(), min, max); } public static CNG signature(RNG rng) { @@ -304,7 +304,7 @@ public class CNG { try { return v.get(fit(0, v.size() - 1, dim)); - } catch (Throwable e) { + } catch (Throwable ignored) { } diff --git a/src/main/java/com/volmit/iris/generator/noise/FastNoiseDouble.java b/src/main/java/com/volmit/iris/generator/noise/FastNoiseDouble.java index 3a873bd3a..6dd33199e 100644 --- a/src/main/java/com/volmit/iris/generator/noise/FastNoiseDouble.java +++ b/src/main/java/com/volmit/iris/generator/noise/FastNoiseDouble.java @@ -183,6 +183,7 @@ public class FastNoiseDouble { m_gradientPerturbAmp = gradientPerturbAmp / 0.45; } + @SuppressWarnings("ClassCanBeRecord") private static class Double2 { public final double x, y; @@ -192,6 +193,7 @@ public class FastNoiseDouble { } } + @SuppressWarnings("ClassCanBeRecord") private static class Double3 { public final double x, y, z; @@ -358,21 +360,21 @@ public class FastNoiseDouble { hash &= 31; double a = yd, b = zd, c = wd; // X,Y,Z switch ((int) hash >> 3) { // OR, DEPENDING ON HIGH ORDER 2 BITS: - case 1: + case 1 -> { a = wd; b = xd; c = yd; - break; // W,X,Y - case 2: + } // W,X,Y + case 2 -> { a = zd; b = wd; c = xd; - break; // Z,W,X - case 3: + } // Z,W,X + case 3 -> { a = yd; b = zd; c = wd; - break; // Y,Z,W + } // Y,Z,W } return ((hash & 4) == 0 ? -a : a) + ((hash & 2) == 0 ? -b : b) + ((hash & 1) == 0 ? -c : c); } @@ -386,66 +388,42 @@ public class FastNoiseDouble { case Value: return SingleValue(m_seed, x, y, z); case ValueFractal: - switch (m_fractalType) { - case FBM: - return SingleValueFractalFBM(x, y, z); - case Billow: - return SingleValueFractalBillow(x, y, z); - case RigidMulti: - return SingleValueFractalRigidMulti(x, y, z); - default: - return 0; - } + return switch (m_fractalType) { + case FBM -> SingleValueFractalFBM(x, y, z); + case Billow -> SingleValueFractalBillow(x, y, z); + case RigidMulti -> SingleValueFractalRigidMulti(x, y, z); + }; case Perlin: return SinglePerlin(m_seed, x, y, z); case PerlinFractal: - switch (m_fractalType) { - case FBM: - return SinglePerlinFractalFBM(x, y, z); - case Billow: - return SinglePerlinFractalBillow(x, y, z); - case RigidMulti: - return SinglePerlinFractalRigidMulti(x, y, z); - default: - return 0; - } + return switch (m_fractalType) { + case FBM -> SinglePerlinFractalFBM(x, y, z); + case Billow -> SinglePerlinFractalBillow(x, y, z); + case RigidMulti -> SinglePerlinFractalRigidMulti(x, y, z); + }; case Simplex: return SingleSimplex(m_seed, x, y, z); case SimplexFractal: - switch (m_fractalType) { - case FBM: - return SingleSimplexFractalFBM(x, y, z); - case Billow: - return SingleSimplexFractalBillow(x, y, z); - case RigidMulti: - return SingleSimplexFractalRigidMulti(x, y, z); - default: - return 0; - } + return switch (m_fractalType) { + case FBM -> SingleSimplexFractalFBM(x, y, z); + case Billow -> SingleSimplexFractalBillow(x, y, z); + case RigidMulti -> SingleSimplexFractalRigidMulti(x, y, z); + }; case Cellular: - switch (m_cellularReturnType) { - case CellValue: - case NoiseLookup: - case Distance: - return SingleCellular(x, y, z); - default: - return SingleCellular2Edge(x, y, z); - } + return switch (m_cellularReturnType) { + case CellValue, NoiseLookup, Distance -> SingleCellular(x, y, z); + default -> SingleCellular2Edge(x, y, z); + }; case WhiteNoise: return GetWhiteNoise(x, y, z); case Cubic: return SingleCubic(m_seed, x, y, z); case CubicFractal: - switch (m_fractalType) { - case FBM: - return SingleCubicFractalFBM(x, y, z); - case Billow: - return SingleCubicFractalBillow(x, y, z); - case RigidMulti: - return SingleCubicFractalRigidMulti(x, y, z); - default: - return 0; - } + return switch (m_fractalType) { + case FBM -> SingleCubicFractalFBM(x, y, z); + case Billow -> SingleCubicFractalBillow(x, y, z); + case RigidMulti -> SingleCubicFractalRigidMulti(x, y, z); + }; default: return 0; } @@ -459,66 +437,42 @@ public class FastNoiseDouble { case Value: return SingleValue(m_seed, x, y); case ValueFractal: - switch (m_fractalType) { - case FBM: - return SingleValueFractalFBM(x, y); - case Billow: - return SingleValueFractalBillow(x, y); - case RigidMulti: - return SingleValueFractalRigidMulti(x, y); - default: - return 0; - } + return switch (m_fractalType) { + case FBM -> SingleValueFractalFBM(x, y); + case Billow -> SingleValueFractalBillow(x, y); + case RigidMulti -> SingleValueFractalRigidMulti(x, y); + }; case Perlin: return SinglePerlin(m_seed, x, y); case PerlinFractal: - switch (m_fractalType) { - case FBM: - return SinglePerlinFractalFBM(x, y); - case Billow: - return SinglePerlinFractalBillow(x, y); - case RigidMulti: - return SinglePerlinFractalRigidMulti(x, y); - default: - return 0; - } + return switch (m_fractalType) { + case FBM -> SinglePerlinFractalFBM(x, y); + case Billow -> SinglePerlinFractalBillow(x, y); + case RigidMulti -> SinglePerlinFractalRigidMulti(x, y); + }; case Simplex: return SingleSimplex(m_seed, x, y); case SimplexFractal: - switch (m_fractalType) { - case FBM: - return SingleSimplexFractalFBM(x, y); - case Billow: - return SingleSimplexFractalBillow(x, y); - case RigidMulti: - return SingleSimplexFractalRigidMulti(x, y); - default: - return 0; - } + return switch (m_fractalType) { + case FBM -> SingleSimplexFractalFBM(x, y); + case Billow -> SingleSimplexFractalBillow(x, y); + case RigidMulti -> SingleSimplexFractalRigidMulti(x, y); + }; case Cellular: - switch (m_cellularReturnType) { - case CellValue: - case NoiseLookup: - case Distance: - return SingleCellular(x, y); - default: - return SingleCellular2Edge(x, y); - } + return switch (m_cellularReturnType) { + case CellValue, NoiseLookup, Distance -> SingleCellular(x, y); + default -> SingleCellular2Edge(x, y); + }; case WhiteNoise: return GetWhiteNoise(x, y); case Cubic: return SingleCubic(m_seed, x, y); case CubicFractal: - switch (m_fractalType) { - case FBM: - return SingleCubicFractalFBM(x, y); - case Billow: - return SingleCubicFractalBillow(x, y); - case RigidMulti: - return SingleCubicFractalRigidMulti(x, y); - default: - return 0; - } + return switch (m_fractalType) { + case FBM -> SingleCubicFractalFBM(x, y); + case Billow -> SingleCubicFractalBillow(x, y); + case RigidMulti -> SingleCubicFractalRigidMulti(x, y); + }; default: return 0; } @@ -574,16 +528,11 @@ public class FastNoiseDouble { y *= m_frequency; z *= m_frequency; - switch (m_fractalType) { - case FBM: - return SingleValueFractalFBM(x, y, z); - case Billow: - return SingleValueFractalBillow(x, y, z); - case RigidMulti: - return SingleValueFractalRigidMulti(x, y, z); - default: - return 0; - } + return switch (m_fractalType) { + case FBM -> SingleValueFractalFBM(x, y, z); + case Billow -> SingleValueFractalBillow(x, y, z); + case RigidMulti -> SingleValueFractalRigidMulti(x, y, z); + }; } private double SingleValueFractalFBM(double x, double y, double z) { @@ -651,22 +600,21 @@ public class FastNoiseDouble { double xs, ys, zs; switch (m_longerp) { - default: - case Linear: + case Linear -> { xs = x - x0; ys = y - y0; zs = z - z0; - break; - case Hermite: + } + case Hermite -> { xs = longerpHermiteFunc(x - x0); ys = longerpHermiteFunc(y - y0); zs = longerpHermiteFunc(z - z0); - break; - case Qulongic: + } + case Qulongic -> { xs = longerpQulongicFunc(x - x0); ys = longerpQulongicFunc(y - y0); zs = longerpQulongicFunc(z - z0); - break; + } } double xf00 = lerp(valCoord3D(seed, x0, y0, z0), valCoord3D(seed, x1, y0, z0), xs); @@ -684,16 +632,11 @@ public class FastNoiseDouble { x *= m_frequency; y *= m_frequency; - switch (m_fractalType) { - case FBM: - return SingleValueFractalFBM(x, y); - case Billow: - return SingleValueFractalBillow(x, y); - case RigidMulti: - return SingleValueFractalRigidMulti(x, y); - default: - return 0; - } + return switch (m_fractalType) { + case FBM -> SingleValueFractalFBM(x, y); + case Billow -> SingleValueFractalBillow(x, y); + case RigidMulti -> SingleValueFractalRigidMulti(x, y); + }; } private double SingleValueFractalFBM(double x, double y) { @@ -755,19 +698,18 @@ public class FastNoiseDouble { double xs, ys; switch (m_longerp) { - default: - case Linear: + case Linear -> { xs = x - x0; ys = y - y0; - break; - case Hermite: + } + case Hermite -> { xs = longerpHermiteFunc(x - x0); ys = longerpHermiteFunc(y - y0); - break; - case Qulongic: + } + case Qulongic -> { xs = longerpQulongicFunc(x - x0); ys = longerpQulongicFunc(y - y0); - break; + } } double xf0 = lerp(valCoord2D(seed, x0, y0), valCoord2D(seed, x1, y0), xs); @@ -782,16 +724,11 @@ public class FastNoiseDouble { y *= m_frequency; z *= m_frequency; - switch (m_fractalType) { - case FBM: - return SinglePerlinFractalFBM(x, y, z); - case Billow: - return SinglePerlinFractalBillow(x, y, z); - case RigidMulti: - return SinglePerlinFractalRigidMulti(x, y, z); - default: - return 0; - } + return switch (m_fractalType) { + case FBM -> SinglePerlinFractalFBM(x, y, z); + case Billow -> SinglePerlinFractalBillow(x, y, z); + case RigidMulti -> SinglePerlinFractalRigidMulti(x, y, z); + }; } private double SinglePerlinFractalFBM(double x, double y, double z) { @@ -859,22 +796,21 @@ public class FastNoiseDouble { double xs, ys, zs; switch (m_longerp) { - default: - case Linear: + case Linear -> { xs = x - x0; ys = y - y0; zs = z - z0; - break; - case Hermite: + } + case Hermite -> { xs = longerpHermiteFunc(x - x0); ys = longerpHermiteFunc(y - y0); zs = longerpHermiteFunc(z - z0); - break; - case Qulongic: + } + case Qulongic -> { xs = longerpQulongicFunc(x - x0); ys = longerpQulongicFunc(y - y0); zs = longerpQulongicFunc(z - z0); - break; + } } double xd0 = x - x0; @@ -899,16 +835,11 @@ public class FastNoiseDouble { x *= m_frequency; y *= m_frequency; - switch (m_fractalType) { - case FBM: - return SinglePerlinFractalFBM(x, y); - case Billow: - return SinglePerlinFractalBillow(x, y); - case RigidMulti: - return SinglePerlinFractalRigidMulti(x, y); - default: - return 0; - } + return switch (m_fractalType) { + case FBM -> SinglePerlinFractalFBM(x, y); + case Billow -> SinglePerlinFractalBillow(x, y); + case RigidMulti -> SinglePerlinFractalRigidMulti(x, y); + }; } private double SinglePerlinFractalFBM(double x, double y) { @@ -1002,16 +933,11 @@ public class FastNoiseDouble { y *= m_frequency; z *= m_frequency; - switch (m_fractalType) { - case FBM: - return SingleSimplexFractalFBM(x, y, z); - case Billow: - return SingleSimplexFractalBillow(x, y, z); - case RigidMulti: - return SingleSimplexFractalRigidMulti(x, y, z); - default: - return 0; - } + return switch (m_fractalType) { + case FBM -> SingleSimplexFractalFBM(x, y, z); + case Billow -> SingleSimplexFractalBillow(x, y, z); + case RigidMulti -> SingleSimplexFractalRigidMulti(x, y, z); + }; } private double SingleSimplexFractalFBM(double x, double y, double z) { @@ -1189,16 +1115,11 @@ public class FastNoiseDouble { x *= m_frequency; y *= m_frequency; - switch (m_fractalType) { - case FBM: - return SingleSimplexFractalFBM(x, y); - case Billow: - return SingleSimplexFractalBillow(x, y); - case RigidMulti: - return SingleSimplexFractalRigidMulti(x, y); - default: - return 0; - } + return switch (m_fractalType) { + case FBM -> SingleSimplexFractalFBM(x, y); + case Billow -> SingleSimplexFractalBillow(x, y); + case RigidMulti -> SingleSimplexFractalRigidMulti(x, y); + }; } private double SingleSimplexFractalFBM(double x, double y) { @@ -1421,16 +1342,11 @@ public class FastNoiseDouble { y *= m_frequency; z *= m_frequency; - switch (m_fractalType) { - case FBM: - return SingleCubicFractalFBM(x, y, z); - case Billow: - return SingleCubicFractalBillow(x, y, z); - case RigidMulti: - return SingleCubicFractalRigidMulti(x, y, z); - default: - return 0; - } + return switch (m_fractalType) { + case FBM -> SingleCubicFractalFBM(x, y, z); + case Billow -> SingleCubicFractalBillow(x, y, z); + case RigidMulti -> SingleCubicFractalRigidMulti(x, y, z); + }; } private double SingleCubicFractalFBM(double x, double y, double z) { @@ -1519,16 +1435,11 @@ public class FastNoiseDouble { x *= m_frequency; y *= m_frequency; - switch (m_fractalType) { - case FBM: - return SingleCubicFractalFBM(x, y); - case Billow: - return SingleCubicFractalBillow(x, y); - case RigidMulti: - return SingleCubicFractalRigidMulti(x, y); - default: - return 0; - } + return switch (m_fractalType) { + case FBM -> SingleCubicFractalFBM(x, y); + case Billow -> SingleCubicFractalBillow(x, y); + case RigidMulti -> SingleCubicFractalRigidMulti(x, y); + }; } private double SingleCubicFractalFBM(double x, double y) { @@ -1614,14 +1525,10 @@ public class FastNoiseDouble { y *= m_frequency; z *= m_frequency; - switch (m_cellularReturnType) { - case CellValue: - case NoiseLookup: - case Distance: - return SingleCellular(x, y, z); - default: - return SingleCellular2Edge(x, y, z); - } + return switch (m_cellularReturnType) { + case CellValue, NoiseLookup, Distance -> SingleCellular(x, y, z); + default -> SingleCellular2Edge(x, y, z); + }; } private double SingleCellular(double x, double y, double z) { @@ -1783,34 +1690,24 @@ public class FastNoiseDouble { break; } - switch (m_cellularReturnType) { - case Distance2: - return distance2 - 1; - case Distance2Add: - return distance2 + distance - 1; - case Distance2Sub: - return distance2 - distance - 1; - case Distance2Mul: - return distance2 * distance - 1; - case Distance2Div: - return distance / distance2 - 1; - default: - return 0; - } + return switch (m_cellularReturnType) { + case Distance2 -> distance2 - 1; + case Distance2Add -> distance2 + distance - 1; + case Distance2Sub -> distance2 - distance - 1; + case Distance2Mul -> distance2 * distance - 1; + case Distance2Div -> distance / distance2 - 1; + default -> 0; + }; } public double GetCellular(double x, double y) { x *= m_frequency; y *= m_frequency; - switch (m_cellularReturnType) { - case CellValue: - case NoiseLookup: - case Distance: - return SingleCellular(x, y); - default: - return SingleCellular2Edge(x, y); - } + return switch (m_cellularReturnType) { + case CellValue, NoiseLookup, Distance -> SingleCellular(x, y); + default -> SingleCellular2Edge(x, y); + }; } private double SingleCellular(double x, double y) { @@ -1949,20 +1846,14 @@ public class FastNoiseDouble { break; } - switch (m_cellularReturnType) { - case Distance2: - return distance2 - 1; - case Distance2Add: - return distance2 + distance - 1; - case Distance2Sub: - return distance2 - distance - 1; - case Distance2Mul: - return distance2 * distance - 1; - case Distance2Div: - return distance / distance2 - 1; - default: - return 0; - } + return switch (m_cellularReturnType) { + case Distance2 -> distance2 - 1; + case Distance2Add -> distance2 + distance - 1; + case Distance2Sub -> distance2 - distance - 1; + case Distance2Mul -> distance2 * distance - 1; + case Distance2Div -> distance / distance2 - 1; + default -> 0; + }; } public void GradientPerturb(Vector3f v3) { @@ -1997,22 +1888,21 @@ public class FastNoiseDouble { double xs, ys, zs; switch (m_longerp) { - default: - case Linear: + case Linear -> { xs = xf - x0; ys = yf - y0; zs = zf - z0; - break; - case Hermite: + } + case Hermite -> { xs = longerpHermiteFunc(xf - x0); ys = longerpHermiteFunc(yf - y0); zs = longerpHermiteFunc(zf - z0); - break; - case Qulongic: + } + case Qulongic -> { xs = longerpQulongicFunc(xf - x0); ys = longerpQulongicFunc(yf - y0); zs = longerpQulongicFunc(zf - z0); - break; + } } Double3 vec0 = CELL_3D[(int) hash3D(seed, x0, y0, z0) & 255]; @@ -2081,19 +1971,18 @@ public class FastNoiseDouble { double xs, ys; switch (m_longerp) { - default: - case Linear: + case Linear -> { xs = xf - x0; ys = yf - y0; - break; - case Hermite: + } + case Hermite -> { xs = longerpHermiteFunc(xf - x0); ys = longerpHermiteFunc(yf - y0); - break; - case Qulongic: + } + case Qulongic -> { xs = longerpQulongicFunc(xf - x0); ys = longerpQulongicFunc(yf - y0); - break; + } } Double2 vec0 = CELL_2D[(int) hash2D(seed, x0, y0) & 255]; diff --git a/src/main/java/com/volmit/iris/manager/ConversionManager.java b/src/main/java/com/volmit/iris/manager/ConversionManager.java index 0a64ea78d..f08c02d19 100644 --- a/src/main/java/com/volmit/iris/manager/ConversionManager.java +++ b/src/main/java/com/volmit/iris/manager/ConversionManager.java @@ -46,46 +46,44 @@ public class ConversionManager { converters = new KList<>(); J.s(() -> - { - J.attemptAsync(() -> - { - if (Bukkit.getPluginManager().isPluginEnabled("WorldEdit")) { - converters.add(new Converter() { - @Override - public String getOutExtension() { - return "iob"; - } + J.attemptAsync(() -> + { + if (Bukkit.getPluginManager().isPluginEnabled("WorldEdit")) { + converters.add(new Converter() { + @Override + public String getOutExtension() { + return "iob"; + } - @Override - public String getInExtension() { - return "schem"; - } + @Override + public String getInExtension() { + return "schem"; + } - @Override - public void convert(File in, File out) { - SKConversion.convertSchematic(in, out); - } - }); + @Override + public void convert(File in, File out) { + SKConversion.convertSchematic(in, out); + } + }); - converters.add(new Converter() { - @Override - public String getOutExtension() { - return "iob"; - } + converters.add(new Converter() { + @Override + public String getOutExtension() { + return "iob"; + } - @Override - public String getInExtension() { - return "schematic"; - } + @Override + public String getInExtension() { + return "schematic"; + } - @Override - public void convert(File in, File out) { - SKConversion.convertSchematic(in, out); - } - }); - } - }); - }, 5); + @Override + public void convert(File in, File out) { + SKConversion.convertSchematic(in, out); + } + }); + } + }), 5); } private String toPoolName(String poolReference) { @@ -136,22 +134,22 @@ public class ConversionManager { if (compound.containsKey("blocks") && compound.containsKey("palette") && compound.containsKey("size")) { String id = in.toURI().relativize(folder.toURI()).getPath() + file.getName().split("\\Q.\\E")[0]; - ListTag size = (ListTag) compound.getListTag("size"); + @SuppressWarnings("unchecked") ListTag size = (ListTag) compound.getListTag("size"); int w = size.get(0).asInt(); int h = size.get(1).asInt(); int d = size.get(2).asInt(); KList palette = new KList<>(); - ListTag paletteList = (ListTag) compound.getListTag("palette"); + @SuppressWarnings("unchecked") ListTag paletteList = (ListTag) compound.getListTag("palette"); for (int i = 0; i < paletteList.size(); i++) { CompoundTag cp = paletteList.get(i); palette.add(DirectWorldWriter.getBlockData(cp)); } IrisJigsawPiece piece = new IrisJigsawPiece(); IrisObject object = new IrisObject(w, h, d); - ListTag blockList = (ListTag) compound.getListTag("blocks"); + @SuppressWarnings("unchecked") ListTag blockList = (ListTag) compound.getListTag("blocks"); for (int i = 0; i < blockList.size(); i++) { CompoundTag cp = blockList.get(i); - ListTag pos = (ListTag) cp.getListTag("pos"); + @SuppressWarnings("unchecked") ListTag pos = (ListTag) cp.getListTag("pos"); int x = pos.get(0).asInt(); int y = pos.get(1).asInt(); int z = pos.get(2).asInt(); diff --git a/src/main/java/com/volmit/iris/manager/IrisBoardManager.java b/src/main/java/com/volmit/iris/manager/IrisBoardManager.java index ce9234100..2c42115ec 100644 --- a/src/main/java/com/volmit/iris/manager/IrisBoardManager.java +++ b/src/main/java/com/volmit/iris/manager/IrisBoardManager.java @@ -35,8 +35,8 @@ public class IrisBoardManager implements BoardProvider, Listener { private final BoardManager manager; private String mem = "..."; - public RollingSequence hits = new RollingSequence(20); - public RollingSequence tp = new RollingSequence(100); + public final RollingSequence hits = new RollingSequence(20); + public final RollingSequence tp = new RollingSequence(100); private final ChronoLatch cl = new ChronoLatch(1000); @@ -105,9 +105,9 @@ public class IrisBoardManager implements BoardProvider, Listener { parallaxRegions += g.getCompound().getEngine(i).getParallax().getRegionCount(); parallaxChunks += g.getCompound().getEngine(i).getParallax().getChunkCount(); loadedObjects += g.getCompound().getData().getObjectLoader().getSize(); - memoryGuess += g.getCompound().getData().getObjectLoader().getTotalStorage() * 225; - memoryGuess += parallaxChunks * 3500; - memoryGuess += parallaxRegions * 1700000; + memoryGuess += g.getCompound().getData().getObjectLoader().getTotalStorage() * 225L; + memoryGuess += parallaxChunks * 3500L; + memoryGuess += parallaxRegions * 1700000L; } tp.put(0); // TODO: CHUNK SPEED diff --git a/src/main/java/com/volmit/iris/manager/IrisProject.java b/src/main/java/com/volmit/iris/manager/IrisProject.java index bde4fe8da..62b543c6b 100644 --- a/src/main/java/com/volmit/iris/manager/IrisProject.java +++ b/src/main/java/com/volmit/iris/manager/IrisProject.java @@ -41,6 +41,7 @@ import java.io.IOException; import java.util.Objects; import java.util.UUID; +@SuppressWarnings("ALL") @Data public class IrisProject { private File path; @@ -122,21 +123,18 @@ public class IrisProject { } private KList scanForErrors(IrisBiome biome, IrisObjectPlacement i) { - KList reports = new KList<>(); - return reports; + return new KList<>(); } private KList scanForErrors(IrisBiome biome, IrisBiomePaletteLayer i) { - KList reports = new KList<>(); - return reports; + return new KList<>(); } private KList scanForErrorsSeaLayers(IrisBiome biome, IrisBiomePaletteLayer i) { - KList reports = new KList<>(); - return reports; + return new KList<>(); } public boolean isOpen() { diff --git a/src/main/java/com/volmit/iris/manager/ProjectManager.java b/src/main/java/com/volmit/iris/manager/ProjectManager.java index 11dd593b9..6aedd4700 100644 --- a/src/main/java/com/volmit/iris/manager/ProjectManager.java +++ b/src/main/java/com/volmit/iris/manager/ProjectManager.java @@ -30,7 +30,6 @@ import org.zeroturnaround.zip.ZipUtil; import org.zeroturnaround.zip.commons.FileUtils; import java.io.File; -import java.io.FileFilter; import java.io.IOException; import java.util.UUID; @@ -53,7 +52,7 @@ public class ProjectManager { if (m != null) { try { IO.copyFile(m, ignore); - } catch (IOException e) { + } catch (IOException ignored) { } } @@ -63,7 +62,8 @@ public class ProjectManager { } public static int countUniqueDimensions() { - int vv = counter.aquire(() -> { + + return counter.aquire(() -> { int v = 0; try { @@ -82,8 +82,6 @@ public class ProjectManager { return v; }); - - return vv; } public IrisDimension installIntoWorld(MortarSender sender, String type, File folder) { @@ -106,7 +104,7 @@ public class ProjectManager { try { FileUtils.copyDirectory(f, irispack); - } catch (IOException e) { + } catch (IOException ignored) { } } @@ -192,12 +190,13 @@ public class ProjectManager { } catch (Throwable e) { e.printStackTrace(); sender.sendMessage( - "Issue when unpacking. Please check/do the following:" + - "\n1. Do you have a functioning internet connection?" + - "\n2. Did the download corrupt?" + - "\n3. Try deleting the */plugins/iris/packs folder and re-download." + - "\n4. Download the pack from the GitHub repo: https://github.com/IrisDimensions/overworld" + - "\n5. Contact support (if all other options do not help)" + """ + Issue when unpacking. Please check/do the following: + 1. Do you have a functioning internet connection? + 2. Did the download corrupt? + 3. Try deleting the */plugins/iris/packs folder and re-download. + 4. Download the pack from the GitHub repo: https://github.com/IrisDimensions/overworld + 5. Contact support (if all other options do not help)""" ); } File dir = null; @@ -352,12 +351,7 @@ public class ProjectManager { } try { - FileUtils.copyDirectory(importPack, newPack, new FileFilter() { - @Override - public boolean accept(File pathname) { - return !pathname.getAbsolutePath().contains(".git"); - } - }, false); + FileUtils.copyDirectory(importPack, newPack, pathname -> !pathname.getAbsolutePath().contains(".git"), false); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/manager/SchemaBuilder.java b/src/main/java/com/volmit/iris/manager/SchemaBuilder.java index 9cac321c4..0c978ce74 100644 --- a/src/main/java/com/volmit/iris/manager/SchemaBuilder.java +++ b/src/main/java/com/volmit/iris/manager/SchemaBuilder.java @@ -27,6 +27,7 @@ import java.awt.*; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.List; +import java.util.Map; public class SchemaBuilder { private static final String SYMBOL_LIMIT__N = "*"; @@ -43,7 +44,7 @@ public class SchemaBuilder { public SchemaBuilder(Class root, IrisDataManager data) { this.data = data; warnings = new KList<>(); - this.definitions = new KMap(); + this.definitions = new KMap<>(); this.root = root; } @@ -62,8 +63,8 @@ public class SchemaBuilder { JSONObject defs = new JSONObject(); - for (String i : definitions.keySet()) { - defs.put(i, definitions.get(i)); + for (Map.Entry entry : definitions.entrySet()) { + defs.put(entry.getKey(), entry.getValue()); } schema.put("definitions", defs); @@ -111,625 +112,618 @@ public class SchemaBuilder { private JSONObject buildProperty(Field k, Class cl) { JSONObject prop = new JSONObject(); String type = getType(k.getType()); - KList description = new KList(); + KList description = new KList<>(); prop.put("!required", k.isAnnotationPresent(Required.class)); prop.put("type", type); String fancyType = "Unknown Type"; - if (type.equals("boolean")) { - fancyType = "Boolean"; - } else if (type.equals("integer")) { - fancyType = "Integer"; - if (k.isAnnotationPresent(MinNumber.class)) { - int min = (int) k.getDeclaredAnnotation(MinNumber.class).value(); - prop.put("minimum", min); - description.add(SYMBOL_LIMIT__N + " Minimum allowed is " + min); + switch (type) { + case "boolean" -> fancyType = "Boolean"; + case "integer" -> { + fancyType = "Integer"; + if (k.isAnnotationPresent(MinNumber.class)) { + int min = (int) k.getDeclaredAnnotation(MinNumber.class).value(); + prop.put("minimum", min); + description.add(SYMBOL_LIMIT__N + " Minimum allowed is " + min); + } + if (k.isAnnotationPresent(MaxNumber.class)) { + int max = (int) k.getDeclaredAnnotation(MaxNumber.class).value(); + prop.put("maximum", max); + description.add(SYMBOL_LIMIT__N + " Maximum allowed is " + max); + } } - - if (k.isAnnotationPresent(MaxNumber.class)) { - int max = (int) k.getDeclaredAnnotation(MaxNumber.class).value(); - prop.put("maximum", max); - description.add(SYMBOL_LIMIT__N + " Maximum allowed is " + max); + case "number" -> { + fancyType = "Number"; + if (k.isAnnotationPresent(MinNumber.class)) { + double min = k.getDeclaredAnnotation(MinNumber.class).value(); + prop.put("minimum", min); + description.add(SYMBOL_LIMIT__N + " Minimum allowed is " + min); + } + if (k.isAnnotationPresent(MaxNumber.class)) { + double max = k.getDeclaredAnnotation(MaxNumber.class).value(); + prop.put("maximum", max); + description.add(SYMBOL_LIMIT__N + " Maximum allowed is " + max); + } } - } else if (type.equals("number")) { - fancyType = "Number"; - if (k.isAnnotationPresent(MinNumber.class)) { - double min = k.getDeclaredAnnotation(MinNumber.class).value(); - prop.put("minimum", min); - description.add(SYMBOL_LIMIT__N + " Minimum allowed is " + min); - } - - if (k.isAnnotationPresent(MaxNumber.class)) { - double max = k.getDeclaredAnnotation(MaxNumber.class).value(); - prop.put("maximum", max); - description.add(SYMBOL_LIMIT__N + " Maximum allowed is " + max); - } - } else if (type.equals("string")) { - fancyType = "Text"; - if (k.isAnnotationPresent(MinNumber.class)) { - int min = (int) k.getDeclaredAnnotation(MinNumber.class).value(); - prop.put("minLength", min); - description.add(SYMBOL_LIMIT__N + " Minimum Length allowed is " + min); - } - - if (k.isAnnotationPresent(MaxNumber.class)) { - int max = (int) k.getDeclaredAnnotation(MaxNumber.class).value(); - prop.put("maxLength", max); - description.add(SYMBOL_LIMIT__N + " Maximum Length allowed is " + max); - } - - if (k.isAnnotationPresent(RegistryListBiome.class)) { - String key = "enum-reg-biome"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getBiomeLoader().getPossibleKeys())); - definitions.put(key, j); + case "string" -> { + fancyType = "Text"; + if (k.isAnnotationPresent(MinNumber.class)) { + int min = (int) k.getDeclaredAnnotation(MinNumber.class).value(); + prop.put("minLength", min); + description.add(SYMBOL_LIMIT__N + " Minimum Length allowed is " + min); } - - fancyType = "Iris Biome"; - prop.put("$ref", "#/definitions/" + key); - description.add(SYMBOL_TYPE__N + " Must be a valid Biome (use ctrl+space for auto complete!)"); - - } else if (k.isAnnotationPresent(RegistryListMythical.class)) { - String key = "enum-reg-mythical"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(Iris.linkMythicMobs.getMythicMobTypes())); - definitions.put(key, j); + if (k.isAnnotationPresent(MaxNumber.class)) { + int max = (int) k.getDeclaredAnnotation(MaxNumber.class).value(); + prop.put("maxLength", max); + description.add(SYMBOL_LIMIT__N + " Maximum Length allowed is " + max); } - - fancyType = "Mythic Mob Type"; - prop.put("$ref", "#/definitions/" + key); - description.add(SYMBOL_TYPE__N + " Must be a valid Mythic Mob Type (use ctrl+space for auto complete!) Define mythic mobs with the mythic mobs plugin configuration files."); - } else if (k.isAnnotationPresent(RegistryListBlockType.class)) { - String key = "enum-block-type"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - JSONArray ja = new JSONArray(); - - for (String i : data.getBlockLoader().getPossibleKeys()) { - ja.put(i); - } - - for (String i : B.getBlockTypes()) { - ja.put(i); - } - - j.put("enum", ja); - definitions.put(key, j); - } - - fancyType = "Block Type"; - prop.put("$ref", "#/definitions/" + key); - description.add(SYMBOL_TYPE__N + " Must be a valid Block Type (use ctrl+space for auto complete!)"); - - } else if (k.isAnnotationPresent(RegistryListItemType.class)) { - String key = "enum-item-type"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", ITEM_TYPES); - definitions.put(key, j); - } - - fancyType = "Item Type"; - prop.put("$ref", "#/definitions/" + key); - description.add(SYMBOL_TYPE__N + " Must be a valid Item Type (use ctrl+space for auto complete!)"); - - } else if (k.isAnnotationPresent(RegistryListEntity.class)) { - String key = "enum-reg-entity"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getEntityLoader().getPossibleKeys())); - definitions.put(key, j); - } - - fancyType = "Iris Entity"; - prop.put("$ref", "#/definitions/" + key); - description.add(SYMBOL_TYPE__N + " Must be a valid Iris Entity (use ctrl+space for auto complete!)"); - - } else if (k.isAnnotationPresent(RegistryListFont.class)) { - String key = "enum-font"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", FONT_TYPES); - definitions.put(key, j); - } - - fancyType = "Font Family"; - prop.put("$ref", "#/definitions/" + key); - description.add(SYMBOL_TYPE__N + " Must be a valid Font Family (use ctrl+space for auto complete!)"); - - } else if (k.isAnnotationPresent(RegistryListLoot.class)) { - String key = "enum-reg-loot-table"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getLootLoader().getPossibleKeys())); - definitions.put(key, j); - } - - fancyType = "Iris Loot Table"; - prop.put("$ref", "#/definitions/" + key); - description.add(SYMBOL_TYPE__N + " Must be a valid Loot Table (use ctrl+space for auto complete!)"); - } else if (k.isAnnotationPresent(RegistryListDimension.class)) { - String key = "enum-reg-dimension"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getDimensionLoader().getPossibleKeys())); - definitions.put(key, j); - } - - fancyType = "Iris Dimension"; - prop.put("$ref", "#/definitions/" + key); - description.add(SYMBOL_TYPE__N + " Must be a valid Dimension (use ctrl+space for auto complete!)"); - - } else if (k.isAnnotationPresent(RegistryListGenerator.class)) { - String key = "enum-reg-generator"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getGeneratorLoader().getPossibleKeys())); - definitions.put(key, j); - } - - fancyType = "Iris Generator"; - prop.put("$ref", "#/definitions/" + key); - description.add(SYMBOL_TYPE__N + " Must be a valid Generator (use ctrl+space for auto complete!)"); - - } else if (k.isAnnotationPresent(RegistryListObject.class)) { - String key = "enum-reg-object"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getObjectLoader().getPossibleKeys())); - definitions.put(key, j); - } - - fancyType = "Iris Object"; - prop.put("$ref", "#/definitions/" + key); - description.add(SYMBOL_TYPE__N + " Must be a valid Object (use ctrl+space for auto complete!)"); - - } else if (k.isAnnotationPresent(RegistryListRegion.class)) { - String key = "enum-reg-region"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getRegionLoader().getPossibleKeys())); - definitions.put(key, j); - } - - fancyType = "Iris Region"; - prop.put("$ref", "#/definitions/" + key); - description.add(SYMBOL_TYPE__N + " Must be a valid Region (use ctrl+space for auto complete!)"); - - } else if (k.isAnnotationPresent(RegistryListJigsawPiece.class)) { - String key = "enum-reg-structure-piece"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getJigsawPieceLoader().getPossibleKeys())); - definitions.put(key, j); - } - - fancyType = "Iris Jigsaw Piece"; - prop.put("$ref", "#/definitions/" + key); - description.add(SYMBOL_TYPE__N + " Must be a valid Jigsaw Piece (use ctrl+space for auto complete!)"); - } else if (k.isAnnotationPresent(RegistryListJigsaw.class)) { - String key = "enum-reg-jigsaw"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getJigsawStructureLoader().getPossibleKeys())); - definitions.put(key, j); - } - - fancyType = "Iris Jigsaw"; - prop.put("$ref", "#/definitions/" + key); - description.add(SYMBOL_TYPE__N + " Must be a valid Jigsaw (use ctrl+space for auto complete!)"); - } else if (k.isAnnotationPresent(RegistryListJigsawPool.class)) { - String key = "enum-reg-structure-pool"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getJigsawPoolLoader().getPossibleKeys())); - definitions.put(key, j); - } - - fancyType = "Iris Jigsaw Pool"; - prop.put("$ref", "#/definitions/" + key); - description.add(SYMBOL_TYPE__N + " Must be a valid Jigsaw Piece (use ctrl+space for auto complete!)"); - } else if (k.getType().equals(Enchantment.class)) { - String key = "enum-enchantment"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", ENCHANT_TYPES); - definitions.put(key, j); - } - - fancyType = "Enchantment Type"; - prop.put("$ref", "#/definitions/" + key); - description.add(SYMBOL_TYPE__N + " Must be a valid Enchantment Type (use ctrl+space for auto complete!)"); - } else if (k.getType().equals(PotionEffectType.class)) { - String key = "enum-potion-effect-type"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", POTION_TYPES); - definitions.put(key, j); - } - - fancyType = "Potion Effect Type"; - prop.put("$ref", "#/definitions/" + key); - description.add(SYMBOL_TYPE__N + " Must be a valid Potion Effect Type (use ctrl+space for auto complete!)"); - - } else if (k.getType().isEnum()) { - fancyType = k.getType().getSimpleName().replaceAll("\\QIris\\E", ""); - JSONArray a = new JSONArray(); - boolean advanced = k.getType().isAnnotationPresent(Desc.class); - for (Object gg : k.getType().getEnumConstants()) { - if (advanced) { - try { - JSONObject j = new JSONObject(); - String name = ((Enum) gg).name(); - j.put("const", name); - Desc dd = k.getType().getField(name).getAnnotation(Desc.class); - j.put("description", dd == null ? ("No Description for " + name) : dd.value()); - a.put(j); - } catch (Throwable e) { - e.printStackTrace(); - } - } else { - a.put(((Enum) gg).name()); - } - } - - String key = (advanced ? "oneof-" : "") + "enum-" + k.getType().getCanonicalName().replaceAll("\\Q.\\E", "-").toLowerCase(); - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put(advanced ? "oneOf" : "enum", a); - definitions.put(key, j); - } - - prop.put("$ref", "#/definitions/" + key); - description.add(SYMBOL_TYPE__N + " Must be a valid " + k.getType().getSimpleName().replaceAll("\\QIris\\E", "") + " (use ctrl+space for auto complete!)"); - - } - } else if (type.equals("object")) { - fancyType = k.getType().getSimpleName().replaceAll("\\QIris\\E", "") + " (Object)"; - - String key = "obj-" + k.getType().getCanonicalName().replaceAll("\\Q.\\E", "-").toLowerCase(); - - if (!definitions.containsKey(key)) { - definitions.put(key, new JSONObject()); - definitions.put(key, buildProperties(k.getType())); - } - - prop.put("$ref", "#/definitions/" + key); - } else if (type.equals("array")) { - fancyType = "List of Something...?"; - - ArrayType t = k.getDeclaredAnnotation(ArrayType.class); - - if (t != null) { - if (t.min() > 0) { - prop.put("minItems", t.min()); - if (t.min() == 1) { - description.add(SYMBOL_LIMIT__N + " At least one entry must be defined, or just remove this list."); - } else { - description.add(SYMBOL_LIMIT__N + " Requires at least " + t.min() + " entries."); - } - } - - String arrayType = getType(t.type()); - - if (arrayType.equals("integer")) { - fancyType = "List of Integers"; - } else if (arrayType.equals("number")) { - fancyType = "List of Numbers"; - } else if (arrayType.equals("object")) { - fancyType = "List of " + t.type().getSimpleName().replaceAll("\\QIris\\E", "") + "s (Objects)"; - String key = "obj-" + t.type().getCanonicalName().replaceAll("\\Q.\\E", "-").toLowerCase(); + if (k.isAnnotationPresent(RegistryListBiome.class)) { + String key = "enum-reg-biome"; if (!definitions.containsKey(key)) { - definitions.put(key, new JSONObject()); - definitions.put(key, buildProperties(t.type())); + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getBiomeLoader().getPossibleKeys())); + definitions.put(key, j); } - JSONObject items = new JSONObject(); - items.put("$ref", "#/definitions/" + key); - prop.put("items", items); - } else if (arrayType.equals("string")) { - fancyType = "List of Text"; + fancyType = "Iris Biome"; + prop.put("$ref", "#/definitions/" + key); + description.add(SYMBOL_TYPE__N + " Must be a valid Biome (use ctrl+space for auto complete!)"); - if (k.isAnnotationPresent(RegistryListBiome.class)) { - fancyType = "List of Iris Biomes"; - String key = "enum-reg-biome"; + } else if (k.isAnnotationPresent(RegistryListMythical.class)) { + String key = "enum-reg-mythical"; - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getBiomeLoader().getPossibleKeys())); - definitions.put(key, j); - } - - JSONObject items = new JSONObject(); - items.put("$ref", "#/definitions/" + key); - prop.put("items", items); - description.add(SYMBOL_TYPE__N + " Must be a valid Biome (use ctrl+space for auto complete!)"); - } else if (k.isAnnotationPresent(RegistryListMythical.class)) { - fancyType = "List of Mythic Mob Types"; - String key = "enum-reg-mythical"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - JSONArray ja = new JSONArray(); - - for (String i : Iris.linkMythicMobs.getMythicMobTypes()) { - ja.put(i); - } - - j.put("enum", ja); - definitions.put(key, j); - } - - JSONObject items = new JSONObject(); - items.put("$ref", "#/definitions/" + key); - prop.put("items", items); - description.add(SYMBOL_TYPE__N + " Must be a valid Mythic Mob Type (use ctrl+space for auto complete!) Configure mob types in the mythic mobs plugin configuration files."); - } else if (k.isAnnotationPresent(RegistryListBlockType.class)) { - fancyType = "List of Block Types"; - String key = "enum-block-type"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - JSONArray ja = new JSONArray(); - - for (String i : data.getBlockLoader().getPossibleKeys()) { - ja.put(i); - } - - for (String i : B.getBlockTypes()) { - ja.put(i); - } - - j.put("enum", ja); - definitions.put(key, j); - } - - JSONObject items = new JSONObject(); - items.put("$ref", "#/definitions/" + key); - prop.put("items", items); - description.add(SYMBOL_TYPE__N + " Must be a valid Block Type (use ctrl+space for auto complete!)"); - } else if (k.isAnnotationPresent(RegistryListItemType.class)) { - fancyType = "List of Item Types"; - String key = "enum-item-type"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", ITEM_TYPES); - definitions.put(key, j); - } - - JSONObject items = new JSONObject(); - items.put("$ref", "#/definitions/" + key); - prop.put("items", items); - description.add(SYMBOL_TYPE__N + " Must be a valid Item Type (use ctrl+space for auto complete!)"); - } else if (k.isAnnotationPresent(RegistryListEntity.class)) { - fancyType = "List of Iris Entities"; - String key = "enum-reg-entity"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getEntityLoader().getPossibleKeys())); - definitions.put(key, j); - } - - JSONObject items = new JSONObject(); - items.put("$ref", "#/definitions/" + key); - prop.put("items", items); - description.add(SYMBOL_TYPE__N + " Must be a valid Iris Entity (use ctrl+space for auto complete!)"); - } else if (k.isAnnotationPresent(RegistryListFont.class)) { - String key = "enum-font"; - fancyType = "List of Font Families"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", FONT_TYPES); - definitions.put(key, j); - } - - JSONObject items = new JSONObject(); - items.put("$ref", "#/definitions/" + key); - prop.put("items", items); - description.add(SYMBOL_TYPE__N + " Must be a valid Font Family (use ctrl+space for auto complete!)"); - } else if (k.isAnnotationPresent(RegistryListLoot.class)) { - fancyType = "List of Iris Loot Tables"; - String key = "enum-reg-loot-table"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getLootLoader().getPossibleKeys())); - definitions.put(key, j); - } - - JSONObject items = new JSONObject(); - items.put("$ref", "#/definitions/" + key); - prop.put("items", items); - description.add(SYMBOL_TYPE__N + " Must be a valid Loot Table (use ctrl+space for auto complete!)"); - } else if (k.isAnnotationPresent(RegistryListDimension.class)) { - fancyType = "List of Iris Dimensions"; - String key = "enum-reg-dimension"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getDimensionLoader().getPossibleKeys())); - definitions.put(key, j); - } - - JSONObject items = new JSONObject(); - items.put("$ref", "#/definitions/" + key); - prop.put("items", items); - description.add(SYMBOL_TYPE__N + " Must be a valid Dimension (use ctrl+space for auto complete!)"); - } else if (k.isAnnotationPresent(RegistryListGenerator.class)) { - fancyType = "List of Iris Generators"; - String key = "enum-reg-generator"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getGeneratorLoader().getPossibleKeys())); - definitions.put(key, j); - } - - JSONObject items = new JSONObject(); - items.put("$ref", "#/definitions/" + key); - prop.put("items", items); - description.add(SYMBOL_TYPE__N + " Must be a valid Generator (use ctrl+space for auto complete!)"); - } else if (k.isAnnotationPresent(RegistryListObject.class)) { - fancyType = "List of Iris Objects"; - String key = "enum-reg-object"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getObjectLoader().getPossibleKeys())); - definitions.put(key, j); - } - - JSONObject items = new JSONObject(); - items.put("$ref", "#/definitions/" + key); - prop.put("items", items); - description.add(SYMBOL_TYPE__N + " Must be a valid Object (use ctrl+space for auto complete!)"); - } else if (k.isAnnotationPresent(RegistryListRegion.class)) { - fancyType = "List of Iris Regions"; - String key = "enum-reg-region"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getRegionLoader().getPossibleKeys())); - definitions.put(key, j); - } - - JSONObject items = new JSONObject(); - items.put("$ref", "#/definitions/" + key); - prop.put("items", items); - description.add(SYMBOL_TYPE__N + " Must be a valid Region (use ctrl+space for auto complete!)"); - } else if (k.isAnnotationPresent(RegistryListJigsawPiece.class)) { - fancyType = "List of Iris Jigsaw Pieces"; - String key = "enum-reg-structure-piece"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getJigsawPieceLoader().getPossibleKeys())); - definitions.put(key, j); - } - - JSONObject items = new JSONObject(); - items.put("$ref", "#/definitions/" + key); - prop.put("items", items); - description.add(SYMBOL_TYPE__N + " Must be a valid Jigsaw Piece (use ctrl+space for auto complete!)"); - } else if (k.isAnnotationPresent(RegistryListJigsawPool.class)) { - fancyType = "List of Iris Jigsaw Pools"; - String key = "enum-reg-structure-pool"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getJigsawPoolLoader().getPossibleKeys())); - definitions.put(key, j); - } - - JSONObject items = new JSONObject(); - items.put("$ref", "#/definitions/" + key); - prop.put("items", items); - description.add(SYMBOL_TYPE__N + " Must be a valid Jigsaw Pool (use ctrl+space for auto complete!)"); - } else if (k.isAnnotationPresent(RegistryListJigsaw.class)) { - fancyType = "List of Iris Jigsaw Structures"; - String key = "enum-reg-jigsaw"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", new JSONArray(data.getJigsawStructureLoader().getPossibleKeys())); - definitions.put(key, j); - } - - JSONObject items = new JSONObject(); - items.put("$ref", "#/definitions/" + key); - prop.put("items", items); - description.add(SYMBOL_TYPE__N + " Must be a valid Jigsaw (use ctrl+space for auto complete!)"); - } else if (t.type().equals(Enchantment.class)) { - fancyType = "List of Enchantment Types"; - String key = "enum-enchantment"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", ENCHANT_TYPES); - definitions.put(key, j); - } - - JSONObject items = new JSONObject(); - items.put("$ref", "#/definitions/" + key); - prop.put("items", items); - description.add(SYMBOL_TYPE__N + " Must be a valid Enchantment Type (use ctrl+space for auto complete!)"); - } else if (t.type().equals(PotionEffectType.class)) { - fancyType = "List of Potion Effect Types"; - String key = "enum-potion-effect-type"; - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put("enum", POTION_TYPES); - definitions.put(key, j); - } - - JSONObject items = new JSONObject(); - items.put("$ref", "#/definitions/" + key); - prop.put("items", items); - description.add(SYMBOL_TYPE__N + " Must be a valid Potion Effect Type (use ctrl+space for auto complete!)"); - } else if (t.type().isEnum()) { - fancyType = "List of " + t.type().getSimpleName().replaceAll("\\QIris\\E", "") + "s"; - JSONArray a = new JSONArray(); - boolean advanced = t.type().isAnnotationPresent(Desc.class); - for (Object gg : t.type().getEnumConstants()) { - if (advanced) { - try { - JSONObject j = new JSONObject(); - String name = ((Enum) gg).name(); - j.put("const", name); - Desc dd = t.type().getField(name).getAnnotation(Desc.class); - j.put("description", dd == null ? ("No Description for " + name) : dd.value()); - a.put(j); - } catch (Throwable e) { - e.printStackTrace(); - } - } else { - a.put(((Enum) gg).name()); - } - } - - String key = (advanced ? "oneof-" : "") + "enum-" + t.type().getCanonicalName().replaceAll("\\Q.\\E", "-").toLowerCase(); - - if (!definitions.containsKey(key)) { - JSONObject j = new JSONObject(); - j.put(advanced ? "oneOf" : "enum", a); - definitions.put(key, j); - } - - JSONObject items = new JSONObject(); - items.put("$ref", "#/definitions/" + key); - prop.put("items", items); - description.add(SYMBOL_TYPE__N + " Must be a valid " + t.type().getSimpleName().replaceAll("\\QIris\\E", "") + " (use ctrl+space for auto complete!)"); + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(Iris.linkMythicMobs.getMythicMobTypes())); + definitions.put(key, j); } + + fancyType = "Mythic Mob Type"; + prop.put("$ref", "#/definitions/" + key); + description.add(SYMBOL_TYPE__N + " Must be a valid Mythic Mob Type (use ctrl+space for auto complete!) Define mythic mobs with the mythic mobs plugin configuration files."); + } else if (k.isAnnotationPresent(RegistryListBlockType.class)) { + String key = "enum-block-type"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + JSONArray ja = new JSONArray(); + + for (String i : data.getBlockLoader().getPossibleKeys()) { + ja.put(i); + } + + for (String i : B.getBlockTypes()) { + ja.put(i); + } + + j.put("enum", ja); + definitions.put(key, j); + } + + fancyType = "Block Type"; + prop.put("$ref", "#/definitions/" + key); + description.add(SYMBOL_TYPE__N + " Must be a valid Block Type (use ctrl+space for auto complete!)"); + + } else if (k.isAnnotationPresent(RegistryListItemType.class)) { + String key = "enum-item-type"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", ITEM_TYPES); + definitions.put(key, j); + } + + fancyType = "Item Type"; + prop.put("$ref", "#/definitions/" + key); + description.add(SYMBOL_TYPE__N + " Must be a valid Item Type (use ctrl+space for auto complete!)"); + + } else if (k.isAnnotationPresent(RegistryListEntity.class)) { + String key = "enum-reg-entity"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getEntityLoader().getPossibleKeys())); + definitions.put(key, j); + } + + fancyType = "Iris Entity"; + prop.put("$ref", "#/definitions/" + key); + description.add(SYMBOL_TYPE__N + " Must be a valid Iris Entity (use ctrl+space for auto complete!)"); + + } else if (k.isAnnotationPresent(RegistryListFont.class)) { + String key = "enum-font"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", FONT_TYPES); + definitions.put(key, j); + } + + fancyType = "Font Family"; + prop.put("$ref", "#/definitions/" + key); + description.add(SYMBOL_TYPE__N + " Must be a valid Font Family (use ctrl+space for auto complete!)"); + + } else if (k.isAnnotationPresent(RegistryListLoot.class)) { + String key = "enum-reg-loot-table"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getLootLoader().getPossibleKeys())); + definitions.put(key, j); + } + + fancyType = "Iris Loot Table"; + prop.put("$ref", "#/definitions/" + key); + description.add(SYMBOL_TYPE__N + " Must be a valid Loot Table (use ctrl+space for auto complete!)"); + } else if (k.isAnnotationPresent(RegistryListDimension.class)) { + String key = "enum-reg-dimension"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getDimensionLoader().getPossibleKeys())); + definitions.put(key, j); + } + + fancyType = "Iris Dimension"; + prop.put("$ref", "#/definitions/" + key); + description.add(SYMBOL_TYPE__N + " Must be a valid Dimension (use ctrl+space for auto complete!)"); + + } else if (k.isAnnotationPresent(RegistryListGenerator.class)) { + String key = "enum-reg-generator"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getGeneratorLoader().getPossibleKeys())); + definitions.put(key, j); + } + + fancyType = "Iris Generator"; + prop.put("$ref", "#/definitions/" + key); + description.add(SYMBOL_TYPE__N + " Must be a valid Generator (use ctrl+space for auto complete!)"); + + } else if (k.isAnnotationPresent(RegistryListObject.class)) { + String key = "enum-reg-object"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getObjectLoader().getPossibleKeys())); + definitions.put(key, j); + } + + fancyType = "Iris Object"; + prop.put("$ref", "#/definitions/" + key); + description.add(SYMBOL_TYPE__N + " Must be a valid Object (use ctrl+space for auto complete!)"); + + } else if (k.isAnnotationPresent(RegistryListRegion.class)) { + String key = "enum-reg-region"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getRegionLoader().getPossibleKeys())); + definitions.put(key, j); + } + + fancyType = "Iris Region"; + prop.put("$ref", "#/definitions/" + key); + description.add(SYMBOL_TYPE__N + " Must be a valid Region (use ctrl+space for auto complete!)"); + + } else if (k.isAnnotationPresent(RegistryListJigsawPiece.class)) { + String key = "enum-reg-structure-piece"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getJigsawPieceLoader().getPossibleKeys())); + definitions.put(key, j); + } + + fancyType = "Iris Jigsaw Piece"; + prop.put("$ref", "#/definitions/" + key); + description.add(SYMBOL_TYPE__N + " Must be a valid Jigsaw Piece (use ctrl+space for auto complete!)"); + } else if (k.isAnnotationPresent(RegistryListJigsaw.class)) { + String key = "enum-reg-jigsaw"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getJigsawStructureLoader().getPossibleKeys())); + definitions.put(key, j); + } + + fancyType = "Iris Jigsaw"; + prop.put("$ref", "#/definitions/" + key); + description.add(SYMBOL_TYPE__N + " Must be a valid Jigsaw (use ctrl+space for auto complete!)"); + } else if (k.isAnnotationPresent(RegistryListJigsawPool.class)) { + String key = "enum-reg-structure-pool"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getJigsawPoolLoader().getPossibleKeys())); + definitions.put(key, j); + } + + fancyType = "Iris Jigsaw Pool"; + prop.put("$ref", "#/definitions/" + key); + description.add(SYMBOL_TYPE__N + " Must be a valid Jigsaw Piece (use ctrl+space for auto complete!)"); + } else if (k.getType().equals(Enchantment.class)) { + String key = "enum-enchantment"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", ENCHANT_TYPES); + definitions.put(key, j); + } + + fancyType = "Enchantment Type"; + prop.put("$ref", "#/definitions/" + key); + description.add(SYMBOL_TYPE__N + " Must be a valid Enchantment Type (use ctrl+space for auto complete!)"); + } else if (k.getType().equals(PotionEffectType.class)) { + String key = "enum-potion-effect-type"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", POTION_TYPES); + definitions.put(key, j); + } + + fancyType = "Potion Effect Type"; + prop.put("$ref", "#/definitions/" + key); + description.add(SYMBOL_TYPE__N + " Must be a valid Potion Effect Type (use ctrl+space for auto complete!)"); + + } else if (k.getType().isEnum()) { + fancyType = k.getType().getSimpleName().replaceAll("\\QIris\\E", ""); + JSONArray a = new JSONArray(); + boolean advanced = k.getType().isAnnotationPresent(Desc.class); + for (Object gg : k.getType().getEnumConstants()) { + if (advanced) { + try { + JSONObject j = new JSONObject(); + String name = ((Enum) gg).name(); + j.put("const", name); + Desc dd = k.getType().getField(name).getAnnotation(Desc.class); + j.put("description", dd == null ? ("No Description for " + name) : dd.value()); + a.put(j); + } catch (Throwable e) { + e.printStackTrace(); + } + } else { + a.put(((Enum) gg).name()); + } + } + + String key = (advanced ? "oneof-" : "") + "enum-" + k.getType().getCanonicalName().replaceAll("\\Q.\\E", "-").toLowerCase(); + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put(advanced ? "oneOf" : "enum", a); + definitions.put(key, j); + } + + prop.put("$ref", "#/definitions/" + key); + description.add(SYMBOL_TYPE__N + " Must be a valid " + k.getType().getSimpleName().replaceAll("\\QIris\\E", "") + " (use ctrl+space for auto complete!)"); + } - } else { - warnings.add("Undefined array type for field " + k.getName() + " (" + k.getType().getSimpleName() + ") in class " + cl.getSimpleName()); } - } else { - warnings.add("Unexpected Schema Type: " + type + " for field " + k.getName() + " (" + k.getType().getSimpleName() + ") in class " + cl.getSimpleName()); + case "object" -> { + fancyType = k.getType().getSimpleName().replaceAll("\\QIris\\E", "") + " (Object)"; + String key = "obj-" + k.getType().getCanonicalName().replaceAll("\\Q.\\E", "-").toLowerCase(); + if (!definitions.containsKey(key)) { + definitions.put(key, new JSONObject()); + definitions.put(key, buildProperties(k.getType())); + } + prop.put("$ref", "#/definitions/" + key); + } + case "array" -> { + fancyType = "List of Something...?"; + ArrayType t = k.getDeclaredAnnotation(ArrayType.class); + if (t != null) { + if (t.min() > 0) { + prop.put("minItems", t.min()); + if (t.min() == 1) { + description.add(SYMBOL_LIMIT__N + " At least one entry must be defined, or just remove this list."); + } else { + description.add(SYMBOL_LIMIT__N + " Requires at least " + t.min() + " entries."); + } + } + + String arrayType = getType(t.type()); + + switch (arrayType) { + case "integer" -> fancyType = "List of Integers"; + case "number" -> fancyType = "List of Numbers"; + case "object" -> { + fancyType = "List of " + t.type().getSimpleName().replaceAll("\\QIris\\E", "") + "s (Objects)"; + String key = "obj-" + t.type().getCanonicalName().replaceAll("\\Q.\\E", "-").toLowerCase(); + if (!definitions.containsKey(key)) { + definitions.put(key, new JSONObject()); + definitions.put(key, buildProperties(t.type())); + } + JSONObject items = new JSONObject(); + items.put("$ref", "#/definitions/" + key); + prop.put("items", items); + } + case "string" -> { + fancyType = "List of Text"; + if (k.isAnnotationPresent(RegistryListBiome.class)) { + fancyType = "List of Iris Biomes"; + String key = "enum-reg-biome"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getBiomeLoader().getPossibleKeys())); + definitions.put(key, j); + } + + JSONObject items = new JSONObject(); + items.put("$ref", "#/definitions/" + key); + prop.put("items", items); + description.add(SYMBOL_TYPE__N + " Must be a valid Biome (use ctrl+space for auto complete!)"); + } else if (k.isAnnotationPresent(RegistryListMythical.class)) { + fancyType = "List of Mythic Mob Types"; + String key = "enum-reg-mythical"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + JSONArray ja = new JSONArray(); + + for (String i : Iris.linkMythicMobs.getMythicMobTypes()) { + ja.put(i); + } + + j.put("enum", ja); + definitions.put(key, j); + } + + JSONObject items = new JSONObject(); + items.put("$ref", "#/definitions/" + key); + prop.put("items", items); + description.add(SYMBOL_TYPE__N + " Must be a valid Mythic Mob Type (use ctrl+space for auto complete!) Configure mob types in the mythic mobs plugin configuration files."); + } else if (k.isAnnotationPresent(RegistryListBlockType.class)) { + fancyType = "List of Block Types"; + String key = "enum-block-type"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + JSONArray ja = new JSONArray(); + + for (String i : data.getBlockLoader().getPossibleKeys()) { + ja.put(i); + } + + for (String i : B.getBlockTypes()) { + ja.put(i); + } + + j.put("enum", ja); + definitions.put(key, j); + } + + JSONObject items = new JSONObject(); + items.put("$ref", "#/definitions/" + key); + prop.put("items", items); + description.add(SYMBOL_TYPE__N + " Must be a valid Block Type (use ctrl+space for auto complete!)"); + } else if (k.isAnnotationPresent(RegistryListItemType.class)) { + fancyType = "List of Item Types"; + String key = "enum-item-type"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", ITEM_TYPES); + definitions.put(key, j); + } + + JSONObject items = new JSONObject(); + items.put("$ref", "#/definitions/" + key); + prop.put("items", items); + description.add(SYMBOL_TYPE__N + " Must be a valid Item Type (use ctrl+space for auto complete!)"); + } else if (k.isAnnotationPresent(RegistryListEntity.class)) { + fancyType = "List of Iris Entities"; + String key = "enum-reg-entity"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getEntityLoader().getPossibleKeys())); + definitions.put(key, j); + } + + JSONObject items = new JSONObject(); + items.put("$ref", "#/definitions/" + key); + prop.put("items", items); + description.add(SYMBOL_TYPE__N + " Must be a valid Iris Entity (use ctrl+space for auto complete!)"); + } else if (k.isAnnotationPresent(RegistryListFont.class)) { + String key = "enum-font"; + fancyType = "List of Font Families"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", FONT_TYPES); + definitions.put(key, j); + } + + JSONObject items = new JSONObject(); + items.put("$ref", "#/definitions/" + key); + prop.put("items", items); + description.add(SYMBOL_TYPE__N + " Must be a valid Font Family (use ctrl+space for auto complete!)"); + } else if (k.isAnnotationPresent(RegistryListLoot.class)) { + fancyType = "List of Iris Loot Tables"; + String key = "enum-reg-loot-table"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getLootLoader().getPossibleKeys())); + definitions.put(key, j); + } + + JSONObject items = new JSONObject(); + items.put("$ref", "#/definitions/" + key); + prop.put("items", items); + description.add(SYMBOL_TYPE__N + " Must be a valid Loot Table (use ctrl+space for auto complete!)"); + } else if (k.isAnnotationPresent(RegistryListDimension.class)) { + fancyType = "List of Iris Dimensions"; + String key = "enum-reg-dimension"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getDimensionLoader().getPossibleKeys())); + definitions.put(key, j); + } + + JSONObject items = new JSONObject(); + items.put("$ref", "#/definitions/" + key); + prop.put("items", items); + description.add(SYMBOL_TYPE__N + " Must be a valid Dimension (use ctrl+space for auto complete!)"); + } else if (k.isAnnotationPresent(RegistryListGenerator.class)) { + fancyType = "List of Iris Generators"; + String key = "enum-reg-generator"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getGeneratorLoader().getPossibleKeys())); + definitions.put(key, j); + } + + JSONObject items = new JSONObject(); + items.put("$ref", "#/definitions/" + key); + prop.put("items", items); + description.add(SYMBOL_TYPE__N + " Must be a valid Generator (use ctrl+space for auto complete!)"); + } else if (k.isAnnotationPresent(RegistryListObject.class)) { + fancyType = "List of Iris Objects"; + String key = "enum-reg-object"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getObjectLoader().getPossibleKeys())); + definitions.put(key, j); + } + + JSONObject items = new JSONObject(); + items.put("$ref", "#/definitions/" + key); + prop.put("items", items); + description.add(SYMBOL_TYPE__N + " Must be a valid Object (use ctrl+space for auto complete!)"); + } else if (k.isAnnotationPresent(RegistryListRegion.class)) { + fancyType = "List of Iris Regions"; + String key = "enum-reg-region"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getRegionLoader().getPossibleKeys())); + definitions.put(key, j); + } + + JSONObject items = new JSONObject(); + items.put("$ref", "#/definitions/" + key); + prop.put("items", items); + description.add(SYMBOL_TYPE__N + " Must be a valid Region (use ctrl+space for auto complete!)"); + } else if (k.isAnnotationPresent(RegistryListJigsawPiece.class)) { + fancyType = "List of Iris Jigsaw Pieces"; + String key = "enum-reg-structure-piece"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getJigsawPieceLoader().getPossibleKeys())); + definitions.put(key, j); + } + + JSONObject items = new JSONObject(); + items.put("$ref", "#/definitions/" + key); + prop.put("items", items); + description.add(SYMBOL_TYPE__N + " Must be a valid Jigsaw Piece (use ctrl+space for auto complete!)"); + } else if (k.isAnnotationPresent(RegistryListJigsawPool.class)) { + fancyType = "List of Iris Jigsaw Pools"; + String key = "enum-reg-structure-pool"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getJigsawPoolLoader().getPossibleKeys())); + definitions.put(key, j); + } + + JSONObject items = new JSONObject(); + items.put("$ref", "#/definitions/" + key); + prop.put("items", items); + description.add(SYMBOL_TYPE__N + " Must be a valid Jigsaw Pool (use ctrl+space for auto complete!)"); + } else if (k.isAnnotationPresent(RegistryListJigsaw.class)) { + fancyType = "List of Iris Jigsaw Structures"; + String key = "enum-reg-jigsaw"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", new JSONArray(data.getJigsawStructureLoader().getPossibleKeys())); + definitions.put(key, j); + } + + JSONObject items = new JSONObject(); + items.put("$ref", "#/definitions/" + key); + prop.put("items", items); + description.add(SYMBOL_TYPE__N + " Must be a valid Jigsaw (use ctrl+space for auto complete!)"); + } else if (t.type().equals(Enchantment.class)) { + fancyType = "List of Enchantment Types"; + String key = "enum-enchantment"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", ENCHANT_TYPES); + definitions.put(key, j); + } + + JSONObject items = new JSONObject(); + items.put("$ref", "#/definitions/" + key); + prop.put("items", items); + description.add(SYMBOL_TYPE__N + " Must be a valid Enchantment Type (use ctrl+space for auto complete!)"); + } else if (t.type().equals(PotionEffectType.class)) { + fancyType = "List of Potion Effect Types"; + String key = "enum-potion-effect-type"; + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put("enum", POTION_TYPES); + definitions.put(key, j); + } + + JSONObject items = new JSONObject(); + items.put("$ref", "#/definitions/" + key); + prop.put("items", items); + description.add(SYMBOL_TYPE__N + " Must be a valid Potion Effect Type (use ctrl+space for auto complete!)"); + } else if (t.type().isEnum()) { + fancyType = "List of " + t.type().getSimpleName().replaceAll("\\QIris\\E", "") + "s"; + JSONArray a = new JSONArray(); + boolean advanced = t.type().isAnnotationPresent(Desc.class); + for (Object gg : t.type().getEnumConstants()) { + if (advanced) { + try { + JSONObject j = new JSONObject(); + String name = ((Enum) gg).name(); + j.put("const", name); + Desc dd = t.type().getField(name).getAnnotation(Desc.class); + j.put("description", dd == null ? ("No Description for " + name) : dd.value()); + a.put(j); + } catch (Throwable e) { + e.printStackTrace(); + } + } else { + a.put(((Enum) gg).name()); + } + } + + String key = (advanced ? "oneof-" : "") + "enum-" + t.type().getCanonicalName().replaceAll("\\Q.\\E", "-").toLowerCase(); + + if (!definitions.containsKey(key)) { + JSONObject j = new JSONObject(); + j.put(advanced ? "oneOf" : "enum", a); + definitions.put(key, j); + } + + JSONObject items = new JSONObject(); + items.put("$ref", "#/definitions/" + key); + prop.put("items", items); + description.add(SYMBOL_TYPE__N + " Must be a valid " + t.type().getSimpleName().replaceAll("\\QIris\\E", "") + " (use ctrl+space for auto complete!)"); + } + } + } + } else { + warnings.add("Undefined array type for field " + k.getName() + " (" + k.getType().getSimpleName() + ") in class " + cl.getSimpleName()); + } + } + default -> warnings.add("Unexpected Schema Type: " + type + " for field " + k.getName() + " (" + k.getType().getSimpleName() + ") in class " + cl.getSimpleName()); } KList d = new KList<>(); @@ -752,7 +746,7 @@ public class SchemaBuilder { d.add("* Default Value is " + value); } } - } catch (Throwable e) { + } catch (Throwable ignored) { } diff --git a/src/main/java/com/volmit/iris/manager/WandManager.java b/src/main/java/com/volmit/iris/manager/WandManager.java index 4e36fb1a1..aacd365be 100644 --- a/src/main/java/com/volmit/iris/manager/WandManager.java +++ b/src/main/java/com/volmit/iris/manager/WandManager.java @@ -127,7 +127,7 @@ public class WandManager implements Listener { } Location lv = new Location(d[0].getWorld(), j, k, l).clone().add(0.5, 0.5, 0.5).clone().add(push); - Color color = Color.getHSBColor((float) (0.5f + (Math.sin((j + k + l + (p.getTicksLived() / 2)) / 20f) / 2)), 1, 1); + Color color = Color.getHSBColor((float) (0.5f + (Math.sin((j + k + l + (p.getTicksLived() / 2f)) / 20f) / 2)), 1, 1); int r = color.getRed(); int g = color.getGreen(); int b = color.getBlue(); diff --git a/src/main/java/com/volmit/iris/manager/command/CommandIrisDownload.java b/src/main/java/com/volmit/iris/manager/command/CommandIrisDownload.java index bfce503ae..bdecd724b 100644 --- a/src/main/java/com/volmit/iris/manager/command/CommandIrisDownload.java +++ b/src/main/java/com/volmit/iris/manager/command/CommandIrisDownload.java @@ -47,6 +47,7 @@ public class CommandIrisDownload extends MortarCommand { for (String i : args) { if (i.equals("-t") || i.equals("--trim")) { trim = true; + break; } } diff --git a/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectContract.java b/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectContract.java index 3f7467d4c..adc8ea7e8 100644 --- a/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectContract.java +++ b/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectContract.java @@ -59,7 +59,7 @@ public class CommandIrisObjectContract extends MortarCommand { return true; } - int amt = args.length == 1 ? Integer.valueOf(args[0]) : 1; + int amt = args.length == 1 ? Integer.parseInt(args[0]) : 1; Location[] b = WandManager.getCuboid(p.getInventory().getItemInMainHand()); Location a1 = b[0].clone(); Location a2 = b[1].clone(); diff --git a/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectExpand.java b/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectExpand.java index 81ddeb938..89b429168 100644 --- a/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectExpand.java +++ b/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectExpand.java @@ -59,7 +59,7 @@ public class CommandIrisObjectExpand extends MortarCommand { return true; } - int amt = args.length == 1 ? Integer.valueOf(args[0]) : 1; + int amt = args.length == 1 ? Integer.parseInt(args[0]) : 1; Location[] b = WandManager.getCuboid(p.getInventory().getItemInMainHand()); Location a1 = b[0].clone(); Location a2 = b[1].clone(); diff --git a/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectPaste.java b/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectPaste.java index d96c61655..3c5f32fac 100644 --- a/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectPaste.java +++ b/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectPaste.java @@ -79,6 +79,7 @@ public class CommandIrisObjectPaste extends MortarCommand { for (String i : args) { if (i.equalsIgnoreCase("-edit")) { intoWand = true; + break; } } diff --git a/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectSave.java b/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectSave.java index eea898bb4..69ec7b5ed 100644 --- a/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectSave.java +++ b/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectSave.java @@ -69,6 +69,7 @@ public class CommandIrisObjectSave extends MortarCommand { for (String i : args) { if (i.equals("-o")) { overwrite = true; + break; } } diff --git a/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectShift.java b/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectShift.java index 9ab41dfe6..07f53aaa0 100644 --- a/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectShift.java +++ b/src/main/java/com/volmit/iris/manager/command/object/CommandIrisObjectShift.java @@ -59,7 +59,7 @@ public class CommandIrisObjectShift extends MortarCommand { return true; } - int amt = args.length == 1 ? Integer.valueOf(args[0]) : 1; + int amt = args.length == 1 ? Integer.parseInt(args[0]) : 1; Location[] b = WandManager.getCuboid(p.getInventory().getItemInMainHand()); Location a1 = b[0].clone(); Location a2 = b[1].clone(); diff --git a/src/main/java/com/volmit/iris/manager/command/studio/CommandIrisStudioLoot.java b/src/main/java/com/volmit/iris/manager/command/studio/CommandIrisStudioLoot.java index 0935c1ad3..a45d6ac8b 100644 --- a/src/main/java/com/volmit/iris/manager/command/studio/CommandIrisStudioLoot.java +++ b/src/main/java/com/volmit/iris/manager/command/studio/CommandIrisStudioLoot.java @@ -90,7 +90,7 @@ public class CommandIrisStudioLoot extends MortarCommand { boolean fast = ffast; boolean add = fadd; - O ta = new O(); + O ta = new O<>(); ta.set(-1); ta.set(Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, () -> diff --git a/src/main/java/com/volmit/iris/manager/command/studio/CommandIrisStudioPackage.java b/src/main/java/com/volmit/iris/manager/command/studio/CommandIrisStudioPackage.java index b191d2064..6f372d270 100644 --- a/src/main/java/com/volmit/iris/manager/command/studio/CommandIrisStudioPackage.java +++ b/src/main/java/com/volmit/iris/manager/command/studio/CommandIrisStudioPackage.java @@ -58,6 +58,7 @@ public class CommandIrisStudioPackage extends MortarCommand { for (String i : args) { if (i.equalsIgnoreCase("-o")) { o = true; + break; } } diff --git a/src/main/java/com/volmit/iris/manager/command/studio/CommandIrisStudioProfile.java b/src/main/java/com/volmit/iris/manager/command/studio/CommandIrisStudioProfile.java index 15930804e..aec8f2c72 100644 --- a/src/main/java/com/volmit/iris/manager/command/studio/CommandIrisStudioProfile.java +++ b/src/main/java/com/volmit/iris/manager/command/studio/CommandIrisStudioProfile.java @@ -113,12 +113,7 @@ public class CommandIrisStudioProfile extends MortarCommand { in.setFunction(i); in.setHorizontalScale(8); - NoiseProvider np = new NoiseProvider() { - @Override - public double noise(double x, double z) { - return Math.random(); - } - }; + NoiseProvider np = (x, z) -> Math.random(); for (int j = 0; j < 3000; j++) { in.interpolate(j, -j, np); diff --git a/src/main/java/com/volmit/iris/manager/command/what/CommandIrisWhatBiome.java b/src/main/java/com/volmit/iris/manager/command/what/CommandIrisWhatBiome.java index 282dbbbe1..47fcd6ae0 100644 --- a/src/main/java/com/volmit/iris/manager/command/what/CommandIrisWhatBiome.java +++ b/src/main/java/com/volmit/iris/manager/command/what/CommandIrisWhatBiome.java @@ -63,7 +63,7 @@ public class CommandIrisWhatBiome extends MortarCommand { if (p.getLocation().getBlock().getBiome().equals(Biome.CUSTOM)) { try { sender.sendMessage("Data Pack Biome: " + INMS.get().getTrueBiomeBaseKey(p.getLocation()) + " (ID: " + INMS.get().getTrueBiomeBaseId(INMS.get().getTrueBiomeBase(p.getLocation())) + ")"); - } catch (Throwable ex) { + } catch (Throwable ignored) { } } diff --git a/src/main/java/com/volmit/iris/manager/command/what/CommandIrisWhatObjects.java b/src/main/java/com/volmit/iris/manager/command/what/CommandIrisWhatObjects.java index 992993e2c..57f4b9d4d 100644 --- a/src/main/java/com/volmit/iris/manager/command/what/CommandIrisWhatObjects.java +++ b/src/main/java/com/volmit/iris/manager/command/what/CommandIrisWhatObjects.java @@ -54,6 +54,7 @@ public class CommandIrisWhatObjects extends MortarCommand { } + @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") @Override public boolean handle(MortarSender sender, String[] args) { if (sender.isPlayer()) { @@ -78,7 +79,7 @@ public class CommandIrisWhatObjects extends MortarCommand { int cz = l.getChunk().getZ(); new Spiraler(3, 3, (x, z) -> chunks.addIfMissing(world.getChunkAt(x + cx, z + cz))).drain(); } - } catch (Throwable e) { + } catch (Throwable ignored) { } @@ -218,6 +219,7 @@ public class CommandIrisWhatObjects extends MortarCommand { objects.compute(n1, (k1, v1) -> { + //noinspection ReplaceNullCheck if (v1 == null) { return new KMap<>(); } diff --git a/src/main/java/com/volmit/iris/manager/command/world/CommandIrisCreate.java b/src/main/java/com/volmit/iris/manager/command/world/CommandIrisCreate.java index 7df545414..7cda1755d 100644 --- a/src/main/java/com/volmit/iris/manager/command/world/CommandIrisCreate.java +++ b/src/main/java/com/volmit/iris/manager/command/world/CommandIrisCreate.java @@ -60,24 +60,28 @@ public class CommandIrisCreate extends MortarCommand { String pre = split[0].toLowerCase(); - if (pre.equals("type")) { - for (String s : Iris.proj.getListing(true).keySet()) { - list.add("type=" + s); + switch (pre) { + case "type" -> { + for (String s : Iris.proj.getListing(true).keySet()) { + list.add("type=" + s); + } + if (!list.contains("type=overworld")) { + list.contains("type=overworld"); + } } - if (!list.contains("type=overworld")) { - list.contains("type=overworld"); + case "seed" -> { + list.add("seed=1337"); + list.add("seed=" + new Random().nextInt()); + list.add("seed=random"); + } + case "pregen" -> { + list.add("500"); + list.add("1000"); + list.add("2000"); + list.add("5k"); + list.add("10k"); + list.add("25k"); } - } else if (pre.equals("seed")) { - list.add("seed=1337"); - list.add("seed=" + new Random().nextInt()); - list.add("seed=random"); - } else if (pre.equals("pregen")) { - list.add("500"); - list.add("1000"); - list.add("2000"); - list.add("5k"); - list.add("10k"); - list.add("25k"); } } @@ -129,13 +133,13 @@ public class CommandIrisCreate extends MortarCommand { sender.sendMessage("You must remember to either have multiverse installed or use the Bukkit method, otherwise the world will go corrupt!"); sender.sendMessage("Wiki: https://volmitsoftware.gitbook.io/iris/getting-started"); - O b = new O(); + O b = new O<>(); b.set(true); if (sender.isPlayer()) { try { sender.player().teleport(world.get().getSpawnLocation()); - } catch (Throwable e) { + } catch (Throwable ignored) { } } @@ -148,9 +152,7 @@ public class CommandIrisCreate extends MortarCommand { sender.sendMessage("Expect server lag during this time. Use '/iris pregen stop' to cancel"); new Pregenerator(world.get(), size, () -> - { - b.set(true); - }); + b.set(true)); } World ww = world.get(); diff --git a/src/main/java/com/volmit/iris/manager/command/world/CommandIrisFix.java b/src/main/java/com/volmit/iris/manager/command/world/CommandIrisFix.java index 86cbe85bf..c3170c168 100644 --- a/src/main/java/com/volmit/iris/manager/command/world/CommandIrisFix.java +++ b/src/main/java/com/volmit/iris/manager/command/world/CommandIrisFix.java @@ -47,7 +47,7 @@ public class CommandIrisFix extends MortarCommand { return true; } - int viewDistance = args.length > 0 ? Integer.valueOf(args[0]) : -1; + int viewDistance = args.length > 0 ? Integer.parseInt(args[0]) : -1; if (viewDistance <= 1) { J.a(() -> { int fixed = a.getCompound().getDefaultEngine().getFramework().getEngineParallax().repairChunk(sender.player().getLocation().getChunk()); diff --git a/src/main/java/com/volmit/iris/manager/command/world/CommandIrisPregen.java b/src/main/java/com/volmit/iris/manager/command/world/CommandIrisPregen.java index 9fb1722cc..6db7e0e4e 100644 --- a/src/main/java/com/volmit/iris/manager/command/world/CommandIrisPregen.java +++ b/src/main/java/com/volmit/iris/manager/command/world/CommandIrisPregen.java @@ -33,10 +33,11 @@ public class CommandIrisPregen extends MortarCommand { public CommandIrisPregen() { super("pregen", "preg", "p"); setDescription( - "Pregen this world with optional parameters: " + - "\n'1k' = 1000 by 1000 blocks, '1c' = 1 by 1 chunks, and '1r' = 32 by 32 chunks." + - "\nIf you are using the console or want to pregen a world you're not in:" + - "\nalso specify the name of the world. E.g. /ir pregen 5k world" + """ + Pregen this world with optional parameters:\s + '1k' = 1000 by 1000 blocks, '1c' = 1 by 1 chunks, and '1r' = 32 by 32 chunks. + If you are using the console or want to pregen a world you're not in: + also specify the name of the world. E.g. /ir pregen 5k world""" ); requiresPermission(Iris.perm.studio); setCategory("Pregen"); diff --git a/src/main/java/com/volmit/iris/manager/command/world/CommandIrisUpdateWorld.java b/src/main/java/com/volmit/iris/manager/command/world/CommandIrisUpdateWorld.java index bcc777fcb..22808dccc 100644 --- a/src/main/java/com/volmit/iris/manager/command/world/CommandIrisUpdateWorld.java +++ b/src/main/java/com/volmit/iris/manager/command/world/CommandIrisUpdateWorld.java @@ -48,6 +48,7 @@ public class CommandIrisUpdateWorld extends MortarCommand { for (String i : args) { if (i.equalsIgnoreCase("--fresh-download")) { fresh = true; + break; } } diff --git a/src/main/java/com/volmit/iris/manager/command/world/CommandLocate.java b/src/main/java/com/volmit/iris/manager/command/world/CommandLocate.java index 0eb242659..800cc34c4 100644 --- a/src/main/java/com/volmit/iris/manager/command/world/CommandLocate.java +++ b/src/main/java/com/volmit/iris/manager/command/world/CommandLocate.java @@ -31,7 +31,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import java.util.Arrays; public class CommandLocate extends MortarCommand implements Listener { - CommandLocate instance; + final CommandLocate instance; @EventHandler public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) { diff --git a/src/main/java/com/volmit/iris/manager/edit/BlockSignal.java b/src/main/java/com/volmit/iris/manager/edit/BlockSignal.java index 419998b06..b7139034d 100644 --- a/src/main/java/com/volmit/iris/manager/edit/BlockSignal.java +++ b/src/main/java/com/volmit/iris/manager/edit/BlockSignal.java @@ -28,6 +28,7 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Player; import org.bukkit.util.Vector; +@SuppressWarnings("InstantiationOfUtilityClass") public class BlockSignal { public static void of(Block block, int ticks) { new BlockSignal(block, ticks); diff --git a/src/main/java/com/volmit/iris/manager/edit/BukkitBlockEditor.java b/src/main/java/com/volmit/iris/manager/edit/BukkitBlockEditor.java index 01b09f925..792eda3e6 100644 --- a/src/main/java/com/volmit/iris/manager/edit/BukkitBlockEditor.java +++ b/src/main/java/com/volmit/iris/manager/edit/BukkitBlockEditor.java @@ -23,6 +23,7 @@ import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.block.data.BlockData; +@SuppressWarnings("ClassCanBeRecord") public class BukkitBlockEditor implements BlockEditor { private final World world; diff --git a/src/main/java/com/volmit/iris/manager/edit/DustRevealer.java b/src/main/java/com/volmit/iris/manager/edit/DustRevealer.java index c6d6249ca..a7c9e5527 100644 --- a/src/main/java/com/volmit/iris/manager/edit/DustRevealer.java +++ b/src/main/java/com/volmit/iris/manager/edit/DustRevealer.java @@ -26,6 +26,7 @@ import lombok.Data; import org.bukkit.World; import org.bukkit.block.Block; +@SuppressWarnings("ALL") @Data public class DustRevealer { private final ParallaxAccess parallax; diff --git a/src/main/java/com/volmit/iris/manager/edit/WEBlockEditor.java b/src/main/java/com/volmit/iris/manager/edit/WEBlockEditor.java index 09e5f967b..ca1b1cd8a 100644 --- a/src/main/java/com/volmit/iris/manager/edit/WEBlockEditor.java +++ b/src/main/java/com/volmit/iris/manager/edit/WEBlockEditor.java @@ -62,7 +62,6 @@ public class WEBlockEditor implements BlockEditor { @Override public void close() { es.close(); - return; } @Override diff --git a/src/main/java/com/volmit/iris/manager/gui/IrisRenderer.java b/src/main/java/com/volmit/iris/manager/gui/IrisRenderer.java index 44d2e08c3..085b443b3 100644 --- a/src/main/java/com/volmit/iris/manager/gui/IrisRenderer.java +++ b/src/main/java/com/volmit/iris/manager/gui/IrisRenderer.java @@ -24,6 +24,7 @@ import org.bukkit.Material; import java.awt.image.BufferedImage; +@SuppressWarnings("ClassCanBeRecord") public class IrisRenderer { private final Renderer renderer; diff --git a/src/main/java/com/volmit/iris/manager/gui/IrisVision.java b/src/main/java/com/volmit/iris/manager/gui/IrisVision.java index 9e64356ba..ac4e19923 100644 --- a/src/main/java/com/volmit/iris/manager/gui/IrisVision.java +++ b/src/main/java/com/volmit/iris/manager/gui/IrisVision.java @@ -32,12 +32,10 @@ import java.awt.event.MouseMotionListener; import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; import java.awt.image.BufferedImage; -import java.awt.image.ImageObserver; import java.io.File; import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; public class IrisVision extends JPanel implements MouseWheelListener { private static final long serialVersionUID = 2094606939770332040L; @@ -63,38 +61,32 @@ public class IrisVision extends JPanel implements MouseWheelListener { private final KMap fastpositions = new KMap<>(); private final KSet working = new KSet<>(); private final KSet workingfast = new KSet<>(); - private final ExecutorService e = Executors.newFixedThreadPool(8, new ThreadFactory() { - @Override - public Thread newThread(Runnable r) { - tid++; - Thread t = new Thread(r); - t.setName("Iris HD Renderer " + tid); - t.setPriority(Thread.MIN_PRIORITY); - t.setUncaughtExceptionHandler((et, e) -> - { - Iris.info("Exception encountered in " + et.getName()); - e.printStackTrace(); - }); + private final ExecutorService e = Executors.newFixedThreadPool(8, r -> { + tid++; + Thread t = new Thread(r); + t.setName("Iris HD Renderer " + tid); + t.setPriority(Thread.MIN_PRIORITY); + t.setUncaughtExceptionHandler((et, e) -> + { + Iris.info("Exception encountered in " + et.getName()); + e.printStackTrace(); + }); - return t; - } + return t; }); - private final ExecutorService eh = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), new ThreadFactory() { - @Override - public Thread newThread(Runnable r) { - tid++; - Thread t = new Thread(r); - t.setName("Iris Renderer " + tid); - t.setPriority(Thread.NORM_PRIORITY); - t.setUncaughtExceptionHandler((et, e) -> - { - Iris.info("Exception encountered in " + et.getName()); - e.printStackTrace(); - }); + private final ExecutorService eh = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), r -> { + tid++; + Thread t = new Thread(r); + t.setName("Iris Renderer " + tid); + t.setPriority(Thread.NORM_PRIORITY); + t.setUncaughtExceptionHandler((et, e) -> + { + Iris.info("Exception encountered in " + et.getName()); + e.printStackTrace(); + }); - return t; - } + return t; }); public IrisVision() { @@ -241,12 +233,7 @@ public class IrisVision extends JPanel implements MouseWheelListener { BufferedImage t = getTile(gg, iscale, Math.floorDiv((posX / iscale) + i, iscale) * iscale, Math.floorDiv((posZ / iscale) + j, iscale) * iscale, m); if (t != null) { - g.drawImage(t, i - ((posX / iscale) % (iscale)), j - ((posZ / iscale) % (iscale)), iscale, iscale, new ImageObserver() { - @Override - public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) { - return true; - } - }); + g.drawImage(t, i - ((posX / iscale) % (iscale)), j - ((posZ / iscale) % (iscale)), iscale, iscale, (img, infoflags, x, y, width, height) -> true); } } } @@ -298,7 +285,7 @@ public class IrisVision extends JPanel implements MouseWheelListener { if (file != null) { try { frame.setIconImage(ImageIO.read(file)); - } catch (IOException e) { + } catch (IOException ignored) { } } @@ -306,9 +293,7 @@ public class IrisVision extends JPanel implements MouseWheelListener { public static void launch(IrisAccess g, int i) { J.a(() -> - { - createAndShowGUI((x, z) -> g.getEngineAccess(i).draw(x, z), i, g.getCompound().getWorld()); - }); + createAndShowGUI((x, z) -> g.getEngineAccess(i).draw(x, z), i, g.getCompound().getWorld())); } public void mouseWheelMoved(MouseWheelEvent e) { @@ -321,6 +306,6 @@ public class IrisVision extends JPanel implements MouseWheelListener { positions.clear(); fastpositions.clear(); mscale = mscale + ((0.044 * mscale) * notches); - mscale = mscale < 0.00001 ? 0.00001 : mscale; + mscale = Math.max(mscale, 0.00001); } } diff --git a/src/main/java/com/volmit/iris/manager/gui/NoiseExplorer.java b/src/main/java/com/volmit/iris/manager/gui/NoiseExplorer.java index 9bb701ea6..afe016593 100644 --- a/src/main/java/com/volmit/iris/manager/gui/NoiseExplorer.java +++ b/src/main/java/com/volmit/iris/manager/gui/NoiseExplorer.java @@ -37,12 +37,16 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener { private static final long serialVersionUID = 2094606939770332040L; static JComboBox combo; + @SuppressWarnings("CanBeFinal") RollingSequence r = new RollingSequence(90); + @SuppressWarnings("CanBeFinal") boolean colorMode = true; double scale = 1; + @SuppressWarnings("CanBeFinal") static boolean hd = false; static double ascale = 10; CNG cng = NoiseStyle.STATIC.create(new RNG(RNG.r.nextLong())); + @SuppressWarnings("CanBeFinal") GroupedExecutor gx = new GroupedExecutor(Runtime.getRuntime().availableProcessors(), Thread.MAX_PRIORITY, "Iris Renderer"); ReentrantLock l = new ReentrantLock(); int[][] co; @@ -57,6 +61,7 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener { double mz = 0; static double mxx = 0; static double mzz = 0; + @SuppressWarnings("CanBeFinal") static boolean down = false; double lx = Double.MAX_VALUE; //MouseX double lz = Double.MAX_VALUE; //MouseY @@ -154,8 +159,7 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener { accuracy = down ? accuracy * 4 : accuracy; int v = 1000; - if (g instanceof Graphics2D) { - Graphics2D gg = (Graphics2D) g; + if (g instanceof Graphics2D gg) { if (getParent().getWidth() != w || getParent().getHeight() != h) { w = getParent().getWidth(); @@ -250,8 +254,8 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener { JFrame frame = new JFrame("Noise Explorer"); NoiseExplorer nv = new NoiseExplorer(); frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); - KList li = new KList(NoiseStyle.values()).toStringList(); - combo = new JComboBox(li.toArray(new String[li.size()])); + KList li = new KList<>(NoiseStyle.values()).toStringList(); + combo = new JComboBox<>(li.toArray(new String[0])); combo.setSelectedItem("STATIC"); combo.setFocusable(false); combo.addActionListener(e -> { @@ -284,7 +288,7 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener { } public static void launch() { - EventQueue.invokeLater(() -> createAndShowGUI()); + EventQueue.invokeLater(NoiseExplorer::createAndShowGUI); } static class HandScrollListener extends MouseAdapter { diff --git a/src/main/java/com/volmit/iris/manager/link/BKLink.java b/src/main/java/com/volmit/iris/manager/link/BKLink.java index 2733e75da..aec8a9d6a 100644 --- a/src/main/java/com/volmit/iris/manager/link/BKLink.java +++ b/src/main/java/com/volmit/iris/manager/link/BKLink.java @@ -40,8 +40,7 @@ public class BKLink { } public Plugin getBK() { - Plugin p = Bukkit.getPluginManager().getPlugin("BKCommonLib"); - return p; + return Bukkit.getPluginManager().getPlugin("BKCommonLib"); } } diff --git a/src/main/java/com/volmit/iris/manager/link/CitizensLink.java b/src/main/java/com/volmit/iris/manager/link/CitizensLink.java index 00cc6b518..fcbeaed31 100644 --- a/src/main/java/com/volmit/iris/manager/link/CitizensLink.java +++ b/src/main/java/com/volmit/iris/manager/link/CitizensLink.java @@ -30,21 +30,8 @@ public class CitizensLink { return getCitizens() != null; } - // public Entity spawn(EntityType type, String npcType, Location a) - // { - // if(!supported()) - // { - // return null; - // } - // - // NPC npc = CitizensAPI.getNPCRegistry().createNPC(type, ""); - // npc.spawn(a); - // return npc.getEntity(); - // } - public Plugin getCitizens() { - Plugin p = Bukkit.getPluginManager().getPlugin("Citizens"); - return p; + return Bukkit.getPluginManager().getPlugin("Citizens"); } } diff --git a/src/main/java/com/volmit/iris/manager/link/MultiverseCoreLink.java b/src/main/java/com/volmit/iris/manager/link/MultiverseCoreLink.java index 98324f374..531b00cae 100644 --- a/src/main/java/com/volmit/iris/manager/link/MultiverseCoreLink.java +++ b/src/main/java/com/volmit/iris/manager/link/MultiverseCoreLink.java @@ -118,9 +118,8 @@ public class MultiverseCoreLink { } public Plugin getMultiverse() { - Plugin p = Bukkit.getPluginManager().getPlugin("Multiverse-Core"); - return p; + return Bukkit.getPluginManager().getPlugin("Multiverse-Core"); } public String envName(World.Environment environment) { @@ -128,15 +127,12 @@ public class MultiverseCoreLink { return "normal"; } - switch (environment) { - case NORMAL: - return "normal"; - case NETHER: - return "nether"; - case THE_END: - return "end"; - } + return switch (environment) { + case NORMAL -> "normal"; + case NETHER -> "nether"; + case THE_END -> "end"; + default -> environment.toString().toLowerCase(); + }; - return environment.toString().toLowerCase(); } } diff --git a/src/main/java/com/volmit/iris/manager/link/MythicMobsLink.java b/src/main/java/com/volmit/iris/manager/link/MythicMobsLink.java index 5fd86b88f..4f80ad9b7 100644 --- a/src/main/java/com/volmit/iris/manager/link/MythicMobsLink.java +++ b/src/main/java/com/volmit/iris/manager/link/MythicMobsLink.java @@ -55,12 +55,11 @@ public class MythicMobsLink { } } - return v.toArray(new String[v.size()]); + return v.toArray(new String[0]); } public Plugin getMythicMobs() { - Plugin p = Bukkit.getPluginManager().getPlugin("MythicMobs"); - return p; + return Bukkit.getPluginManager().getPlugin("MythicMobs"); } } diff --git a/src/main/java/com/volmit/iris/nms/v17_1/NMSBinding17_1.java b/src/main/java/com/volmit/iris/nms/v17_1/NMSBinding17_1.java index 119618ab0..331e32ab2 100644 --- a/src/main/java/com/volmit/iris/nms/v17_1/NMSBinding17_1.java +++ b/src/main/java/com/volmit/iris/nms/v17_1/NMSBinding17_1.java @@ -102,6 +102,7 @@ public class NMSBinding17_1 implements INMSBinding { return getCustomBiomeRegistry().d(ResourceKey.a(IRegistry.aO, new MinecraftKey(mckey))); } + @SuppressWarnings("OptionalGetWithoutIsPresent") @Override public String getKeyForBiomeBase(Object biomeBase) { return getCustomBiomeRegistry().c((BiomeBase) biomeBase).get().a().toString(); @@ -125,6 +126,7 @@ public class NMSBinding17_1 implements INMSBinding { try { Method f = from.getClass().getDeclaredMethod(name, classify(par)); f.setAccessible(true); + //noinspection unchecked return (T) f.invoke(from, par); } catch (Throwable e) { e.printStackTrace(); @@ -137,6 +139,7 @@ public class NMSBinding17_1 implements INMSBinding { try { Method f = from.getDeclaredMethod(name, classify(par)); f.setAccessible(true); + //noinspection unchecked return (T) f.invoke(null, par); } catch (Throwable e) { e.printStackTrace(); @@ -149,6 +152,7 @@ public class NMSBinding17_1 implements INMSBinding { try { Field f = from.getClass().getDeclaredField(name); f.setAccessible(true); + //noinspection unchecked return (T) f.get(from); } catch (Throwable e) { e.printStackTrace(); @@ -161,6 +165,7 @@ public class NMSBinding17_1 implements INMSBinding { try { Field f = t.getDeclaredField(name); f.setAccessible(true); + //noinspection unchecked return (T) f.get(null); } catch (Throwable e) { e.printStackTrace(); @@ -176,11 +181,13 @@ public class NMSBinding17_1 implements INMSBinding { if (v != null) { return v; } + //noinspection unchecked v = org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock.biomeToBiomeBase((IRegistry) registry, biome); if (v == null) { // Ok so there is this new biome name called "CUSTOM" in Paper's new releases. // But, this does NOT exist within CraftBukkit which makes it return an error. // So, we will just return the ID that the plains biome returns instead. + //noinspection unchecked return org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock.biomeToBiomeBase((IRegistry) registry, Biome.PLAINS); } baseBiomeCache.put(biome, v); @@ -204,7 +211,7 @@ public class NMSBinding17_1 implements INMSBinding { @Override public int countCustomBiomes() { AtomicInteger a = new AtomicInteger(0); - getCustomBiomeRegistry().d().stream().forEach((i) -> { + getCustomBiomeRegistry().d().forEach((i) -> { MinecraftKey k = i.getKey().a(); if (k.getNamespace().equals("minecraft")) { diff --git a/src/main/java/com/volmit/iris/object/CarvingMode.java b/src/main/java/com/volmit/iris/object/CarvingMode.java index e86c0b775..443d21311 100644 --- a/src/main/java/com/volmit/iris/object/CarvingMode.java +++ b/src/main/java/com/volmit/iris/object/CarvingMode.java @@ -34,10 +34,12 @@ public enum CarvingMode { ANYWHERE; + @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean supportsCarving() { return this.equals(ANYWHERE) || this.equals(CARVING_ONLY); } + @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean supportsSurface() { return this.equals(ANYWHERE) || this.equals(SURFACE_ONLY); } diff --git a/src/main/java/com/volmit/iris/object/IrisBiome.java b/src/main/java/com/volmit/iris/object/IrisBiome.java index d43e150c8..edc282ce3 100644 --- a/src/main/java/com/volmit/iris/object/IrisBiome.java +++ b/src/main/java/com/volmit/iris/object/IrisBiome.java @@ -35,6 +35,7 @@ import org.bukkit.block.data.BlockData; import java.awt.*; +@SuppressWarnings("DefaultAnnotationParam") @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor @@ -166,15 +167,15 @@ public class IrisBiome extends IrisRegistrant implements IRare { @ArrayType(min = 1, type = IrisBiomePaletteLayer.class) @Desc("This defines the layers of materials in this biome. Each layer has a palette and min/max height and some other properties. Usually a grassy/sandy layer then a dirt layer then a stone layer. Iris will fill in the remaining blocks below your layers with stone.") - private KList seaLayers = new KList(); + private KList seaLayers = new KList<>(); @ArrayType(min = 1, type = IrisDecorator.class) @Desc("Decorators are used for things like tall grass, bisected flowers, and even kelp or cactus (random heights)") - private KList decorators = new KList(); + private KList decorators = new KList<>(); @ArrayType(min = 1, type = IrisObjectPlacement.class) @Desc("Objects define what schematics (iob files) iris will place in this biome") - private KList objects = new KList(); + private KList objects = new KList<>(); @Required @ArrayType(min = 1, type = IrisBiomeGeneratorLink.class) @@ -307,9 +308,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { public CNG getBiomeGenerator(RNG random) { return biomeGenerator.aquire(() -> - { - return biomeStyle.create(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length())); - }); + biomeStyle.create(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length()))); } public CNG getChildrenGenerator(RNG random, int sig, double scale) { @@ -403,7 +402,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { for (int i = 0; i < maxDepth; i++) { int offset = (255 - height) - i; int index = offset % data.size(); - real.add(data.get(index < 0 ? 0 : index)); + real.add(data.get(Math.max(index, 0))); } return real; @@ -521,6 +520,7 @@ public class IrisBiome extends IrisRegistrant implements IRare { return isSea() || isLake() || isRiver(); } + @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean isShore() { if (inferredType == null) { return false; @@ -569,12 +569,11 @@ public class IrisBiome extends IrisRegistrant implements IRare { if (limit > 0) { for (String i : getChildren()) { IrisBiome b = g.getData().getBiomeLoader().load(i); - int l = limit; - m.addAll(b.getAllChildren(g, l)); + m.addAll(b.getAllChildren(g, limit)); } } - return new KList(m); + return new KList<>(m); } //TODO: Test diff --git a/src/main/java/com/volmit/iris/object/IrisBiomeMutation.java b/src/main/java/com/volmit/iris/object/IrisBiomeMutation.java index 5bb67a95f..b45fb536d 100644 --- a/src/main/java/com/volmit/iris/object/IrisBiomeMutation.java +++ b/src/main/java/com/volmit/iris/object/IrisBiomeMutation.java @@ -60,7 +60,7 @@ public class IrisBiomeMutation { @RegistryListObject @ArrayType(min = 1, type = IrisObjectPlacement.class) @Desc("Objects define what schematics (iob files) iris will place in this biome mutation") - private KList objects = new KList(); + private KList objects = new KList<>(); private final transient AtomicCache> sideACache = new AtomicCache<>(); private final transient AtomicCache> sideBCache = new AtomicCache<>(); @@ -77,24 +77,26 @@ public class IrisBiomeMutation { KSet r = new KSet<>(); for (String i : s) { - String q = i; - if (q.startsWith("^")) { - r.addAll(xg.getData().getRegionLoader().load(q.substring(1)).getLandBiomes()); - continue; - } else if (q.startsWith("*")) { - String name = q.substring(1); + if (i.startsWith("^")) { + r.addAll(xg.getData().getRegionLoader().load(i.substring(1)).getLandBiomes()); + } else if (i.startsWith("*")) { + String name = i.substring(1); r.addAll(xg.getData().getBiomeLoader().load(name).getAllChildren(xg, 7)); - } else if (q.startsWith("!")) { - r.remove(q.substring(1)); - } else if (q.startsWith("!*")) { - String name = q.substring(2); - r.removeAll(xg.getData().getBiomeLoader().load(name).getAllChildren(xg, 7)); + } else if (i.startsWith("!")) { + r.remove(i.substring(1)); + } else if (i.startsWith("!*")) { + String name = i.substring(2); + + for(String g : xg.getData().getBiomeLoader().load(name).getAllChildren(xg, 7)) + { + r.remove(g); + } } else { - r.add(q); + r.add(i); } } - return new KList(r); + return new KList<>(r); } } diff --git a/src/main/java/com/volmit/iris/object/IrisBlockData.java b/src/main/java/com/volmit/iris/object/IrisBlockData.java index 217d84f60..f4fc4a766 100644 --- a/src/main/java/com/volmit/iris/object/IrisBlockData.java +++ b/src/main/java/com/volmit/iris/object/IrisBlockData.java @@ -29,6 +29,9 @@ import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import org.bukkit.block.data.BlockData; +import java.util.Map; + +@SuppressWarnings("DefaultAnnotationParam") @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor @@ -77,8 +80,8 @@ public class IrisBlockData extends IrisRegistrant { KList r = new KList<>(); - for (String i : data.keySet()) { - r.add(i + "=" + filter(data.get(i).toString())); + for (Map.Entry entry : data.entrySet()) { + r.add(entry.getKey() + "=" + filter(entry.getValue().toString())); } return "[" + r.toString(",") + "]"; @@ -194,13 +197,13 @@ public class IrisBlockData extends IrisRegistrant { try { return Integer.valueOf(string); - } catch (Throwable e) { + } catch (Throwable ignored) { } try { return Double.valueOf(string).intValue(); - } catch (Throwable e) { + } catch (Throwable ignored) { } diff --git a/src/main/java/com/volmit/iris/object/IrisBlockDrops.java b/src/main/java/com/volmit/iris/object/IrisBlockDrops.java index 4a6295f04..fee02ac61 100644 --- a/src/main/java/com/volmit/iris/object/IrisBlockDrops.java +++ b/src/main/java/com/volmit/iris/object/IrisBlockDrops.java @@ -37,7 +37,7 @@ public class IrisBlockDrops { @Required @ArrayType(min = 1, type = IrisBlockData.class) @Desc("The blocks that drop loot") - private KList blocks = new KList(); + private KList blocks = new KList<>(); @Desc("If exact blocks is set to true, minecraft:barrel[axis=x] will only drop for that axis. When exact is false (default) any barrel will drop the defined drops.") diff --git a/src/main/java/com/volmit/iris/object/IrisColor.java b/src/main/java/com/volmit/iris/object/IrisColor.java index 181e57ff1..3bf34e712 100644 --- a/src/main/java/com/volmit/iris/object/IrisColor.java +++ b/src/main/java/com/volmit/iris/object/IrisColor.java @@ -65,7 +65,7 @@ public class IrisColor { String v = (hex.startsWith("#") ? hex : "#" + hex).trim(); try { return Color.decode(v); - } catch (Throwable e) { + } catch (Throwable ignored) { } } @@ -89,8 +89,8 @@ public class IrisColor { int g = 0; int b = 0; - for (int i = 0; i < c.length; i++) { - int rgb = c[i].getRGB(); + for (Color value : c) { + int rgb = value.getRGB(); int a1 = (rgb >> 24 & 0xff); int r1 = ((rgb & 0xff0000) >> 16); int g1 = ((rgb & 0xff00) >> 8); diff --git a/src/main/java/com/volmit/iris/object/IrisCompat.java b/src/main/java/com/volmit/iris/object/IrisCompat.java index 624f87c92..6edf71b33 100644 --- a/src/main/java/com/volmit/iris/object/IrisCompat.java +++ b/src/main/java/com/volmit/iris/object/IrisCompat.java @@ -167,8 +167,6 @@ public class IrisCompat { } } catch (JsonSyntaxException e) { e.printStackTrace(); - } catch (IOException e) { - throw e; } return def; diff --git a/src/main/java/com/volmit/iris/object/IrisDecorator.java b/src/main/java/com/volmit/iris/object/IrisDecorator.java index 5764869aa..27bc2054b 100644 --- a/src/main/java/com/volmit/iris/object/IrisDecorator.java +++ b/src/main/java/com/volmit/iris/object/IrisDecorator.java @@ -83,7 +83,7 @@ public class IrisDecorator { @ArrayType(min = 1, type = IrisBlockData.class) @Desc("The palette of blocks used at the very top of a 'stackMax' of higher than 1. For example, bamboo tops.") - private KList topPalette = new KList(); + private KList topPalette = new KList<>(); @DependsOn("topPalette") @MinNumber(0.01) @@ -107,9 +107,7 @@ public class IrisDecorator { public CNG getHeightGenerator(RNG rng, IrisDataManager data) { return heightGenerator.aquire(() -> - { - return heightVariance.create(rng.nextParallelRNG(getBlockData(data).size() + stackMax + stackMin)); - }); + heightVariance.create(rng.nextParallelRNG(getBlockData(data).size() + stackMax + stackMin))); } public CNG getGenerator(RNG rng, IrisDataManager data) { @@ -223,6 +221,7 @@ public class IrisDecorator { }); } + @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean isStacking() { return getStackMax() > 1; } diff --git a/src/main/java/com/volmit/iris/object/IrisDepositGenerator.java b/src/main/java/com/volmit/iris/object/IrisDepositGenerator.java index d11fc0274..8ade96569 100644 --- a/src/main/java/com/volmit/iris/object/IrisDepositGenerator.java +++ b/src/main/java/com/volmit/iris/object/IrisDepositGenerator.java @@ -75,7 +75,7 @@ public class IrisDepositGenerator { @Required @ArrayType(min = 1, type = IrisBlockData.class) @Desc("The palette of blocks to be used in this deposit generator") - private KList palette = new KList(); + private KList palette = new KList<>(); @MinNumber(1) @MaxNumber(64) diff --git a/src/main/java/com/volmit/iris/object/IrisDimension.java b/src/main/java/com/volmit/iris/object/IrisDimension.java index ee0bc9ac9..6bf73d4a9 100644 --- a/src/main/java/com/volmit/iris/object/IrisDimension.java +++ b/src/main/java/com/volmit/iris/object/IrisDimension.java @@ -36,6 +36,7 @@ import org.bukkit.block.data.BlockData; import java.io.File; import java.io.IOException; +@SuppressWarnings("DefaultAnnotationParam") @Accessors(chain = true) @AllArgsConstructor @NoArgsConstructor @@ -483,12 +484,14 @@ public class IrisDimension extends IrisRegistrant { if (write) { File mcm = new File(datapacks, "iris/pack.mcmeta"); try { - IO.writeAll(mcm, "{\n" + - " \"pack\": {\n" + - " \"description\": \"Iris Data Pack. This pack contains all installed Iris Packs' resources.\",\n" + - " \"pack_format\": 7\n" + - " }\n" + - "}\n"); + IO.writeAll(mcm, """ + { + "pack": { + "description": "Iris Data Pack. This pack contains all installed Iris Packs' resources.", + "pack_format": 7 + } + } + """); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/object/IrisDimensionIndex.java b/src/main/java/com/volmit/iris/object/IrisDimensionIndex.java index 88dadc030..ea1bc6ce6 100644 --- a/src/main/java/com/volmit/iris/object/IrisDimensionIndex.java +++ b/src/main/java/com/volmit/iris/object/IrisDimensionIndex.java @@ -28,6 +28,7 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; +@SuppressWarnings("DefaultAnnotationParam") @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor diff --git a/src/main/java/com/volmit/iris/object/IrisDirection.java b/src/main/java/com/volmit/iris/object/IrisDirection.java index 1411bc836..eb96dd101 100644 --- a/src/main/java/com/volmit/iris/object/IrisDirection.java +++ b/src/main/java/com/volmit/iris/object/IrisDirection.java @@ -25,6 +25,8 @@ import org.bukkit.block.BlockFace; import org.bukkit.block.data.type.Jigsaw; import org.bukkit.util.Vector; +import java.util.Map; + /** * Directions * @@ -47,35 +49,15 @@ public enum IrisDirection { private final CuboidDirection f; public static IrisDirection getDirection(BlockFace f) { - switch (f) { - case DOWN: - return DOWN_NEGATIVE_Y; - case EAST: - case EAST_NORTH_EAST: - case EAST_SOUTH_EAST: - return EAST_POSITIVE_X; - case NORTH: - case NORTH_NORTH_WEST: - case NORTH_EAST: - case NORTH_NORTH_EAST: - case NORTH_WEST: - return NORTH_NEGATIVE_Z; - case SELF: - case UP: - return UP_POSITIVE_Y; - case SOUTH: - case SOUTH_EAST: - case SOUTH_SOUTH_EAST: - case SOUTH_SOUTH_WEST: - case SOUTH_WEST: - return SOUTH_POSITIVE_Z; - case WEST: - case WEST_NORTH_WEST: - case WEST_SOUTH_WEST: - return WEST_NEGATIVE_X; - } + return switch (f) { + case DOWN -> DOWN_NEGATIVE_Y; + case EAST, EAST_NORTH_EAST, EAST_SOUTH_EAST -> EAST_POSITIVE_X; + case NORTH, NORTH_NORTH_WEST, NORTH_EAST, NORTH_NORTH_EAST, NORTH_WEST -> NORTH_NEGATIVE_Z; + case SELF, UP -> UP_POSITIVE_Y; + case SOUTH, SOUTH_EAST, SOUTH_SOUTH_EAST, SOUTH_SOUTH_WEST, SOUTH_WEST -> SOUTH_POSITIVE_Z; + case WEST, WEST_NORTH_WEST, WEST_SOUTH_WEST -> WEST_NEGATIVE_X; + }; - return DOWN_NEGATIVE_Y; } public static IrisDirection fromJigsawBlock(String direction) { @@ -90,46 +72,26 @@ public enum IrisDirection { } public static IrisDirection getDirection(Jigsaw.Orientation orientation) { - switch (orientation) { - case DOWN_EAST: - case UP_EAST: - case EAST_UP: - return EAST_POSITIVE_X; - case DOWN_NORTH: - case UP_NORTH: - case NORTH_UP: - return NORTH_NEGATIVE_Z; - case DOWN_SOUTH: - case UP_SOUTH: - case SOUTH_UP: - return SOUTH_POSITIVE_Z; - case DOWN_WEST: - case UP_WEST: - case WEST_UP: - return WEST_NEGATIVE_X; - } + return switch (orientation) { + case DOWN_EAST, UP_EAST, EAST_UP -> EAST_POSITIVE_X; + case DOWN_NORTH, UP_NORTH, NORTH_UP -> NORTH_NEGATIVE_Z; + case DOWN_SOUTH, UP_SOUTH, SOUTH_UP -> SOUTH_POSITIVE_Z; + case DOWN_WEST, UP_WEST, WEST_UP -> WEST_NEGATIVE_X; + }; - return null; } @Override public String toString() { - switch (this) { - case DOWN_NEGATIVE_Y: - return "Down"; - case EAST_POSITIVE_X: - return "East"; - case NORTH_NEGATIVE_Z: - return "North"; - case SOUTH_POSITIVE_Z: - return "South"; - case UP_POSITIVE_Y: - return "Up"; - case WEST_NEGATIVE_X: - return "West"; - } + return switch (this) { + case DOWN_NEGATIVE_Y -> "Down"; + case EAST_POSITIVE_X -> "East"; + case NORTH_NEGATIVE_Z -> "North"; + case SOUTH_POSITIVE_Z -> "South"; + case UP_POSITIVE_Y -> "Up"; + case WEST_NEGATIVE_X -> "West"; + }; - return "?"; } public boolean isVertical() { @@ -209,9 +171,10 @@ public enum IrisDirection { public Vector angle(Vector initial, IrisDirection d) { calculatePermutations(); - for (GBiset i : permute.keySet()) { + for (Map.Entry, DOP> entry : permute.entrySet()) { + GBiset i = entry.getKey(); if (i.getA().equals(this) && i.getB().equals(d)) { - return permute.get(i).op(initial); + return entry.getValue().op(initial); } } @@ -334,11 +297,11 @@ public enum IrisDirection { return; } - permute = new KMap, DOP>(); + permute = new KMap<>(); for (IrisDirection i : udnews()) { for (IrisDirection j : udnews()) { - GBiset b = new GBiset(i, j); + GBiset b = new GBiset<>(i, j); if (i.equals(j)) { permute.put(b, new DOP("DIRECT") { @@ -418,37 +381,23 @@ public enum IrisDirection { } public BlockFace getFace() { - switch (this) { - case DOWN_NEGATIVE_Y: - return BlockFace.DOWN; - case EAST_POSITIVE_X: - return BlockFace.EAST; - case NORTH_NEGATIVE_Z: - return BlockFace.NORTH; - case SOUTH_POSITIVE_Z: - return BlockFace.SOUTH; - case UP_POSITIVE_Y: - return BlockFace.UP; - case WEST_NEGATIVE_X: - return BlockFace.WEST; - } + return switch (this) { + case DOWN_NEGATIVE_Y -> BlockFace.DOWN; + case EAST_POSITIVE_X -> BlockFace.EAST; + case NORTH_NEGATIVE_Z -> BlockFace.NORTH; + case SOUTH_POSITIVE_Z -> BlockFace.SOUTH; + case UP_POSITIVE_Y -> BlockFace.UP; + case WEST_NEGATIVE_X -> BlockFace.WEST; + }; - return null; } public Axis getAxis() { - switch (this) { - case DOWN_NEGATIVE_Y: - case UP_POSITIVE_Y: - return Axis.Y; - case EAST_POSITIVE_X: - case WEST_NEGATIVE_X: - return Axis.X; - case NORTH_NEGATIVE_Z: - case SOUTH_POSITIVE_Z: - return Axis.Z; - } + return switch (this) { + case DOWN_NEGATIVE_Y, UP_POSITIVE_Y -> Axis.Y; + case EAST_POSITIVE_X, WEST_NEGATIVE_X -> Axis.X; + case NORTH_NEGATIVE_Z, SOUTH_POSITIVE_Z -> Axis.Z; + }; - return null; } } diff --git a/src/main/java/com/volmit/iris/object/IrisEffect.java b/src/main/java/com/volmit/iris/object/IrisEffect.java index a38969368..12b5316ba 100644 --- a/src/main/java/com/volmit/iris/object/IrisEffect.java +++ b/src/main/java/com/volmit/iris/object/IrisEffect.java @@ -190,7 +190,7 @@ public class IrisEffect { return t; } } - } catch (Throwable e) { + } catch (Throwable ignored) { } @@ -212,9 +212,7 @@ public class IrisEffect { if (sound != null) { Location part = p.getLocation().clone().add(RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance)); - J.s(() -> { - p.playSound(part, getSound(), (float) volume, (float) RNG.r.d(minPitch, maxPitch)); - }); + J.s(() -> p.playSound(part, getSound(), (float) volume, (float) RNG.r.d(minPitch, maxPitch))); } if (particleEffect != null) { @@ -223,23 +221,19 @@ public class IrisEffect { part.setY(Math.round(g.getHeight(part.getBlockX(), part.getBlockZ())) + 1); part.add(RNG.r.d(), 0, RNG.r.d()); if (extra != 0) { - J.s(() -> { - p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), - part.getZ(), - particleCount, - randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX, - randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY, - randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ, - extra); - }); + J.s(() -> p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), + part.getZ(), + particleCount, + randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX, + randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY, + randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ, + extra)); } else { - J.s(() -> { - p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), part.getZ(), - particleCount, - randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX, - randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY, - randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ); - }); + J.s(() -> p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), part.getZ(), + particleCount, + randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX, + randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY, + randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ)); } } @@ -250,18 +244,14 @@ public class IrisEffect { return; } - J.s(() -> { - p.removePotionEffect(getRealType()); - }); + J.s(() -> p.removePotionEffect(getRealType())); } - J.s(() -> { - p.addPotionEffect(new PotionEffect(getRealType(), - RNG.r.i(Math.min(potionTicksMax, potionTicksMin), - Math.max(potionTicksMax, potionTicksMin)), - getPotionStrength(), - true, false, false)); - }); + J.s(() -> p.addPotionEffect(new PotionEffect(getRealType(), + RNG.r.i(Math.min(potionTicksMax, potionTicksMin), + Math.max(potionTicksMax, potionTicksMin)), + getPotionStrength(), + true, false, false))); } } } diff --git a/src/main/java/com/volmit/iris/object/IrisEnchantment.java b/src/main/java/com/volmit/iris/object/IrisEnchantment.java index a4985b1c2..0687b272d 100644 --- a/src/main/java/com/volmit/iris/object/IrisEnchantment.java +++ b/src/main/java/com/volmit/iris/object/IrisEnchantment.java @@ -63,7 +63,7 @@ public class IrisEnchantment { } meta.addEnchant(getEnchant(), getLevel(rng), true); } - } catch (Throwable e) { + } catch (Throwable ignored) { } } diff --git a/src/main/java/com/volmit/iris/object/IrisEntity.java b/src/main/java/com/volmit/iris/object/IrisEntity.java index e4009f6f6..1e3840149 100644 --- a/src/main/java/com/volmit/iris/object/IrisEntity.java +++ b/src/main/java/com/volmit/iris/object/IrisEntity.java @@ -42,6 +42,7 @@ import java.util.Collection; import java.util.Random; import java.util.concurrent.atomic.AtomicReference; +@SuppressWarnings("ALL") @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor @@ -286,7 +287,7 @@ public class IrisEntity extends IrisRegistrant { J.s(() -> ae.set(doSpawn(at))); PrecisionStopwatch p = PrecisionStopwatch.start(); - while (ae == null) { + while (ae.get() == null) { J.sleep(3); } diff --git a/src/main/java/com/volmit/iris/object/IrisGenerator.java b/src/main/java/com/volmit/iris/object/IrisGenerator.java index a8b8b4768..d9eee3459 100644 --- a/src/main/java/com/volmit/iris/object/IrisGenerator.java +++ b/src/main/java/com/volmit/iris/object/IrisGenerator.java @@ -30,6 +30,7 @@ import lombok.experimental.Accessors; import java.util.List; +@SuppressWarnings("DefaultAnnotationParam") @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor @@ -96,7 +97,7 @@ public class IrisGenerator extends IrisRegistrant { @ArrayType(min = 1, type = IrisNoiseGenerator.class) @Desc("The list of noise gens this gen contains.") - private KList composite = new KList(); + private KList composite = new KList<>(); @Desc("The noise gen for cliff height.") diff --git a/src/main/java/com/volmit/iris/object/IrisGeneratorStyle.java b/src/main/java/com/volmit/iris/object/IrisGeneratorStyle.java index dc34df681..02c1dc9c4 100644 --- a/src/main/java/com/volmit/iris/object/IrisGeneratorStyle.java +++ b/src/main/java/com/volmit/iris/object/IrisGeneratorStyle.java @@ -62,7 +62,7 @@ public class IrisGeneratorStyle { @Desc("The exponent") private double exponent = 1; - private final transient AtomicCache cng = new AtomicCache(); + private final transient AtomicCache cng = new AtomicCache<>(); public IrisGeneratorStyle(NoiseStyle s) { this.style = s; @@ -87,6 +87,7 @@ public class IrisGeneratorStyle { }); } + @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean isFlat() { return style.equals(NoiseStyle.FLAT); } diff --git a/src/main/java/com/volmit/iris/object/IrisJigsawPiece.java b/src/main/java/com/volmit/iris/object/IrisJigsawPiece.java index c04380caa..7ebb4bd00 100644 --- a/src/main/java/com/volmit/iris/object/IrisJigsawPiece.java +++ b/src/main/java/com/volmit/iris/object/IrisJigsawPiece.java @@ -29,6 +29,7 @@ import org.bukkit.util.BlockVector; import java.io.IOException; +@SuppressWarnings("DefaultAnnotationParam") @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor diff --git a/src/main/java/com/volmit/iris/object/IrisJigsawPieceConnector.java b/src/main/java/com/volmit/iris/object/IrisJigsawPieceConnector.java index a346b1705..a43348edd 100644 --- a/src/main/java/com/volmit/iris/object/IrisJigsawPieceConnector.java +++ b/src/main/java/com/volmit/iris/object/IrisJigsawPieceConnector.java @@ -25,6 +25,7 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; +@SuppressWarnings("DefaultAnnotationParam") @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor diff --git a/src/main/java/com/volmit/iris/object/IrisJigsawPool.java b/src/main/java/com/volmit/iris/object/IrisJigsawPool.java index aa9a1857a..39eee924b 100644 --- a/src/main/java/com/volmit/iris/object/IrisJigsawPool.java +++ b/src/main/java/com/volmit/iris/object/IrisJigsawPool.java @@ -25,6 +25,7 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; +@SuppressWarnings("DefaultAnnotationParam") @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor diff --git a/src/main/java/com/volmit/iris/object/IrisJigsawStructure.java b/src/main/java/com/volmit/iris/object/IrisJigsawStructure.java index deb00ebad..4f70f3d20 100644 --- a/src/main/java/com/volmit/iris/object/IrisJigsawStructure.java +++ b/src/main/java/com/volmit/iris/object/IrisJigsawStructure.java @@ -27,6 +27,7 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; +@SuppressWarnings("DefaultAnnotationParam") @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor diff --git a/src/main/java/com/volmit/iris/object/IrisJigsawStructurePlacement.java b/src/main/java/com/volmit/iris/object/IrisJigsawStructurePlacement.java index abd347fa7..819457c95 100644 --- a/src/main/java/com/volmit/iris/object/IrisJigsawStructurePlacement.java +++ b/src/main/java/com/volmit/iris/object/IrisJigsawStructurePlacement.java @@ -27,6 +27,7 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; +@SuppressWarnings("DefaultAnnotationParam") @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor diff --git a/src/main/java/com/volmit/iris/object/IrisLoot.java b/src/main/java/com/volmit/iris/object/IrisLoot.java index c7857fc8d..c91f547fb 100644 --- a/src/main/java/com/volmit/iris/object/IrisLoot.java +++ b/src/main/java/com/volmit/iris/object/IrisLoot.java @@ -124,8 +124,7 @@ public class IrisLoot { ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount()))); ItemMeta m = is.getItemMeta(); - if (getType().getMaxDurability() > 0 && m instanceof Damageable) { - Damageable d = (Damageable) m; + if (getType().getMaxDurability() > 0 && m instanceof Damageable d) { int max = getType().getMaxDurability(); d.setDamage((int) Math.round(Math.max(0, Math.min(max, (1D - rng.d(getMinDurability(), getMaxDurability())) * max)))); } @@ -186,7 +185,7 @@ public class IrisLoot { is.setItemMeta(m); return is; - } catch (Throwable e) { + } catch (Throwable ignored) { } @@ -208,8 +207,7 @@ public class IrisLoot { ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount()))); ItemMeta m = is.getItemMeta(); - if (getType().getMaxDurability() > 0 && m instanceof Damageable) { - Damageable d = (Damageable) m; + if (getType().getMaxDurability() > 0 && m instanceof Damageable d) { int max = getType().getMaxDurability(); d.setDamage((int) Math.round(Math.max(0, Math.min(max, (1D - rng.d(getMinDurability(), getMaxDurability())) * max)))); } @@ -261,7 +259,7 @@ public class IrisLoot { m.setLore(lore); is.setItemMeta(m); return is; - } catch (Throwable e) { + } catch (Throwable ignored) { } } diff --git a/src/main/java/com/volmit/iris/object/IrisLootTable.java b/src/main/java/com/volmit/iris/object/IrisLootTable.java index 8ce224541..ced2acb21 100644 --- a/src/main/java/com/volmit/iris/object/IrisLootTable.java +++ b/src/main/java/com/volmit/iris/object/IrisLootTable.java @@ -27,6 +27,7 @@ import lombok.experimental.Accessors; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +@SuppressWarnings("DefaultAnnotationParam") @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor diff --git a/src/main/java/com/volmit/iris/object/IrisNoiseGenerator.java b/src/main/java/com/volmit/iris/object/IrisNoiseGenerator.java index 23753b6c3..79a09c79b 100644 --- a/src/main/java/com/volmit/iris/object/IrisNoiseGenerator.java +++ b/src/main/java/com/volmit/iris/object/IrisNoiseGenerator.java @@ -138,7 +138,7 @@ public class IrisNoiseGenerator { } public KList getAllComposites() { - KList g = new KList(); + KList g = new KList<>(); g.add(this); diff --git a/src/main/java/com/volmit/iris/object/IrisObject.java b/src/main/java/com/volmit/iris/object/IrisObject.java index 9649ca2b2..86ddb26c1 100644 --- a/src/main/java/com/volmit/iris/object/IrisObject.java +++ b/src/main/java/com/volmit/iris/object/IrisObject.java @@ -38,12 +38,10 @@ import org.bukkit.util.BlockVector; import org.bukkit.util.Vector; import java.io.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Objects; +import java.util.*; import java.util.function.Consumer; +@SuppressWarnings("DefaultAnnotationParam") @Accessors(chain = true) @Data @EqualsAndHashCode(callSuper = false) @@ -214,7 +212,7 @@ public class IrisObject extends IrisRegistrant { center = new BlockVector(w / 2, h / 2, d / 2); } - @SuppressWarnings("resource") + @SuppressWarnings({"resource", "RedundantSuppression"}) public static BlockVector sampleSize(File file) throws IOException { FileInputStream in = new FileInputStream(file); DataInputStream din = new DataInputStream(in); @@ -811,23 +809,24 @@ public class IrisObject extends IrisRegistrant { if (getD() == 2) { center = center.setZ(center.getBlockZ() + 0.5); } - HashMap placeBlock = new HashMap(); + @SuppressWarnings({"unchecked", "rawtypes"}) HashMap placeBlock = new HashMap(); IrisObject oo = new IrisObject((int) Math.ceil((w * scale) + (scale * 2)), (int) Math.ceil((h * scale) + (scale * 2)), (int) Math.ceil((d * scale) + (scale * 2))); - for (BlockVector i : blocks.keySet()) { - BlockData bd = blocks.get(i); - placeBlock.put(i.clone().add(HALF).subtract(center) + for (Map.Entry entry : blocks.entrySet()) { + BlockData bd = entry.getValue(); + placeBlock.put(entry.getKey().clone().add(HALF).subtract(center) .multiply(scale).toBlockVector(), bd); } - for (BlockVector v : placeBlock.keySet()) { + for (Map.Entry entry : placeBlock.entrySet()) { + BlockVector v = entry.getKey(); if (scale > 1) { for (BlockVector vec : blocksBetweenTwoPoints(v.clone().add(center), v.clone().add(center).add(sm1))) { - oo.getBlocks().put(vec, placeBlock.get(v)); + oo.getBlocks().put(vec, entry.getValue()); } } else { - oo.setUnsigned(v.getBlockX(), v.getBlockY(), v.getBlockZ(), placeBlock.get(v)); + oo.setUnsigned(v.getBlockX(), v.getBlockY(), v.getBlockZ(), entry.getValue()); } } @@ -943,14 +942,14 @@ public class IrisObject extends IrisRegistrant { double d = Double.MAX_VALUE; - for (BlockVector i : blocks.keySet()) { - BlockData dat = blocks.get(i); + for (Map.Entry entry : blocks.entrySet()) { + BlockData dat = entry.getValue(); if (dat.getMaterial().isAir()) { continue; } - double dx = i.distanceSquared(vv); + double dx = entry.getKey().distanceSquared(vv); if (dx < d) { d = dx; diff --git a/src/main/java/com/volmit/iris/object/IrisObjectPlacement.java b/src/main/java/com/volmit/iris/object/IrisObjectPlacement.java index 6911af9fd..a379d541c 100644 --- a/src/main/java/com/volmit/iris/object/IrisObjectPlacement.java +++ b/src/main/java/com/volmit/iris/object/IrisObjectPlacement.java @@ -177,9 +177,7 @@ public class IrisObjectPlacement { public CNG getSurfaceWarp(RNG rng) { return surfaceWarp.aquire(() -> - { - return getWarp().create(rng); - }); + getWarp().create(rng)); } public double warp(RNG rng, double x, double y, double z) { @@ -212,10 +210,10 @@ public class IrisObjectPlacement { private transient AtomicCache cache = new AtomicCache<>(); - private class TableCache { - transient WeightedRandom global = new WeightedRandom<>(); - transient KMap> basic = new KMap<>(); - transient KMap>> exact = new KMap<>(); + private static class TableCache { + final transient WeightedRandom global = new WeightedRandom<>(); + final transient KMap> basic = new KMap<>(); + final transient KMap>> exact = new KMap<>(); } private TableCache getCache(IrisDataManager manager) { diff --git a/src/main/java/com/volmit/iris/object/IrisObjectRotation.java b/src/main/java/com/volmit/iris/object/IrisObjectRotation.java index 1359dc67a..b38e602f5 100644 --- a/src/main/java/com/volmit/iris/object/IrisObjectRotation.java +++ b/src/main/java/com/volmit/iris/object/IrisObjectRotation.java @@ -190,47 +190,29 @@ public class IrisObjectRotation { } public BlockFace faceForAxis(Axis axis) { - switch (axis) { - case X: - return BlockFace.EAST; - case Y: - return BlockFace.UP; - case Z: - return BlockFace.NORTH; - } + return switch (axis) { + case X -> BlockFace.EAST; + case Y -> BlockFace.UP; + case Z -> BlockFace.NORTH; + }; - return BlockFace.NORTH; } public Axis axisFor(BlockFace f) { - switch (f) { - case NORTH: - case SOUTH: - return Axis.Z; - case EAST: - case WEST: - return Axis.X; - case UP: - case DOWN: - return Axis.Y; - } + return switch (f) { + case NORTH, SOUTH -> Axis.Z; + case EAST, WEST -> Axis.X; + default -> Axis.Y; + }; - return Axis.Y; } public Axis axisFor2D(BlockFace f) { - switch (f) { - case NORTH: - case SOUTH: - return Axis.Z; - case EAST: - case WEST: - case UP: - case DOWN: - return Axis.X; - } + return switch (f) { + case EAST, WEST, UP, DOWN -> Axis.X; + default -> Axis.Z; + }; - return Axis.Z; } public BlockData rotate(BlockData dd, int spinxx, int spinyy, int spinzz) { @@ -244,8 +226,7 @@ public class IrisObjectRotation { return d; } - if (d instanceof Directional) { - Directional g = ((Directional) d); + if (d instanceof Directional g) { BlockFace f = g.getFacing(); BlockVector bv = new BlockVector(f.getModX(), f.getModY(), f.getModZ()); bv = rotate(bv.clone(), spinx, spiny, spinz); @@ -256,8 +237,7 @@ public class IrisObjectRotation { } else if (!g.getMaterial().isSolid()) { d = null; } - } else if (d instanceof Rotatable) { - Rotatable g = ((Rotatable) d); + } else if (d instanceof Rotatable g) { BlockFace f = g.getRotation(); BlockVector bv = new BlockVector(f.getModX(), 0, f.getModZ()); @@ -275,9 +255,8 @@ public class IrisObjectRotation { if (!a.equals(((Orientable) d).getAxis()) && ((Orientable) d).getAxes().contains(a)) { ((Orientable) d).setAxis(a); } - } else if (d instanceof MultipleFacing) { + } else if (d instanceof MultipleFacing g) { List faces = new KList<>(); - MultipleFacing g = (MultipleFacing) d; for (BlockFace i : g.getFaces()) { BlockVector bv = new BlockVector(i.getModX(), i.getModY(), i.getModZ()); @@ -296,9 +275,8 @@ public class IrisObjectRotation { for (BlockFace i : faces) { g.setFace(i, true); } - } else if (d.getMaterial().equals(Material.NETHER_PORTAL) && d instanceof Orientable) { + } else if (d.getMaterial().equals(Material.NETHER_PORTAL) && d instanceof Orientable g) { //TODO: Fucks up logs - Orientable g = ((Orientable) d); BlockFace f = faceForAxis(g.getAxis()); BlockVector bv = new BlockVector(f.getModX(), f.getModY(), f.getModZ()); bv = rotate(bv.clone(), spinx, spiny, spinz); @@ -306,7 +284,7 @@ public class IrisObjectRotation { Axis a = !g.getAxes().contains(Axis.Y) ? axisFor(t) : axisFor2D(t); ((Orientable) d).setAxis(a); } - } catch (Throwable throwable) { + } catch (Throwable ignored) { } @@ -431,6 +409,7 @@ public class IrisObjectRotation { return enabled && zAxis.isEnabled(); } + @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean canRotate() { return canRotateX() || canRotateY() || canRotateZ(); } diff --git a/src/main/java/com/volmit/iris/object/IrisPotionEffect.java b/src/main/java/com/volmit/iris/object/IrisPotionEffect.java index 497fa8598..2500acaf4 100644 --- a/src/main/java/com/volmit/iris/object/IrisPotionEffect.java +++ b/src/main/java/com/volmit/iris/object/IrisPotionEffect.java @@ -83,7 +83,7 @@ public class IrisPotionEffect { return t; } } - } catch (Throwable e) { + } catch (Throwable ignored) { } diff --git a/src/main/java/com/volmit/iris/object/IrisRareObject.java b/src/main/java/com/volmit/iris/object/IrisRareObject.java index 9865b651c..27ad7dad5 100644 --- a/src/main/java/com/volmit/iris/object/IrisRareObject.java +++ b/src/main/java/com/volmit/iris/object/IrisRareObject.java @@ -28,6 +28,7 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; +@SuppressWarnings("DefaultAnnotationParam") @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor diff --git a/src/main/java/com/volmit/iris/object/IrisRegion.java b/src/main/java/com/volmit/iris/object/IrisRegion.java index 679dcd951..e4d9e3ce8 100644 --- a/src/main/java/com/volmit/iris/object/IrisRegion.java +++ b/src/main/java/com/volmit/iris/object/IrisRegion.java @@ -29,6 +29,7 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; +@SuppressWarnings("DefaultAnnotationParam") @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor @@ -81,7 +82,7 @@ public class IrisRegion extends IrisRegistrant implements IRare { @ArrayType(min = 1, type = IrisObjectPlacement.class) @Desc("Objects define what schematics (iob files) iris will place in this region") - private KList objects = new KList(); + private KList objects = new KList<>(); @MinNumber(0) @Desc("The min shore height") @@ -311,7 +312,7 @@ public class IrisRegion extends IrisRegistrant implements IRare { public KList getRidgeBiomeKeys() { return cacheRidge.aquire(() -> { - KList cacheRidge = new KList(); + KList cacheRidge = new KList<>(); ridgeBiomes.forEach((i) -> cacheRidge.add(i.getBiome())); return cacheRidge; @@ -321,7 +322,7 @@ public class IrisRegion extends IrisRegistrant implements IRare { public KList getSpotBiomeKeys() { return cacheSpot.aquire(() -> { - KList cacheSpot = new KList(); + KList cacheSpot = new KList<>(); spotBiomes.forEach((i) -> cacheSpot.add(i.getBiome())); return cacheSpot; }); @@ -329,9 +330,7 @@ public class IrisRegion extends IrisRegistrant implements IRare { public CNG getShoreHeightGenerator() { return shoreHeightGenerator.aquire(() -> - { - return CNG.signature(new RNG((long) (getName().length() + getLandBiomeZoom() + getLandBiomes().size() + 3458612))); - }); + CNG.signature(new RNG((long) (getName().length() + getLandBiomeZoom() + getLandBiomes().size() + 3458612)))); } public double getShoreHeight(double x, double z) { diff --git a/src/main/java/com/volmit/iris/object/IrisSlopeClip.java b/src/main/java/com/volmit/iris/object/IrisSlopeClip.java index bd3c033b0..779b26737 100644 --- a/src/main/java/com/volmit/iris/object/IrisSlopeClip.java +++ b/src/main/java/com/volmit/iris/object/IrisSlopeClip.java @@ -46,6 +46,7 @@ public class IrisSlopeClip { return minimumSlope <= 0 && maximumSlope >= 10; } + @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean isValid(double slope) { if (isDefault()) { return true; diff --git a/src/main/java/com/volmit/iris/object/tile/TileBanner.java b/src/main/java/com/volmit/iris/object/tile/TileBanner.java index ba0f4a268..3dde8372b 100644 --- a/src/main/java/com/volmit/iris/object/tile/TileBanner.java +++ b/src/main/java/com/volmit/iris/object/tile/TileBanner.java @@ -38,7 +38,7 @@ import java.util.List; public class TileBanner implements TileData { public static final int id = 2; - private List patterns = new ArrayList(); + private List patterns = new ArrayList<>(); private DyeColor baseColor; @Override @@ -65,6 +65,7 @@ public class TileBanner implements TileData { @Override public TileBanner clone() { + TileBanner tileBanner = (TileBanner) super.clone(); TileBanner ts = new TileBanner(); ts.setBaseColor(getBaseColor()); ts.setPatterns(getPatterns()); @@ -95,9 +96,10 @@ public class TileBanner implements TileData { } } + @SuppressWarnings("deprecation") @Override public void toNBT(CompoundTag tag) { - ListTag listTag = (ListTag) ListTag.createUnchecked(CompoundTag.class); + @SuppressWarnings("unchecked") ListTag listTag = (ListTag) ListTag.createUnchecked(CompoundTag.class); for (Pattern p : patterns) { CompoundTag pattern = new CompoundTag(); pattern.putString("Pattern", p.getPattern().getIdentifier()); @@ -108,43 +110,9 @@ public class TileBanner implements TileData { } public boolean isBanner(Material material) { - switch (material) { - - case RED_BANNER: - case RED_WALL_BANNER: - case ORANGE_BANNER: - case ORANGE_WALL_BANNER: - case YELLOW_BANNER: - case YELLOW_WALL_BANNER: - case LIME_BANNER: - case LIME_WALL_BANNER: - case GREEN_BANNER: - case GREEN_WALL_BANNER: - case CYAN_BANNER: - case CYAN_WALL_BANNER: - case LIGHT_BLUE_BANNER: - case LIGHT_BLUE_WALL_BANNER: - case BLUE_BANNER: - case BLUE_WALL_BANNER: - case PURPLE_BANNER: - case PURPLE_WALL_BANNER: - case MAGENTA_BANNER: - case MAGENTA_WALL_BANNER: - case PINK_BANNER: - case PINK_WALL_BANNER: - case WHITE_BANNER: - case WHITE_WALL_BANNER: - case LIGHT_GRAY_BANNER: - case LIGHT_GRAY_WALL_BANNER: - case GRAY_BANNER: - case GRAY_WALL_BANNER: - case BLACK_BANNER: - case BLACK_WALL_BANNER: - case BROWN_BANNER: - case BROWN_WALL_BANNER: - return true; - default: - return false; - } + return switch (material) { + case RED_BANNER, RED_WALL_BANNER, ORANGE_BANNER, ORANGE_WALL_BANNER, YELLOW_BANNER, YELLOW_WALL_BANNER, LIME_BANNER, LIME_WALL_BANNER, GREEN_BANNER, GREEN_WALL_BANNER, CYAN_BANNER, CYAN_WALL_BANNER, LIGHT_BLUE_BANNER, LIGHT_BLUE_WALL_BANNER, BLUE_BANNER, BLUE_WALL_BANNER, PURPLE_BANNER, PURPLE_WALL_BANNER, MAGENTA_BANNER, MAGENTA_WALL_BANNER, PINK_BANNER, PINK_WALL_BANNER, WHITE_BANNER, WHITE_WALL_BANNER, LIGHT_GRAY_BANNER, LIGHT_GRAY_WALL_BANNER, GRAY_BANNER, GRAY_WALL_BANNER, BLACK_BANNER, BLACK_WALL_BANNER, BROWN_BANNER, BROWN_WALL_BANNER -> true; + default -> false; + }; } } diff --git a/src/main/java/com/volmit/iris/object/tile/TileData.java b/src/main/java/com/volmit/iris/object/tile/TileData.java index 169c3a194..e14dc3bff 100644 --- a/src/main/java/com/volmit/iris/object/tile/TileData.java +++ b/src/main/java/com/volmit/iris/object/tile/TileData.java @@ -29,6 +29,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +@SuppressWarnings("ALL") public interface TileData extends Cloneable { KList> registry = setup(); @@ -45,7 +46,7 @@ public interface TileData extends Cloneable { static TileData read(DataInputStream s) throws Throwable { int id = s.readShort(); - TileData d = registry.get(id).getClass().getConstructor().newInstance(); + @SuppressWarnings("unchecked") TileData d = registry.get(id).getClass().getConstructor().newInstance(); d.fromBinary(s); return d; } @@ -62,7 +63,7 @@ public interface TileData extends Cloneable { if (i.isApplicable(data)) { try { - TileData s = i.getClass().getConstructor().newInstance(); + @SuppressWarnings("unchecked") TileData s = i.getClass().getConstructor().newInstance(); s.fromBukkitTry(block.getState()); return s; } catch (Throwable e) { @@ -84,6 +85,7 @@ public interface TileData extends Cloneable { default boolean toBukkitTry(BlockState t) { try { + //noinspection unchecked toBukkit((T) t); return true; } catch (Throwable e) { @@ -95,6 +97,7 @@ public interface TileData extends Cloneable { default boolean fromBukkitTry(BlockState t) { try { + //noinspection unchecked fromBukkit((T) t); return true; } catch (Throwable e) { diff --git a/src/main/java/com/volmit/iris/object/tile/TileSign.java b/src/main/java/com/volmit/iris/object/tile/TileSign.java index 92324d0e2..e4fa593fe 100644 --- a/src/main/java/com/volmit/iris/object/tile/TileSign.java +++ b/src/main/java/com/volmit/iris/object/tile/TileSign.java @@ -68,6 +68,7 @@ public class TileSign implements TileData { @Override public TileSign clone() { + TileSign tileSign = (TileSign) super.clone(); TileSign ts = new TileSign(); ts.setDyeColor(getDyeColor()); ts.setLine1(getLine1()); diff --git a/src/main/java/com/volmit/iris/object/tile/TileSpawner.java b/src/main/java/com/volmit/iris/object/tile/TileSpawner.java index f489c73e2..9ad94c772 100644 --- a/src/main/java/com/volmit/iris/object/tile/TileSpawner.java +++ b/src/main/java/com/volmit/iris/object/tile/TileSpawner.java @@ -57,6 +57,7 @@ public class TileSpawner implements TileData { @Override public TileSpawner clone() { + TileSpawner tileSpawner = (TileSpawner) super.clone(); TileSpawner ts = new TileSpawner(); ts.setEntityType(getEntityType()); return ts; @@ -75,7 +76,7 @@ public class TileSpawner implements TileData { @Override public void toNBT(CompoundTag tag) { - ListTag potentials = (ListTag) ListTag.createUnchecked(CompoundTag.class); + @SuppressWarnings("unchecked") ListTag potentials = (ListTag) ListTag.createUnchecked(CompoundTag.class); CompoundTag t = new CompoundTag(); CompoundTag ent = new CompoundTag(); ent.putString("id", entityType.getKey().toString()); diff --git a/src/main/java/com/volmit/iris/pregen/DirectWorldWriter.java b/src/main/java/com/volmit/iris/pregen/DirectWorldWriter.java index 5ce3857d5..4101675e4 100644 --- a/src/main/java/com/volmit/iris/pregen/DirectWorldWriter.java +++ b/src/main/java/com/volmit/iris/pregen/DirectWorldWriter.java @@ -39,6 +39,7 @@ import java.io.File; import java.io.IOException; import java.util.Map; +@SuppressWarnings("EmptyMethod") public class DirectWorldWriter { private final File worldFolder; private final Map writeBuffer; @@ -156,7 +157,7 @@ public class DirectWorldWriter { } return getBlockData(tag); - } catch (Throwable e) { + } catch (Throwable ignored) { } return B.get("AIR"); diff --git a/src/main/java/com/volmit/iris/pregen/Pregenerator.java b/src/main/java/com/volmit/iris/pregen/Pregenerator.java index fbee42d1e..1101464ae 100644 --- a/src/main/java/com/volmit/iris/pregen/Pregenerator.java +++ b/src/main/java/com/volmit/iris/pregen/Pregenerator.java @@ -39,7 +39,6 @@ import java.awt.*; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.image.BufferedImage; -import java.awt.image.ImageObserver; import java.io.File; import java.io.IOException; import java.nio.file.Files; @@ -295,44 +294,40 @@ public class Pregenerator implements Listener { int mcaoz = z << 5; if (PaperLib.isPaper()) { method.set("PaperAsync (Slow)"); - mcaIteration.accept(mcaox, mcaoz, (ii, jj) -> { - e.queue(() -> { - try { - CompletableFuture cc = PaperLib.getChunkAtAsync(world, ii, jj); - draw(ii, jj, COLOR_MCA_GENERATE_SLOW_ASYNC); - cc.join(); - draw(ii, jj, COLOR_MCA_GENERATED); - generated.getAndIncrement(); - vcax.set(ii); - vcaz.set(jj); - } catch (Throwable ex) { - draw(ii, jj, COLOR_ERROR); - ChunkPosition pos = new ChunkPosition(ii, jj); - errors.add(pos); - totalChunks.addAndGet(1024); - mcaDefer.add(new ChunkPosition(pos.getX() >> 5, pos.getZ() >> 5)); - Iris.warn("Hole Detected in Chunk: " + pos.getX() + ", " + pos.getZ() + " (at block " + (pos.getX() << 4) + ", " + lowestBedrock + ", " + (pos.getZ() << 4) + ")"); - } - }); - }); + mcaIteration.accept(mcaox, mcaoz, (ii, jj) -> e.queue(() -> { + try { + CompletableFuture cc = PaperLib.getChunkAtAsync(world, ii, jj); + draw(ii, jj, COLOR_MCA_GENERATE_SLOW_ASYNC); + cc.join(); + draw(ii, jj, COLOR_MCA_GENERATED); + generated.getAndIncrement(); + vcax.set(ii); + vcaz.set(jj); + } catch (Throwable ex) { + draw(ii, jj, COLOR_ERROR); + ChunkPosition pos = new ChunkPosition(ii, jj); + errors.add(pos); + totalChunks.addAndGet(1024); + mcaDefer.add(new ChunkPosition(pos.getX() >> 5, pos.getZ() >> 5)); + Iris.warn("Hole Detected in Chunk: " + pos.getX() + ", " + pos.getZ() + " (at block " + (pos.getX() << 4) + ", " + lowestBedrock + ", " + (pos.getZ() << 4) + ")"); + } + })); e.complete(); } else { AtomicInteger m = new AtomicInteger(); method.set("Spigot (Very Slow)"); KList q = new KList<>(); - mcaIteration.accept(mcaox, mcaoz, (ii, jj) -> { - q.add(() -> { - draw(ii, jj, COLOR_MCA_GENERATE_SLOW); - world.getChunkAt(ii, jj).load(true); - Chunk c = world.getChunkAt(ii, jj); - draw(ii, jj, COLOR_MCA_GENERATED); - checkForError(c); - m.getAndIncrement(); - generated.getAndIncrement(); - vcax.set(ii); - vcaz.set(jj); - }); - }); + mcaIteration.accept(mcaox, mcaoz, (ii, jj) -> q.add(() -> { + draw(ii, jj, COLOR_MCA_GENERATE_SLOW); + world.getChunkAt(ii, jj).load(true); + Chunk c = world.getChunkAt(ii, jj); + draw(ii, jj, COLOR_MCA_GENERATED); + checkForError(c); + m.getAndIncrement(); + generated.getAndIncrement(); + vcax.set(ii); + vcaz.set(jj); + })); ChronoLatch tick = new ChronoLatch(1000); new SR(0) { @Override @@ -348,7 +343,7 @@ public class Pregenerator implements Listener { try { q.pop().run(); - } catch (Throwable e) { + } catch (Throwable ignored) { } } @@ -524,18 +519,13 @@ public class Pregenerator implements Listener { while (order.isNotEmpty()) { try { order.pop().run(); - } catch (Throwable e) { + } catch (Throwable ignored) { } } l.unlock(); - g.drawImage(image, 0, 0, getParent().getWidth(), getParent().getHeight(), new ImageObserver() { - @Override - public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) { - return true; - } - }); + g.drawImage(image, 0, 0, getParent().getWidth(), getParent().getHeight(), (img, infoflags, x, y, width, height) -> true); g.setColor(Color.WHITE); g.setFont(new Font("Hevetica", Font.BOLD, 28)); @@ -575,11 +565,7 @@ public class Pregenerator implements Listener { @SuppressWarnings("deprecation") private static MCAPregenGui createAndShowGUI(Pregenerator j) throws HeadlessException { JFrame frame; - try { - frame = new JFrame("Pregen View"); - } catch (HeadlessException e) { - throw e; - } + frame = new JFrame("Pregen View"); MCAPregenGui nv = new MCAPregenGui(); frame.addKeyListener(nv); nv.l = new ReentrantLock(); @@ -602,7 +588,7 @@ public class Pregenerator implements Listener { if (file != null) { try { frame.setIconImage(ImageIO.read(file)); - } catch (IOException e) { + } catch (IOException ignored) { } } diff --git a/src/main/java/com/volmit/iris/scaffold/IrisWorlds.java b/src/main/java/com/volmit/iris/scaffold/IrisWorlds.java index 13e2886a4..1b538b53b 100644 --- a/src/main/java/com/volmit/iris/scaffold/IrisWorlds.java +++ b/src/main/java/com/volmit/iris/scaffold/IrisWorlds.java @@ -27,6 +27,7 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; +@SuppressWarnings("ALL") public class IrisWorlds { private static final KMap provisioned = new KMap<>(); diff --git a/src/main/java/com/volmit/iris/scaffold/cache/AtomicCache.java b/src/main/java/com/volmit/iris/scaffold/cache/AtomicCache.java index cb48355c4..abf0b2f0e 100644 --- a/src/main/java/com/volmit/iris/scaffold/cache/AtomicCache.java +++ b/src/main/java/com/volmit/iris/scaffold/cache/AtomicCache.java @@ -68,6 +68,7 @@ public class AtomicCache { if (this.t != null && M.ms() - a > 1000) { if (this.t != null) { + //noinspection NonAtomicOperationOnVolatileField validations++; } @@ -100,6 +101,7 @@ public class AtomicCache { } if (M.ms() - a > 1000) { + //noinspection NonAtomicOperationOnVolatileField validations++; return this.t; } diff --git a/src/main/java/com/volmit/iris/scaffold/cache/Multicache.java b/src/main/java/com/volmit/iris/scaffold/cache/Multicache.java index 9572e9013..b2540fb66 100644 --- a/src/main/java/com/volmit/iris/scaffold/cache/Multicache.java +++ b/src/main/java/com/volmit/iris/scaffold/cache/Multicache.java @@ -19,10 +19,8 @@ package com.volmit.iris.scaffold.cache; public interface Multicache { - @SuppressWarnings("hiding") Cache getCache(int id); - @SuppressWarnings("hiding") Cache createCache(); } \ No newline at end of file diff --git a/src/main/java/com/volmit/iris/scaffold/data/DataPalette.java b/src/main/java/com/volmit/iris/scaffold/data/DataPalette.java index cc4102770..28a3a00b0 100644 --- a/src/main/java/com/volmit/iris/scaffold/data/DataPalette.java +++ b/src/main/java/com/volmit/iris/scaffold/data/DataPalette.java @@ -58,8 +58,8 @@ public class DataPalette { synchronized (palette) { dos.writeShort(getPalette().size() + Short.MIN_VALUE); - for (int i = 0; i < palette.size(); i++) { - adapter.write(palette.get(i), dos); + for (T t : palette) { + adapter.write(t, dos); } } } diff --git a/src/main/java/com/volmit/iris/scaffold/data/mca/LoadFlags.java b/src/main/java/com/volmit/iris/scaffold/data/mca/LoadFlags.java index 0ef80251b..d73ef54c1 100644 --- a/src/main/java/com/volmit/iris/scaffold/data/mca/LoadFlags.java +++ b/src/main/java/com/volmit/iris/scaffold/data/mca/LoadFlags.java @@ -20,23 +20,23 @@ package com.volmit.iris.scaffold.data.mca; public class LoadFlags { - public static long BIOMES = 0x0001; - public static long HEIGHTMAPS = 0x0002; - public static long CARVING_MASKS = 0x0004; - public static long ENTITIES = 0x0008; - public static long TILE_ENTITIES = 0x0010; - public static long TILE_TICKS = 0x0040; - public static long LIQUID_TICKS = 0x0080; - public static long TO_BE_TICKED = 0x0100; - public static long POST_PROCESSING = 0x0200; - public static long STRUCTURES = 0x0400; - public static long BLOCK_LIGHTS = 0x0800; - public static long BLOCK_STATES = 0x1000; - public static long SKY_LIGHT = 0x2000; - public static long LIGHTS = 0x4000; - public static long LIQUIDS_TO_BE_TICKED = 0x8000; + public static final long BIOMES = 0x0001; + public static final long HEIGHTMAPS = 0x0002; + public static final long CARVING_MASKS = 0x0004; + public static final long ENTITIES = 0x0008; + public static final long TILE_ENTITIES = 0x0010; + public static final long TILE_TICKS = 0x0040; + public static final long LIQUID_TICKS = 0x0080; + public static final long TO_BE_TICKED = 0x0100; + public static final long POST_PROCESSING = 0x0200; + public static final long STRUCTURES = 0x0400; + public static final long BLOCK_LIGHTS = 0x0800; + public static final long BLOCK_STATES = 0x1000; + public static final long SKY_LIGHT = 0x2000; + public static final long LIGHTS = 0x4000; + public static final long LIQUIDS_TO_BE_TICKED = 0x8000; - public static long ALL_DATA = 0xffffffffffffffffL; + public static final long ALL_DATA = 0xffffffffffffffffL; } diff --git a/src/main/java/com/volmit/iris/scaffold/data/mca/MCAFile.java b/src/main/java/com/volmit/iris/scaffold/data/mca/MCAFile.java index 1c4b1f732..f4b11cad6 100644 --- a/src/main/java/com/volmit/iris/scaffold/data/mca/MCAFile.java +++ b/src/main/java/com/volmit/iris/scaffold/data/mca/MCAFile.java @@ -23,6 +23,7 @@ import com.volmit.iris.scaffold.data.nbt.tag.CompoundTag; import java.io.IOException; import java.io.RandomAccessFile; +@SuppressWarnings("ALL") public class MCAFile { /** @@ -80,7 +81,7 @@ public class MCAFile { raf.seek(4096 + i * 4); int timestamp = raf.readInt(); Chunk chunk = new Chunk(timestamp); - raf.seek(4096 * offset + 4); //+4: skip data size + raf.seek(4096L * offset + 4); //+4: skip data size chunk.deserialize(raf, loadFlags); chunks[i] = chunk; } @@ -131,7 +132,7 @@ public class MCAFile { if (chunk == null) { continue; } - raf.seek(4096 * globalOffset); + raf.seek(4096L * globalOffset); lastWritten = chunk.serialize(raf, chunkXOffset + cx, chunkZOffset + cz); if (lastWritten == 0) { @@ -142,14 +143,14 @@ public class MCAFile { int sectors = (lastWritten >> 12) + (lastWritten % 4096 == 0 ? 0 : 1); - raf.seek(index * 4); + raf.seek(index * 4L); raf.writeByte(globalOffset >>> 16); raf.writeByte(globalOffset >> 8 & 0xFF); raf.writeByte(globalOffset & 0xFF); raf.writeByte(sectors); // write timestamp - raf.seek(index * 4 + 4096); + raf.seek(index * 4L + 4096); raf.writeInt(changeLastUpdate ? timestamp : chunk.getLastMCAUpdate()); globalOffset += sectors; @@ -158,7 +159,7 @@ public class MCAFile { // padding if (lastWritten % 4096 != 0) { - raf.seek(globalOffset * 4096 - 1); + raf.seek(globalOffset * 4096L - 1); raf.write(0); } return chunksWritten; diff --git a/src/main/java/com/volmit/iris/scaffold/data/mca/Section.java b/src/main/java/com/volmit/iris/scaffold/data/mca/Section.java index 9aa63a773..c73a55a07 100644 --- a/src/main/java/com/volmit/iris/scaffold/data/mca/Section.java +++ b/src/main/java/com/volmit/iris/scaffold/data/mca/Section.java @@ -105,10 +105,11 @@ public class Section { return null; } + @SuppressWarnings("ClassCanBeRecord") private static class PaletteIndex { - CompoundTag data; - int index; + final CompoundTag data; + final int index; PaletteIndex(CompoundTag data, int index) { this.data = data; @@ -139,7 +140,7 @@ public class Section { int index = getBlockIndex(blockX, blockY, blockZ); int paletteIndex = getPaletteIndex(index); return palette.get(paletteIndex); - } catch (Throwable e) { + } catch (Throwable ignored) { } diff --git a/src/main/java/com/volmit/iris/scaffold/data/nbt/io/SNBTWriter.java b/src/main/java/com/volmit/iris/scaffold/data/nbt/io/SNBTWriter.java index e1c87c533..c3a2de04d 100644 --- a/src/main/java/com/volmit/iris/scaffold/data/nbt/io/SNBTWriter.java +++ b/src/main/java/com/volmit/iris/scaffold/data/nbt/io/SNBTWriter.java @@ -30,6 +30,7 @@ import java.util.regex.Pattern; /** * SNBTWriter creates an SNBT String. */ +@SuppressWarnings("ClassCanBeRecord") public final class SNBTWriter implements MaxDepthIO { private static final Pattern NON_QUOTE_PATTERN = Pattern.compile("[a-zA-Z_.+\\-]+"); diff --git a/src/main/java/com/volmit/iris/scaffold/data/nbt/io/StringPointer.java b/src/main/java/com/volmit/iris/scaffold/data/nbt/io/StringPointer.java index c27264612..adfd33f73 100644 --- a/src/main/java/com/volmit/iris/scaffold/data/nbt/io/StringPointer.java +++ b/src/main/java/com/volmit/iris/scaffold/data/nbt/io/StringPointer.java @@ -66,6 +66,7 @@ public class StringPointer { throw parseException("missing end quote"); } + @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean nextArrayElement() { skipWhitespace(); if (hasNext() && currentChar() == ',') { diff --git a/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/ArrayTag.java b/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/ArrayTag.java index 061c7a7b3..84a48565b 100644 --- a/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/ArrayTag.java +++ b/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/ArrayTag.java @@ -54,7 +54,7 @@ public abstract class ArrayTag extends Tag { return arrayToString("", ""); } - protected String arrayToString(String prefix, String suffix) { + protected String arrayToString(@SuppressWarnings("SameParameterValue") String prefix, @SuppressWarnings("SameParameterValue") String suffix) { StringBuilder sb = new StringBuilder("[").append(prefix).append("".equals(prefix) ? "" : ";"); for (int i = 0; i < length(); i++) { sb.append(i == 0 ? "" : ",").append(Array.get(getValue(), i)).append(suffix); diff --git a/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/CompoundTag.java b/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/CompoundTag.java index 008b395c2..7bc880947 100644 --- a/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/CompoundTag.java +++ b/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/CompoundTag.java @@ -24,6 +24,7 @@ import com.volmit.iris.util.KMap; import java.util.*; import java.util.function.BiConsumer; +@SuppressWarnings("ALL") public class CompoundTag extends Tag>> implements Iterable>>, Comparable, MaxDepthIO { public static final byte ID = 10; diff --git a/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/ListTag.java b/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/ListTag.java index 2e7e4c42f..e7c65dbe4 100644 --- a/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/ListTag.java +++ b/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/ListTag.java @@ -31,6 +31,7 @@ import java.util.function.Consumer; * The type of an empty untyped {@link ListTag} can be set by using any of the {@code add()} * methods or any of the {@code as...List()} methods. */ +@SuppressWarnings("ALL") public class ListTag> extends Tag> implements Iterable, Comparable>, MaxDepthIO { public static final byte ID = 9; @@ -68,7 +69,7 @@ public class ListTag> extends Tag> implements Iterable< * @param initialCapacity The initial capacity of the returned List * @return An instance of {@link List} with an initial capacity of 3 */ - private static List createEmptyValue(int initialCapacity) { + private static List createEmptyValue(@SuppressWarnings("SameParameterValue") int initialCapacity) { return new KList<>(initialCapacity); } diff --git a/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/NonNullEntrySet.java b/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/NonNullEntrySet.java index c04000737..9ae678749 100644 --- a/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/NonNullEntrySet.java +++ b/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/NonNullEntrySet.java @@ -18,6 +18,8 @@ package com.volmit.iris.scaffold.data.nbt.tag; +import org.jetbrains.annotations.NotNull; + import java.util.Collection; import java.util.Iterator; import java.util.Map; @@ -27,6 +29,7 @@ import java.util.Set; * A decorator for the Set returned by CompoundTag#entrySet() * that disallows setting null values. */ +@SuppressWarnings("ClassCanBeRecord") class NonNullEntrySet implements Set> { private final Set> set; @@ -61,7 +64,7 @@ class NonNullEntrySet implements Set> { } @Override - public T[] toArray(T[] a) { + public T[] toArray(@NotNull T[] a) { return set.toArray(a); } @@ -76,22 +79,22 @@ class NonNullEntrySet implements Set> { } @Override - public boolean containsAll(Collection c) { + public boolean containsAll(@NotNull Collection c) { return set.containsAll(c); } @Override - public boolean addAll(Collection> c) { + public boolean addAll(@NotNull Collection> c) { return set.addAll(c); } @Override - public boolean retainAll(Collection c) { + public boolean retainAll(@NotNull Collection c) { return set.retainAll(c); } @Override - public boolean removeAll(Collection c) { + public boolean removeAll(@NotNull Collection c) { return set.removeAll(c); } @@ -145,6 +148,7 @@ class NonNullEntrySet implements Set> { return entry.setValue(value); } + @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") @Override public boolean equals(Object o) { return entry.equals(o); diff --git a/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/Tag.java b/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/Tag.java index 5f1d97355..709c7ac6e 100644 --- a/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/Tag.java +++ b/src/main/java/com/volmit/iris/scaffold/data/nbt/tag/Tag.java @@ -67,6 +67,7 @@ public abstract class Tag implements Cloneable { temp.put("\t", "\\\\t"); temp.put("\r", "\\\\r"); temp.put("\"", "\\\\\""); + //noinspection Java9CollectionFactory ESCAPE_CHARACTERS = Collections.unmodifiableMap(temp); } @@ -190,7 +191,6 @@ public abstract class Tag implements Cloneable { * * @return A clone of this Tag. */ - @SuppressWarnings("CloneDoesntDeclareCloneNotSupportedException") public abstract Tag clone(); /** @@ -202,7 +202,8 @@ public abstract class Tag implements Cloneable { * the end of the string. * @return The escaped string. */ - protected static String escapeString(String s, boolean lenient) { + @SuppressWarnings("StringBufferMayBeStringBuilder") + protected static String escapeString(String s, @SuppressWarnings("SameParameterValue") boolean lenient) { StringBuffer sb = new StringBuffer(); Matcher m = ESCAPE_PATTERN.matcher(s); while (m.find()) { diff --git a/src/main/java/com/volmit/iris/scaffold/engine/Engine.java b/src/main/java/com/volmit/iris/scaffold/engine/Engine.java index ab5586b32..9897b8933 100644 --- a/src/main/java/com/volmit/iris/scaffold/engine/Engine.java +++ b/src/main/java/com/volmit/iris/scaffold/engine/Engine.java @@ -113,9 +113,8 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro IrisColor ibc = biome.getColor(); Color rc = irc != null ? irc.getColor() : Color.GREEN.darker(); Color bc = ibc != null ? ibc.getColor() : biome.isAquatic() ? Color.BLUE : Color.YELLOW; - Color f = IrisColor.blend(rc, bc, bc, Color.getHSBColor(0, 0, (float) heightFactor)); - return f; + return IrisColor.blend(rc, bc, bc, Color.getHSBColor(0, 0, (float) heightFactor)); } @Override @@ -213,11 +212,10 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro if (slot != null) { KList tables = getLootTables(rx, block); - InventorySlotType slott = slot; try { InventoryHolder m = (InventoryHolder) block.getState(); - addItems(false, m.getInventory(), rx, tables, slott, x, y, z, 15); + addItems(false, m.getInventory(), rx, tables, slot, x, y, z, 15); } catch (Throwable ignored) { } @@ -256,7 +254,7 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro try { Arrays.parallelSort(nitems, (a, b) -> rng.nextInt()); break; - } catch (Throwable e) { + } catch (Throwable ignored) { } } diff --git a/src/main/java/com/volmit/iris/scaffold/engine/EngineCompositeGenerator.java b/src/main/java/com/volmit/iris/scaffold/engine/EngineCompositeGenerator.java index a3c6b51a3..2d3d1c028 100644 --- a/src/main/java/com/volmit/iris/scaffold/engine/EngineCompositeGenerator.java +++ b/src/main/java/com/volmit/iris/scaffold/engine/EngineCompositeGenerator.java @@ -109,7 +109,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce new MortarSender(i, Iris.instance.getTag()).sendMessage("Dimension Hotloaded"); i.playSound(i.getLocation(), Sound.ITEM_BOTTLE_FILL, 1f, 1.25f); } - } catch (Throwable e) { + } catch (Throwable ignored) { } }); @@ -131,7 +131,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce J.a(() -> hotloader.check()); getComposite().clean(); } - } catch (Throwable e) { + } catch (Throwable ignored) { } @@ -315,7 +315,6 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce /** * Place strongholds in the world * - * @param world */ public void placeStrongholds(World world) { EngineData metadata = getComposite().getEngineMetadata(); @@ -330,7 +329,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce Class clazz = Class.forName("net.minecraft.world.level.chunk.ChunkGenerator"); Class clazzSG = Class.forName("net.minecraft.world.level.levelgen.feature.StructureGenerator"); Class clazzBP = Class.forName("net.minecraft.core.BlockPosition"); - Constructor bpCon = clazzBP.getConstructor(int.class, int.class, int.class); + @SuppressWarnings("rawtypes") Constructor bpCon = clazzBP.getConstructor(int.class, int.class, int.class); //By default, we place 9 strongholds. One near 0,0 and 8 all around it at about 10_000 blocks out int[][] coords = {{0, 0}, {7000, -7000}, {10000, 0}, {7000, 7000}, {0, 10000}, {-7000, 7000}, {-10000, 0}, {-7000, -7000}, {0, -10000}}; @@ -358,7 +357,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce }); } - CompletableFuture all = CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()])); + CompletableFuture all = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])); all.thenAccept((_void) -> { //Once all futures for all 9 strongholds have completed for (CompletableFuture future : futures) { try { @@ -407,7 +406,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce /** * Get BlockPosition for nearest stronghold from the provided position */ - private Object getBP(Class clazz, Class clazzSG, Class clazzBP, Object nmsWorld, Object pos, Object chunkGenerator) throws NoSuchFieldException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, ClassNotFoundException { + private Object getBP(Class clazz, Class clazzSG, Class clazzBP, Object nmsWorld, Object pos, Object chunkGenerator) throws NoSuchFieldException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { final String stronghold = "k"; //1.17_01 mapping Object structureGeneratorStronghold = clazzSG.getDeclaredField(stronghold).get(null); @@ -418,14 +417,13 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce int.class, boolean.class ); - Object nearestPOS = getNearestGeneratedFeature.invoke(chunkGenerator, + return getNearestGeneratedFeature.invoke(chunkGenerator, nmsWorld, structureGeneratorStronghold, pos, 100, false ); - return nearestPOS; } private File getDataFolder(World world) { @@ -466,6 +464,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce int oz = z << 4; com.volmit.iris.scaffold.data.mca.Chunk cc = writer.getChunk(x, z); BiomeBaseInjector injector = (xx, yy, zz, biomeBase) -> cc.setBiomeAt(ox + xx, yy, oz + zz, INMS.get().getTrueBiomeBaseId(biomeBase)); + //noinspection deprecation generateChunkRawData(w, x, z, new TerrainChunk() { @Override public BiomeBaseInjector getBiomeBaseInjector() { @@ -477,11 +476,13 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce } + @NotNull @Override public Biome getBiome(int x, int z) { return Biome.THE_VOID; } + @NotNull @Override public Biome getBiome(int x, int y, int z) { return Biome.THE_VOID; @@ -519,6 +520,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce cc.setBlockStateAt(xx, y, zz, DirectWorldWriter.getCompound(blockData), false); } + @NotNull @Override public BlockData getBlockData(int x, int y, int z) { if (y > getMaxHeight()) { @@ -772,6 +774,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce int zz = z * 16; BiomeBaseInjector inj = (a, b, c, d) -> { }; + //noinspection deprecation generateChunkRawData(getComposite().getWorld(), x, z, new TerrainChunk() { @Override public BiomeBaseInjector getBiomeBaseInjector() { @@ -783,11 +786,13 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce } + @NotNull @Override public Biome getBiome(int x, int z) { return Biome.THE_VOID; } + @NotNull @Override public Biome getBiome(int x, int y, int z) { return Biome.THE_VOID; @@ -820,6 +825,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce } } + @NotNull @Override public BlockData getBlockData(int x, int y, int z) { return Iris.edit.get(compound.getWorld(), x + xx, y, z + zz); @@ -949,7 +955,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce try { dim.getDimensionalComposite().forEach((m) -> IrisDataManager.loadAnyDimension(m.getDimension()).getAllAnyBiomes().forEach((i) -> v.put(i.getLoadKey(), i))); - } catch (Throwable e) { + } catch (Throwable ignored) { } diff --git a/src/main/java/com/volmit/iris/scaffold/engine/EngineCompound.java b/src/main/java/com/volmit/iris/scaffold/engine/EngineCompound.java index 6fb02177b..425c80a8f 100644 --- a/src/main/java/com/volmit/iris/scaffold/engine/EngineCompound.java +++ b/src/main/java/com/volmit/iris/scaffold/engine/EngineCompound.java @@ -140,7 +140,7 @@ public interface EngineCompound extends Listener, Hotloadable, DataProvider { try { dim.getDimensionalComposite().forEach((m) -> getData().getDimensionLoader().load(m.getDimension()).getAllBiomes(this).forEach((i) -> v.put(i.getLoadKey(), i))); - } catch (Throwable e) { + } catch (Throwable ignored) { } diff --git a/src/main/java/com/volmit/iris/scaffold/engine/EngineData.java b/src/main/java/com/volmit/iris/scaffold/engine/EngineData.java index 49bf5c37f..c5e240066 100644 --- a/src/main/java/com/volmit/iris/scaffold/engine/EngineData.java +++ b/src/main/java/com/volmit/iris/scaffold/engine/EngineData.java @@ -46,7 +46,7 @@ public class EngineData { try { f.getParentFile().mkdirs(); return new Gson().fromJson(IO.readAll(f), EngineData.class); - } catch (Throwable e) { + } catch (Throwable ignored) { } diff --git a/src/main/java/com/volmit/iris/scaffold/engine/EngineDecorator.java b/src/main/java/com/volmit/iris/scaffold/engine/EngineDecorator.java index c6b8b839f..4caeb70b0 100644 --- a/src/main/java/com/volmit/iris/scaffold/engine/EngineDecorator.java +++ b/src/main/java/com/volmit/iris/scaffold/engine/EngineDecorator.java @@ -30,6 +30,7 @@ public interface EngineDecorator extends EngineComponent { decorate(x, z, realX, realX, realX, realZ, realZ, realZ, data, biome, height, max); } + @SuppressWarnings("BooleanMethodIsAlwaysInverted") default boolean canGoOn(BlockData decorant, BlockData atop) { if (atop == null || B.isAir(atop)) { return false; diff --git a/src/main/java/com/volmit/iris/scaffold/engine/EngineParallaxManager.java b/src/main/java/com/volmit/iris/scaffold/engine/EngineParallaxManager.java index d3bfcf99a..ed49e2c44 100644 --- a/src/main/java/com/volmit/iris/scaffold/engine/EngineParallaxManager.java +++ b/src/main/java/com/volmit/iris/scaffold/engine/EngineParallaxManager.java @@ -41,6 +41,7 @@ import org.bukkit.util.Consumer; import java.io.IOException; import java.util.List; +import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; @@ -212,6 +213,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer { } } + @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") default void generateParallaxArea(int x, int z) { try { PrecisionStopwatch p = PrecisionStopwatch.start(); @@ -644,9 +646,9 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer { }); } - for (IrisObjectScale i : scalars.keySet()) { - double ms = i.getMaximumScale(); - for (String j : scalars.get(i)) { + for (Map.Entry> entry : scalars.entrySet()) { + double ms = entry.getKey().getMaximumScale(); + for (String j : entry.getValue()) { e.queue(() -> { try { BlockVector bv = sizeCache.compute(j, (k, v) -> { diff --git a/src/main/java/com/volmit/iris/scaffold/engine/EnginePlayer.java b/src/main/java/com/volmit/iris/scaffold/engine/EnginePlayer.java index 70cff1443..571e5d36c 100644 --- a/src/main/java/com/volmit/iris/scaffold/engine/EnginePlayer.java +++ b/src/main/java/com/volmit/iris/scaffold/engine/EnginePlayer.java @@ -52,7 +52,7 @@ public class EnginePlayer { for (IrisEffect j : region.getEffects()) { try { j.apply(player, getEngine()); - } catch (Throwable e) { + } catch (Throwable ignored) { } } @@ -62,7 +62,7 @@ public class EnginePlayer { for (IrisEffect j : biome.getEffects()) { try { j.apply(player, getEngine()); - } catch (Throwable e) { + } catch (Throwable ignored) { } } @@ -81,7 +81,7 @@ public class EnginePlayer { lastSample = M.ms(); sampleBiomeRegion(); } - } catch (Throwable ew) { + } catch (Throwable ignored) { } } diff --git a/src/main/java/com/volmit/iris/scaffold/engine/EngineWorldManager.java b/src/main/java/com/volmit/iris/scaffold/engine/EngineWorldManager.java index 8999a5c9a..afa88d372 100644 --- a/src/main/java/com/volmit/iris/scaffold/engine/EngineWorldManager.java +++ b/src/main/java/com/volmit/iris/scaffold/engine/EngineWorldManager.java @@ -23,6 +23,7 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntitySpawnEvent; +@SuppressWarnings("EmptyMethod") public interface EngineWorldManager { void close(); diff --git a/src/main/java/com/volmit/iris/scaffold/engine/IrisAccess.java b/src/main/java/com/volmit/iris/scaffold/engine/IrisAccess.java index 9ce1214ee..f11318439 100644 --- a/src/main/java/com/volmit/iris/scaffold/engine/IrisAccess.java +++ b/src/main/java/com/volmit/iris/scaffold/engine/IrisAccess.java @@ -35,6 +35,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; +@SuppressWarnings("EmptyMethod") public interface IrisAccess extends Hotloadable, DataProvider { void directWriteMCA(World w, int x, int z, DirectWorldWriter writer, MultiBurst burst); diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/Hunk.java b/src/main/java/com/volmit/iris/scaffold/hunk/Hunk.java index 1cc8b989f..d8361064b 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/Hunk.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/Hunk.java @@ -38,6 +38,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; import java.util.function.Predicate; +@SuppressWarnings("ALL") public interface Hunk { /** * Create a hunk view from a source hunk. This view reads and writes through to @@ -248,11 +249,11 @@ public interface Hunk { } default int getMax2DParallelism() { - return (int) Math.pow(getMinimumDimension() / 2, 2); + return (int) Math.pow(getMinimumDimension() / 2f, 2); } default int getMax3DParallelism() { - return (int) Math.pow(getMinimumDimension() / 2, 3); + return (int) Math.pow(getMinimumDimension() / 2f, 3); } default int filterDimension(int dim) { diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/io/HunkRegion.java b/src/main/java/com/volmit/iris/scaffold/hunk/io/HunkRegion.java index d3879d46c..421cd201e 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/io/HunkRegion.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/io/HunkRegion.java @@ -26,6 +26,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.Map; +@SuppressWarnings("SynchronizeOnNonFinalField") public class HunkRegion { private final File folder; private CompoundTag compound; @@ -63,7 +64,7 @@ public class HunkRegion { Map v = readTag.getValue(); if (!(v instanceof KMap)) { - return new CompoundTag(readTag.getName(), new KMap(v)); + return new CompoundTag(readTag.getName(), new KMap<>(v)); } return readTag; diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/io/HunkRegionSlice.java b/src/main/java/com/volmit/iris/scaffold/hunk/io/HunkRegionSlice.java index f18873933..fb3649bd7 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/io/HunkRegionSlice.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/io/HunkRegionSlice.java @@ -100,7 +100,7 @@ public class HunkRegionSlice { try { lock.withNasty(i.getX(), i.getZ(), () -> save.remove(i)); - } catch (Throwable ef) { + } catch (Throwable ignored) { } } diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/io/PaletteHunkIOAdapter.java b/src/main/java/com/volmit/iris/scaffold/hunk/io/PaletteHunkIOAdapter.java index 2727b6c8d..779d6f615 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/io/PaletteHunkIOAdapter.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/io/PaletteHunkIOAdapter.java @@ -34,7 +34,7 @@ public abstract class PaletteHunkIOAdapter implements HunkIOAdapter { dos.writeShort(t.getHeight() + Short.MIN_VALUE); dos.writeShort(t.getDepth() + Short.MIN_VALUE); AtomicInteger nonNull = new AtomicInteger(0); - DataPalette palette = new DataPalette(); + DataPalette palette = new DataPalette<>(); t.iterateSync((x, y, z, w) -> { if (w != null) { diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/storage/ArrayHunk.java b/src/main/java/com/volmit/iris/scaffold/hunk/storage/ArrayHunk.java index e0c3b591e..c9dbc6596 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/storage/ArrayHunk.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/storage/ArrayHunk.java @@ -24,6 +24,7 @@ import lombok.EqualsAndHashCode; import java.util.Arrays; +@SuppressWarnings("Lombok") @Data @EqualsAndHashCode(callSuper = false) public class ArrayHunk extends StorageHunk implements Hunk { diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/storage/AtomicDoubleHunk.java b/src/main/java/com/volmit/iris/scaffold/hunk/storage/AtomicDoubleHunk.java index 65c3ecac0..a15e269b9 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/storage/AtomicDoubleHunk.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/storage/AtomicDoubleHunk.java @@ -23,6 +23,7 @@ import com.volmit.iris.scaffold.hunk.Hunk; import lombok.Data; import lombok.EqualsAndHashCode; +@SuppressWarnings({"DefaultAnnotationParam", "Lombok"}) @Data @EqualsAndHashCode(callSuper = false) public class AtomicDoubleHunk extends StorageHunk implements Hunk { diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/storage/AtomicHunk.java b/src/main/java/com/volmit/iris/scaffold/hunk/storage/AtomicHunk.java index 66d93f31d..796becf28 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/storage/AtomicHunk.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/storage/AtomicHunk.java @@ -24,6 +24,7 @@ import lombok.EqualsAndHashCode; import java.util.concurrent.atomic.AtomicReferenceArray; +@SuppressWarnings({"DefaultAnnotationParam", "Lombok"}) @Data @EqualsAndHashCode(callSuper = false) public class AtomicHunk extends StorageHunk implements Hunk { @@ -31,7 +32,7 @@ public class AtomicHunk extends StorageHunk implements Hunk { public AtomicHunk(int w, int h, int d) { super(w, h, d); - data = new AtomicReferenceArray(w * h * d); + data = new AtomicReferenceArray<>(w * h * d); } @Override diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/storage/AtomicIntegerHunk.java b/src/main/java/com/volmit/iris/scaffold/hunk/storage/AtomicIntegerHunk.java index 8ad79fabb..747824de3 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/storage/AtomicIntegerHunk.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/storage/AtomicIntegerHunk.java @@ -24,6 +24,7 @@ import lombok.EqualsAndHashCode; import java.util.concurrent.atomic.AtomicIntegerArray; +@SuppressWarnings({"DefaultAnnotationParam", "Lombok"}) @Data @EqualsAndHashCode(callSuper = false) public class AtomicIntegerHunk extends StorageHunk implements Hunk { diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/storage/AtomicLongHunk.java b/src/main/java/com/volmit/iris/scaffold/hunk/storage/AtomicLongHunk.java index 6b5aef9b8..d1eafe184 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/storage/AtomicLongHunk.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/storage/AtomicLongHunk.java @@ -24,6 +24,7 @@ import lombok.EqualsAndHashCode; import java.util.concurrent.atomic.AtomicLongArray; +@SuppressWarnings({"DefaultAnnotationParam", "Lombok"}) @Data @EqualsAndHashCode(callSuper = false) public class AtomicLongHunk extends StorageHunk implements Hunk { diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/storage/MappedHunk.java b/src/main/java/com/volmit/iris/scaffold/hunk/storage/MappedHunk.java index 5e10b0a02..6a6d6d6bf 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/storage/MappedHunk.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/storage/MappedHunk.java @@ -26,6 +26,7 @@ import lombok.EqualsAndHashCode; import java.util.Map; +@SuppressWarnings({"DefaultAnnotationParam", "Lombok"}) @Data @EqualsAndHashCode(callSuper = false) public class MappedHunk extends StorageHunk implements Hunk { diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/storage/SynchronizedArrayHunk.java b/src/main/java/com/volmit/iris/scaffold/hunk/storage/SynchronizedArrayHunk.java index d5f97ea5b..2ff7aa2c3 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/storage/SynchronizedArrayHunk.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/storage/SynchronizedArrayHunk.java @@ -24,6 +24,7 @@ import lombok.EqualsAndHashCode; import java.util.Arrays; +@SuppressWarnings({"DefaultAnnotationParam", "Lombok"}) @Data @EqualsAndHashCode(callSuper = false) public class SynchronizedArrayHunk extends StorageHunk implements Hunk { diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/view/BiomeGridHunkView.java b/src/main/java/com/volmit/iris/scaffold/hunk/view/BiomeGridHunkView.java index 89338b7de..1862360af 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/view/BiomeGridHunkView.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/view/BiomeGridHunkView.java @@ -25,6 +25,7 @@ import lombok.Getter; import org.bukkit.block.Biome; import org.bukkit.generator.ChunkGenerator.BiomeGrid; +@SuppressWarnings("ClassCanBeRecord") public class BiomeGridHunkView implements Hunk { @Getter private final BiomeGrid chunk; diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/view/ChunkBiomeHunkView.java b/src/main/java/com/volmit/iris/scaffold/hunk/view/ChunkBiomeHunkView.java index 4f95b0093..7389d4d31 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/view/ChunkBiomeHunkView.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/view/ChunkBiomeHunkView.java @@ -23,6 +23,7 @@ import com.volmit.iris.scaffold.hunk.Hunk; import org.bukkit.Chunk; import org.bukkit.block.Biome; +@SuppressWarnings("ClassCanBeRecord") public class ChunkBiomeHunkView implements Hunk { private final Chunk chunk; diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/view/ChunkDataHunkView.java b/src/main/java/com/volmit/iris/scaffold/hunk/view/ChunkDataHunkView.java index dad8715fd..b3d10c16c 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/view/ChunkDataHunkView.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/view/ChunkDataHunkView.java @@ -22,6 +22,7 @@ import com.volmit.iris.scaffold.hunk.Hunk; import org.bukkit.block.data.BlockData; import org.bukkit.generator.ChunkGenerator.ChunkData; +@SuppressWarnings("ClassCanBeRecord") public class ChunkDataHunkView implements Hunk { private final ChunkData chunk; diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/view/ChunkHunkView.java b/src/main/java/com/volmit/iris/scaffold/hunk/view/ChunkHunkView.java index 73150239a..fb5499901 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/view/ChunkHunkView.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/view/ChunkHunkView.java @@ -23,6 +23,7 @@ import com.volmit.iris.scaffold.hunk.Hunk; import org.bukkit.Chunk; import org.bukkit.block.data.BlockData; +@SuppressWarnings("ClassCanBeRecord") public class ChunkHunkView implements Hunk { private final Chunk chunk; diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/view/DriftHunkView.java b/src/main/java/com/volmit/iris/scaffold/hunk/view/DriftHunkView.java index 3c6c68de6..c3844ce09 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/view/DriftHunkView.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/view/DriftHunkView.java @@ -20,6 +20,7 @@ package com.volmit.iris.scaffold.hunk.view; import com.volmit.iris.scaffold.hunk.Hunk; +@SuppressWarnings("ClassCanBeRecord") public class DriftHunkView implements Hunk { private final int ox; private final int oy; diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/view/FringedHunkView.java b/src/main/java/com/volmit/iris/scaffold/hunk/view/FringedHunkView.java index f1d018d0e..1946550e5 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/view/FringedHunkView.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/view/FringedHunkView.java @@ -20,6 +20,7 @@ package com.volmit.iris.scaffold.hunk.view; import com.volmit.iris.scaffold.hunk.Hunk; +@SuppressWarnings("ClassCanBeRecord") public class FringedHunkView implements Hunk { private final Hunk src; private final Hunk out; diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/view/InvertedHunkView.java b/src/main/java/com/volmit/iris/scaffold/hunk/view/InvertedHunkView.java index ba2f064ba..e272f4181 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/view/InvertedHunkView.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/view/InvertedHunkView.java @@ -20,6 +20,7 @@ package com.volmit.iris.scaffold.hunk.view; import com.volmit.iris.scaffold.hunk.Hunk; +@SuppressWarnings("ClassCanBeRecord") public class InvertedHunkView implements Hunk { private final Hunk src; diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/view/ListeningHunk.java b/src/main/java/com/volmit/iris/scaffold/hunk/view/ListeningHunk.java index ad40ae7b7..2378c6ec4 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/view/ListeningHunk.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/view/ListeningHunk.java @@ -21,6 +21,7 @@ package com.volmit.iris.scaffold.hunk.view; import com.volmit.iris.scaffold.hunk.Hunk; import com.volmit.iris.util.Consumer4; +@SuppressWarnings("ClassCanBeRecord") public class ListeningHunk implements Hunk { private final Hunk src; private final Consumer4 listener; diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/view/ReadOnlyHunk.java b/src/main/java/com/volmit/iris/scaffold/hunk/view/ReadOnlyHunk.java index a94a6b5a9..c136ee08b 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/view/ReadOnlyHunk.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/view/ReadOnlyHunk.java @@ -20,6 +20,7 @@ package com.volmit.iris.scaffold.hunk.view; import com.volmit.iris.scaffold.hunk.Hunk; +@SuppressWarnings("ClassCanBeRecord") public class ReadOnlyHunk implements Hunk { private final Hunk src; diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/view/RotatedXHunkView.java b/src/main/java/com/volmit/iris/scaffold/hunk/view/RotatedXHunkView.java index 3d7d4ef80..abe5e1de1 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/view/RotatedXHunkView.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/view/RotatedXHunkView.java @@ -33,8 +33,8 @@ public class RotatedXHunkView implements Hunk { @Override public void setRaw(int x, int y, int z, T t) { - int yc = (int) Math.round(cos * (getHeight() / 2) - sin * (getDepth() / 2)); - int zc = (int) Math.round(sin * (getHeight() / 2) + cos * (getDepth() / 2)); + int yc = (int) Math.round(cos * (getHeight() / 2f) - sin * (getDepth() / 2f)); + int zc = (int) Math.round(sin * (getHeight() / 2f) + cos * (getDepth() / 2f)); src.setIfExists(x, (int) Math.round(cos * (y - yc) - sin * (z - zc)) - yc, (int) Math.round(sin * y - yc + cos * (z - zc)) - zc, @@ -43,8 +43,8 @@ public class RotatedXHunkView implements Hunk { @Override public T getRaw(int x, int y, int z) { - int yc = (int) Math.round(cos * (getHeight() / 2) - sin * (getDepth() / 2)); - int zc = (int) Math.round(sin * (getHeight() / 2) + cos * (getDepth() / 2)); + int yc = (int) Math.round(cos * (getHeight() / 2f) - sin * (getDepth() / 2f)); + int zc = (int) Math.round(sin * (getHeight() / 2f) + cos * (getDepth() / 2f)); return src.getIfExists(x, (int) Math.round(cos * (y - yc) - sin * (z - zc)) - yc, (int) Math.round(sin * y - yc + cos * (z - zc)) - zc diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/view/RotatedYHunkView.java b/src/main/java/com/volmit/iris/scaffold/hunk/view/RotatedYHunkView.java index eb765b65e..6bdf5be26 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/view/RotatedYHunkView.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/view/RotatedYHunkView.java @@ -33,8 +33,8 @@ public class RotatedYHunkView implements Hunk { @Override public void setRaw(int x, int y, int z, T t) { - int xc = (int) Math.round(cos * (getWidth() / 2) + sin * (getDepth() / 2)); - int zc = (int) Math.round(-sin * (getWidth() / 2) + cos * (getDepth() / 2)); + int xc = (int) Math.round(cos * (getWidth() / 2f) + sin * (getDepth() / 2f)); + int zc = (int) Math.round(-sin * (getWidth() / 2f) + cos * (getDepth() / 2f)); src.setIfExists((int) Math.round(cos * (x - xc) + sin * (z - zc)) - xc, y, @@ -43,8 +43,8 @@ public class RotatedYHunkView implements Hunk { @Override public T getRaw(int x, int y, int z) { - int xc = (int) Math.round(cos * (getWidth() / 2) + sin * (getDepth() / 2)); - int zc = (int) Math.round(-sin * (getWidth() / 2) + cos * (getDepth() / 2)); + int xc = (int) Math.round(cos * (getWidth() / 2f) + sin * (getDepth() / 2f)); + int zc = (int) Math.round(-sin * (getWidth() / 2f) + cos * (getDepth() / 2f)); return src.getIfExists( (int) Math.round(cos * (x - xc) + sin * (z - zc)) - xc, y, diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/view/RotatedZHunkView.java b/src/main/java/com/volmit/iris/scaffold/hunk/view/RotatedZHunkView.java index ee3425f62..7bfb957ce 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/view/RotatedZHunkView.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/view/RotatedZHunkView.java @@ -33,15 +33,15 @@ public class RotatedZHunkView implements Hunk { @Override public void setRaw(int x, int y, int z, T t) { - int xc = (int) Math.round(cos * (getWidth() / 2) - sin * (getHeight() / 2)); - int yc = (int) Math.round(sin * (getWidth() / 2) + cos * (getHeight() / 2)); + int xc = (int) Math.round(cos * (getWidth() / 2f) - sin * (getHeight() / 2f)); + int yc = (int) Math.round(sin * (getWidth() / 2f) + cos * (getHeight() / 2f)); src.setIfExists((int) Math.round(cos * (x - xc) - sin * (y - yc)) - xc, (int) Math.round(sin * (x - xc) + cos * (y - yc)) - yc, z, t); } @Override public T getRaw(int x, int y, int z) { - int xc = (int) Math.round(cos * (getWidth() / 2) - sin * (getHeight() / 2)); - int yc = (int) Math.round(sin * (getWidth() / 2) + cos * (getHeight() / 2)); + int xc = (int) Math.round(cos * (getWidth() / 2f) - sin * (getHeight() / 2f)); + int yc = (int) Math.round(sin * (getWidth() / 2f) + cos * (getHeight() / 2f)); return src.getIfExists((int) Math.round(cos * (x - xc) - sin * (y - yc)) - xc, (int) Math.round(sin * (x - xc) + cos * (y - yc)) - yc , z); diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/view/SynchronizedHunkView.java b/src/main/java/com/volmit/iris/scaffold/hunk/view/SynchronizedHunkView.java index 3b1a05698..ae989a33a 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/view/SynchronizedHunkView.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/view/SynchronizedHunkView.java @@ -20,6 +20,7 @@ package com.volmit.iris.scaffold.hunk.view; import com.volmit.iris.scaffold.hunk.Hunk; +@SuppressWarnings("ClassCanBeRecord") public class SynchronizedHunkView implements Hunk { private final Hunk src; diff --git a/src/main/java/com/volmit/iris/scaffold/hunk/view/WriteTrackHunk.java b/src/main/java/com/volmit/iris/scaffold/hunk/view/WriteTrackHunk.java index caedca978..3f990738b 100644 --- a/src/main/java/com/volmit/iris/scaffold/hunk/view/WriteTrackHunk.java +++ b/src/main/java/com/volmit/iris/scaffold/hunk/view/WriteTrackHunk.java @@ -22,6 +22,7 @@ import com.volmit.iris.scaffold.hunk.Hunk; import java.util.concurrent.atomic.AtomicBoolean; +@SuppressWarnings("ClassCanBeRecord") public class WriteTrackHunk implements Hunk { private final Hunk src; private final AtomicBoolean b; diff --git a/src/main/java/com/volmit/iris/scaffold/jigsaw/PlannedPiece.java b/src/main/java/com/volmit/iris/scaffold/jigsaw/PlannedPiece.java index 5da8773a8..a1931a6b9 100644 --- a/src/main/java/com/volmit/iris/scaffold/jigsaw/PlannedPiece.java +++ b/src/main/java/com/volmit/iris/scaffold/jigsaw/PlannedPiece.java @@ -35,6 +35,7 @@ import org.bukkit.block.data.BlockData; import org.bukkit.inventory.InventoryHolder; import org.bukkit.util.BlockVector; +@SuppressWarnings("ALL") @Data public class PlannedPiece { private IrisPosition position; diff --git a/src/main/java/com/volmit/iris/scaffold/lighting/FlatRegionInfo.java b/src/main/java/com/volmit/iris/scaffold/lighting/FlatRegionInfo.java index 1775a099f..d184eb076 100644 --- a/src/main/java/com/volmit/iris/scaffold/lighting/FlatRegionInfo.java +++ b/src/main/java/com/volmit/iris/scaffold/lighting/FlatRegionInfo.java @@ -150,7 +150,6 @@ public class FlatRegionInfo { * Adds another Region Y-coordinate to the list. * The set of chunks and other properties are copied. * - * @param ry * @return new flat region info object with updated ry */ public FlatRegionInfo addRegionYCoordinate(int ry) { diff --git a/src/main/java/com/volmit/iris/scaffold/lighting/FlatRegionInfoMap.java b/src/main/java/com/volmit/iris/scaffold/lighting/FlatRegionInfoMap.java index ba64a8b67..b676594dd 100644 --- a/src/main/java/com/volmit/iris/scaffold/lighting/FlatRegionInfoMap.java +++ b/src/main/java/com/volmit/iris/scaffold/lighting/FlatRegionInfoMap.java @@ -64,8 +64,6 @@ public class FlatRegionInfoMap { /** * Gets whether a chunk exists * - * @param cx - * @param cz * @return True if the chunk exists */ public boolean containsChunk(int cx, int cz) { @@ -76,8 +74,6 @@ public class FlatRegionInfoMap { /** * Gets whether a chunk, and all its 8 neighbours, exist * - * @param cx - * @param cz * @return True if the chunk and all its neighbours exist */ public boolean containsChunkAndNeighbours(int cx, int cz) { @@ -107,7 +103,6 @@ public class FlatRegionInfoMap { * Computes all the region Y-coordinates used by a region and its neighbouring 8 regions. * The returned array is sorted in increasing order and is distinct (no duplicate values). * - * @param region * @return region and neighbouring regions' Y-coordinates */ public int[] getRegionYCoordinatesSelfAndNeighbours(FlatRegionInfo region) { @@ -134,11 +129,10 @@ public class FlatRegionInfoMap { * Creates a region information mapping of all existing chunks of a world * that are currently loaded. No further loading is required. * - * @param world * @return region info map */ public static FlatRegionInfoMap createLoaded(World world) { - LongHashMap regions = new LongHashMap(); + LongHashMap regions = new LongHashMap<>(); for (Chunk chunk : world.getLoadedChunks()) { int rx = WorldUtil.chunkToRegionIndex(chunk.getX()); int rz = WorldUtil.chunkToRegionIndex(chunk.getZ()); @@ -151,7 +145,7 @@ public class FlatRegionInfoMap { // Refresh y-coordinates for (Integer y_coord : WorldUtil.getLoadedSectionCoordinates(chunk)) { - new_info = new_info.addRegionYCoordinate(WorldUtil.chunkToRegionIndex(y_coord.intValue())); + new_info = new_info.addRegionYCoordinate(WorldUtil.chunkToRegionIndex(y_coord)); } // Add chunk to region bitset @@ -169,11 +163,10 @@ public class FlatRegionInfoMap { /** * Creates a region information mapping of all existing chunks of a world * - * @param world * @return region info map */ public static FlatRegionInfoMap create(World world) { - LongHashMap regions = new LongHashMap(); + LongHashMap regions = new LongHashMap<>(); // Obtain the region coordinates in 3d space (vertical too!) Set regionCoordinates = WorldUtil.getWorldRegions3(world); diff --git a/src/main/java/com/volmit/iris/scaffold/lighting/LightingAutoClean.java b/src/main/java/com/volmit/iris/scaffold/lighting/LightingAutoClean.java index ae9cebb68..18a9e4693 100644 --- a/src/main/java/com/volmit/iris/scaffold/lighting/LightingAutoClean.java +++ b/src/main/java/com/volmit/iris/scaffold/lighting/LightingAutoClean.java @@ -30,7 +30,7 @@ import java.util.HashMap; * Handles the automatic cleanup of chunk lighting when chunks are generated */ public class LightingAutoClean { - private static final HashMap queues = new HashMap(); + private static final HashMap queues = new HashMap<>(); private static Task autoCleanTask = null; /** diff --git a/src/main/java/com/volmit/iris/scaffold/lighting/LightingCategory.java b/src/main/java/com/volmit/iris/scaffold/lighting/LightingCategory.java index 8a9518126..732c11e93 100644 --- a/src/main/java/com/volmit/iris/scaffold/lighting/LightingCategory.java +++ b/src/main/java/com/volmit/iris/scaffold/lighting/LightingCategory.java @@ -167,16 +167,12 @@ public enum LightingCategory { /** * Initializes the lighting in the chunk for this category * - * @param chunk */ public abstract void initialize(LightingChunk chunk); /** * Gets the y-coordinate to start processing from when spreading light around * - * @param chunk - * @param x - * @param z * @return start y-coordinate */ public abstract int getStartY(LightingChunk chunk, int x, int z); @@ -185,8 +181,6 @@ public enum LightingCategory { * Sets whether this category of light is dirty, indicating this category of light is all good, * or that more work is needed spreading light around. * - * @param chunk - * @param dirty */ public abstract void setDirty(LightingChunk chunk, boolean dirty); @@ -194,10 +188,6 @@ public enum LightingCategory { * Gets the light level in a section at the coordinates specified. * No bounds checking is performed. * - * @param section - * @param x - * @param y - * @param z * @return light level */ public abstract int get(LightingCube section, int x, int y, int z); @@ -206,11 +196,6 @@ public enum LightingCategory { * Sets the light level in a section at the coordinates specified. * No bounds checking is performed. * - * @param section - * @param x - * @param y - * @param z - * @param level */ public abstract void set(LightingCube section, int x, int y, int z, int level); } \ No newline at end of file diff --git a/src/main/java/com/volmit/iris/scaffold/lighting/LightingChunk.java b/src/main/java/com/volmit/iris/scaffold/lighting/LightingChunk.java index d6fc9a6e4..7b0996953 100644 --- a/src/main/java/com/volmit/iris/scaffold/lighting/LightingChunk.java +++ b/src/main/java/com/volmit/iris/scaffold/lighting/LightingChunk.java @@ -34,6 +34,7 @@ import org.bukkit.World; import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.Objects; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -157,7 +158,7 @@ public class LightingChunk { .map(WorldUtil::regionToChunkIndex) .flatMap(base_cy -> IntStream.range(base_cy, base_cy + WorldUtil.CHUNKS_PER_REGION_AXIS)) .mapToObj(cy -> WorldUtil.getSection(chunk, cy)) - .filter(section -> section != null) + .filter(Objects::nonNull) .collect(Collectors.toList()); // Then process all the gathered chunk sections into a LightingChunkSection in parallel @@ -168,7 +169,7 @@ public class LightingChunk { } // Add to mapping - this.sections = new IntHashMap(); + this.sections = new IntHashMap<>(); for (LightingCube lightingChunkSection : lightingChunkSectionList) { this.sections.put(lightingChunkSection.cy, lightingChunkSection); } @@ -397,11 +398,10 @@ public class LightingChunk { } else if (++loops > 100) { lasterrx += this.chunkX << 4; lasterrz += this.chunkZ << 4; - StringBuilder msg = new StringBuilder(); - msg.append("Failed to fix all " + category.getName() + " lighting at ["); - msg.append(lasterrx).append('/').append(lasterry); - msg.append('/').append(lasterrz).append(']'); - Iris.warn(msg.toString()); + String msg = "Failed to fix all " + category.getName() + " lighting at [" + + lasterrx + '/' + lasterry + + '/' + lasterrz + ']'; + Iris.warn(msg); break; } } @@ -457,7 +457,7 @@ public class LightingChunk { try { for (CompletableFuture future : futures) { - if (future.get().booleanValue()) { + if (future.get()) { ChunkHandle.fromBukkit(chunk).markDirty(); return Boolean.TRUE; } diff --git a/src/main/java/com/volmit/iris/scaffold/lighting/LightingChunkNeighboring.java b/src/main/java/com/volmit/iris/scaffold/lighting/LightingChunkNeighboring.java index 694f0dca2..04b7374fa 100644 --- a/src/main/java/com/volmit/iris/scaffold/lighting/LightingChunkNeighboring.java +++ b/src/main/java/com/volmit/iris/scaffold/lighting/LightingChunkNeighboring.java @@ -57,8 +57,6 @@ public class LightingChunkNeighboring { /** * Gets the neighbor representing the given relative chunk * - * @param deltaChunkX - * @param deltaChunkZ * @return neighbor */ public LightingChunk get(int deltaChunkX, int deltaChunkZ) { @@ -68,8 +66,6 @@ public class LightingChunkNeighboring { /** * Gets a relative neighboring chunk, and then a vertical cube in that chunk, if possible. * - * @param deltaChunkX - * @param deltaChunkZ * @param cy Cube absolute y-coordinate * @return cube, null if the chunk or cube is not available */ @@ -81,8 +77,6 @@ public class LightingChunkNeighboring { /** * Sets the neighbor representing the given relative chunk * - * @param deltaChunkX - * @param deltaChunkZ * @param neighbor to set to */ public void set(int deltaChunkX, int deltaChunkZ, LightingChunk neighbor) { diff --git a/src/main/java/com/volmit/iris/scaffold/lighting/LightingCube.java b/src/main/java/com/volmit/iris/scaffold/lighting/LightingCube.java index d01ee0ab9..fea892a60 100644 --- a/src/main/java/com/volmit/iris/scaffold/lighting/LightingCube.java +++ b/src/main/java/com/volmit/iris/scaffold/lighting/LightingCube.java @@ -135,9 +135,6 @@ public class LightingCube { * higher light value if all these tests pass. * The x/y/z coordinates are allowed to check neighboring cubes. * - * @param category - * @param old_light - * @param faceMask * @param x The X-coordinate of the block (-1 to 16) * @param y The Y-coordinate of the block (-1 to 16) * @param z The Z-coordinate of the block (-1 to 16) @@ -308,7 +305,7 @@ public class LightingCube { } } } catch (Throwable t) { - CompletableFuture exceptionally = new CompletableFuture(); + CompletableFuture exceptionally = new CompletableFuture<>(); exceptionally.completeExceptionally(t); return exceptionally; } diff --git a/src/main/java/com/volmit/iris/scaffold/lighting/LightingCubeNeighboring.java b/src/main/java/com/volmit/iris/scaffold/lighting/LightingCubeNeighboring.java index d31ffe55e..9f5809801 100644 --- a/src/main/java/com/volmit/iris/scaffold/lighting/LightingCubeNeighboring.java +++ b/src/main/java/com/volmit/iris/scaffold/lighting/LightingCubeNeighboring.java @@ -59,9 +59,6 @@ public class LightingCubeNeighboring { /** * Gets the neighbor representing the given relative cube * - * @param deltaCubeX - * @param deltaCubeY - * @param deltaCubeZ * @return neighbor, null if no neighbor is available here */ public LightingCube get(int deltaCubeX, int deltaCubeY, int deltaCubeZ) { @@ -71,9 +68,6 @@ public class LightingCubeNeighboring { /** * Sets the neighbor representing the given relative cube * - * @param deltaCubeX - * @param deltaCubeY - * @param deltaCubeZ * @param neighbor to set to, is allowed to be null to set to 'none' */ public void set(int deltaCubeX, int deltaCubeY, int deltaCubeZ, LightingCube neighbor) { diff --git a/src/main/java/com/volmit/iris/scaffold/lighting/LightingForcedChunkCache.java b/src/main/java/com/volmit/iris/scaffold/lighting/LightingForcedChunkCache.java index c333b25e3..d3866b252 100644 --- a/src/main/java/com/volmit/iris/scaffold/lighting/LightingForcedChunkCache.java +++ b/src/main/java/com/volmit/iris/scaffold/lighting/LightingForcedChunkCache.java @@ -30,7 +30,7 @@ import java.util.Map; * Reduces chunk unloading-loading grind. */ public class LightingForcedChunkCache { - private static final Map _cache = new HashMap(); + private static final Map _cache = new HashMap<>(); public static ForcedChunk get(World world, int x, int z) { ForcedChunk cached; @@ -63,6 +63,7 @@ public class LightingForcedChunkCache { } } + @SuppressWarnings("ClassCanBeRecord") private static final class Key { public final World world; public final int x; @@ -81,8 +82,7 @@ public class LightingForcedChunkCache { @Override public boolean equals(Object o) { - if (o instanceof Key) { - Key other = (Key) o; + if (o instanceof Key other) { return other.x == this.x && other.z == this.z && other.world == this.world; diff --git a/src/main/java/com/volmit/iris/scaffold/lighting/LightingService.java b/src/main/java/com/volmit/iris/scaffold/lighting/LightingService.java index c0ba9bfe9..94855868c 100644 --- a/src/main/java/com/volmit/iris/scaffold/lighting/LightingService.java +++ b/src/main/java/com/volmit/iris/scaffold/lighting/LightingService.java @@ -36,6 +36,7 @@ import org.bukkit.entity.Player; import java.util.*; +@SuppressWarnings("ALL") public class LightingService extends AsyncTask { private static final Set recipientsForDone = new HashSet(); private static final LinkedList tasks = new LinkedList(); diff --git a/src/main/java/com/volmit/iris/scaffold/lighting/LightingTaskBatch.java b/src/main/java/com/volmit/iris/scaffold/lighting/LightingTaskBatch.java index 86448ec4c..597cd7e42 100644 --- a/src/main/java/com/volmit/iris/scaffold/lighting/LightingTaskBatch.java +++ b/src/main/java/com/volmit/iris/scaffold/lighting/LightingTaskBatch.java @@ -29,6 +29,7 @@ import org.bukkit.Chunk; import org.bukkit.World; import java.util.Arrays; +import java.util.Comparator; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -75,13 +76,7 @@ public class LightingTaskBatch implements LightingTask { } // Sort the array along the axis. This makes chunk loading more efficient. - Arrays.sort(coordinates, (a, b) -> { - int comp = Integer.compare(a.x, b.x); - if (comp == 0) { - comp = Integer.compare(a.z, b.z); - } - return comp; - }); + Arrays.sort(coordinates, Comparator.comparingInt((IntVector2 a) -> a.x).thenComparingInt(a -> a.z)); // Turn back into a long[] array for memory efficiency this.chunks_coords = Stream.of(coordinates).mapToLong(c -> MathUtil.longHashToLong(c.x, c.z)).toArray(); @@ -108,7 +103,8 @@ public class LightingTaskBatch implements LightingTask { coords[i] = MathUtil.longHashToLong(chunks[i].chunkX, chunks[i].chunkZ); } return coords; - } else if (this.chunks_coords != null) { + } else //noinspection ReplaceNullCheck + if (this.chunks_coords != null) { return this.chunks_coords; } else { return new long[0]; @@ -148,6 +144,7 @@ public class LightingTaskBatch implements LightingTask { return this.timeStarted; } + @SuppressWarnings("ClassCanBeRecord") private static final class BatchChunkInfo { public final int cx; public final int cz; @@ -235,6 +232,7 @@ public class LightingTaskBatch implements LightingTask { } } + @SuppressWarnings("BooleanMethodIsAlwaysInverted") private boolean waitForCheckAborted(CompletableFuture future) { while (!aborted) { try { @@ -310,7 +308,7 @@ public class LightingTaskBatch implements LightingTask { chunkFutures = new CompletableFuture[this.chunks.length]; } for (int i = 0; i < chunkFutures.length; i++) { - chunkFutures[i] = new CompletableFuture(); + chunkFutures[i] = new CompletableFuture<>(); } // Start loading up to [asyncLoadConcurrency] number of chunks right now @@ -496,7 +494,7 @@ public class LightingTaskBatch implements LightingTask { applyFutures[i] = lc.saveToChunk(bchunk).whenComplete((changed, t) -> { if (t != null) { t.printStackTrace(); - } else if (changed.booleanValue()) { + } else if (changed) { WorldUtil.queueChunkSendLight(world, lc.chunkX, lc.chunkZ); } diff --git a/src/main/java/com/volmit/iris/scaffold/lighting/LightingTaskWorld.java b/src/main/java/com/volmit/iris/scaffold/lighting/LightingTaskWorld.java index 0cd7f9aec..ce5133f4e 100644 --- a/src/main/java/com/volmit/iris/scaffold/lighting/LightingTaskWorld.java +++ b/src/main/java/com/volmit/iris/scaffold/lighting/LightingTaskWorld.java @@ -67,12 +67,13 @@ public class LightingTaskWorld implements LightingTask { } } + @SuppressWarnings("NonAtomicOperationOnVolatileField") @Override public void process() { // Load regions on the main thread // TODO: Can use main thread executor instead this.timeStarted = System.currentTimeMillis(); - final CompletableFuture regionsLoadedFuture = new CompletableFuture(); + final CompletableFuture regionsLoadedFuture = new CompletableFuture<>(); CommonUtil.nextTick(() -> { try { if (this.options.getLoadedChunksOnly()) { diff --git a/src/main/java/com/volmit/iris/scaffold/lighting/TimeDurationFormat.java b/src/main/java/com/volmit/iris/scaffold/lighting/TimeDurationFormat.java index 3a5398af9..925e0da50 100644 --- a/src/main/java/com/volmit/iris/scaffold/lighting/TimeDurationFormat.java +++ b/src/main/java/com/volmit/iris/scaffold/lighting/TimeDurationFormat.java @@ -38,7 +38,6 @@ public class TimeDurationFormat { * Creates a new time duration format. The format accepts the same formatting * tokens as the Date formatter does. * - * @param format * @throws IllegalArgumentException if the input format is invalid */ public TimeDurationFormat(String format) { @@ -53,7 +52,6 @@ public class TimeDurationFormat { /** * Formats the duration * - * @param durationMillis * @return formatted string */ public String format(long durationMillis) { diff --git a/src/main/java/com/volmit/iris/scaffold/parallax/ParallaxChunkMeta.java b/src/main/java/com/volmit/iris/scaffold/parallax/ParallaxChunkMeta.java index 9c4caea4d..3377362cc 100644 --- a/src/main/java/com/volmit/iris/scaffold/parallax/ParallaxChunkMeta.java +++ b/src/main/java/com/volmit/iris/scaffold/parallax/ParallaxChunkMeta.java @@ -35,7 +35,7 @@ import java.util.function.Function; @AllArgsConstructor @Data public class ParallaxChunkMeta { - public static final Function> adapter = (c) -> new PaletteHunkIOAdapter() { + public static final Function> adapter = (c) -> new PaletteHunkIOAdapter<>() { @Override public void write(ParallaxChunkMeta parallaxChunkMeta, DataOutputStream dos) throws IOException { dos.writeUTF(new Gson().toJson(parallaxChunkMeta)); diff --git a/src/main/java/com/volmit/iris/scaffold/parallax/ParallaxWorld.java b/src/main/java/com/volmit/iris/scaffold/parallax/ParallaxWorld.java index a82a63a8f..128206d35 100644 --- a/src/main/java/com/volmit/iris/scaffold/parallax/ParallaxWorld.java +++ b/src/main/java/com/volmit/iris/scaffold/parallax/ParallaxWorld.java @@ -30,6 +30,7 @@ import org.bukkit.block.data.BlockData; import java.io.File; import java.io.IOException; +@SuppressWarnings("ALL") public class ParallaxWorld implements ParallaxAccess { private final KMap loadedRegions; private final KList save; diff --git a/src/main/java/com/volmit/iris/scaffold/parallel/BurstExecutor.java b/src/main/java/com/volmit/iris/scaffold/parallel/BurstExecutor.java index 3eb0b8968..7151132f7 100644 --- a/src/main/java/com/volmit/iris/scaffold/parallel/BurstExecutor.java +++ b/src/main/java/com/volmit/iris/scaffold/parallel/BurstExecutor.java @@ -24,6 +24,7 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; +@SuppressWarnings("ALL") public class BurstExecutor { private final ExecutorService executor; private final KList> futures; @@ -33,6 +34,7 @@ public class BurstExecutor { futures = new KList>(burstSizeEstimate); } + @SuppressWarnings("UnusedReturnValue") public CompletableFuture queue(Runnable r) { synchronized (futures) { CompletableFuture c = CompletableFuture.runAsync(r, executor); @@ -70,7 +72,7 @@ public class BurstExecutor { } try { - CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()])).get(); + CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).get(); futures.clear(); } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); diff --git a/src/main/java/com/volmit/iris/scaffold/parallel/MultiBurst.java b/src/main/java/com/volmit/iris/scaffold/parallel/MultiBurst.java index 3449d8e84..0cdf56631 100644 --- a/src/main/java/com/volmit/iris/scaffold/parallel/MultiBurst.java +++ b/src/main/java/com/volmit/iris/scaffold/parallel/MultiBurst.java @@ -23,30 +23,26 @@ import com.volmit.iris.util.KList; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; public class MultiBurst { - public static MultiBurst burst = new MultiBurst(Runtime.getRuntime().availableProcessors()); + public static final MultiBurst burst = new MultiBurst(Runtime.getRuntime().availableProcessors()); private final ExecutorService service; private ExecutorService syncService; private int tid; public MultiBurst(int tc) { - service = Executors.newFixedThreadPool(tc, new ThreadFactory() { - @Override - public Thread newThread(Runnable r) { - tid++; - Thread t = new Thread(r); - t.setName("Iris Generator " + tid); - t.setPriority(6); - t.setUncaughtExceptionHandler((et, e) -> - { - Iris.info("Exception encountered in " + et.getName()); - e.printStackTrace(); - }); + service = Executors.newFixedThreadPool(tc, r -> { + tid++; + Thread t = new Thread(r); + t.setName("Iris Generator " + tid); + t.setPriority(6); + t.setUncaughtExceptionHandler((et, e) -> + { + Iris.info("Exception encountered in " + et.getName()); + e.printStackTrace(); + }); - return t; - } + return t; }); } diff --git a/src/main/java/com/volmit/iris/scaffold/stream/ProceduralStream.java b/src/main/java/com/volmit/iris/scaffold/stream/ProceduralStream.java index 9d3592ee6..4522956ff 100644 --- a/src/main/java/com/volmit/iris/scaffold/stream/ProceduralStream.java +++ b/src/main/java/com/volmit/iris/scaffold/stream/ProceduralStream.java @@ -30,6 +30,7 @@ import com.volmit.iris.util.*; import java.util.List; import java.util.function.Function; +@SuppressWarnings("ALL") public interface ProceduralStream extends ProceduralLayer, Interpolated { static ProceduralStream ofDouble(Function2 f) { try { diff --git a/src/main/java/com/volmit/iris/scaffold/stream/convert/ForceDoubleStream.java b/src/main/java/com/volmit/iris/scaffold/stream/convert/ForceDoubleStream.java index 0dc751b2f..5fb56893e 100644 --- a/src/main/java/com/volmit/iris/scaffold/stream/convert/ForceDoubleStream.java +++ b/src/main/java/com/volmit/iris/scaffold/stream/convert/ForceDoubleStream.java @@ -33,7 +33,6 @@ public class ForceDoubleStream extends BasicStream { return t; } - @SuppressWarnings("unchecked") @Override public Double fromDouble(double d) { return d; diff --git a/src/main/java/com/volmit/iris/scaffold/stream/convert/SignificanceStream.java b/src/main/java/com/volmit/iris/scaffold/stream/convert/SignificanceStream.java index cb1ad6401..92d5e761b 100644 --- a/src/main/java/com/volmit/iris/scaffold/stream/convert/SignificanceStream.java +++ b/src/main/java/com/volmit/iris/scaffold/stream/convert/SignificanceStream.java @@ -50,9 +50,9 @@ public class SignificanceStream, T> extends BasicStrea @Override public K get(double x, double z) { KList ke = new KList<>(8); - KList va = new KList(8); + KList va = new KList<>(8); - double m = (360 / checks); + double m = (360d / checks); double v = 0; for (int i = 0; i < 360; i += m) { @@ -75,7 +75,7 @@ public class SignificanceStream, T> extends BasicStrea va.set(i, va.get(i) / v); } - return (K) new ArraySignificance(ke, va); + return (K) new ArraySignificance<>(ke, va); } @Override diff --git a/src/main/java/com/volmit/iris/scaffold/stream/interpolation/Interpolated.java b/src/main/java/com/volmit/iris/scaffold/stream/interpolation/Interpolated.java index 606cc1805..621d46ee9 100644 --- a/src/main/java/com/volmit/iris/scaffold/stream/interpolation/Interpolated.java +++ b/src/main/java/com/volmit/iris/scaffold/stream/interpolation/Interpolated.java @@ -40,14 +40,14 @@ public interface Interpolated { default InterpolatorFactory interpolate() { if (this instanceof ProceduralStream) { - return new InterpolatorFactory((ProceduralStream) this); + return new InterpolatorFactory<>((ProceduralStream) this); } return null; } static Interpolated of(Function a, Function b) { - return new Interpolated() { + return new Interpolated<>() { @Override public double toDouble(T t) { return a.apply(t); diff --git a/src/main/java/com/volmit/iris/scaffold/stream/interpolation/Interpolator.java b/src/main/java/com/volmit/iris/scaffold/stream/interpolation/Interpolator.java index 7a6940fcc..b42e96d9b 100644 --- a/src/main/java/com/volmit/iris/scaffold/stream/interpolation/Interpolator.java +++ b/src/main/java/com/volmit/iris/scaffold/stream/interpolation/Interpolator.java @@ -24,7 +24,7 @@ public interface Interpolator { @SuppressWarnings("unchecked") default InterpolatorFactory into() { if (this instanceof ProceduralStream) { - return new InterpolatorFactory((ProceduralStream) this); + return new InterpolatorFactory<>((ProceduralStream) this); } return null; diff --git a/src/main/java/com/volmit/iris/scaffold/stream/interpolation/InterpolatorFactory.java b/src/main/java/com/volmit/iris/scaffold/stream/interpolation/InterpolatorFactory.java index 1a16abf2e..b1c9e5cfd 100644 --- a/src/main/java/com/volmit/iris/scaffold/stream/interpolation/InterpolatorFactory.java +++ b/src/main/java/com/volmit/iris/scaffold/stream/interpolation/InterpolatorFactory.java @@ -21,6 +21,7 @@ package com.volmit.iris.scaffold.stream.interpolation; import com.volmit.iris.object.InterpolationMethod; import com.volmit.iris.scaffold.stream.ProceduralStream; +@SuppressWarnings("ClassCanBeRecord") public class InterpolatorFactory { private final ProceduralStream stream; @@ -29,7 +30,7 @@ public class InterpolatorFactory { } public InterpolatingStream with(InterpolationMethod t, int rx) { - return new InterpolatingStream(stream, rx, t); + return new InterpolatingStream<>(stream, rx, t); } public TrilinearStream trilinear(int rx, int ry, int rz) { diff --git a/src/main/java/com/volmit/iris/scaffold/stream/utility/ProfiledStream.java b/src/main/java/com/volmit/iris/scaffold/stream/utility/ProfiledStream.java index 71e6800d7..6a235035a 100644 --- a/src/main/java/com/volmit/iris/scaffold/stream/utility/ProfiledStream.java +++ b/src/main/java/com/volmit/iris/scaffold/stream/utility/ProfiledStream.java @@ -60,7 +60,7 @@ public class ProfiledStream extends BasicStream { T t = getTypedSource().get(x, z); try { metrics.put(p.getMilliseconds()); - } catch (Throwable e) { + } catch (Throwable ignored) { } return t; @@ -72,7 +72,7 @@ public class ProfiledStream extends BasicStream { T t = getTypedSource().get(x, y, z); try { metrics.put(p.getMilliseconds()); - } catch (Throwable e) { + } catch (Throwable ignored) { } return t; @@ -113,8 +113,7 @@ public class ProfiledStream extends BasicStream { } private static ProfiledTail getTail(ProceduralStream t) { - if (t instanceof ProfiledStream) { - ProfiledStream s = ((ProfiledStream) t); + if (t instanceof ProfiledStream s) { return new ProfiledTail(s.getId(), s.getMetrics(), s.getClass().getSimpleName().replaceAll("\\QStream\\E", "")); } diff --git a/src/main/java/com/volmit/iris/util/AtomicAverage.java b/src/main/java/com/volmit/iris/util/AtomicAverage.java index 0ab9a28fb..009e84c19 100644 --- a/src/main/java/com/volmit/iris/util/AtomicAverage.java +++ b/src/main/java/com/volmit/iris/util/AtomicAverage.java @@ -28,7 +28,7 @@ import com.google.common.util.concurrent.AtomicDoubleArray; * @author cyberpwn */ public class AtomicAverage { - protected AtomicDoubleArray values; + protected final AtomicDoubleArray values; private double average; private double lastSum; private boolean dirty; @@ -71,7 +71,7 @@ public class AtomicAverage { lastSum = (lastSum - current) + i; values.set(cursor, i); cursor = cursor + 1 < size() ? cursor + 1 : 0; - } catch (Throwable e) { + } catch (Throwable ignored) { } } diff --git a/src/main/java/com/volmit/iris/util/Average.java b/src/main/java/com/volmit/iris/util/Average.java index afbb9b2ae..e0ccd95b9 100644 --- a/src/main/java/com/volmit/iris/util/Average.java +++ b/src/main/java/com/volmit/iris/util/Average.java @@ -26,7 +26,7 @@ package com.volmit.iris.util; * @author cyberpwn */ public class Average { - protected double[] values; + protected final double[] values; private double average; private double lastSum; private boolean dirty; diff --git a/src/main/java/com/volmit/iris/util/B.java b/src/main/java/com/volmit/iris/util/B.java index 84286a802..bfae2e51e 100644 --- a/src/main/java/com/volmit/iris/util/B.java +++ b/src/main/java/com/volmit/iris/util/B.java @@ -140,7 +140,7 @@ public class B { BlockData bx = Bukkit.createBlockData(ix); blockDataCache.put(ix, bx); return bx; - } catch (Throwable e) { + } catch (Throwable ignored) { } @@ -151,7 +151,7 @@ public class B { try { BlockData bd = Material.valueOf(i).createBlockData(); blockDataCache.put(ix, bd); - } catch (Throwable e) { + } catch (Throwable ignored) { } @@ -485,7 +485,7 @@ public class B { public static String[] getBlockTypes() { - KList bt = new KList(); + KList bt = new KList<>(); for (Material i : Material.values()) { if (i.isBlock()) { @@ -503,17 +503,17 @@ public class B { } } - return bt.toArray(new String[bt.size()]); + return bt.toArray(new String[0]); } public static String[] getItemTypes() { - KList bt = new KList(); + KList bt = new KList<>(); for (Material i : Material.values()) { String v = i.name().toLowerCase().trim(); bt.add(v); } - return bt.toArray(new String[bt.size()]); + return bt.toArray(new String[0]); } } diff --git a/src/main/java/com/volmit/iris/util/BlockPosition.java b/src/main/java/com/volmit/iris/util/BlockPosition.java index 3efd38acf..1a29c8b0d 100644 --- a/src/main/java/com/volmit/iris/util/BlockPosition.java +++ b/src/main/java/com/volmit/iris/util/BlockPosition.java @@ -53,8 +53,7 @@ public class BlockPosition { return false; } - if (o instanceof BlockPosition) { - BlockPosition ot = (BlockPosition) o; + if (o instanceof BlockPosition ot) { return ot.x == x && ot.y == y && ot.z == z; } @@ -85,7 +84,7 @@ public class BlockPosition { public static long toLong(int x, int y, int z) { long var3 = 0L; var3 |= (x & m4) << m3; - var3 |= (y & m5) << 0L; + var3 |= (y & m5); var3 |= (z & m6) << m2; return var3; } diff --git a/src/main/java/com/volmit/iris/util/Board.java b/src/main/java/com/volmit/iris/util/Board.java index ab85ac6ff..14f9b94b4 100644 --- a/src/main/java/com/volmit/iris/util/Board.java +++ b/src/main/java/com/volmit/iris/util/Board.java @@ -127,12 +127,8 @@ public class Board { team.setSuffix(entry.getSuffix()); switch (boardSettings.getScoreDirection()) { - case UP: - objective.getScore(team.getName()).setScore(1 + i); - break; - case DOWN: - objective.getScore(team.getName()).setScore(15 - i); - break; + case UP -> objective.getScore(team.getName()).setScore(1 + i); + case DOWN -> objective.getScore(team.getName()).setScore(15 - i); } } } diff --git a/src/main/java/com/volmit/iris/util/BoardEntry.java b/src/main/java/com/volmit/iris/util/BoardEntry.java index ad03783b0..c19000269 100644 --- a/src/main/java/com/volmit/iris/util/BoardEntry.java +++ b/src/main/java/com/volmit/iris/util/BoardEntry.java @@ -25,6 +25,7 @@ import org.apache.commons.lang.StringUtils; * @author Missionary (missionarymc@gmail.com) * @since 3/29/2018 */ +@SuppressWarnings("ClassCanBeRecord") public class BoardEntry { @Getter diff --git a/src/main/java/com/volmit/iris/util/BoardSettings.java b/src/main/java/com/volmit/iris/util/BoardSettings.java index 8e3c12336..ca0e0abeb 100644 --- a/src/main/java/com/volmit/iris/util/BoardSettings.java +++ b/src/main/java/com/volmit/iris/util/BoardSettings.java @@ -22,6 +22,7 @@ import lombok.Builder; import lombok.Getter; +@SuppressWarnings("ClassCanBeRecord") @Getter @Builder public class BoardSettings { diff --git a/src/main/java/com/volmit/iris/util/C.java b/src/main/java/com/volmit/iris/util/C.java index 9719b96f5..0050348a4 100644 --- a/src/main/java/com/volmit/iris/util/C.java +++ b/src/main/java/com/volmit/iris/util/C.java @@ -245,11 +245,12 @@ public enum C { private final char code; private final boolean isFormat; private final String toString; - private final static Map BY_ID = new HashMap(); - private final static Map BY_CHAR = new HashMap(); - private final static Map dyeChatMap = new HashMap(); - private final static Map chatHexMap = new HashMap(); - private final static Map dyeHexMap = new HashMap(); + @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") + private final static Map BY_ID = new HashMap<>(); + private final static Map BY_CHAR = new HashMap<>(); + private final static Map dyeChatMap = new HashMap<>(); + private final static Map chatHexMap = new HashMap<>(); + private final static Map dyeHexMap = new HashMap<>(); static { chatHexMap.put(C.BLACK, "#000"); @@ -334,7 +335,6 @@ public enum C { /** * get the dye color for the chatcolor * - * @return */ public DyeColor dye() { return chatToDye(chatColor()); @@ -424,9 +424,9 @@ public enum C { } public static DyeColor chatToDye(ChatColor color) { - for (DyeColor i : dyeChatMap.keySet()) { - if (dyeChatMap.get(i).toString().equals(color.toString())) { - return i; + for (Map.Entry entry : dyeChatMap.entrySet()) { + if (entry.getValue().toString().equals(color.toString())) { + return entry.getKey(); } } @@ -455,7 +455,7 @@ public enum C { hex = hex.substring(1); } - if (hex.indexOf("x") != -1) { + if (hex.contains("x")) { hex = hex.substring(hex.indexOf("x")); } @@ -509,7 +509,6 @@ public enum C { /** * Get the ChatColor enum instance instead of C * - * @return */ public ChatColor chatColor() { return ChatColor.getByChar(code); @@ -551,105 +550,43 @@ public enum C { } public byte getMeta() { - switch (this) { - case AQUA: - return 11; - case BLACK: - return 0; - case BLUE: - return 9; - case BOLD: - return -1; - case DARK_AQUA: - return 9; - case DARK_BLUE: - return 1; - case DARK_GRAY: - return 8; - case DARK_GREEN: - return 2; - case DARK_PURPLE: - return 5; - case DARK_RED: - return 4; - case GOLD: - return 6; - case GRAY: - return 7; - case GREEN: - return 10; - case ITALIC: - return -1; - case LIGHT_PURPLE: - return 13; - case MAGIC: - return -1; - case RED: - return 12; - case RESET: - return -1; - case STRIKETHROUGH: - return -1; - case UNDERLINE: - return -1; - case WHITE: - return 15; - case YELLOW: - return 14; - default: - return -1; - } + return switch (this) { + case AQUA -> (byte)11; + case BLACK -> (byte)0; + case BLUE, DARK_AQUA -> (byte)9; + case BOLD, UNDERLINE, STRIKETHROUGH, RESET, MAGIC, ITALIC -> (byte)-1; + case DARK_BLUE -> (byte)1; + case DARK_GRAY -> (byte)8; + case DARK_GREEN -> (byte)2; + case DARK_PURPLE -> (byte)5; + case DARK_RED -> (byte)4; + case GOLD -> (byte)6; + case GRAY -> (byte)7; + case GREEN -> (byte)10; + case LIGHT_PURPLE -> (byte)13; + case RED -> (byte)12; + case WHITE -> (byte)15; + case YELLOW -> (byte)14; + }; } public byte getItemMeta() { - switch (this) { - case AQUA: - return 9; - case BLACK: - return 15; - case BLUE: - return 3; - case BOLD: - return -1; - case DARK_AQUA: - return 9; - case DARK_BLUE: - return 11; - case DARK_GRAY: - return 7; - case DARK_GREEN: - return 13; - case DARK_PURPLE: - return 10; - case DARK_RED: - return 14; - case GOLD: - return 4; - case GRAY: - return 8; - case GREEN: - return 5; - case ITALIC: - return -1; - case LIGHT_PURPLE: - return 2; - case MAGIC: - return -1; - case RED: - return 14; - case RESET: - return -1; - case STRIKETHROUGH: - return -1; - case UNDERLINE: - return -1; - case WHITE: - return 0; - case YELLOW: - return 4; - default: - return -1; - } + return switch (this) { + case AQUA, DARK_AQUA -> (byte)9; + case BLACK -> (byte)15; + case BLUE -> (byte)3; + case BOLD, UNDERLINE, RESET, STRIKETHROUGH, MAGIC, ITALIC -> (byte)-1; + case DARK_BLUE -> (byte)11; + case DARK_GRAY -> (byte)7; + case DARK_GREEN -> (byte)13; + case DARK_PURPLE -> (byte)10; + case DARK_RED, RED -> (byte)14; + case GOLD, YELLOW -> (byte)4; + case GRAY -> (byte)8; + case GREEN -> (byte)5; + case LIGHT_PURPLE -> (byte)2; + case WHITE -> (byte)0; + }; } public static C randomColor() { @@ -663,7 +600,7 @@ public enum C { * @return Any remaining ChatColors to pass onto the next line. */ public static String getLastColors(String input) { - String result = ""; + StringBuilder result = new StringBuilder(); int length = input.length(); // Search backwards from the end as it is faster @@ -674,7 +611,7 @@ public enum C { C color = getByChar(c); if (color != null) { - result = color + result; + result.insert(0, color); // Once we find a color or reset we can stop searching if (color.isColor() || color.equals(RESET)) { @@ -684,7 +621,7 @@ public enum C { } } - return result; + return result.toString(); } static { diff --git a/src/main/java/com/volmit/iris/util/CDou.java b/src/main/java/com/volmit/iris/util/CDou.java index 409337983..53ca67f80 100644 --- a/src/main/java/com/volmit/iris/util/CDou.java +++ b/src/main/java/com/volmit/iris/util/CDou.java @@ -18,6 +18,7 @@ package com.volmit.iris.util; +@SuppressWarnings("ALL") public class CDou { private double number; private final double max; diff --git a/src/main/java/com/volmit/iris/util/CarveResult.java b/src/main/java/com/volmit/iris/util/CarveResult.java index a8597719b..bcadddeef 100644 --- a/src/main/java/com/volmit/iris/util/CarveResult.java +++ b/src/main/java/com/volmit/iris/util/CarveResult.java @@ -20,9 +20,12 @@ package com.volmit.iris.util; import lombok.Value; +@SuppressWarnings("ClassCanBeRecord") @Value public class CarveResult { + @SuppressWarnings("RedundantModifiersValueLombok") private final int surface; + @SuppressWarnings("RedundantModifiersValueLombok") private final int ceiling; public int getHeight() { diff --git a/src/main/java/com/volmit/iris/util/ChunkPosition.java b/src/main/java/com/volmit/iris/util/ChunkPosition.java index c4f62a337..f3b4935aa 100644 --- a/src/main/java/com/volmit/iris/util/ChunkPosition.java +++ b/src/main/java/com/volmit/iris/util/ChunkPosition.java @@ -57,10 +57,9 @@ public class ChunkPosition { if (this == obj) { return true; } - if (!(obj instanceof ChunkPosition)) { + if (!(obj instanceof ChunkPosition other)) { return false; } - ChunkPosition other = (ChunkPosition) obj; return x == other.x && z == other.z; } diff --git a/src/main/java/com/volmit/iris/util/Chunker.java b/src/main/java/com/volmit/iris/util/Chunker.java index e12f1d506..e2007fde5 100644 --- a/src/main/java/com/volmit/iris/util/Chunker.java +++ b/src/main/java/com/volmit/iris/util/Chunker.java @@ -45,14 +45,14 @@ public class Chunker { public void execute(Consumer consumer, Callback progress, int progressInterval) { ChronoLatch cl = new ChronoLatch(progressInterval); - Contained consumed = new Contained(0); + Contained consumed = new Contained<>(0); executor = Executors.newFixedThreadPool(threads); int length = q.size(); int remaining = length; while (remaining > 0) { int at = remaining; - remaining -= (remaining > workload ? workload : remaining); + remaining -= (Math.min(remaining, workload)); int to = remaining; executor.submit(() -> diff --git a/src/main/java/com/volmit/iris/util/CompoundTag.java b/src/main/java/com/volmit/iris/util/CompoundTag.java index 4c004d920..4b5cce527 100644 --- a/src/main/java/com/volmit/iris/util/CompoundTag.java +++ b/src/main/java/com/volmit/iris/util/CompoundTag.java @@ -56,9 +56,9 @@ public final class CompoundTag extends Tag { append = "(\"" + this.getName() + "\")"; } StringBuilder bldr = new StringBuilder(); - bldr.append("TAG_Compound" + append + ": " + value.size() + " entries\r\n{\r\n"); + bldr.append("TAG_Compound").append(append).append(": ").append(value.size()).append(" entries\r\n{\r\n"); for (Map.Entry entry : value.entrySet()) { - bldr.append(" " + entry.getValue().toString().replaceAll("\r\n", "\r\n ") + "\r\n"); + bldr.append(" ").append(entry.getValue().toString().replaceAll("\r\n", "\r\n ")).append("\r\n"); } bldr.append("}"); return bldr.toString(); diff --git a/src/main/java/com/volmit/iris/util/Consumer2.java b/src/main/java/com/volmit/iris/util/Consumer2.java index 4f89bb13e..f911d4f18 100644 --- a/src/main/java/com/volmit/iris/util/Consumer2.java +++ b/src/main/java/com/volmit/iris/util/Consumer2.java @@ -18,7 +18,7 @@ package com.volmit.iris.util; -@SuppressWarnings("hiding") +@SuppressWarnings({"hiding", "RedundantSuppression"}) @FunctionalInterface public interface Consumer2 { void accept(A a, B b); diff --git a/src/main/java/com/volmit/iris/util/Consumer3.java b/src/main/java/com/volmit/iris/util/Consumer3.java index 302ad9113..36d36021e 100644 --- a/src/main/java/com/volmit/iris/util/Consumer3.java +++ b/src/main/java/com/volmit/iris/util/Consumer3.java @@ -18,7 +18,7 @@ package com.volmit.iris.util; -@SuppressWarnings("hiding") +@SuppressWarnings("ALL") @FunctionalInterface public interface Consumer3 { void accept(A a, B b, C c); diff --git a/src/main/java/com/volmit/iris/util/Consumer4.java b/src/main/java/com/volmit/iris/util/Consumer4.java index 06e8c277d..b80c64c67 100644 --- a/src/main/java/com/volmit/iris/util/Consumer4.java +++ b/src/main/java/com/volmit/iris/util/Consumer4.java @@ -18,7 +18,6 @@ package com.volmit.iris.util; -@SuppressWarnings("hiding") @FunctionalInterface public interface Consumer4 { void accept(A a, B b, C c, D d); diff --git a/src/main/java/com/volmit/iris/util/Consumer5.java b/src/main/java/com/volmit/iris/util/Consumer5.java index c1c4f1348..fa23c0055 100644 --- a/src/main/java/com/volmit/iris/util/Consumer5.java +++ b/src/main/java/com/volmit/iris/util/Consumer5.java @@ -18,7 +18,6 @@ package com.volmit.iris.util; -@SuppressWarnings("hiding") @FunctionalInterface public interface Consumer5 { void accept(A a, B b, C c, D d, E e); diff --git a/src/main/java/com/volmit/iris/util/Consumer6.java b/src/main/java/com/volmit/iris/util/Consumer6.java index 7dd0fd499..8a75d353d 100644 --- a/src/main/java/com/volmit/iris/util/Consumer6.java +++ b/src/main/java/com/volmit/iris/util/Consumer6.java @@ -18,7 +18,6 @@ package com.volmit.iris.util; -@SuppressWarnings("hiding") @FunctionalInterface public interface Consumer6 { void accept(A a, B b, C c, D d, E e, F f); diff --git a/src/main/java/com/volmit/iris/util/Consumer7.java b/src/main/java/com/volmit/iris/util/Consumer7.java index 7b9396d19..a1f216a9f 100644 --- a/src/main/java/com/volmit/iris/util/Consumer7.java +++ b/src/main/java/com/volmit/iris/util/Consumer7.java @@ -18,7 +18,6 @@ package com.volmit.iris.util; -@SuppressWarnings("hiding") @FunctionalInterface public interface Consumer7 { void accept(A a, B b, C c, D d, E e, F f, G g); diff --git a/src/main/java/com/volmit/iris/util/Consumer8.java b/src/main/java/com/volmit/iris/util/Consumer8.java index 877a498a4..6c95faf19 100644 --- a/src/main/java/com/volmit/iris/util/Consumer8.java +++ b/src/main/java/com/volmit/iris/util/Consumer8.java @@ -18,7 +18,6 @@ package com.volmit.iris.util; -@SuppressWarnings("hiding") @FunctionalInterface public interface Consumer8 { void accept(A a, B b, C c, D d, E e, F f, G g, H h); diff --git a/src/main/java/com/volmit/iris/util/Controller.java b/src/main/java/com/volmit/iris/util/Controller.java index 533182ce0..e651b0874 100644 --- a/src/main/java/com/volmit/iris/util/Controller.java +++ b/src/main/java/com/volmit/iris/util/Controller.java @@ -29,7 +29,7 @@ public abstract class Controller implements IController { tickRate = -1; } - protected void setTickRate(int rate) { + protected void setTickRate(@SuppressWarnings("SameParameterValue") int rate) { this.tickRate = rate; } diff --git a/src/main/java/com/volmit/iris/util/Converter.java b/src/main/java/com/volmit/iris/util/Converter.java index 6db8489a6..6f0779cdd 100644 --- a/src/main/java/com/volmit/iris/util/Converter.java +++ b/src/main/java/com/volmit/iris/util/Converter.java @@ -23,6 +23,7 @@ import java.io.File; public interface Converter { String getInExtension(); + @SuppressWarnings("SameReturnValue") String getOutExtension(); void convert(File in, File out); diff --git a/src/main/java/com/volmit/iris/util/Cuboid.java b/src/main/java/com/volmit/iris/util/Cuboid.java index 6358542e0..fa9c1131e 100644 --- a/src/main/java/com/volmit/iris/util/Cuboid.java +++ b/src/main/java/com/volmit/iris/util/Cuboid.java @@ -22,6 +22,7 @@ import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.entity.Entity; +import org.jetbrains.annotations.NotNull; import java.util.*; @@ -57,7 +58,7 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ } public KList getEntities() { - KList en = new KList(); + KList en = new KList<>(); for (Chunk i : getChunks()) { for (Entity j : i.getEntities()) { @@ -155,9 +156,10 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ z2 = (Integer) map.get("z2"); } + @NotNull @Override public Map serialize() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("worldName", worldName); map.put("x1", x1); map.put("y1", y1); @@ -337,22 +339,15 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ * @return a new Cuboid expanded by the given direction and amount */ public Cuboid expand(CuboidDirection dir, int amount) { - switch (dir) { - case North: - return new Cuboid(worldName, x1 - amount, y1, z1, x2, y2, z2); - case South: - return new Cuboid(worldName, x1, y1, z1, x2 + amount, y2, z2); - case East: - return new Cuboid(worldName, x1, y1, z1 - amount, x2, y2, z2); - case West: - return new Cuboid(worldName, x1, y1, z1, x2, y2, z2 + amount); - case Down: - return new Cuboid(worldName, x1, y1 - amount, z1, x2, y2, z2); - case Up: - return new Cuboid(worldName, x1, y1, z1, x2, y2 + amount, z2); - default: - throw new IllegalArgumentException("invalid direction " + dir); - } + return switch (dir) { + case North -> new Cuboid(worldName, x1 - amount, y1, z1, x2, y2, z2); + case South -> new Cuboid(worldName, x1, y1, z1, x2 + amount, y2, z2); + case East -> new Cuboid(worldName, x1, y1, z1 - amount, x2, y2, z2); + case West -> new Cuboid(worldName, x1, y1, z1, x2, y2, z2 + amount); + case Down -> new Cuboid(worldName, x1, y1 - amount, z1, x2, y2, z2); + case Up -> new Cuboid(worldName, x1, y1, z1, x2, y2 + amount, z2); + default -> throw new IllegalArgumentException("invalid direction " + dir); + }; } public Cuboid expand(Direction dir, int amount) { @@ -385,20 +380,12 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ * @return a new Cuboid outset by the given direction and amount */ public Cuboid outset(CuboidDirection dir, int amount) { - Cuboid c; - switch (dir) { - case Horizontal: - c = expand(CuboidDirection.North, amount).expand(CuboidDirection.South, amount).expand(CuboidDirection.East, amount).expand(CuboidDirection.West, amount); - break; - case Vertical: - c = expand(CuboidDirection.Down, amount).expand(CuboidDirection.Up, amount); - break; - case Both: - c = outset(CuboidDirection.Horizontal, amount).outset(CuboidDirection.Vertical, amount); - break; - default: - throw new IllegalArgumentException("invalid direction " + dir); - } + Cuboid c = switch (dir) { + case Horizontal -> expand(CuboidDirection.North, amount).expand(CuboidDirection.South, amount).expand(CuboidDirection.East, amount).expand(CuboidDirection.West, amount); + case Vertical -> expand(CuboidDirection.Down, amount).expand(CuboidDirection.Up, amount); + case Both -> outset(CuboidDirection.Horizontal, amount).outset(CuboidDirection.Vertical, amount); + default -> throw new IllegalArgumentException("invalid direction " + dir); + }; return c; } @@ -495,38 +482,43 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ public Cuboid contract(CuboidDirection dir) { Cuboid face = getFace(dir.opposite()); switch (dir) { - case Down: + case Down -> { while (face.containsOnly(Material.AIR) && face.getLowerY() > this.getLowerY()) { face = face.shift(CuboidDirection.Down, 1); } return new Cuboid(worldName, x1, y1, z1, x2, face.getUpperY(), z2); - case Up: + } + case Up -> { while (face.containsOnly(Material.AIR) && face.getUpperY() < this.getUpperY()) { face = face.shift(CuboidDirection.Up, 1); } return new Cuboid(worldName, x1, face.getLowerY(), z1, x2, y2, z2); - case North: + } + case North -> { while (face.containsOnly(Material.AIR) && face.getLowerX() > this.getLowerX()) { face = face.shift(CuboidDirection.North, 1); } return new Cuboid(worldName, x1, y1, z1, face.getUpperX(), y2, z2); - case South: + } + case South -> { while (face.containsOnly(Material.AIR) && face.getUpperX() < this.getUpperX()) { face = face.shift(CuboidDirection.South, 1); } return new Cuboid(worldName, face.getLowerX(), y1, z1, x2, y2, z2); - case East: + } + case East -> { while (face.containsOnly(Material.AIR) && face.getLowerZ() > this.getLowerZ()) { face = face.shift(CuboidDirection.East, 1); } return new Cuboid(worldName, x1, y1, z1, x2, y2, face.getUpperZ()); - case West: + } + case West -> { while (face.containsOnly(Material.AIR) && face.getUpperZ() < this.getUpperZ()) { face = face.shift(CuboidDirection.West, 1); } return new Cuboid(worldName, x1, y1, face.getLowerZ(), x2, y2, z2); - default: - throw new IllegalArgumentException("Invalid direction " + dir); + } + default -> throw new IllegalArgumentException("Invalid direction " + dir); } } @@ -538,22 +530,15 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ * @return the Cuboid representing this Cuboid's requested face */ public Cuboid getFace(CuboidDirection dir) { - switch (dir) { - case Down: - return new Cuboid(worldName, x1, y1, z1, x2, y1, z2); - case Up: - return new Cuboid(worldName, x1, y2, z1, x2, y2, z2); - case North: - return new Cuboid(worldName, x1, y1, z1, x1, y2, z2); - case South: - return new Cuboid(worldName, x2, y1, z1, x2, y2, z2); - case East: - return new Cuboid(worldName, x1, y1, z1, x2, y2, z1); - case West: - return new Cuboid(worldName, x1, y1, z2, x2, y2, z2); - default: - throw new IllegalArgumentException("Invalid direction " + dir); - } + return switch (dir) { + case Down -> new Cuboid(worldName, x1, y1, z1, x2, y1, z2); + case Up -> new Cuboid(worldName, x1, y2, z1, x2, y2, z2); + case North -> new Cuboid(worldName, x1, y1, z1, x1, y2, z2); + case South -> new Cuboid(worldName, x2, y1, z1, x2, y2, z2); + case East -> new Cuboid(worldName, x1, y1, z1, x2, y2, z1); + case West -> new Cuboid(worldName, x1, y1, z2, x2, y2, z2); + default -> throw new IllegalArgumentException("Invalid direction " + dir); + }; } /** @@ -626,7 +611,7 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ * @return a list of Chunk objects */ public List getChunks() { - List res = new ArrayList(); + List res = new ArrayList<>(); World w = getWorld(); int x1 = getLowerX() & ~0xf; @@ -641,11 +626,11 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ return res; } - /** - * Set all the blocks within the Cuboid to the given MaterialData, using a - * MassBlockUpdate object for fast updates. - * - * @param mat + /* + Set all the blocks within the Cuboid to the given MaterialData, using a + MassBlockUpdate object for fast updates. + + @param mat * the MaterialData to set * @param mbu * the MassBlockUpdate object @@ -670,8 +655,9 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ * * @see java.lang.Object#clone() */ + @SuppressWarnings("MethodDoesntCallSuperMethod") @Override - public Cuboid clone() throws CloneNotSupportedException { + public Cuboid clone() { return new Cuboid(this); } @@ -685,7 +671,7 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ return "Cuboid: " + worldName + "," + x1 + "," + y1 + "," + z1 + "=>" + x2 + "," + y2 + "," + z2; } - public class CuboidIterator implements Iterator { + public static class CuboidIterator implements Iterator { private final World w; private final int baseX; private final int baseY; @@ -744,28 +730,18 @@ public class Cuboid implements Iterable, Cloneable, ConfigurationSerializ Unknown; public CuboidDirection opposite() { - switch (this) { - case North: - return South; - case East: - return West; - case South: - return North; - case West: - return East; - case Horizontal: - return Vertical; - case Vertical: - return Horizontal; - case Up: - return Down; - case Down: - return Up; - case Both: - return Both; - default: - return Unknown; - } + return switch (this) { + case North -> South; + case East -> West; + case South -> North; + case West -> East; + case Horizontal -> Vertical; + case Vertical -> Horizontal; + case Up -> Down; + case Down -> Up; + case Both -> Both; + default -> Unknown; + }; } } diff --git a/src/main/java/com/volmit/iris/util/DataPalette.java b/src/main/java/com/volmit/iris/util/DataPalette.java index cd20f8f6b..b14262904 100644 --- a/src/main/java/com/volmit/iris/util/DataPalette.java +++ b/src/main/java/com/volmit/iris/util/DataPalette.java @@ -37,9 +37,9 @@ public abstract class DataPalette implements Writable { getPaletteId(defaultValue); } - public abstract T readType(DataInputStream i) throws IOException; + public abstract T readType(DataInputStream i); - public abstract void writeType(T t, DataOutputStream o) throws IOException; + public abstract void writeType(T t, DataOutputStream o); @Override public void write(DataOutputStream o) throws IOException { diff --git a/src/main/java/com/volmit/iris/util/Direction.java b/src/main/java/com/volmit/iris/util/Direction.java index 8e0f658df..507fc3650 100644 --- a/src/main/java/com/volmit/iris/util/Direction.java +++ b/src/main/java/com/volmit/iris/util/Direction.java @@ -23,6 +23,8 @@ import org.bukkit.Axis; import org.bukkit.block.BlockFace; import org.bukkit.util.Vector; +import java.util.Map; + /** * Directions * @@ -44,68 +46,28 @@ public enum Direction { private final CuboidDirection f; public static Direction getDirection(BlockFace f) { - switch (f) { - case DOWN: - return D; - case EAST: - return E; - case EAST_NORTH_EAST: - return E; - case EAST_SOUTH_EAST: - return E; - case NORTH: - return N; - case NORTH_EAST: - return N; - case NORTH_NORTH_EAST: - return N; - case NORTH_NORTH_WEST: - return N; - case NORTH_WEST: - return N; - case SELF: - return U; - case SOUTH: - return S; - case SOUTH_EAST: - return S; - case SOUTH_SOUTH_EAST: - return S; - case SOUTH_SOUTH_WEST: - return S; - case SOUTH_WEST: - return S; - case UP: - return U; - case WEST: - return W; - case WEST_NORTH_WEST: - return W; - case WEST_SOUTH_WEST: - return W; - } + return switch (f) { + case DOWN -> D; + case EAST, EAST_SOUTH_EAST, EAST_NORTH_EAST -> E; + case NORTH, NORTH_WEST, NORTH_NORTH_WEST, NORTH_NORTH_EAST, NORTH_EAST -> N; + case SELF, UP -> U; + case SOUTH, SOUTH_WEST, SOUTH_SOUTH_WEST, SOUTH_SOUTH_EAST, SOUTH_EAST -> S; + case WEST, WEST_SOUTH_WEST, WEST_NORTH_WEST -> W; + }; - return D; } @Override public String toString() { - switch (this) { - case D: - return "Down"; - case E: - return "East"; - case N: - return "North"; - case S: - return "South"; - case U: - return "Up"; - case W: - return "West"; - } + return switch (this) { + case D -> "Down"; + case E -> "East"; + case N -> "North"; + case S -> "South"; + case U -> "Up"; + case W -> "West"; + }; - return "?"; } public boolean isVertical() { @@ -185,9 +147,10 @@ public enum Direction { public Vector angle(Vector initial, Direction d) { calculatePermutations(); - for (GBiset i : permute.keySet()) { + for (Map.Entry, DOP> entry : permute.entrySet()) { + GBiset i = entry.getKey(); if (i.getA().equals(this) && i.getB().equals(d)) { - return permute.get(i).op(initial); + return entry.getValue().op(initial); } } @@ -310,11 +273,11 @@ public enum Direction { return; } - permute = new KMap, DOP>(); + permute = new KMap<>(); for (Direction i : udnews()) { for (Direction j : udnews()) { - GBiset b = new GBiset(i, j); + GBiset b = new GBiset<>(i, j); if (i.equals(j)) { permute.put(b, new DOP("DIRECT") { @@ -394,40 +357,23 @@ public enum Direction { } public BlockFace getFace() { - switch (this) { - case D: - return BlockFace.DOWN; - case E: - return BlockFace.EAST; - case N: - return BlockFace.NORTH; - case S: - return BlockFace.SOUTH; - case U: - return BlockFace.UP; - case W: - return BlockFace.WEST; - } + return switch (this) { + case D -> BlockFace.DOWN; + case E -> BlockFace.EAST; + case N -> BlockFace.NORTH; + case S -> BlockFace.SOUTH; + case U -> BlockFace.UP; + case W -> BlockFace.WEST; + }; - return null; } public Axis getAxis() { - switch (this) { - case D: - return Axis.Y; - case E: - return Axis.X; - case N: - return Axis.Z; - case S: - return Axis.Z; - case U: - return Axis.Y; - case W: - return Axis.X; - } + return switch (this) { + case D, U -> Axis.Y; + case E, W -> Axis.X; + case N, S -> Axis.Z; + }; - return null; } } diff --git a/src/main/java/com/volmit/iris/util/DoubleArrayUtils.java b/src/main/java/com/volmit/iris/util/DoubleArrayUtils.java index 4180a6a82..d89e9d8d3 100644 --- a/src/main/java/com/volmit/iris/util/DoubleArrayUtils.java +++ b/src/main/java/com/volmit/iris/util/DoubleArrayUtils.java @@ -25,9 +25,7 @@ import java.util.Arrays; public class DoubleArrayUtils { public static void shiftRight(double[] values, double push) { - for (int index = values.length - 2; index >= 0; index--) { - values[index + 1] = values[index]; - } + if (values.length - 2 + 1 >= 0) System.arraycopy(values, 0, values, 1, values.length - 2 + 1); values[0] = push; } diff --git a/src/main/java/com/volmit/iris/util/Element.java b/src/main/java/com/volmit/iris/util/Element.java index a22c46502..1f0a8fc78 100644 --- a/src/main/java/com/volmit/iris/util/Element.java +++ b/src/main/java/com/volmit/iris/util/Element.java @@ -20,6 +20,7 @@ package com.volmit.iris.util; import org.bukkit.inventory.ItemStack; +@SuppressWarnings("ALL") public interface Element { MaterialBlock getMaterial(); diff --git a/src/main/java/com/volmit/iris/util/FakeWorld.java b/src/main/java/com/volmit/iris/util/FakeWorld.java index 76f548cb0..df1d94994 100644 --- a/src/main/java/com/volmit/iris/util/FakeWorld.java +++ b/src/main/java/com/volmit/iris/util/FakeWorld.java @@ -64,10 +64,11 @@ public class FakeWorld implements World { } @Override - public void sendPluginMessage(Plugin source, String channel, byte[] message) { + public void sendPluginMessage(@NotNull Plugin source, @NotNull String channel, @NotNull byte[] message) { } + @NotNull @Override public Set getListeningPluginChannels() { @@ -75,35 +76,38 @@ public class FakeWorld implements World { } @Override - public void setMetadata(String metadataKey, MetadataValue newMetadataValue) { + public void setMetadata(@NotNull String metadataKey, @NotNull MetadataValue newMetadataValue) { } + @NotNull @Override - public List getMetadata(String metadataKey) { + public List getMetadata(@NotNull String metadataKey) { return null; } @Override - public boolean hasMetadata(String metadataKey) { + public boolean hasMetadata(@NotNull String metadataKey) { return false; } @Override - public void removeMetadata(String metadataKey, Plugin owningPlugin) { + public void removeMetadata(@NotNull String metadataKey, @NotNull Plugin owningPlugin) { } + @NotNull @Override public Block getBlockAt(int x, int y, int z) { return null; } + @NotNull @Override - public Block getBlockAt(Location location) { + public Block getBlockAt(@NotNull Location location) { return null; } @@ -115,71 +119,79 @@ public class FakeWorld implements World { } @Override - public int getHighestBlockYAt(Location location) { + public int getHighestBlockYAt(@NotNull Location location) { return 0; } + @NotNull @Override public Block getHighestBlockAt(int x, int z) { return null; } + @NotNull @Override - public Block getHighestBlockAt(Location location) { + public Block getHighestBlockAt(@NotNull Location location) { return null; } @Override - public int getHighestBlockYAt(int x, int z, HeightMap heightMap) { + public int getHighestBlockYAt(int x, int z, @NotNull HeightMap heightMap) { return 0; } @Override - public int getHighestBlockYAt(Location location, HeightMap heightMap) { + public int getHighestBlockYAt(@NotNull Location location, @NotNull HeightMap heightMap) { return 0; } + @NotNull @Override - public Block getHighestBlockAt(int x, int z, HeightMap heightMap) { + public Block getHighestBlockAt(int x, int z, @NotNull HeightMap heightMap) { return null; } + @NotNull @Override - public Block getHighestBlockAt(Location location, HeightMap heightMap) { + public Block getHighestBlockAt(@NotNull Location location, @NotNull HeightMap heightMap) { return null; } + @NotNull @Override public Chunk getChunkAt(int x, int z) { return null; } + @NotNull @Override - public Chunk getChunkAt(Location location) { + public Chunk getChunkAt(@NotNull Location location) { + + return null; + } + + @NotNull + @Override + public Chunk getChunkAt(@NotNull Block block) { return null; } @Override - public Chunk getChunkAt(Block block) { - - return null; - } - - @Override - public boolean isChunkLoaded(Chunk chunk) { + public boolean isChunkLoaded(@NotNull Chunk chunk) { return false; } + @NotNull @Override public Chunk[] getLoadedChunks() { @@ -187,7 +199,7 @@ public class FakeWorld implements World { } @Override - public void loadChunk(Chunk chunk) { + public void loadChunk(@NotNull Chunk chunk) { } @@ -221,7 +233,7 @@ public class FakeWorld implements World { } @Override - public boolean unloadChunk(Chunk chunk) { + public boolean unloadChunk(@NotNull Chunk chunk) { return false; } @@ -267,6 +279,7 @@ public class FakeWorld implements World { } + @NotNull @Override public Collection getForceLoadedChunks() { @@ -274,36 +287,39 @@ public class FakeWorld implements World { } @Override - public boolean addPluginChunkTicket(int x, int z, Plugin plugin) { + public boolean addPluginChunkTicket(int x, int z, @NotNull Plugin plugin) { return false; } @Override - public boolean removePluginChunkTicket(int x, int z, Plugin plugin) { + public boolean removePluginChunkTicket(int x, int z, @NotNull Plugin plugin) { return false; } @Override - public void removePluginChunkTickets(Plugin plugin) { + public void removePluginChunkTickets(@NotNull Plugin plugin) { } + @NotNull @Override public Collection getPluginChunkTickets(int x, int z) { return null; } + @NotNull @Override public Map> getPluginChunkTickets() { return null; } + @NotNull @Override - public Item dropItem(Location location, ItemStack item) { + public Item dropItem(@NotNull Location location, @NotNull ItemStack item) { return null; } @@ -314,8 +330,9 @@ public class FakeWorld implements World { return null; } + @NotNull @Override - public Item dropItemNaturally(Location location, ItemStack item) { + public Item dropItemNaturally(@NotNull Location location, @NotNull ItemStack item) { return null; } @@ -326,168 +343,187 @@ public class FakeWorld implements World { return null; } + @NotNull @Override - public Arrow spawnArrow(Location location, Vector direction, float speed, float spread) { + public Arrow spawnArrow(@NotNull Location location, @NotNull Vector direction, float speed, float spread) { + + return null; + } + + @NotNull + @Override + public T spawnArrow(@NotNull Location location, @NotNull Vector direction, float speed, float spread, @NotNull Class clazz) { return null; } @Override - public T spawnArrow(Location location, Vector direction, float speed, float spread, Class clazz) { - - return null; - } - - @Override - public boolean generateTree(Location location, TreeType type) { + public boolean generateTree(@NotNull Location location, @NotNull TreeType type) { return false; } @Override - public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { + public boolean generateTree(@NotNull Location loc, @NotNull TreeType type, @NotNull BlockChangeDelegate delegate) { return false; } + @NotNull @Override - public Entity spawnEntity(Location loc, EntityType type) { + public Entity spawnEntity(@NotNull Location loc, @NotNull EntityType type) { return null; } + @NotNull @Override - public LightningStrike strikeLightning(Location loc) { + public LightningStrike strikeLightning(@NotNull Location loc) { return null; } + @NotNull @Override - public LightningStrike strikeLightningEffect(Location loc) { + public LightningStrike strikeLightningEffect(@NotNull Location loc) { return null; } + @NotNull @Override public List getEntities() { return null; } + @NotNull @Override public List getLivingEntities() { return null; } + @NotNull + @SuppressWarnings({"RedundantSuppression", "unchecked"}) @Override - public Collection getEntitiesByClass(@SuppressWarnings("unchecked") Class... classes) { + public Collection getEntitiesByClass(@NotNull @SuppressWarnings("unchecked") Class... classes) { return null; } + @NotNull @Override - public Collection getEntitiesByClass(Class cls) { + public Collection getEntitiesByClass(@NotNull Class cls) { return null; } + @NotNull @Override - public Collection getEntitiesByClasses(Class... classes) { + public Collection getEntitiesByClasses(@NotNull Class... classes) { return null; } + @NotNull @Override public List getPlayers() { return null; } + @NotNull @Override - public Collection getNearbyEntities(Location location, double x, double y, double z) { + public Collection getNearbyEntities(@NotNull Location location, double x, double y, double z) { + + return null; + } + + @NotNull + @Override + public Collection getNearbyEntities(@NotNull Location location, double x, double y, double z, Predicate filter) { + + return null; + } + + @NotNull + @Override + public Collection getNearbyEntities(@NotNull BoundingBox boundingBox) { + + return null; + } + + @NotNull + @Override + public Collection getNearbyEntities(@NotNull BoundingBox boundingBox, Predicate filter) { return null; } @Override - public Collection getNearbyEntities(Location location, double x, double y, double z, Predicate filter) { + public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance) { return null; } @Override - public Collection getNearbyEntities(BoundingBox boundingBox) { + public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, double raySize) { return null; } @Override - public Collection getNearbyEntities(BoundingBox boundingBox, Predicate filter) { + public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, Predicate filter) { return null; } @Override - public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance) { + public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, double raySize, Predicate filter) { return null; } @Override - public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize) { + public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance) { return null; } @Override - public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, Predicate filter) { + public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode) { return null; } @Override - public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize, Predicate filter) { + public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks) { return null; } @Override - public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance) { - - return null; - } - - @Override - public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode) { - - return null; - } - - @Override - public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks) { - - return null; - } - - @Override - public RayTraceResult rayTrace(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, Predicate filter) { + public RayTraceResult rayTrace(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, Predicate filter) { return null; } + @NotNull @Override public String getName() { return worldName; } + @NotNull @Override public UUID getUID() { return null; } + @NotNull @Override public Location getSpawnLocation() { @@ -495,7 +531,7 @@ public class FakeWorld implements World { } @Override - public boolean setSpawnLocation(Location location) { + public boolean setSpawnLocation(@NotNull Location location) { return false; } @@ -622,29 +658,30 @@ public class FakeWorld implements World { } @Override - public boolean createExplosion(Location loc, float power) { + public boolean createExplosion(@NotNull Location loc, float power) { return false; } @Override - public boolean createExplosion(Location loc, float power, boolean setFire) { + public boolean createExplosion(@NotNull Location loc, float power, boolean setFire) { return false; } @Override - public boolean createExplosion(Location loc, float power, boolean setFire, boolean breakBlocks) { + public boolean createExplosion(@NotNull Location loc, float power, boolean setFire, boolean breakBlocks) { return false; } @Override - public boolean createExplosion(Location loc, float power, boolean setFire, boolean breakBlocks, Entity source) { + public boolean createExplosion(@NotNull Location loc, float power, boolean setFire, boolean breakBlocks, Entity source) { return false; } + @NotNull @Override public Environment getEnvironment() { @@ -679,62 +716,69 @@ public class FakeWorld implements World { } + @NotNull @Override public List getPopulators() { return null; } + @NotNull @Override - public T spawn(Location location, Class clazz) throws IllegalArgumentException { + public T spawn(@NotNull Location location, @NotNull Class clazz) throws IllegalArgumentException { + + return null; + } + + @NotNull + @Override + public T spawn(@NotNull Location location, @NotNull Class clazz, Consumer function) throws IllegalArgumentException { + + return null; + } + + @NotNull + @Override + public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull MaterialData data) throws IllegalArgumentException { + + return null; + } + + @NotNull + @Override + public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull BlockData data) throws IllegalArgumentException { + + return null; + } + + @NotNull + @Override + public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull Material material, byte data) throws IllegalArgumentException { return null; } @Override - public T spawn(Location location, Class clazz, Consumer function) throws IllegalArgumentException { - - return null; - } - - @Override - public FallingBlock spawnFallingBlock(Location location, MaterialData data) throws IllegalArgumentException { - - return null; - } - - @Override - public FallingBlock spawnFallingBlock(Location location, BlockData data) throws IllegalArgumentException { - - return null; - } - - @Override - public FallingBlock spawnFallingBlock(Location location, Material material, byte data) throws IllegalArgumentException { - - return null; - } - - @Override - public void playEffect(Location location, Effect effect, int data) { + public void playEffect(@NotNull Location location, @NotNull Effect effect, int data) { } @Override - public void playEffect(Location location, Effect effect, int data, int radius) { + public void playEffect(@NotNull Location location, @NotNull Effect effect, int data, int radius) { } @Override - public void playEffect(Location location, Effect effect, T data) { + public void playEffect(@NotNull Location location, @NotNull Effect effect, T data) { } @Override - public void playEffect(Location location, Effect effect, T data, int radius) { + public void playEffect(@NotNull Location location, @NotNull Effect effect, T data, int radius) { } + @NotNull @Override public ChunkSnapshot getEmptyChunkSnapshot(int x, int z, boolean includeBiome, boolean includeBiomeTemp) { @@ -758,12 +802,14 @@ public class FakeWorld implements World { return false; } + @NotNull @Override public Biome getBiome(int x, int z) { return null; } + @NotNull @Override public Biome getBiome(int x, int y, int z) { @@ -771,12 +817,12 @@ public class FakeWorld implements World { } @Override - public void setBiome(int x, int z, Biome bio) { + public void setBiome(int x, int z, @NotNull Biome bio) { } @Override - public void setBiome(int x, int y, int z, Biome bio) { + public void setBiome(int x, int y, int z, @NotNull Biome bio) { } @@ -844,16 +890,18 @@ public class FakeWorld implements World { } @Override - public void setDifficulty(Difficulty difficulty) { + public void setDifficulty(@NotNull Difficulty difficulty) { } + @NotNull @Override public Difficulty getDifficulty() { return null; } + @NotNull @Override public File getWorldFolder() { @@ -994,25 +1042,26 @@ public class FakeWorld implements World { } @Override - public void playSound(Location location, Sound sound, float volume, float pitch) { + public void playSound(@NotNull Location location, @NotNull Sound sound, float volume, float pitch) { } @Override - public void playSound(Location location, String sound, float volume, float pitch) { + public void playSound(@NotNull Location location, @NotNull String sound, float volume, float pitch) { } @Override - public void playSound(Location location, Sound sound, SoundCategory category, float volume, float pitch) { + public void playSound(@NotNull Location location, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) { } @Override - public void playSound(Location location, String sound, SoundCategory category, float volume, float pitch) { + public void playSound(@NotNull Location location, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch) { } + @NotNull @Override public String[] getGameRules() { @@ -1026,35 +1075,36 @@ public class FakeWorld implements World { } @Override - public boolean setGameRuleValue(String rule, String value) { + public boolean setGameRuleValue(@NotNull String rule, @NotNull String value) { return false; } @Override - public boolean isGameRule(String rule) { + public boolean isGameRule(@NotNull String rule) { return false; } @Override - public T getGameRuleValue(GameRule rule) { + public T getGameRuleValue(@NotNull GameRule rule) { return null; } @Override - public T getGameRuleDefault(GameRule rule) { + public T getGameRuleDefault(@NotNull GameRule rule) { return null; } @Override - public boolean setGameRule(GameRule rule, T newValue) { + public boolean setGameRule(@NotNull GameRule rule, @NotNull T newValue) { return false; } + @NotNull @Override public WorldBorder getWorldBorder() { @@ -1062,77 +1112,77 @@ public class FakeWorld implements World { } @Override - public void spawnParticle(Particle particle, Location location, int count) { + public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count) { } @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count) { + public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count) { } @Override - public void spawnParticle(Particle particle, Location location, int count, T data) { + public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, T data) { } @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count, T data) { + public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, T data) { } @Override - public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ) { + public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ) { } @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ) { + public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ) { } @Override - public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, T data) { + public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, T data) { } @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, T data) { + public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, T data) { } @Override - public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra) { + public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra) { } @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra) { + public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra) { } @Override - public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) { + public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) { } @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) { + public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) { } @Override - public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) { + public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) { } @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) { + public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) { } @Override - public Location locateNearestStructure(Location origin, StructureType structureType, int radius, boolean findUnexplored) { + public Location locateNearestStructure(@NotNull Location origin, @NotNull StructureType structureType, int radius, boolean findUnexplored) { return null; } @@ -1141,16 +1191,18 @@ public class FakeWorld implements World { return 0; } + @NotNull @Override public Spigot spigot() { return null; } @Override - public Raid locateNearestRaid(Location location, int radius) { + public Raid locateNearestRaid(@NotNull Location location, int radius) { return null; } + @NotNull @Override public List getRaids() { return null; diff --git a/src/main/java/com/volmit/iris/util/Form.java b/src/main/java/com/volmit/iris/util/Form.java index 50df5c9d6..6ec1aef10 100644 --- a/src/main/java/com/volmit/iris/util/Form.java +++ b/src/main/java/com/volmit/iris/util/Form.java @@ -36,7 +36,7 @@ public class Form { private static final NavigableMap MAP; static { - MAP = new TreeMap(); + MAP = new TreeMap<>(); for (int i = 0; i < NAMES.length; i++) { MAP.put(THOUSAND.pow(i + 1), NAMES[i]); } @@ -54,7 +54,6 @@ public class Form { * @param smx the text * @param viewport the viewport length * @param time the timeline value - * @return */ public static String scroll(String smx, int viewport, long time) { String src = Form.repeat(" ", viewport) + smx + Form.repeat(" ", viewport); @@ -73,19 +72,19 @@ public class Form { * @return the capitalized string */ public static String capitalize(String s) { - String roll = ""; + StringBuilder roll = new StringBuilder(); boolean f = true; for (Character i : s.trim().toCharArray()) { if (f) { - roll += Character.toUpperCase(i); + roll.append(Character.toUpperCase(i)); f = false; } else { - roll += i; + roll.append(i); } } - return roll; + return roll.toString(); } /** @@ -95,10 +94,10 @@ public class Form { * @return the capitalized string */ public static String capitalizeWords(String s) { - String rollx = ""; + StringBuilder rollx = new StringBuilder(); for (String i : s.trim().split(" ")) { - rollx += " " + capitalize(i.trim()); + rollx.append(" ").append(capitalize(i.trim())); } return rollx.substring(1); @@ -223,7 +222,6 @@ public class Form { /** * Returns a fancy duration up to Years * - * @param rollingSequence * @param duration the duration in ms * @return the fancy duration */ @@ -341,72 +339,33 @@ public class Form { } else { int h = c.get(Calendar.HOUR); h = h == 0 ? 12 : h; - String dow = "Error Day"; - - switch (c.get(Calendar.DAY_OF_WEEK)) { - case Calendar.SUNDAY: - dow = "Sunday"; - break; - case Calendar.MONDAY: - dow = "Monday"; - break; - case Calendar.TUESDAY: - dow = "Tuesday"; - break; - case Calendar.WEDNESDAY: - dow = "Wednesday"; - break; - case Calendar.THURSDAY: - dow = "Thursday"; - break; - case Calendar.FRIDAY: - dow = "Friday"; - break; - case Calendar.SATURDAY: - dow = "Saturday"; - break; - } + String dow = switch (c.get(Calendar.DAY_OF_WEEK)) { + case Calendar.SUNDAY -> "Sunday"; + case Calendar.MONDAY -> "Monday"; + case Calendar.TUESDAY -> "Tuesday"; + case Calendar.WEDNESDAY -> "Wednesday"; + case Calendar.THURSDAY -> "Thursday"; + case Calendar.FRIDAY -> "Friday"; + case Calendar.SATURDAY -> "Saturday"; + default -> "Error Day"; + }; String monthName = "Error Month"; int month = c.get(Calendar.MONTH); switch (month) { - case Calendar.JANUARY: - monthName = "Jan"; - break; - case Calendar.FEBRUARY: - monthName = "Feb"; - break; - case Calendar.MARCH: - monthName = "Mar"; - break; - case Calendar.APRIL: - monthName = "Apr"; - break; - case Calendar.MAY: - monthName = "May"; - break; - case Calendar.JUNE: - monthName = "Jun"; - break; - case Calendar.JULY: - monthName = "Jul"; - break; - case Calendar.AUGUST: - monthName = "Aug"; - break; - case Calendar.SEPTEMBER: - monthName = "Sep"; - break; - case Calendar.OCTOBER: - monthName = "Oct"; - break; - case Calendar.NOVEMBER: - monthName = "Nov"; - break; - case Calendar.DECEMBER: - monthName = "Dec"; - break; + case Calendar.JANUARY -> monthName = "Jan"; + case Calendar.FEBRUARY -> monthName = "Feb"; + case Calendar.MARCH -> monthName = "Mar"; + case Calendar.APRIL -> monthName = "Apr"; + case Calendar.MAY -> monthName = "May"; + case Calendar.JUNE -> monthName = "Jun"; + case Calendar.JULY -> monthName = "Jul"; + case Calendar.AUGUST -> monthName = "Aug"; + case Calendar.SEPTEMBER -> monthName = "Sep"; + case Calendar.OCTOBER -> monthName = "Oct"; + case Calendar.NOVEMBER -> monthName = "Nov"; + case Calendar.DECEMBER -> monthName = "Dec"; } int dayOfMonth = c.get(Calendar.DAY_OF_MONTH); @@ -417,72 +376,33 @@ public class Form { } else { int h = c.get(Calendar.HOUR); h = h == 0 ? 12 : h; - String dow = "Error Day"; - - switch (c.get(Calendar.DAY_OF_WEEK)) { - case Calendar.SUNDAY: - dow = "Sunday"; - break; - case Calendar.MONDAY: - dow = "Monday"; - break; - case Calendar.TUESDAY: - dow = "Tuesday"; - break; - case Calendar.WEDNESDAY: - dow = "Wednesday"; - break; - case Calendar.THURSDAY: - dow = "Thursday"; - break; - case Calendar.FRIDAY: - dow = "Friday"; - break; - case Calendar.SATURDAY: - dow = "Saturday"; - break; - } + String dow = switch (c.get(Calendar.DAY_OF_WEEK)) { + case Calendar.SUNDAY -> "Sunday"; + case Calendar.MONDAY -> "Monday"; + case Calendar.TUESDAY -> "Tuesday"; + case Calendar.WEDNESDAY -> "Wednesday"; + case Calendar.THURSDAY -> "Thursday"; + case Calendar.FRIDAY -> "Friday"; + case Calendar.SATURDAY -> "Saturday"; + default -> "Error Day"; + }; String monthName = "Error Month"; int month = c.get(Calendar.MONTH); switch (month) { - case Calendar.JANUARY: - monthName = "Jan"; - break; - case Calendar.FEBRUARY: - monthName = "Feb"; - break; - case Calendar.MARCH: - monthName = "Mar"; - break; - case Calendar.APRIL: - monthName = "Apr"; - break; - case Calendar.MAY: - monthName = "May"; - break; - case Calendar.JUNE: - monthName = "Jun"; - break; - case Calendar.JULY: - monthName = "Jul"; - break; - case Calendar.AUGUST: - monthName = "Aug"; - break; - case Calendar.SEPTEMBER: - monthName = "Sep"; - break; - case Calendar.OCTOBER: - monthName = "Oct"; - break; - case Calendar.NOVEMBER: - monthName = "Nov"; - break; - case Calendar.DECEMBER: - monthName = "Dec"; - break; + case Calendar.JANUARY -> monthName = "Jan"; + case Calendar.FEBRUARY -> monthName = "Feb"; + case Calendar.MARCH -> monthName = "Mar"; + case Calendar.APRIL -> monthName = "Apr"; + case Calendar.MAY -> monthName = "May"; + case Calendar.JUNE -> monthName = "Jun"; + case Calendar.JULY -> monthName = "Jul"; + case Calendar.AUGUST -> monthName = "Aug"; + case Calendar.SEPTEMBER -> monthName = "Sep"; + case Calendar.OCTOBER -> monthName = "Oct"; + case Calendar.NOVEMBER -> monthName = "Nov"; + case Calendar.DECEMBER -> monthName = "Dec"; } int dayOfMonth = c.get(Calendar.DAY_OF_MONTH); @@ -502,15 +422,10 @@ public class Form { */ public static String numberSuffix(int i) { String[] sufixes = new String[]{"th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"}; - switch (i % 100) { - case 11: - case 12: - case 13: - return i + "th"; - default: - return i + sufixes[i % 10]; - - } + return switch (i % 100) { + case 11, 12, 13 -> i + "th"; + default -> i + sufixes[i % 10]; + }; } /** @@ -722,7 +637,7 @@ public class Form { * @return the string */ public static String ofSize(long s, int div) { - Double d = (double) s; + double d = (double) s; String sub = "Bytes"; if (d > div - 1) { @@ -763,7 +678,7 @@ public class Form { * @return the string */ public static String ofSize(long s, int div, int dec) { - Double d = (double) s; + double d = (double) s; String sub = "Bytes"; if (d > div - 1) { @@ -804,7 +719,7 @@ public class Form { if (neg) { s = -s; } - Double d = (double) s; + double d = (double) s; String sub = "Grams"; if (d > div - 1) { @@ -853,21 +768,21 @@ public class Form { * @return the string representation */ public static String cname(String clazz) { - String codeName = ""; + StringBuilder codeName = new StringBuilder(); for (Character i : clazz.toCharArray()) { if (Character.isUpperCase(i)) { - codeName = codeName + "-" + Character.toLowerCase(i); + codeName.append("-").append(Character.toLowerCase(i)); } else { - codeName = codeName + i; + codeName.append(i); } } - if (codeName.startsWith("-")) { - codeName = codeName.substring(1); + if (codeName.toString().startsWith("-")) { + codeName = new StringBuilder(codeName.substring(1)); } - return codeName; + return codeName.toString(); } /** @@ -887,7 +802,6 @@ public class Form { /** * Get a formatted representation of the memory given in kilobytes * - * @param mb the kilobytes * @return the string representation with suffixes */ public static String memx(long kb) { @@ -1121,7 +1035,6 @@ public class Form { /** * nanoseconds to seconds (double) * - * @param ms the nanoseconds * @return a formatted string to nanoseconds */ public static String nsMs(long ns) { @@ -1131,7 +1044,6 @@ public class Form { /** * nanoseconds to seconds (double) custom decimals * - * @param ms the nanoseconds * @param p number of decimal points * @return a formatted string to nanoseconds */ @@ -1142,7 +1054,6 @@ public class Form { /** * nanoseconds to seconds (double) custom decimals * - * @param ms the nanoseconds * @param p number of decimal points * @return a formatted string to nanoseconds */ @@ -1157,7 +1068,7 @@ public class Form { * @return the numerals */ public static String toRoman(int num) { - LinkedHashMap roman_numerals = new LinkedHashMap(); + LinkedHashMap roman_numerals = new LinkedHashMap<>(); roman_numerals.put("M", 1000); roman_numerals.put("CM", 900); @@ -1173,16 +1084,16 @@ public class Form { roman_numerals.put("IV", 4); roman_numerals.put("I", 1); - String res = ""; + StringBuilder res = new StringBuilder(); for (Map.Entry entry : roman_numerals.entrySet()) { int matches = num / entry.getValue(); - res += repeat(entry.getKey(), matches); + res.append(repeat(entry.getKey(), matches)); num = num % entry.getValue(); } - return res; + return res.toString(); } /** @@ -1260,6 +1171,7 @@ public class Form { * @param n the amount of times to repeat * @return the repeated string */ + @SuppressWarnings("StringRepeatCanBeUsed") public static String repeat(String s, int n) { if (s == null) { return null; diff --git a/src/main/java/com/volmit/iris/util/Function2.java b/src/main/java/com/volmit/iris/util/Function2.java index b4a31d9e0..4bae100b5 100644 --- a/src/main/java/com/volmit/iris/util/Function2.java +++ b/src/main/java/com/volmit/iris/util/Function2.java @@ -18,7 +18,6 @@ package com.volmit.iris.util; -@SuppressWarnings("hiding") @FunctionalInterface public interface Function2 { R apply(A a, B b); diff --git a/src/main/java/com/volmit/iris/util/Function3.java b/src/main/java/com/volmit/iris/util/Function3.java index 327be192e..927026d22 100644 --- a/src/main/java/com/volmit/iris/util/Function3.java +++ b/src/main/java/com/volmit/iris/util/Function3.java @@ -18,7 +18,6 @@ package com.volmit.iris.util; -@SuppressWarnings("hiding") @FunctionalInterface public interface Function3 { R apply(A a, B b, C c); diff --git a/src/main/java/com/volmit/iris/util/Function4.java b/src/main/java/com/volmit/iris/util/Function4.java index 138bb5cd2..a931736d7 100644 --- a/src/main/java/com/volmit/iris/util/Function4.java +++ b/src/main/java/com/volmit/iris/util/Function4.java @@ -18,7 +18,6 @@ package com.volmit.iris.util; -@SuppressWarnings("hiding") @FunctionalInterface public interface Function4 { R apply(A a, B b, C c, D d); diff --git a/src/main/java/com/volmit/iris/util/GBiset.java b/src/main/java/com/volmit/iris/util/GBiset.java index 6902935ef..ff97046d5 100644 --- a/src/main/java/com/volmit/iris/util/GBiset.java +++ b/src/main/java/com/volmit/iris/util/GBiset.java @@ -75,7 +75,6 @@ public class GBiset implements Serializable { /** * Set the second object * - * @param b */ public void setB(B b) { this.b = b; diff --git a/src/main/java/com/volmit/iris/util/GListAdapter.java b/src/main/java/com/volmit/iris/util/GListAdapter.java index b7fc3c7e4..636cfe51d 100644 --- a/src/main/java/com/volmit/iris/util/GListAdapter.java +++ b/src/main/java/com/volmit/iris/util/GListAdapter.java @@ -36,7 +36,7 @@ public abstract class GListAdapter { * @return the to list */ public List adapt(List from) { - List adapted = new KList(); + List adapted = new KList<>(); for (FROM i : from) { TO t = onAdapt(i); diff --git a/src/main/java/com/volmit/iris/util/GroupedExecutor.java b/src/main/java/com/volmit/iris/util/GroupedExecutor.java index dfb3ab74f..cad181d22 100644 --- a/src/main/java/com/volmit/iris/util/GroupedExecutor.java +++ b/src/main/java/com/volmit/iris/util/GroupedExecutor.java @@ -31,7 +31,7 @@ public class GroupedExecutor { public GroupedExecutor(int threadLimit, int priority, String name) { xc = 1; - mirror = new KMap(); + mirror = new KMap<>(); if (threadLimit == 1) { service = Executors.newSingleThreadExecutor((r) -> @@ -43,14 +43,11 @@ public class GroupedExecutor { return t; }); } else if (threadLimit > 1) { - final ForkJoinWorkerThreadFactory factory = new ForkJoinWorkerThreadFactory() { - @Override - public ForkJoinWorkerThread newThread(ForkJoinPool pool) { - final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool); - worker.setName(name + " " + xc++); - worker.setPriority(priority); - return worker; - } + final ForkJoinWorkerThreadFactory factory = pool -> { + final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool); + worker.setName(name + " " + xc++); + worker.setPriority(priority); + return worker; }; service = new ForkJoinPool(threadLimit, factory, null, false); diff --git a/src/main/java/com/volmit/iris/util/HTTP.java b/src/main/java/com/volmit/iris/util/HTTP.java index 8d7714d7e..21faf68cf 100644 --- a/src/main/java/com/volmit/iris/util/HTTP.java +++ b/src/main/java/com/volmit/iris/util/HTTP.java @@ -81,7 +81,6 @@ public class HTTP { * @param string An HTTP header string. * @return A JSONObject containing the elements and attributes of the XML * string. - * @throws JSONException */ public static JSONObject toJSONObject(String string) throws JSONException { JSONObject jo = new JSONObject(); diff --git a/src/main/java/com/volmit/iris/util/HTTPTokener.java b/src/main/java/com/volmit/iris/util/HTTPTokener.java index 3eee8f177..19164cc82 100644 --- a/src/main/java/com/volmit/iris/util/HTTPTokener.java +++ b/src/main/java/com/volmit/iris/util/HTTPTokener.java @@ -41,7 +41,6 @@ public class HTTPTokener extends JSONTokener { * Get the next token or string. This is used in parsing HTTP headers. * * @return A String. - * @throws JSONException */ public String nextToken() throws JSONException { char c; diff --git a/src/main/java/com/volmit/iris/util/HeightedFakeWorld.java b/src/main/java/com/volmit/iris/util/HeightedFakeWorld.java index 4580d2cbc..2d02b0d4c 100644 --- a/src/main/java/com/volmit/iris/util/HeightedFakeWorld.java +++ b/src/main/java/com/volmit/iris/util/HeightedFakeWorld.java @@ -42,7 +42,7 @@ import java.io.File; import java.util.*; import java.util.function.Predicate; -@SuppressWarnings("deprecation") +@SuppressWarnings({"deprecation", "ClassCanBeRecord", "unchecked"}) public class HeightedFakeWorld implements World { private final int height; @@ -51,10 +51,11 @@ public class HeightedFakeWorld implements World { } @Override - public void sendPluginMessage(Plugin source, String channel, byte[] message) { + public void sendPluginMessage(@NotNull Plugin source, @NotNull String channel, @NotNull byte[] message) { } + @NotNull @Override public Set getListeningPluginChannels() { @@ -62,35 +63,38 @@ public class HeightedFakeWorld implements World { } @Override - public void setMetadata(String metadataKey, MetadataValue newMetadataValue) { + public void setMetadata(@NotNull String metadataKey, @NotNull MetadataValue newMetadataValue) { } + @NotNull @Override - public List getMetadata(String metadataKey) { + public List getMetadata(@NotNull String metadataKey) { return null; } @Override - public boolean hasMetadata(String metadataKey) { + public boolean hasMetadata(@NotNull String metadataKey) { return false; } @Override - public void removeMetadata(String metadataKey, Plugin owningPlugin) { + public void removeMetadata(@NotNull String metadataKey, @NotNull Plugin owningPlugin) { } + @NotNull @Override public Block getBlockAt(int x, int y, int z) { return null; } + @NotNull @Override - public Block getBlockAt(Location location) { + public Block getBlockAt(@NotNull Location location) { return null; } @@ -102,71 +106,79 @@ public class HeightedFakeWorld implements World { } @Override - public int getHighestBlockYAt(Location location) { + public int getHighestBlockYAt(@NotNull Location location) { return 0; } + @NotNull @Override public Block getHighestBlockAt(int x, int z) { return null; } + @NotNull @Override - public Block getHighestBlockAt(Location location) { + public Block getHighestBlockAt(@NotNull Location location) { return null; } @Override - public int getHighestBlockYAt(int x, int z, HeightMap heightMap) { + public int getHighestBlockYAt(int x, int z, @NotNull HeightMap heightMap) { return 0; } @Override - public int getHighestBlockYAt(Location location, HeightMap heightMap) { + public int getHighestBlockYAt(@NotNull Location location, @NotNull HeightMap heightMap) { return 0; } + @NotNull @Override - public Block getHighestBlockAt(int x, int z, HeightMap heightMap) { + public Block getHighestBlockAt(int x, int z, @NotNull HeightMap heightMap) { return null; } + @NotNull @Override - public Block getHighestBlockAt(Location location, HeightMap heightMap) { + public Block getHighestBlockAt(@NotNull Location location, @NotNull HeightMap heightMap) { return null; } + @NotNull @Override public Chunk getChunkAt(int x, int z) { return null; } + @NotNull @Override - public Chunk getChunkAt(Location location) { + public Chunk getChunkAt(@NotNull Location location) { + + return null; + } + + @NotNull + @Override + public Chunk getChunkAt(@NotNull Block block) { return null; } @Override - public Chunk getChunkAt(Block block) { - - return null; - } - - @Override - public boolean isChunkLoaded(Chunk chunk) { + public boolean isChunkLoaded(@NotNull Chunk chunk) { return false; } + @NotNull @Override public Chunk[] getLoadedChunks() { @@ -174,7 +186,7 @@ public class HeightedFakeWorld implements World { } @Override - public void loadChunk(Chunk chunk) { + public void loadChunk(@NotNull Chunk chunk) { } @@ -208,7 +220,7 @@ public class HeightedFakeWorld implements World { } @Override - public boolean unloadChunk(Chunk chunk) { + public boolean unloadChunk(@NotNull Chunk chunk) { return false; } @@ -254,6 +266,7 @@ public class HeightedFakeWorld implements World { } + @NotNull @Override public Collection getForceLoadedChunks() { @@ -261,36 +274,39 @@ public class HeightedFakeWorld implements World { } @Override - public boolean addPluginChunkTicket(int x, int z, Plugin plugin) { + public boolean addPluginChunkTicket(int x, int z, @NotNull Plugin plugin) { return false; } @Override - public boolean removePluginChunkTicket(int x, int z, Plugin plugin) { + public boolean removePluginChunkTicket(int x, int z, @NotNull Plugin plugin) { return false; } @Override - public void removePluginChunkTickets(Plugin plugin) { + public void removePluginChunkTickets(@NotNull Plugin plugin) { } + @NotNull @Override public Collection getPluginChunkTickets(int x, int z) { return null; } + @NotNull @Override public Map> getPluginChunkTickets() { return null; } + @NotNull @Override - public Item dropItem(Location location, ItemStack item) { + public Item dropItem(@NotNull Location location, @NotNull ItemStack item) { return null; } @@ -301,8 +317,9 @@ public class HeightedFakeWorld implements World { return null; } + @NotNull @Override - public Item dropItemNaturally(Location location, ItemStack item) { + public Item dropItemNaturally(@NotNull Location location, @NotNull ItemStack item) { return null; } @@ -313,168 +330,186 @@ public class HeightedFakeWorld implements World { return null; } + @NotNull @Override - public Arrow spawnArrow(Location location, Vector direction, float speed, float spread) { + public Arrow spawnArrow(@NotNull Location location, @NotNull Vector direction, float speed, float spread) { + + return null; + } + + @NotNull + @Override + public T spawnArrow(@NotNull Location location, @NotNull Vector direction, float speed, float spread, @NotNull Class clazz) { return null; } @Override - public T spawnArrow(Location location, Vector direction, float speed, float spread, Class clazz) { - - return null; - } - - @Override - public boolean generateTree(Location location, TreeType type) { + public boolean generateTree(@NotNull Location location, @NotNull TreeType type) { return false; } @Override - public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { + public boolean generateTree(@NotNull Location loc, @NotNull TreeType type, @NotNull BlockChangeDelegate delegate) { return false; } + @NotNull @Override - public Entity spawnEntity(Location loc, EntityType type) { + public Entity spawnEntity(@NotNull Location loc, @NotNull EntityType type) { return null; } + @NotNull @Override - public LightningStrike strikeLightning(Location loc) { + public LightningStrike strikeLightning(@NotNull Location loc) { return null; } + @NotNull @Override - public LightningStrike strikeLightningEffect(Location loc) { + public LightningStrike strikeLightningEffect(@NotNull Location loc) { return null; } + @NotNull @Override public List getEntities() { return null; } + @NotNull @Override public List getLivingEntities() { return null; } + @NotNull @Override - public Collection getEntitiesByClass(@SuppressWarnings("unchecked") Class... classes) { + public Collection getEntitiesByClass(@NotNull Class... classes) { return null; } + @NotNull @Override - public Collection getEntitiesByClass(Class cls) { + public Collection getEntitiesByClass(@NotNull Class cls) { return null; } + @NotNull @Override - public Collection getEntitiesByClasses(Class... classes) { + public Collection getEntitiesByClasses(@NotNull Class... classes) { return null; } + @NotNull @Override public List getPlayers() { return null; } + @NotNull @Override - public Collection getNearbyEntities(Location location, double x, double y, double z) { + public Collection getNearbyEntities(@NotNull Location location, double x, double y, double z) { + + return null; + } + + @NotNull + @Override + public Collection getNearbyEntities(@NotNull Location location, double x, double y, double z, Predicate filter) { + + return null; + } + + @NotNull + @Override + public Collection getNearbyEntities(@NotNull BoundingBox boundingBox) { + + return null; + } + + @NotNull + @Override + public Collection getNearbyEntities(@NotNull BoundingBox boundingBox, Predicate filter) { return null; } @Override - public Collection getNearbyEntities(Location location, double x, double y, double z, Predicate filter) { + public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance) { return null; } @Override - public Collection getNearbyEntities(BoundingBox boundingBox) { + public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, double raySize) { return null; } @Override - public Collection getNearbyEntities(BoundingBox boundingBox, Predicate filter) { + public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, Predicate filter) { return null; } @Override - public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance) { + public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, double raySize, Predicate filter) { return null; } @Override - public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize) { + public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance) { return null; } @Override - public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, Predicate filter) { + public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode) { return null; } @Override - public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize, Predicate filter) { + public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks) { return null; } @Override - public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance) { - - return null; - } - - @Override - public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode) { - - return null; - } - - @Override - public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks) { - - return null; - } - - @Override - public RayTraceResult rayTrace(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, Predicate filter) { + public RayTraceResult rayTrace(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, Predicate filter) { return null; } + @NotNull @Override public String getName() { return null; } + @NotNull @Override public UUID getUID() { return null; } + @NotNull @Override public Location getSpawnLocation() { @@ -482,7 +517,7 @@ public class HeightedFakeWorld implements World { } @Override - public boolean setSpawnLocation(Location location) { + public boolean setSpawnLocation(@NotNull Location location) { return false; } @@ -609,29 +644,30 @@ public class HeightedFakeWorld implements World { } @Override - public boolean createExplosion(Location loc, float power) { + public boolean createExplosion(@NotNull Location loc, float power) { return false; } @Override - public boolean createExplosion(Location loc, float power, boolean setFire) { + public boolean createExplosion(@NotNull Location loc, float power, boolean setFire) { return false; } @Override - public boolean createExplosion(Location loc, float power, boolean setFire, boolean breakBlocks) { + public boolean createExplosion(@NotNull Location loc, float power, boolean setFire, boolean breakBlocks) { return false; } @Override - public boolean createExplosion(Location loc, float power, boolean setFire, boolean breakBlocks, Entity source) { + public boolean createExplosion(@NotNull Location loc, float power, boolean setFire, boolean breakBlocks, Entity source) { return false; } + @NotNull @Override public Environment getEnvironment() { @@ -666,62 +702,69 @@ public class HeightedFakeWorld implements World { } + @NotNull @Override public List getPopulators() { return null; } + @NotNull @Override - public T spawn(Location location, Class clazz) throws IllegalArgumentException { + public T spawn(@NotNull Location location, @NotNull Class clazz) throws IllegalArgumentException { + + return null; + } + + @NotNull + @Override + public T spawn(@NotNull Location location, @NotNull Class clazz, Consumer function) throws IllegalArgumentException { + + return null; + } + + @NotNull + @Override + public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull MaterialData data) throws IllegalArgumentException { + + return null; + } + + @NotNull + @Override + public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull BlockData data) throws IllegalArgumentException { + + return null; + } + + @NotNull + @Override + public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull Material material, byte data) throws IllegalArgumentException { return null; } @Override - public T spawn(Location location, Class clazz, Consumer function) throws IllegalArgumentException { - - return null; - } - - @Override - public FallingBlock spawnFallingBlock(Location location, MaterialData data) throws IllegalArgumentException { - - return null; - } - - @Override - public FallingBlock spawnFallingBlock(Location location, BlockData data) throws IllegalArgumentException { - - return null; - } - - @Override - public FallingBlock spawnFallingBlock(Location location, Material material, byte data) throws IllegalArgumentException { - - return null; - } - - @Override - public void playEffect(Location location, Effect effect, int data) { + public void playEffect(@NotNull Location location, @NotNull Effect effect, int data) { } @Override - public void playEffect(Location location, Effect effect, int data, int radius) { + public void playEffect(@NotNull Location location, @NotNull Effect effect, int data, int radius) { } @Override - public void playEffect(Location location, Effect effect, T data) { + public void playEffect(@NotNull Location location, @NotNull Effect effect, T data) { } @Override - public void playEffect(Location location, Effect effect, T data, int radius) { + public void playEffect(@NotNull Location location, @NotNull Effect effect, T data, int radius) { } + @NotNull @Override public ChunkSnapshot getEmptyChunkSnapshot(int x, int z, boolean includeBiome, boolean includeBiomeTemp) { @@ -745,12 +788,14 @@ public class HeightedFakeWorld implements World { return false; } + @NotNull @Override public Biome getBiome(int x, int z) { return null; } + @NotNull @Override public Biome getBiome(int x, int y, int z) { @@ -758,12 +803,12 @@ public class HeightedFakeWorld implements World { } @Override - public void setBiome(int x, int z, Biome bio) { + public void setBiome(int x, int z, @NotNull Biome bio) { } @Override - public void setBiome(int x, int y, int z, Biome bio) { + public void setBiome(int x, int y, int z, @NotNull Biome bio) { } @@ -831,16 +876,18 @@ public class HeightedFakeWorld implements World { } @Override - public void setDifficulty(Difficulty difficulty) { + public void setDifficulty(@NotNull Difficulty difficulty) { } + @NotNull @Override public Difficulty getDifficulty() { return null; } + @NotNull @Override public File getWorldFolder() { @@ -981,25 +1028,26 @@ public class HeightedFakeWorld implements World { } @Override - public void playSound(Location location, Sound sound, float volume, float pitch) { + public void playSound(@NotNull Location location, @NotNull Sound sound, float volume, float pitch) { } @Override - public void playSound(Location location, String sound, float volume, float pitch) { + public void playSound(@NotNull Location location, @NotNull String sound, float volume, float pitch) { } @Override - public void playSound(Location location, Sound sound, SoundCategory category, float volume, float pitch) { + public void playSound(@NotNull Location location, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) { } @Override - public void playSound(Location location, String sound, SoundCategory category, float volume, float pitch) { + public void playSound(@NotNull Location location, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch) { } + @NotNull @Override public String[] getGameRules() { @@ -1013,35 +1061,36 @@ public class HeightedFakeWorld implements World { } @Override - public boolean setGameRuleValue(String rule, String value) { + public boolean setGameRuleValue(@NotNull String rule, @NotNull String value) { return false; } @Override - public boolean isGameRule(String rule) { + public boolean isGameRule(@NotNull String rule) { return false; } @Override - public T getGameRuleValue(GameRule rule) { + public T getGameRuleValue(@NotNull GameRule rule) { return null; } @Override - public T getGameRuleDefault(GameRule rule) { + public T getGameRuleDefault(@NotNull GameRule rule) { return null; } @Override - public boolean setGameRule(GameRule rule, T newValue) { + public boolean setGameRule(@NotNull GameRule rule, @NotNull T newValue) { return false; } + @NotNull @Override public WorldBorder getWorldBorder() { @@ -1049,77 +1098,77 @@ public class HeightedFakeWorld implements World { } @Override - public void spawnParticle(Particle particle, Location location, int count) { + public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count) { } @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count) { + public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count) { } @Override - public void spawnParticle(Particle particle, Location location, int count, T data) { + public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, T data) { } @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count, T data) { + public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, T data) { } @Override - public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ) { + public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ) { } @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ) { + public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ) { } @Override - public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, T data) { + public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, T data) { } @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, T data) { + public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, T data) { } @Override - public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra) { + public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra) { } @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra) { + public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra) { } @Override - public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) { + public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) { } @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) { + public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) { } @Override - public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) { + public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) { } @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) { + public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) { } @Override - public Location locateNearestStructure(Location origin, StructureType structureType, int radius, boolean findUnexplored) { + public Location locateNearestStructure(@NotNull Location origin, @NotNull StructureType structureType, int radius, boolean findUnexplored) { return null; } @@ -1128,16 +1177,18 @@ public class HeightedFakeWorld implements World { return 0; } + @NotNull @Override public Spigot spigot() { return null; } @Override - public Raid locateNearestRaid(Location location, int radius) { + public Raid locateNearestRaid(@NotNull Location location, int radius) { return null; } + @NotNull @Override public List getRaids() { return null; diff --git a/src/main/java/com/volmit/iris/util/IController.java b/src/main/java/com/volmit/iris/util/IController.java index 25a14ae22..fb59649b3 100644 --- a/src/main/java/com/volmit/iris/util/IController.java +++ b/src/main/java/com/volmit/iris/util/IController.java @@ -20,6 +20,7 @@ package com.volmit.iris.util; import org.bukkit.event.Listener; +@SuppressWarnings("EmptyMethod") public interface IController extends Listener { String getName(); diff --git a/src/main/java/com/volmit/iris/util/IO.java b/src/main/java/com/volmit/iris/util/IO.java index fbe012615..253b87487 100644 --- a/src/main/java/com/volmit/iris/util/IO.java +++ b/src/main/java/com/volmit/iris/util/IO.java @@ -29,6 +29,7 @@ import java.util.zip.GZIPInputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +@SuppressWarnings("ALL") public class IO { /** * The Unix directory separator character. @@ -68,7 +69,7 @@ public class IO { IO.fullTransfer(gzi, boas, 256); gzi.close(); - return boas.toString(StandardCharsets.UTF_8); + return boas.toString(); } public static byte[] sdecompress(String compressed) throws IOException { @@ -131,7 +132,6 @@ public class IO { * * @param in the input * @param out the output - * @param amount the buffer and size to use * @return the actual transfered amount * @throws IOException shit happens */ @@ -330,30 +330,30 @@ public class IO { throw e; } BufferedReader bu = new BufferedReader(fr); - String c = ""; + StringBuilder c = new StringBuilder(); String l = ""; while ((l = bu.readLine()) != null) { - c += l + "\n"; + c.append(l).append("\n"); } bu.close(); - return c; + return c.toString(); } public static String readAll(InputStream in) throws IOException { BufferedReader bu = new BufferedReader(new InputStreamReader(in)); - String c = ""; + StringBuilder c = new StringBuilder(); String l = ""; while ((l = bu.readLine()) != null) { - c += l + "\n"; + c.append(l).append("\n"); } bu.close(); - return c; + return c.toString(); } /** @@ -385,7 +385,6 @@ public class IO { * @throws NullPointerException if source or destination is null * @throws IOException if source or destination is invalid * @throws IOException if an IO error occurs during copying - * @see #copyFileToDirectory */ public static void copyFile(File srcFile, File destFile) throws IOException { copyFile(srcFile, destFile, true); @@ -406,7 +405,6 @@ public class IO { * @throws NullPointerException if source or destination is null * @throws IOException if source or destination is invalid * @throws IOException if an IO error occurs during copying - * @see #copyFileToDirectory */ public static void copyFile(File srcFile, File destFile, boolean preserveFileDate) throws IOException { if (srcFile == null) { @@ -415,7 +413,7 @@ public class IO { if (destFile == null) { throw new NullPointerException("Destination must not be null"); } - if (srcFile.exists() == false) { + if (!srcFile.exists()) { throw new FileNotFoundException("Source '" + srcFile + "' does not exist"); } if (srcFile.isDirectory()) { @@ -424,12 +422,12 @@ public class IO { if (srcFile.getCanonicalPath().equals(destFile.getCanonicalPath())) { throw new IOException("Source '" + srcFile + "' and destination '" + destFile + "' are the same"); } - if (destFile.getParentFile() != null && destFile.getParentFile().exists() == false) { - if (destFile.getParentFile().mkdirs() == false) { + if (destFile.getParentFile() != null && !destFile.getParentFile().exists()) { + if (!destFile.getParentFile().mkdirs()) { throw new IOException("Destination '" + destFile + "' directory cannot be created"); } } - if (destFile.exists() && destFile.canWrite() == false) { + if (destFile.exists() && !destFile.canWrite()) { throw new IOException("Destination '" + destFile + "' exists but is read-only"); } doCopyFile(srcFile, destFile, preserveFileDate); @@ -611,11 +609,9 @@ public class IO { * * @param input the String to convert * @return the requested byte array - * @throws NullPointerException if the input is null - * @throws IOException if an I/O error occurs (never occurs) * @deprecated Use {@link String#getBytes()} */ - public static byte[] toByteArray(String input) throws IOException { + public static byte[] toByteArray(String input) { return input.getBytes(); } @@ -748,11 +744,9 @@ public class IO { * * @param input the byte array to read from * @return the requested String - * @throws NullPointerException if the input is null - * @throws IOException if an I/O error occurs (never occurs) * @deprecated Use {@link String#String(byte[])} */ - public static String toString(byte[] input) throws IOException { + public static String toString(byte[] input) { return new String(input); } diff --git a/src/main/java/com/volmit/iris/util/InvertedBiomeGrid.java b/src/main/java/com/volmit/iris/util/InvertedBiomeGrid.java index 4602b6bd2..4cfb64cab 100644 --- a/src/main/java/com/volmit/iris/util/InvertedBiomeGrid.java +++ b/src/main/java/com/volmit/iris/util/InvertedBiomeGrid.java @@ -21,6 +21,7 @@ package com.volmit.iris.util; import com.volmit.iris.Iris; import org.bukkit.block.Biome; import org.bukkit.generator.ChunkGenerator.BiomeGrid; +import org.jetbrains.annotations.NotNull; public class InvertedBiomeGrid implements BiomeGrid { private final BiomeGrid grid; @@ -29,12 +30,14 @@ public class InvertedBiomeGrid implements BiomeGrid { this.grid = real; } + @NotNull @SuppressWarnings("deprecation") @Override public Biome getBiome(int arg0, int arg1) { return grid.getBiome(arg0, arg1); } + @NotNull @Override public Biome getBiome(int arg0, int arg1, int arg2) { if (!Iris.biome3d) { @@ -46,12 +49,12 @@ public class InvertedBiomeGrid implements BiomeGrid { @SuppressWarnings("deprecation") @Override - public void setBiome(int arg0, int arg1, Biome arg2) { + public void setBiome(int arg0, int arg1, @NotNull Biome arg2) { grid.setBiome(arg0, arg1, arg2); } @Override - public void setBiome(int arg0, int arg1, int arg2, Biome arg3) { + public void setBiome(int arg0, int arg1, int arg2, @NotNull Biome arg3) { if (!Iris.biome3d) { setBiome(arg0, arg2, arg3); return; diff --git a/src/main/java/com/volmit/iris/util/IrisInterpolation.java b/src/main/java/com/volmit/iris/util/IrisInterpolation.java index f228e10ee..6dc9af108 100644 --- a/src/main/java/com/volmit/iris/util/IrisInterpolation.java +++ b/src/main/java/com/volmit/iris/util/IrisInterpolation.java @@ -848,8 +848,6 @@ public class IrisInterpolation { return getStarcast(x, z, h, 9D, (xx, zz) -> getHermiteNoise((int) xx, (int) zz, h, n, 0D, 0D)); } else if (method.equals(InterpolationMethod.HERMITE_STARCAST_12)) { return getStarcast(x, z, h, 12D, (xx, zz) -> getHermiteNoise((int) xx, (int) zz, h, n, 0D, 0D)); - } else if (method.equals(InterpolationMethod.BICUBIC)) { - return getBicubicNoise(x, z, h, n); } else if (method.equals(InterpolationMethod.BILINEAR_BEZIER)) { return getBilinearBezierNoise(x, z, h, n); } else if (method.equals(InterpolationMethod.BILINEAR_PARAMETRIC_2)) { diff --git a/src/main/java/com/volmit/iris/util/IrisLock.java b/src/main/java/com/volmit/iris/util/IrisLock.java index fe8b3d535..d0e75330d 100644 --- a/src/main/java/com/volmit/iris/util/IrisLock.java +++ b/src/main/java/com/volmit/iris/util/IrisLock.java @@ -47,7 +47,7 @@ public class IrisLock { } try { lock.unlock(); - } catch (Throwable e) { + } catch (Throwable ignored) { } } diff --git a/src/main/java/com/volmit/iris/util/IrisMathHelper.java b/src/main/java/com/volmit/iris/util/IrisMathHelper.java index dd7fca69f..ccc32dc03 100644 --- a/src/main/java/com/volmit/iris/util/IrisMathHelper.java +++ b/src/main/java/com/volmit/iris/util/IrisMathHelper.java @@ -75,30 +75,21 @@ public class IrisMathHelper { if (var0 < var1) { return var1; } - if (var0 > var2) { - return var2; - } - return var0; + return Math.min(var0, var2); } public static float a(final float var0, final float var1, final float var2) { if (var0 < var1) { return var1; } - if (var0 > var2) { - return var2; - } - return var0; + return Math.min(var0, var2); } public static double a(final double var0, final double var2, final double var4) { if (var0 < var2) { return var2; } - if (var0 > var4) { - return var4; - } - return var0; + return Math.min(var0, var4); } public static double b(final double var0, final double var2, final double var4) { @@ -118,7 +109,7 @@ public class IrisMathHelper { if (var2 < 0.0) { var2 = -var2; } - return (var0 > var2) ? var0 : var2; + return Math.max(var0, var2); } public static int a(final int var0, final int var1) { @@ -260,7 +251,7 @@ public class IrisMathHelper { } public static long c(final int var0, final int var1, final int var2) { - long var3 = (long) (var0 * 3129871) ^ var2 * 116129781L ^ (long) var1; + long var3 = (long) (var0 * 3129871L) ^ var2 * 116129781L ^ (long) var1; var3 = var3 * var3 * 42317861L + var3 * 11L; return var3 >> 16; } @@ -340,43 +331,37 @@ public class IrisMathHelper { float var9 = 0.0f; float var10 = 0.0f; switch (var3) { - case 0: { + case 0 -> { var8 = var2; var9 = var7; var10 = var5; - break; } - case 1: { + case 1 -> { var8 = var6; var9 = var2; var10 = var5; - break; } - case 2: { + case 2 -> { var8 = var5; var9 = var2; var10 = var7; - break; } - case 3: { + case 3 -> { var8 = var5; var9 = var6; var10 = var2; - break; } - case 4: { + case 4 -> { var8 = var7; var9 = var5; var10 = var2; - break; } - case 5: { + case 5 -> { var8 = var2; var9 = var5; var10 = var6; - break; } - default: { + default -> { throw new RuntimeException("Something went wrong when converting from HSV to RGB. Input was " + var0 + ", " + var1 + ", " + var2); } } diff --git a/src/main/java/com/volmit/iris/util/J.java b/src/main/java/com/volmit/iris/util/J.java index 2cb6d8ce0..36948193f 100644 --- a/src/main/java/com/volmit/iris/util/J.java +++ b/src/main/java/com/volmit/iris/util/J.java @@ -26,6 +26,7 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; +@SuppressWarnings("ALL") public class J { private static int tid = 0; private static final ExecutorService e = Executors.newCachedThreadPool(new ThreadFactory() { diff --git a/src/main/java/com/volmit/iris/util/JSONArray.java b/src/main/java/com/volmit/iris/util/JSONArray.java index b3a9ed41e..5695464f1 100644 --- a/src/main/java/com/volmit/iris/util/JSONArray.java +++ b/src/main/java/com/volmit/iris/util/JSONArray.java @@ -74,6 +74,7 @@ import java.util.Map; * @author JSON.org * @version 2015-07-22 */ +@SuppressWarnings("ALL") public class JSONArray implements Iterable { /** @@ -870,6 +871,7 @@ public class JSONArray implements Iterable { * @param other The other JSONArray * @return true if they are equal */ + @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean similar(Object other) { if (!(other instanceof JSONArray)) { return false; diff --git a/src/main/java/com/volmit/iris/util/JSONML.java b/src/main/java/com/volmit/iris/util/JSONML.java index 9372240b9..0372ed510 100644 --- a/src/main/java/com/volmit/iris/util/JSONML.java +++ b/src/main/java/com/volmit/iris/util/JSONML.java @@ -39,7 +39,6 @@ public class JSONML { * @param ja The JSONArray that is containing the current tag or null if we * are at the outermost level. * @return A JSONArray if the value is the outermost tag, otherwise null. - * @throws JSONException */ private static Object parse(XMLTokener x, boolean arrayForm, JSONArray ja) throws JSONException { String attribute; @@ -231,7 +230,6 @@ public class JSONML { * * @param string The source string. * @return A JSONArray containing the structured data from the XML string. - * @throws JSONException */ public static JSONArray toJSONArray(String string) throws JSONException { return toJSONArray(new XMLTokener(string)); @@ -248,7 +246,6 @@ public class JSONML { * * @param x An XMLTokener. * @return A JSONArray containing the structured data from the XML string. - * @throws JSONException */ public static JSONArray toJSONArray(XMLTokener x) throws JSONException { return (JSONArray) parse(x, true, null); @@ -266,7 +263,6 @@ public class JSONML { * * @param x An XMLTokener of the XML source text. * @return A JSONObject containing the structured data from the XML string. - * @throws JSONException */ public static JSONObject toJSONObject(XMLTokener x) throws JSONException { return (JSONObject) parse(x, false, null); @@ -284,7 +280,6 @@ public class JSONML { * * @param string The XML source text. * @return A JSONObject containing the structured data from the XML string. - * @throws JSONException */ public static JSONObject toJSONObject(String string) throws JSONException { return toJSONObject(new XMLTokener(string)); @@ -295,7 +290,6 @@ public class JSONML { * * @param ja A JSONArray. * @return An XML string. - * @throws JSONException */ public static String toString(JSONArray ja) throws JSONException { int i; @@ -346,7 +340,6 @@ public class JSONML { length = ja.length(); if (i >= length) { sb.append('/'); - sb.append('>'); } else { sb.append('>'); do { @@ -367,8 +360,8 @@ public class JSONML { sb.append('<'); sb.append('/'); sb.append(tagName); - sb.append('>'); } + sb.append('>'); return sb.toString(); } @@ -380,7 +373,6 @@ public class JSONML { * * @param jo A JSONObject. * @return An XML string. - * @throws JSONException */ public static String toString(JSONObject jo) throws JSONException { StringBuilder sb = new StringBuilder(); @@ -428,7 +420,6 @@ public class JSONML { ja = jo.optJSONArray("childNodes"); if (ja == null) { sb.append('/'); - sb.append('>'); } else { sb.append('>'); length = ja.length(); @@ -449,8 +440,8 @@ public class JSONML { sb.append('<'); sb.append('/'); sb.append(tagName); - sb.append('>'); } + sb.append('>'); return sb.toString(); } } diff --git a/src/main/java/com/volmit/iris/util/JSONObject.java b/src/main/java/com/volmit/iris/util/JSONObject.java index 4e74d357e..8e7f7845a 100644 --- a/src/main/java/com/volmit/iris/util/JSONObject.java +++ b/src/main/java/com/volmit/iris/util/JSONObject.java @@ -79,6 +79,7 @@ import java.util.Map.Entry; * @author JSON.org * @version 2015-07-22 */ +@SuppressWarnings("ALL") public class JSONObject { /** * JSONObject.NULL is equivalent to the value that JavaScript calls null, @@ -1299,6 +1300,7 @@ public class JSONObject { * @param other The other JSONObject * @return true if they are equal */ + @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean similar(Object other) { try { if (!(other instanceof JSONObject)) { diff --git a/src/main/java/com/volmit/iris/util/JSONTokener.java b/src/main/java/com/volmit/iris/util/JSONTokener.java index 9c7a26d34..210a4f4b8 100644 --- a/src/main/java/com/volmit/iris/util/JSONTokener.java +++ b/src/main/java/com/volmit/iris/util/JSONTokener.java @@ -29,6 +29,7 @@ import java.io.*; * @author JSON.org * @version 2014-05-03 */ +@SuppressWarnings("ALL") public class JSONTokener { private long character; diff --git a/src/main/java/com/volmit/iris/util/JSONWriter.java b/src/main/java/com/volmit/iris/util/JSONWriter.java index f2c7f9db6..bde202b2a 100644 --- a/src/main/java/com/volmit/iris/util/JSONWriter.java +++ b/src/main/java/com/volmit/iris/util/JSONWriter.java @@ -83,7 +83,7 @@ public class JSONWriter { /** * The writer that will receive the output. */ - protected Writer writer; + protected final Writer writer; /** * Make a fresh JSONWriter. It can be used to build one JSON text. @@ -283,7 +283,6 @@ public class JSONWriter { * * @param b A boolean. * @return this - * @throws JSONException */ public JSONWriter value(boolean b) throws JSONException { return this.append(b ? "true" : "false"); @@ -305,7 +304,6 @@ public class JSONWriter { * * @param l A long. * @return this - * @throws JSONException */ public JSONWriter value(long l) throws JSONException { return this.append(Long.toString(l)); diff --git a/src/main/java/com/volmit/iris/util/JarScanner.java b/src/main/java/com/volmit/iris/util/JarScanner.java index a1732ae93..b560bc18f 100644 --- a/src/main/java/com/volmit/iris/util/JarScanner.java +++ b/src/main/java/com/volmit/iris/util/JarScanner.java @@ -36,7 +36,7 @@ public class JarScanner { */ public JarScanner(File jar, String superPackage) { this.jar = jar; - this.classes = new KSet>(); + this.classes = new KSet<>(); this.superPackage = superPackage; } diff --git a/src/main/java/com/volmit/iris/util/KList.java b/src/main/java/com/volmit/iris/util/KList.java index c4bb92262..bbda280e3 100644 --- a/src/main/java/com/volmit/iris/util/KList.java +++ b/src/main/java/com/volmit/iris/util/KList.java @@ -24,6 +24,7 @@ import java.util.*; import java.util.function.Function; import java.util.function.Predicate; +@SuppressWarnings("ALL") public class KList extends ArrayList implements List { private static final long serialVersionUID = -2892550695744823337L; @@ -108,7 +109,6 @@ public class KList extends ArrayList implements List { * @param f the function * @return the new map */ - @SuppressWarnings("hiding") public KMap asKeys(Function f) { KMap m = new KMap(); forEach((i) -> m.putNonNull(i, f.apply(i))); @@ -249,7 +249,7 @@ public class KList extends ArrayList implements List { StringBuilder b = new StringBuilder(); for (String i : toStringList()) { - b.append(split + i); + b.append(split).append(i); } return b.substring(split.length()); @@ -272,7 +272,6 @@ public class KList extends ArrayList implements List { * @param converter the converter that converts the forign type into this list type * @return this list (builder) */ - @SuppressWarnings("hiding") public KList addFrom(List v, Function converter) { v.forEach((g) -> add(converter.apply(g))); return this; @@ -286,7 +285,6 @@ public class KList extends ArrayList implements List { * @param converter * @return */ - @SuppressWarnings("hiding") public KList convert(Function converter) { KList v = new KList(); forEach((t) -> v.addNonNull(converter.apply(t))); diff --git a/src/main/java/com/volmit/iris/util/KMap.java b/src/main/java/com/volmit/iris/util/KMap.java index 4d8f7e675..624fd662b 100644 --- a/src/main/java/com/volmit/iris/util/KMap.java +++ b/src/main/java/com/volmit/iris/util/KMap.java @@ -24,7 +24,7 @@ import java.util.Enumeration; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -@SuppressWarnings("hiding") +@SuppressWarnings("ALL") public class KMap extends ConcurrentHashMap { private static final long serialVersionUID = 7288942695300448163L; diff --git a/src/main/java/com/volmit/iris/util/LinkedTerrainChunk.java b/src/main/java/com/volmit/iris/util/LinkedTerrainChunk.java index add29e88b..77d66b6ef 100644 --- a/src/main/java/com/volmit/iris/util/LinkedTerrainChunk.java +++ b/src/main/java/com/volmit/iris/util/LinkedTerrainChunk.java @@ -28,6 +28,7 @@ import org.bukkit.block.data.BlockData; import org.bukkit.generator.ChunkGenerator.BiomeGrid; import org.bukkit.generator.ChunkGenerator.ChunkData; import org.bukkit.material.MaterialData; +import org.jetbrains.annotations.NotNull; @SuppressWarnings("deprecation") public class LinkedTerrainChunk implements TerrainChunk { @@ -69,6 +70,7 @@ public class LinkedTerrainChunk implements TerrainChunk { return (x, y, z, bb) -> INMS.get().forceBiomeInto(x, y, z, bb, storage); } + @NotNull @Override public Biome getBiome(int x, int z) { if (storage != null) { @@ -82,6 +84,7 @@ public class LinkedTerrainChunk implements TerrainChunk { return biome3D.getBiome(x, 0, z); } + @NotNull @Override public Biome getBiome(int x, int y, int z) { if (storage != null) { @@ -144,6 +147,7 @@ public class LinkedTerrainChunk implements TerrainChunk { rawChunkData.setBlock(x, y, z, blockData); } + @NotNull @Override public BlockData getBlockData(int x, int y, int z) { return rawChunkData.getBlockData(x, y, z); @@ -151,39 +155,41 @@ public class LinkedTerrainChunk implements TerrainChunk { @Deprecated @Override - public void setBlock(int x, int y, int z, Material material) { + public void setBlock(int x, int y, int z, @NotNull Material material) { rawChunkData.setBlock(x, y, z, material); } @Deprecated @Override - public void setBlock(int x, int y, int z, MaterialData material) { + public void setBlock(int x, int y, int z, @NotNull MaterialData material) { rawChunkData.setBlock(x, y, z, material); } @Deprecated @Override - public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, Material material) { + public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull Material material) { rawChunkData.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, material); } @Deprecated @Override - public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, MaterialData material) { + public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull MaterialData material) { rawChunkData.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, material); } @Override - public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, BlockData blockData) { + public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull BlockData blockData) { rawChunkData.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, blockData); } + @NotNull @Deprecated @Override public Material getType(int x, int y, int z) { return rawChunkData.getType(x, y, z); } + @NotNull @Deprecated @Override public MaterialData getTypeAndData(int x, int y, int z) { diff --git a/src/main/java/com/volmit/iris/util/ListTag.java b/src/main/java/com/volmit/iris/util/ListTag.java index 0357bf42a..7b48d0e9f 100644 --- a/src/main/java/com/volmit/iris/util/ListTag.java +++ b/src/main/java/com/volmit/iris/util/ListTag.java @@ -73,9 +73,9 @@ public final class ListTag extends Tag { append = "(\"" + this.getName() + "\")"; } StringBuilder bldr = new StringBuilder(); - bldr.append("TAG_List" + append + ": " + value.size() + " entries of type " + NBTUtils.getTypeName(type) + "\r\n{\r\n"); + bldr.append("TAG_List").append(append).append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n"); for (Tag t : value) { - bldr.append(" " + t.toString().replaceAll("\r\n", "\r\n ") + "\r\n"); + bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n"); } bldr.append("}"); return bldr.toString(); diff --git a/src/main/java/com/volmit/iris/util/Looper.java b/src/main/java/com/volmit/iris/util/Looper.java index 2770b1494..b1690627f 100644 --- a/src/main/java/com/volmit/iris/util/Looper.java +++ b/src/main/java/com/volmit/iris/util/Looper.java @@ -21,6 +21,7 @@ package com.volmit.iris.util; import com.volmit.iris.Iris; public abstract class Looper extends Thread { + @SuppressWarnings("BusyWait") public void run() { while (!interrupted()) { try { @@ -30,6 +31,7 @@ public abstract class Looper extends Thread { break; } + //noinspection BusyWait Thread.sleep(m); } catch (InterruptedException e) { break; diff --git a/src/main/java/com/volmit/iris/util/M.java b/src/main/java/com/volmit/iris/util/M.java index 44a673e95..8074d683d 100644 --- a/src/main/java/com/volmit/iris/util/M.java +++ b/src/main/java/com/volmit/iris/util/M.java @@ -90,8 +90,6 @@ public class M { * @param b the second point (1, 0) * @param c the third point (0, 1) * @param d the fourth point (1, 1) - * @param tx the x - * @param ty the y * @return the bilerped value */ public static double bilerp(double a, double b, double c, double d, double x, double y) { @@ -138,6 +136,7 @@ public class M { * @return true if true */ public static boolean r(Double d) { + //noinspection ReplaceNullCheck if (d == null) { return Math.random() < 0.5; } @@ -252,7 +251,6 @@ public class M { /** * Biggest number * - * @param numbers the numbers * @return the biggest one */ @SuppressWarnings("unchecked") @@ -323,7 +321,7 @@ public class M { ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine scriptEngine = mgr.getEngineByName("JavaScript"); - return Double.valueOf(scriptEngine.eval(expression).toString()); + return Double.parseDouble(scriptEngine.eval(expression).toString()); } /** diff --git a/src/main/java/com/volmit/iris/util/MathHelper.java b/src/main/java/com/volmit/iris/util/MathHelper.java index eb446211c..d6bd8ebdd 100644 --- a/src/main/java/com/volmit/iris/util/MathHelper.java +++ b/src/main/java/com/volmit/iris/util/MathHelper.java @@ -96,30 +96,21 @@ public class MathHelper { if (var0 < var1) { return var1; } - if (var0 > var2) { - return var2; - } - return var0; + return Math.min(var0, var2); } public static float a(float var0, float var1, float var2) { if (var0 < var1) { return var1; } - if (var0 > var2) { - return var2; - } - return var0; + return Math.min(var0, var2); } public static double a(double var0, double var2, double var4) { if (var0 < var2) { return var2; } - if (var0 > var4) { - return var4; - } - return var0; + return Math.min(var0, var4); } public static double b(double var0, double var2, double var4) { @@ -139,7 +130,7 @@ public class MathHelper { if (var2 < 0.0) { var2 = -var2; } - return var0 > var2 ? var0 : var2; + return Math.max(var0, var2); } public static int a(int var0, int var1) { @@ -285,7 +276,7 @@ public class MathHelper { } public static long c(int var0, int var1, int var2) { - long var3 = (long) (var0 * 3129871) ^ (long) var2 * 116129781L ^ (long) var1; + long var3 = (var0 * 3129871L) ^ (long) var2 * 116129781L ^ (long) var1; var3 = var3 * var3 * 42317861L + var3 * 11L; return var3 >> 16; } @@ -370,43 +361,37 @@ public class MathHelper { float var6 = var2 * (1.0f - var4 * var1); float var7 = var2 * (1.0f - (1.0f - var4) * var1); switch (var3) { - case 0: { + case 0 -> { var8 = var2; var9 = var7; var10 = var5; - break; } - case 1: { + case 1 -> { var8 = var6; var9 = var2; var10 = var5; - break; } - case 2: { + case 2 -> { var8 = var5; var9 = var2; var10 = var7; - break; } - case 3: { + case 3 -> { var8 = var5; var9 = var6; var10 = var2; - break; } - case 4: { + case 4 -> { var8 = var7; var9 = var5; var10 = var2; - break; } - case 5: { + case 5 -> { var8 = var2; var9 = var5; var10 = var6; - break; } - default: { + default -> { throw new RuntimeException("Something went wrong when converting from HSV to RGB. Input was " + var0 + ", " + var1 + ", " + var2); } } diff --git a/src/main/java/com/volmit/iris/util/Metrics.java b/src/main/java/com/volmit/iris/util/Metrics.java index e2bec55e8..9d8779c50 100644 --- a/src/main/java/com/volmit/iris/util/Metrics.java +++ b/src/main/java/com/volmit/iris/util/Metrics.java @@ -127,10 +127,11 @@ public class Metrics { // Inform the server owners about bStats config.options().header( - "bStats collects some data for plugin authors like how many servers are using their plugins.\n" + - "To honor their work, you should not disable it.\n" + - "This has nearly no effect on the server performance!\n" + - "Check out https://bStats.org/ to learn more :)" + """ + bStats collects some data for plugin authors like how many servers are using their plugins. + To honor their work, you should not disable it. + This has nearly no effect on the server performance! + Check out https://bStats.org/ to learn more :)""" ).copyDefaults(true); try { config.save(configFile); diff --git a/src/main/java/com/volmit/iris/util/MetricsLite.java b/src/main/java/com/volmit/iris/util/MetricsLite.java index 99ea45a38..e84c3ff36 100644 --- a/src/main/java/com/volmit/iris/util/MetricsLite.java +++ b/src/main/java/com/volmit/iris/util/MetricsLite.java @@ -125,7 +125,11 @@ public class MetricsLite { config.addDefault("logResponseStatusText", false); // Inform the server owners about bStats - config.options().header("bStats collects some data for plugin authors like how many servers are using their plugins.\n" + "To honor their work, you should not disable it.\n" + "This has nearly no effect on the server performance!\n" + "Check out https://bStats.org/ to learn more :)").copyDefaults(true); + config.options().header(""" + bStats collects some data for plugin authors like how many servers are using their plugins. + To honor their work, you should not disable it. + This has nearly no effect on the server performance! + Check out https://bStats.org/ to learn more :)""").copyDefaults(true); try { config.save(configFile); } catch (IOException ignored) { diff --git a/src/main/java/com/volmit/iris/util/MortarCommand.java b/src/main/java/com/volmit/iris/util/MortarCommand.java index 4fc8d292e..6c0e0b7ce 100644 --- a/src/main/java/com/volmit/iris/util/MortarCommand.java +++ b/src/main/java/com/volmit/iris/util/MortarCommand.java @@ -47,7 +47,7 @@ public abstract class MortarCommand implements ICommand { public MortarCommand(String node, String... nodes) { category = ""; this.node = node; - this.nodes = new KList(nodes); + this.nodes = new KList<>(nodes); requiredPermissions = new KList<>(); children = buildChildren(); description = "No Description"; @@ -83,7 +83,6 @@ public abstract class MortarCommand implements ICommand { for (MortarCommand i : getChildren()) { for (String j : i.getRequiredPermissions()) { if (!sender.hasPermission(j)) { - continue; } } @@ -132,16 +131,16 @@ public abstract class MortarCommand implements ICommand { if (a.length > past) { int p = past; - String m = ""; + StringBuilder m = new StringBuilder(); for (String i : a) { p--; if (p < 0) { - m += i + ", "; + m.append(i).append(", "); } } - if (!m.trim().isEmpty()) { + if (!m.toString().trim().isEmpty()) { sender.sendMessage("Parameters Ignored: " + m); } } diff --git a/src/main/java/com/volmit/iris/util/MortarSender.java b/src/main/java/com/volmit/iris/util/MortarSender.java index af83fccd4..470ea9541 100644 --- a/src/main/java/com/volmit/iris/util/MortarSender.java +++ b/src/main/java/com/volmit/iris/util/MortarSender.java @@ -107,47 +107,49 @@ public class MortarSender implements CommandSender { } @Override - public boolean isPermissionSet(String name) { + public boolean isPermissionSet(@NotNull String name) { return s.isPermissionSet(name); } @Override - public boolean isPermissionSet(Permission perm) { + public boolean isPermissionSet(@NotNull Permission perm) { return s.isPermissionSet(perm); } @Override - public boolean hasPermission(String name) { + public boolean hasPermission(@NotNull String name) { return s.hasPermission(name); } @Override - public boolean hasPermission(Permission perm) { + public boolean hasPermission(@NotNull Permission perm) { return s.hasPermission(perm); } + @NotNull @Override - public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) { + public PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value) { return s.addAttachment(plugin, name, value); } + @NotNull @Override - public PermissionAttachment addAttachment(Plugin plugin) { + public PermissionAttachment addAttachment(@NotNull Plugin plugin) { return s.addAttachment(plugin); } @Override - public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) { + public PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks) { return s.addAttachment(plugin, name, value, ticks); } @Override - public PermissionAttachment addAttachment(Plugin plugin, int ticks) { + public PermissionAttachment addAttachment(@NotNull Plugin plugin, int ticks) { return s.addAttachment(plugin, ticks); } @Override - public void removeAttachment(PermissionAttachment attachment) { + public void removeAttachment(@NotNull PermissionAttachment attachment) { s.removeAttachment(attachment); } @@ -156,6 +158,7 @@ public class MortarSender implements CommandSender { s.recalculatePermissions(); } + @NotNull @Override public Set getEffectivePermissions() { return s.getEffectivePermissions(); @@ -176,7 +179,7 @@ public class MortarSender implements CommandSender { } @Override - public void sendMessage(String message) { + public void sendMessage(@NotNull String message) { s.sendMessage(C.translateAlternateColorCodes('&', getTag()) + message); } @@ -196,16 +199,19 @@ public class MortarSender implements CommandSender { sendMessage(messages); } + @NotNull @Override public Server getServer() { return s.getServer(); } + @NotNull @Override public String getName() { return s.getName(); } + @NotNull @Override public Spigot spigot() { return s.spigot(); diff --git a/src/main/java/com/volmit/iris/util/NBTConstants.java b/src/main/java/com/volmit/iris/util/NBTConstants.java index 6d538f661..0e8300f5b 100644 --- a/src/main/java/com/volmit/iris/util/NBTConstants.java +++ b/src/main/java/com/volmit/iris/util/NBTConstants.java @@ -21,8 +21,8 @@ package com.volmit.iris.util; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; -/** - * Changes : Neil Wightman - Support 19133 Tag_Int_Array tag +/* + Changes : Neil Wightman - Support 19133 Tag_Int_Array tag */ /** diff --git a/src/main/java/com/volmit/iris/util/NBTInputStream.java b/src/main/java/com/volmit/iris/util/NBTInputStream.java index ff7e86354..95e4d2fab 100644 --- a/src/main/java/com/volmit/iris/util/NBTInputStream.java +++ b/src/main/java/com/volmit/iris/util/NBTInputStream.java @@ -28,9 +28,9 @@ import java.util.List; import java.util.Map; import java.util.zip.GZIPInputStream; -/** - * Changes : - * Neil Wightman - Support 19133 Tag_Int_Array tag +/* + Changes : + Neil Wightman - Support 19133 Tag_Int_Array tag */ /** @@ -147,7 +147,7 @@ public final class NBTInputStream implements Closeable { int childType = is.readByte(); length = is.readInt(); - List tagList = new ArrayList(); + List tagList = new ArrayList<>(); for (int i = 0; i < length; i++) { Tag tag = readTagPayload(childType, "", depth + 1); if (tag instanceof EndTag) { @@ -158,7 +158,7 @@ public final class NBTInputStream implements Closeable { return new ListTag(name, NBTUtils.getTypeClass(childType), tagList); case NBTConstants.TYPE_COMPOUND: - Map tagMap = new HashMap(); + Map tagMap = new HashMap<>(); while (true) { Tag tag = readTag(depth + 1); if (tag instanceof EndTag) { diff --git a/src/main/java/com/volmit/iris/util/NBTOutputStream.java b/src/main/java/com/volmit/iris/util/NBTOutputStream.java index 8402b4c42..8ca1d05b7 100644 --- a/src/main/java/com/volmit/iris/util/NBTOutputStream.java +++ b/src/main/java/com/volmit/iris/util/NBTOutputStream.java @@ -24,8 +24,8 @@ import java.io.IOException; import java.io.OutputStream; import java.util.List; import java.util.zip.GZIPOutputStream; -/** - * Changes : Neil Wightman - Support 19133 Tag_Int_Array tag +/* + Changes : Neil Wightman - Support 19133 Tag_Int_Array tag */ /** @@ -39,6 +39,7 @@ import java.util.zip.GZIPOutputStream; * * @author Graham Edgecombe */ +@SuppressWarnings({"EmptyMethod", "JavaDoc"}) public final class NBTOutputStream implements Closeable { /** @@ -97,44 +98,19 @@ public final class NBTOutputStream implements Closeable { private void writeTagPayload(Tag tag) throws IOException { int type = NBTUtils.getTypeCode(tag.getClass()); switch (type) { - case NBTConstants.TYPE_END: - writeEndTagPayload((EndTag) tag); - break; - case NBTConstants.TYPE_BYTE: - writeByteTagPayload((ByteTag) tag); - break; - case NBTConstants.TYPE_SHORT: - writeShortTagPayload((ShortTag) tag); - break; - case NBTConstants.TYPE_INT: - writeIntTagPayload((IntTag) tag); - break; - case NBTConstants.TYPE_LONG: - writeLongTagPayload((LongTag) tag); - break; - case NBTConstants.TYPE_FLOAT: - writeFloatTagPayload((FloatTag) tag); - break; - case NBTConstants.TYPE_DOUBLE: - writeDoubleTagPayload((DoubleTag) tag); - break; - case NBTConstants.TYPE_BYTE_ARRAY: - writeByteArrayTagPayload((ByteArrayTag) tag); - break; - case NBTConstants.TYPE_STRING: - writeStringTagPayload((StringTag) tag); - break; - case NBTConstants.TYPE_LIST: - writeListTagPayload((ListTag) tag); - break; - case NBTConstants.TYPE_COMPOUND: - writeCompoundTagPayload((CompoundTag) tag); - break; - case NBTConstants.TYPE_INT_ARRAY: - writeIntArrayTagPayload((IntArrayTag) tag); - break; - default: - throw new IOException("Invalid tag type: " + type + "."); + case NBTConstants.TYPE_END -> writeEndTagPayload((EndTag) tag); + case NBTConstants.TYPE_BYTE -> writeByteTagPayload((ByteTag) tag); + case NBTConstants.TYPE_SHORT -> writeShortTagPayload((ShortTag) tag); + case NBTConstants.TYPE_INT -> writeIntTagPayload((IntTag) tag); + case NBTConstants.TYPE_LONG -> writeLongTagPayload((LongTag) tag); + case NBTConstants.TYPE_FLOAT -> writeFloatTagPayload((FloatTag) tag); + case NBTConstants.TYPE_DOUBLE -> writeDoubleTagPayload((DoubleTag) tag); + case NBTConstants.TYPE_BYTE_ARRAY -> writeByteArrayTagPayload((ByteArrayTag) tag); + case NBTConstants.TYPE_STRING -> writeStringTagPayload((StringTag) tag); + case NBTConstants.TYPE_LIST -> writeListTagPayload((ListTag) tag); + case NBTConstants.TYPE_COMPOUND -> writeCompoundTagPayload((CompoundTag) tag); + case NBTConstants.TYPE_INT_ARRAY -> writeIntArrayTagPayload((IntArrayTag) tag); + default -> throw new IOException("Invalid tag type: " + type + "."); } } @@ -187,8 +163,8 @@ public final class NBTOutputStream implements Closeable { os.writeByte(NBTUtils.getTypeCode(clazz)); os.writeInt(size); - for (int i = 0; i < size; i++) { - writeTagPayload(tags.get(i)); + for (Tag value : tags) { + writeTagPayload(value); } } diff --git a/src/main/java/com/volmit/iris/util/NBTUtils.java b/src/main/java/com/volmit/iris/util/NBTUtils.java index 290a11dcc..08ff8d664 100644 --- a/src/main/java/com/volmit/iris/util/NBTUtils.java +++ b/src/main/java/com/volmit/iris/util/NBTUtils.java @@ -18,8 +18,8 @@ package com.volmit.iris.util; -/** - * Changes : Neil Wightman - Support 19133 Tag_Int_Array tag +/* + Changes : Neil Wightman - Support 19133 Tag_Int_Array tag */ /** @@ -110,34 +110,21 @@ public final class NBTUtils { * @throws IllegalArgumentException if the tag type is invalid. */ public static Class getTypeClass(int type) { - switch (type) { - case NBTConstants.TYPE_END: - return EndTag.class; - case NBTConstants.TYPE_BYTE: - return ByteTag.class; - case NBTConstants.TYPE_SHORT: - return ShortTag.class; - case NBTConstants.TYPE_INT: - return IntTag.class; - case NBTConstants.TYPE_LONG: - return LongTag.class; - case NBTConstants.TYPE_FLOAT: - return FloatTag.class; - case NBTConstants.TYPE_DOUBLE: - return DoubleTag.class; - case NBTConstants.TYPE_BYTE_ARRAY: - return ByteArrayTag.class; - case NBTConstants.TYPE_STRING: - return StringTag.class; - case NBTConstants.TYPE_LIST: - return ListTag.class; - case NBTConstants.TYPE_COMPOUND: - return CompoundTag.class; - case NBTConstants.TYPE_INT_ARRAY: - return IntArrayTag.class; - default: - throw new IllegalArgumentException("Invalid tag type : " + type + "."); - } + return switch (type) { + case NBTConstants.TYPE_END -> EndTag.class; + case NBTConstants.TYPE_BYTE -> ByteTag.class; + case NBTConstants.TYPE_SHORT -> ShortTag.class; + case NBTConstants.TYPE_INT -> IntTag.class; + case NBTConstants.TYPE_LONG -> LongTag.class; + case NBTConstants.TYPE_FLOAT -> FloatTag.class; + case NBTConstants.TYPE_DOUBLE -> DoubleTag.class; + case NBTConstants.TYPE_BYTE_ARRAY -> ByteArrayTag.class; + case NBTConstants.TYPE_STRING -> StringTag.class; + case NBTConstants.TYPE_LIST -> ListTag.class; + case NBTConstants.TYPE_COMPOUND -> CompoundTag.class; + case NBTConstants.TYPE_INT_ARRAY -> IntArrayTag.class; + default -> throw new IllegalArgumentException("Invalid tag type : " + type + "."); + }; } /** diff --git a/src/main/java/com/volmit/iris/util/NMSVersion.java b/src/main/java/com/volmit/iris/util/NMSVersion.java index 946d613e1..b1a96acfb 100644 --- a/src/main/java/com/volmit/iris/util/NMSVersion.java +++ b/src/main/java/com/volmit/iris/util/NMSVersion.java @@ -129,7 +129,7 @@ public enum NMSVersion { try { Class.forName("org.bukkit.craftbukkit.v" + v + ".CraftWorld"); return true; - } catch (Throwable e) { + } catch (Throwable ignored) { } diff --git a/src/main/java/com/volmit/iris/util/NastyFunction.java b/src/main/java/com/volmit/iris/util/NastyFunction.java index 79f719ad9..c62568d3e 100644 --- a/src/main/java/com/volmit/iris/util/NastyFunction.java +++ b/src/main/java/com/volmit/iris/util/NastyFunction.java @@ -19,5 +19,5 @@ package com.volmit.iris.util; public interface NastyFunction { - R run(T t) throws Throwable; + R run(T t); } diff --git a/src/main/java/com/volmit/iris/util/NastyFuture.java b/src/main/java/com/volmit/iris/util/NastyFuture.java index db713be61..77ae7ccd6 100644 --- a/src/main/java/com/volmit/iris/util/NastyFuture.java +++ b/src/main/java/com/volmit/iris/util/NastyFuture.java @@ -19,5 +19,5 @@ package com.volmit.iris.util; public interface NastyFuture { - R run() throws Throwable; + R run(); } diff --git a/src/main/java/com/volmit/iris/util/NibbleArray.java b/src/main/java/com/volmit/iris/util/NibbleArray.java index ddaac8bdd..153179e04 100644 --- a/src/main/java/com/volmit/iris/util/NibbleArray.java +++ b/src/main/java/com/volmit/iris/util/NibbleArray.java @@ -139,8 +139,8 @@ public class NibbleArray implements Writable { public String toBitsString(ByteOrder byteOrder) { StringJoiner joiner = new StringJoiner(" "); - for (int i = 0; i < data.length; i++) { - joiner.add(binaryString(data[i], byteOrder)); + for (byte datum : data) { + joiner.add(binaryString(datum, byteOrder)); } return joiner.toString(); diff --git a/src/main/java/com/volmit/iris/util/O.java b/src/main/java/com/volmit/iris/util/O.java index 18ead5d20..e2e2f9974 100644 --- a/src/main/java/com/volmit/iris/util/O.java +++ b/src/main/java/com/volmit/iris/util/O.java @@ -29,11 +29,10 @@ public class O implements Observable { @Override public O set(T t) { - T x = t; this.t = t; if (observers != null && observers.hasElements()) { - observers.forEach((o) -> o.onChanged(x, t)); + observers.forEach((o) -> o.onChanged(t, t)); } return this; diff --git a/src/main/java/com/volmit/iris/util/ObjectResourceLoader.java b/src/main/java/com/volmit/iris/util/ObjectResourceLoader.java index 1f86ee7ad..65d481d27 100644 --- a/src/main/java/com/volmit/iris/util/ObjectResourceLoader.java +++ b/src/main/java/com/volmit/iris/util/ObjectResourceLoader.java @@ -151,7 +151,7 @@ public class ObjectResourceLoader extends ResourceLoader { } KList v = new KList<>(m); - possibleKeys = v.toArray(new String[v.size()]); + possibleKeys = v.toArray(new String[0]); return possibleKeys; } diff --git a/src/main/java/com/volmit/iris/util/ParticleSenderLegacy.java b/src/main/java/com/volmit/iris/util/ParticleSenderLegacy.java index e4c997ca7..ca08d5a9a 100644 --- a/src/main/java/com/volmit/iris/util/ParticleSenderLegacy.java +++ b/src/main/java/com/volmit/iris/util/ParticleSenderLegacy.java @@ -33,7 +33,7 @@ import java.lang.reflect.Method; * * @author MrMicky */ -@SuppressWarnings("deprecation") +@SuppressWarnings({"deprecation", "JavaReflectionInvocation"}) class ParticleSenderLegacy implements ParticleSender { private static final boolean SERVER_IS_1_8; @@ -158,20 +158,18 @@ class ParticleSenderLegacy implements ParticleSender { private int[] toData(ParticleType particle, Object data) { Class dataType = particle.getDataType(); if (dataType == ItemStack.class) { - if (!(data instanceof ItemStack)) { + if (!(data instanceof ItemStack itemStack)) { return SERVER_IS_1_8 ? new int[2] : new int[]{1, 0}; } - ItemStack itemStack = (ItemStack) data; return new int[]{itemStack.getType().getId(), itemStack.getDurability()}; } if (dataType == MaterialData.class) { - if (!(data instanceof MaterialData)) { + if (!(data instanceof MaterialData materialData)) { return SERVER_IS_1_8 ? new int[1] : new int[]{1, 0}; } - MaterialData materialData = (MaterialData) data; if (SERVER_IS_1_8) { return new int[]{materialData.getItemType().getId() + (materialData.getData() << 12)}; } else { diff --git a/src/main/java/com/volmit/iris/util/ParticleType.java b/src/main/java/com/volmit/iris/util/ParticleType.java index 52e273582..b4ce9430a 100644 --- a/src/main/java/com/volmit/iris/util/ParticleType.java +++ b/src/main/java/com/volmit/iris/util/ParticleType.java @@ -161,19 +161,14 @@ public enum ParticleType { } public Class getDataType() { - switch (this) { - case ITEM_CRACK: - return ItemStack.class; - case BLOCK_CRACK: - case BLOCK_DUST: - case FALLING_DUST: - //noinspection deprecation - return MaterialData.class; - case REDSTONE: - return Color.class; - default: - return Void.class; - } + return switch (this) { + case ITEM_CRACK -> ItemStack.class; + case BLOCK_CRACK, BLOCK_DUST, FALLING_DUST -> + //noinspection deprecation + MaterialData.class; + case REDSTONE -> Color.class; + default -> Void.class; + }; } public static ParticleType getParticle(String particleName) { diff --git a/src/main/java/com/volmit/iris/util/Queue.java b/src/main/java/com/volmit/iris/util/Queue.java index 75c344bee..17310f457 100644 --- a/src/main/java/com/volmit/iris/util/Queue.java +++ b/src/main/java/com/volmit/iris/util/Queue.java @@ -18,6 +18,7 @@ package com.volmit.iris.util; +@SuppressWarnings("ALL") public interface Queue { Queue queue(T t); diff --git a/src/main/java/com/volmit/iris/util/QueueExecutor.java b/src/main/java/com/volmit/iris/util/QueueExecutor.java index a15a2b709..bfc2d5307 100644 --- a/src/main/java/com/volmit/iris/util/QueueExecutor.java +++ b/src/main/java/com/volmit/iris/util/QueueExecutor.java @@ -23,7 +23,7 @@ public class QueueExecutor extends Looper { private boolean shutdown; public QueueExecutor() { - queue = new ShurikenQueue(); + queue = new ShurikenQueue<>(); shutdown = false; } diff --git a/src/main/java/com/volmit/iris/util/RNG.java b/src/main/java/com/volmit/iris/util/RNG.java index 7ca3a9a54..2616fdfc7 100644 --- a/src/main/java/com/volmit/iris/util/RNG.java +++ b/src/main/java/com/volmit/iris/util/RNG.java @@ -45,7 +45,7 @@ public class RNG extends Random { * @param seed the seed (string) */ public RNG(String seed) { - this(UUID.nameUUIDFromBytes(seed.getBytes(StandardCharsets.UTF_8)).getLeastSignificantBits() + UUID.nameUUIDFromBytes(seed.getBytes(StandardCharsets.UTF_8)).getMostSignificantBits() + (seed.length() * 32564)); + this(UUID.nameUUIDFromBytes(seed.getBytes(StandardCharsets.UTF_8)).getLeastSignificantBits() + UUID.nameUUIDFromBytes(seed.getBytes(StandardCharsets.UTF_8)).getMostSignificantBits() + (seed.length() * 32564L)); } public RNG nextParallelRNG(int signature) { diff --git a/src/main/java/com/volmit/iris/util/ResourceLoader.java b/src/main/java/com/volmit/iris/util/ResourceLoader.java index 54b8f2fed..ea11748c7 100644 --- a/src/main/java/com/volmit/iris/util/ResourceLoader.java +++ b/src/main/java/com/volmit/iris/util/ResourceLoader.java @@ -99,7 +99,7 @@ public class ResourceLoader { } KList v = new KList<>(m); - possibleKeys = v.toArray(new String[v.size()]); + possibleKeys = v.toArray(new String[0]); return possibleKeys; } @@ -140,8 +140,7 @@ public class ResourceLoader { String key = name + "-" + cname; if (loadCache.containsKey(key)) { - T t = loadCache.get(key); - return t; + return loadCache.get(key); } lock.lock(); diff --git a/src/main/java/com/volmit/iris/util/RouterCommand.java b/src/main/java/com/volmit/iris/util/RouterCommand.java index 76eca95fa..df4fa1eb0 100644 --- a/src/main/java/com/volmit/iris/util/RouterCommand.java +++ b/src/main/java/com/volmit/iris/util/RouterCommand.java @@ -21,6 +21,7 @@ package com.volmit.iris.util; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.jetbrains.annotations.NotNull; /** * Assistive command router @@ -44,19 +45,21 @@ public class RouterCommand extends org.bukkit.command.Command { this.ex = ex; } + @NotNull @Override - public Command setUsage(String u) { + public Command setUsage(@NotNull String u) { this.usage = u; return this; } + @NotNull @Override public String getUsage() { return usage; } @Override - public boolean execute(CommandSender sender, String commandLabel, String[] args) { + public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) { return ex.onCommand(sender, this, commandLabel, args); } } diff --git a/src/main/java/com/volmit/iris/util/SKConversion.java b/src/main/java/com/volmit/iris/util/SKConversion.java index 47d23c3ca..bfa553576 100644 --- a/src/main/java/com/volmit/iris/util/SKConversion.java +++ b/src/main/java/com/volmit/iris/util/SKConversion.java @@ -28,7 +28,6 @@ import com.volmit.iris.object.IrisObject; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; public class SKConversion { @@ -48,8 +47,6 @@ public class SKConversion { } o.write(out); - } catch (FileNotFoundException e) { - e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/util/ShurikenQueue.java b/src/main/java/com/volmit/iris/util/ShurikenQueue.java index 5dad610e4..ce0589b13 100644 --- a/src/main/java/com/volmit/iris/util/ShurikenQueue.java +++ b/src/main/java/com/volmit/iris/util/ShurikenQueue.java @@ -81,7 +81,7 @@ public class ShurikenQueue implements Queue { @Override public ShurikenQueue clear() { - queue = new KList(); + queue = new KList<>(); return this; } diff --git a/src/main/java/com/volmit/iris/util/Spiraler.java b/src/main/java/com/volmit/iris/util/Spiraler.java index 0e2524945..58036d898 100644 --- a/src/main/java/com/volmit/iris/util/Spiraler.java +++ b/src/main/java/com/volmit/iris/util/Spiraler.java @@ -18,6 +18,7 @@ package com.volmit.iris.util; +@SuppressWarnings("EmptyMethod") public class Spiraler { int x, z, dx, dz, sizeX, sizeZ, t, maxI, i; int ox, oz; diff --git a/src/main/java/com/volmit/iris/util/TaskExecutor.java b/src/main/java/com/volmit/iris/util/TaskExecutor.java index ab6ebc660..c6717ec61 100644 --- a/src/main/java/com/volmit/iris/util/TaskExecutor.java +++ b/src/main/java/com/volmit/iris/util/TaskExecutor.java @@ -45,14 +45,11 @@ public class TaskExecutor { return t; }); } else if (threadLimit > 1) { - final ForkJoinWorkerThreadFactory factory = new ForkJoinWorkerThreadFactory() { - @Override - public ForkJoinWorkerThread newThread(ForkJoinPool pool) { - final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool); - worker.setName(name + " " + xc++); - worker.setPriority(priority); - return worker; - } + final ForkJoinWorkerThreadFactory factory = pool -> { + final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool); + worker.setName(name + " " + xc++); + worker.setPriority(priority); + return worker; }; service = new ForkJoinPool(threadLimit, factory, null, false); @@ -120,8 +117,9 @@ public class TaskExecutor { waiting: while (true) { try { + //noinspection BusyWait Thread.sleep(0); - } catch (InterruptedException e1) { + } catch (InterruptedException ignored) { } @@ -150,6 +148,7 @@ public class TaskExecutor { } } + @SuppressWarnings("ClassCanBeRecord") @ToString public static class TaskResult { public TaskResult(double timeElapsed, int tasksExecuted, int tasksFailed, int tasksCompleted) { diff --git a/src/main/java/com/volmit/iris/util/TerrainChunk.java b/src/main/java/com/volmit/iris/util/TerrainChunk.java index 9e03be1fb..038ccab9d 100644 --- a/src/main/java/com/volmit/iris/util/TerrainChunk.java +++ b/src/main/java/com/volmit/iris/util/TerrainChunk.java @@ -24,6 +24,7 @@ import org.bukkit.block.Biome; import org.bukkit.block.data.BlockData; import org.bukkit.generator.ChunkGenerator.BiomeGrid; import org.bukkit.generator.ChunkGenerator.ChunkData; +import org.jetbrains.annotations.NotNull; public interface TerrainChunk extends BiomeGrid, ChunkData { static TerrainChunk create(World world) { @@ -58,6 +59,7 @@ public interface TerrainChunk extends BiomeGrid, ChunkData { * @return Biome value * @deprecated biomes are now 3-dimensional */ + @NotNull @Deprecated Biome getBiome(int x, int z); @@ -69,6 +71,7 @@ public interface TerrainChunk extends BiomeGrid, ChunkData { * @param z - 0-15 * @return Biome value */ + @NotNull Biome getBiome(int x, int y, int z); /** @@ -80,7 +83,7 @@ public interface TerrainChunk extends BiomeGrid, ChunkData { * @deprecated biomes are now 3-dimensional */ @Deprecated - void setBiome(int x, int z, Biome bio); + void setBiome(int x, int z, @NotNull Biome bio); /** * Set biome at x, z within chunk being generated @@ -90,7 +93,7 @@ public interface TerrainChunk extends BiomeGrid, ChunkData { * @param z - 0-15 * @param bio - Biome value */ - void setBiome(int x, int y, int z, Biome bio); + void setBiome(int x, int y, int z, @NotNull Biome bio); /** * Get the maximum height for the chunk. @@ -112,7 +115,7 @@ public interface TerrainChunk extends BiomeGrid, ChunkData { * @param z the z location in the chunk from 0-15 inclusive * @param blockData the type to set the block to */ - void setBlock(int x, int y, int z, BlockData blockData); + void setBlock(int x, int y, int z, @NotNull BlockData blockData); /** * Get the type and data of the block at x, y, z. @@ -126,6 +129,7 @@ public interface TerrainChunk extends BiomeGrid, ChunkData { * @return the data of the block or the BlockData for air if x, y or z are * outside the chunk's bounds */ + @NotNull BlockData getBlockData(int x, int y, int z); ChunkData getRaw(); diff --git a/src/main/java/com/volmit/iris/util/ThreadMonitor.java b/src/main/java/com/volmit/iris/util/ThreadMonitor.java index 5a80259cc..30a98b020 100644 --- a/src/main/java/com/volmit/iris/util/ThreadMonitor.java +++ b/src/main/java/com/volmit/iris/util/ThreadMonitor.java @@ -47,6 +47,7 @@ public class ThreadMonitor extends Thread { public void run() { while (running) { try { + //noinspection BusyWait Thread.sleep(0); State s = monitor.getState(); if (lastState != s) { diff --git a/src/main/java/com/volmit/iris/util/Tuple2d.java b/src/main/java/com/volmit/iris/util/Tuple2d.java index b6a5cc491..e4a0ebd54 100644 --- a/src/main/java/com/volmit/iris/util/Tuple2d.java +++ b/src/main/java/com/volmit/iris/util/Tuple2d.java @@ -311,9 +311,7 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { try { Tuple2d t2 = (Tuple2d) t1; return (this.x == t2.x && this.y == t2.y); - } catch (NullPointerException e2) { - return false; - } catch (ClassCastException e1) { + } catch (NullPointerException | ClassCastException e2) { return false; } @@ -363,19 +361,11 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { public final void clamp(double min, double max, Tuple2d t) { if (t.x > max) { x = max; - } else if (t.x < min) { - x = min; - } else { - x = t.x; - } + } else x = Math.max(t.x, min); if (t.y > max) { y = max; - } else if (t.y < min) { - y = min; - } else { - y = t.y; - } + } else y = Math.max(t.y, min); } @@ -388,17 +378,9 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * @param t the source tuple, which will not be modified */ public final void clampMin(double min, Tuple2d t) { - if (t.x < min) { - x = min; - } else { - x = t.x; - } + x = Math.max(t.x, min); - if (t.y < min) { - y = min; - } else { - y = t.y; - } + y = Math.max(t.y, min); } @@ -411,17 +393,9 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable { * @param t the source tuple, which will not be modified */ public final void clampMax(double max, Tuple2d t) { - if (t.x > max) { - x = max; - } else { - x = t.x; - } + x = Math.min(t.x, max); - if (t.y > max) { - y = max; - } else { - y = t.y; - } + y = Math.min(t.y, max); } diff --git a/src/main/java/com/volmit/iris/util/Tuple2f.java b/src/main/java/com/volmit/iris/util/Tuple2f.java index 457083ba7..91cc48409 100644 --- a/src/main/java/com/volmit/iris/util/Tuple2f.java +++ b/src/main/java/com/volmit/iris/util/Tuple2f.java @@ -313,9 +313,7 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { try { Tuple2f t2 = (Tuple2f) t1; return (this.x == t2.x && this.y == t2.y); - } catch (NullPointerException e2) { - return false; - } catch (ClassCastException e1) { + } catch (NullPointerException | ClassCastException e2) { return false; } @@ -365,19 +363,11 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { public final void clamp(float min, float max, Tuple2f t) { if (t.x > max) { x = max; - } else if (t.x < min) { - x = min; - } else { - x = t.x; - } + } else x = Math.max(t.x, min); if (t.y > max) { y = max; - } else if (t.y < min) { - y = min; - } else { - y = t.y; - } + } else y = Math.max(t.y, min); } @@ -390,17 +380,9 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * @param t the source tuple, which will not be modified */ public final void clampMin(float min, Tuple2f t) { - if (t.x < min) { - x = min; - } else { - x = t.x; - } + x = Math.max(t.x, min); - if (t.y < min) { - y = min; - } else { - y = t.y; - } + y = Math.max(t.y, min); } @@ -413,17 +395,9 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable { * @param t the source tuple, which will not be modified */ public final void clampMax(float max, Tuple2f t) { - if (t.x > max) { - x = max; - } else { - x = t.x; - } + x = Math.min(t.x, max); - if (t.y > max) { - y = max; - } else { - y = t.y; - } + y = Math.min(t.y, max); } diff --git a/src/main/java/com/volmit/iris/util/Tuple3d.java b/src/main/java/com/volmit/iris/util/Tuple3d.java index 747fe6b7b..a7842a21f 100644 --- a/src/main/java/com/volmit/iris/util/Tuple3d.java +++ b/src/main/java/com/volmit/iris/util/Tuple3d.java @@ -361,9 +361,7 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { try { Tuple3d t2 = (Tuple3d) t1; return (this.x == t2.x && this.y == t2.y && this.z == t2.z); - } catch (ClassCastException e1) { - return false; - } catch (NullPointerException e2) { + } catch (ClassCastException | NullPointerException e1) { return false; } @@ -416,27 +414,15 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { public final void clamp(double min, double max, Tuple3d t) { if (t.x > max) { x = max; - } else if (t.x < min) { - x = min; - } else { - x = t.x; - } + } else x = Math.max(t.x, min); if (t.y > max) { y = max; - } else if (t.y < min) { - y = min; - } else { - y = t.y; - } + } else y = Math.max(t.y, min); if (t.z > max) { z = max; - } else if (t.z < min) { - z = min; - } else { - z = t.z; - } + } else z = Math.max(t.z, min); } @@ -457,23 +443,11 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * @param t the source tuple, which will not be modified */ public final void clampMin(double min, Tuple3d t) { - if (t.x < min) { - x = min; - } else { - x = t.x; - } + x = Math.max(t.x, min); - if (t.y < min) { - y = min; - } else { - y = t.y; - } + y = Math.max(t.y, min); - if (t.z < min) { - z = min; - } else { - z = t.z; - } + z = Math.max(t.z, min); } @@ -494,23 +468,11 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable { * @param t the source tuple, which will not be modified */ public final void clampMax(double max, Tuple3d t) { - if (t.x > max) { - x = max; - } else { - x = t.x; - } + x = Math.min(t.x, max); - if (t.y > max) { - y = max; - } else { - y = t.y; - } + y = Math.min(t.y, max); - if (t.z > max) { - z = max; - } else { - z = t.z; - } + z = Math.min(t.z, max); } diff --git a/src/main/java/com/volmit/iris/util/Tuple3f.java b/src/main/java/com/volmit/iris/util/Tuple3f.java index a49a39377..d038b0b3b 100644 --- a/src/main/java/com/volmit/iris/util/Tuple3f.java +++ b/src/main/java/com/volmit/iris/util/Tuple3f.java @@ -346,9 +346,7 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { try { Tuple3f t2 = (Tuple3f) t1; return (this.x == t2.x && this.y == t2.y && this.z == t2.z); - } catch (NullPointerException e2) { - return false; - } catch (ClassCastException e1) { + } catch (NullPointerException | ClassCastException e2) { return false; } } @@ -411,27 +409,15 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { public final void clamp(float min, float max, Tuple3f t) { if (t.x > max) { x = max; - } else if (t.x < min) { - x = min; - } else { - x = t.x; - } + } else x = Math.max(t.x, min); if (t.y > max) { y = max; - } else if (t.y < min) { - y = min; - } else { - y = t.y; - } + } else y = Math.max(t.y, min); if (t.z > max) { z = max; - } else if (t.z < min) { - z = min; - } else { - z = t.z; - } + } else z = Math.max(t.z, min); } @@ -444,23 +430,11 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * @param t the source tuple, which will not be modified */ public final void clampMin(float min, Tuple3f t) { - if (t.x < min) { - x = min; - } else { - x = t.x; - } + x = Math.max(t.x, min); - if (t.y < min) { - y = min; - } else { - y = t.y; - } + y = Math.max(t.y, min); - if (t.z < min) { - z = min; - } else { - z = t.z; - } + z = Math.max(t.z, min); } @@ -473,23 +447,11 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable { * @param t the source tuple, which will not be modified */ public final void clampMax(float max, Tuple3f t) { - if (t.x > max) { - x = max; - } else { - x = t.x; - } + x = Math.min(t.x, max); - if (t.y > max) { - y = max; - } else { - y = t.y; - } + y = Math.min(t.y, max); - if (t.z > max) { - z = max; - } else { - z = t.z; - } + z = Math.min(t.z, max); } diff --git a/src/main/java/com/volmit/iris/util/Tuple4d.java b/src/main/java/com/volmit/iris/util/Tuple4d.java index 56551f4ab..64ffed5d0 100644 --- a/src/main/java/com/volmit/iris/util/Tuple4d.java +++ b/src/main/java/com/volmit/iris/util/Tuple4d.java @@ -387,9 +387,7 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { Tuple4d t2 = (Tuple4d) t1; return (this.x == t2.x && this.y == t2.y && this.z == t2.z && this.w == t2.w); - } catch (NullPointerException e2) { - return false; - } catch (ClassCastException e1) { + } catch (NullPointerException | ClassCastException e2) { return false; } } @@ -466,35 +464,19 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { public final void clamp(double min, double max, Tuple4d t) { if (t.x > max) { x = max; - } else if (t.x < min) { - x = min; - } else { - x = t.x; - } + } else x = Math.max(t.x, min); if (t.y > max) { y = max; - } else if (t.y < min) { - y = min; - } else { - y = t.y; - } + } else y = Math.max(t.y, min); if (t.z > max) { z = max; - } else if (t.z < min) { - z = min; - } else { - z = t.z; - } + } else z = Math.max(t.z, min); if (t.w > max) { w = max; - } else if (t.w < min) { - w = min; - } else { - w = t.w; - } + } else w = Math.max(t.w, min); } @@ -515,29 +497,13 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * @param t the source tuple, which will not be modified */ public final void clampMin(double min, Tuple4d t) { - if (t.x < min) { - x = min; - } else { - x = t.x; - } + x = Math.max(t.x, min); - if (t.y < min) { - y = min; - } else { - y = t.y; - } + y = Math.max(t.y, min); - if (t.z < min) { - z = min; - } else { - z = t.z; - } + z = Math.max(t.z, min); - if (t.w < min) { - w = min; - } else { - w = t.w; - } + w = Math.max(t.w, min); } @@ -558,23 +524,11 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable { * @param t the source tuple, which will not be modified */ public final void clampMax(double max, Tuple4d t) { - if (t.x > max) { - x = max; - } else { - x = t.x; - } + x = Math.min(t.x, max); - if (t.y > max) { - y = max; - } else { - y = t.y; - } + y = Math.min(t.y, max); - if (t.z > max) { - z = max; - } else { - z = t.z; - } + z = Math.min(t.z, max); if (t.w > max) { w = max; diff --git a/src/main/java/com/volmit/iris/util/Tuple4f.java b/src/main/java/com/volmit/iris/util/Tuple4f.java index 145e75a8a..41ddcf3ea 100644 --- a/src/main/java/com/volmit/iris/util/Tuple4f.java +++ b/src/main/java/com/volmit/iris/util/Tuple4f.java @@ -374,9 +374,7 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { Tuple4f t2 = (Tuple4f) t1; return (this.x == t2.x && this.y == t2.y && this.z == t2.z && this.w == t2.w); - } catch (NullPointerException e2) { - return false; - } catch (ClassCastException e1) { + } catch (NullPointerException | ClassCastException e2) { return false; } } @@ -444,35 +442,19 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { public final void clamp(float min, float max, Tuple4f t) { if (t.x > max) { x = max; - } else if (t.x < min) { - x = min; - } else { - x = t.x; - } + } else x = Math.max(t.x, min); if (t.y > max) { y = max; - } else if (t.y < min) { - y = min; - } else { - y = t.y; - } + } else y = Math.max(t.y, min); if (t.z > max) { z = max; - } else if (t.z < min) { - z = min; - } else { - z = t.z; - } + } else z = Math.max(t.z, min); if (t.w > max) { w = max; - } else if (t.w < min) { - w = min; - } else { - w = t.w; - } + } else w = Math.max(t.w, min); } @@ -485,29 +467,13 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * @param t the source tuple, which will not be modified */ public final void clampMin(float min, Tuple4f t) { - if (t.x < min) { - x = min; - } else { - x = t.x; - } + x = Math.max(t.x, min); - if (t.y < min) { - y = min; - } else { - y = t.y; - } + y = Math.max(t.y, min); - if (t.z < min) { - z = min; - } else { - z = t.z; - } + z = Math.max(t.z, min); - if (t.w < min) { - w = min; - } else { - w = t.w; - } + w = Math.max(t.w, min); } @@ -521,23 +487,11 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable { * @param t the source tuple, which will not be modified */ public final void clampMax(float max, Tuple4f t) { - if (t.x > max) { - x = max; - } else { - x = t.x; - } + x = Math.min(t.x, max); - if (t.y > max) { - y = max; - } else { - y = t.y; - } + y = Math.min(t.y, max); - if (t.z > max) { - z = max; - } else { - z = t.z; - } + z = Math.min(t.z, max); if (t.w > max) { w = max; diff --git a/src/main/java/com/volmit/iris/util/UIElement.java b/src/main/java/com/volmit/iris/util/UIElement.java index dea5f60ad..7b756474c 100644 --- a/src/main/java/com/volmit/iris/util/UIElement.java +++ b/src/main/java/com/volmit/iris/util/UIElement.java @@ -53,7 +53,7 @@ public class UIElement implements Element { } public Double clip(double value, double min, double max) { - return Double.valueOf(Math.min(max, Math.max(min, value))); + return Math.min(max, Math.max(min, value)); } @Override @@ -134,26 +134,32 @@ public class UIElement implements Element { public Element call(ElementEvent event, Element context) { try { switch (event) { - case DRAG_INTO: + case DRAG_INTO -> { eDraggedInto.run(context); return this; - case LEFT: + } + case LEFT -> { eLeft.run(context); return this; - case OTHER_DRAG_INTO: + } + case OTHER_DRAG_INTO -> { eOtherDraggedInto.run(context); return this; - case RIGHT: + } + case RIGHT -> { eRight.run(context); return this; - case SHIFT_LEFT: + } + case SHIFT_LEFT -> { eShiftLeft.run(context); return this; - case SHIFT_RIGHT: + } + case SHIFT_RIGHT -> { eShiftRight.run(context); return this; + } } - } catch (NullPointerException e) { + } catch (NullPointerException ignored) { } catch (Throwable e) { e.printStackTrace(); diff --git a/src/main/java/com/volmit/iris/util/UIStaticDecorator.java b/src/main/java/com/volmit/iris/util/UIStaticDecorator.java index a7b5d45dd..edfd1707c 100644 --- a/src/main/java/com/volmit/iris/util/UIStaticDecorator.java +++ b/src/main/java/com/volmit/iris/util/UIStaticDecorator.java @@ -20,6 +20,7 @@ package com.volmit.iris.util; import org.bukkit.Material; +@SuppressWarnings("ClassCanBeRecord") public class UIStaticDecorator implements WindowDecorator { private final Element element; diff --git a/src/main/java/com/volmit/iris/util/UIWindow.java b/src/main/java/com/volmit/iris/util/UIWindow.java index 308efb5a2..d879ee38f 100644 --- a/src/main/java/com/volmit/iris/util/UIWindow.java +++ b/src/main/java/com/volmit/iris/util/UIWindow.java @@ -85,55 +85,31 @@ public class UIWindow implements Window, Listener { switch (e.getAction()) { case CLONE_STACK: - break; - case COLLECT_TO_CURSOR: - break; - case DROP_ALL_CURSOR: - break; - case DROP_ALL_SLOT: - break; - case DROP_ONE_CURSOR: - break; - case DROP_ONE_SLOT: - break; - case HOTBAR_MOVE_AND_READD: - break; - case HOTBAR_SWAP: - break; - case MOVE_TO_OTHER_INVENTORY: - break; - case NOTHING: - break; - case PICKUP_ALL: - break; - case PICKUP_HALF: - break; - case PICKUP_ONE: - break; - case PICKUP_SOME: - break; - case PLACE_ALL: - break; - case PLACE_ONE: - break; - case PLACE_SOME: - break; - case SWAP_WITH_CURSOR: - break; case UNKNOWN: + case SWAP_WITH_CURSOR: + case PLACE_SOME: + case PLACE_ONE: + case PLACE_ALL: + case PICKUP_SOME: + case PICKUP_ONE: + case PICKUP_HALF: + case PICKUP_ALL: + case NOTHING: + case MOVE_TO_OTHER_INVENTORY: + case HOTBAR_SWAP: + case HOTBAR_MOVE_AND_READD: + case DROP_ONE_SLOT: + case DROP_ONE_CURSOR: + case DROP_ALL_SLOT: + case DROP_ALL_CURSOR: + case COLLECT_TO_CURSOR: break; } switch (e.getClick()) { - case CONTROL_DROP: - break; - case CREATIVE: - break; case DOUBLE_CLICK: doubleclicked = true; break; - case DROP: - break; case LEFT: clickcheck++; @@ -162,10 +138,6 @@ public class UIWindow implements Window, Listener { }); } - break; - case MIDDLE: - break; - case NUMBER_KEY: break; case RIGHT: if (element != null) { @@ -184,14 +156,15 @@ public class UIWindow implements Window, Listener { element.call(ElementEvent.SHIFT_RIGHT, element); } break; - case WINDOW_BORDER_LEFT: - break; - case WINDOW_BORDER_RIGHT: - break; - case UNKNOWN: - break; case SWAP_OFFHAND: - break; + case UNKNOWN: + case WINDOW_BORDER_RIGHT: + case WINDOW_BORDER_LEFT: + case NUMBER_KEY: + case MIDDLE: + case DROP: + case CREATIVE: + case CONTROL_DROP: default: break; } @@ -414,7 +387,7 @@ public class UIWindow implements Window, Listener { } public Double clip(double value, double min, double max) { - return Double.valueOf(Math.min(max, Math.max(min, value))); + return Math.min(max, Math.max(min, value)); } @Override @@ -437,7 +410,7 @@ public class UIWindow implements Window, Listener { public Window updateInventory() { if (isVisible()) { ItemStack[] is = inventory.getContents(); - KSet isf = new KSet(); + @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") KSet isf = new KSet<>(); for (int i = 0; i < is.length; i++) { ItemStack isc = is[i]; diff --git a/src/main/java/com/volmit/iris/util/V.java b/src/main/java/com/volmit/iris/util/V.java index 713dbd751..73e499a63 100644 --- a/src/main/java/com/volmit/iris/util/V.java +++ b/src/main/java/com/volmit/iris/util/V.java @@ -100,14 +100,14 @@ public class V { } public Object invoke(String method, Object... parameters) { - KList> par = new KList>(); + KList> par = new KList<>(); for (Object i : parameters) { par.add(i.getClass()); } try { - return (local ? Violator.getDeclaredMethod(o.getClass(), method, par.toArray(new Class[par.size()])) : Violator.getMethod(o.getClass(), method, par.toArray(new Class[par.size()]))).invoke(o, parameters); + return (local ? Violator.getDeclaredMethod(o.getClass(), method, par.toArray(new Class[0])) : Violator.getMethod(o.getClass(), method, par.toArray(new Class[0]))).invoke(o, parameters); } catch (Throwable e) { if (!suppress) { e.printStackTrace(); diff --git a/src/main/java/com/volmit/iris/util/VectorMath.java b/src/main/java/com/volmit/iris/util/VectorMath.java index 68db740f4..068944b07 100644 --- a/src/main/java/com/volmit/iris/util/VectorMath.java +++ b/src/main/java/com/volmit/iris/util/VectorMath.java @@ -32,16 +32,12 @@ import org.bukkit.util.Vector; */ public class VectorMath { public static Vector scaleStatic(Axis x, Vector v, double amt) { - switch (x) { - case X: - return scaleX(v, amt); - case Y: - return scaleY(v, amt); - case Z: - return scaleZ(v, amt); - } + return switch (x) { + case X -> scaleX(v, amt); + case Y -> scaleY(v, amt); + case Z -> scaleZ(v, amt); + }; - return null; } public static Vector scaleX(Vector v, double amt) { @@ -227,7 +223,7 @@ public class VectorMath { } private static double round(double value, int precision) { - return Double.valueOf(Form.f(value, precision)); + return Double.parseDouble(Form.f(value, precision)); } public static Vector clip(Vector v, int decimals) { @@ -247,9 +243,10 @@ public class VectorMath { u = axis.getX(); v = axis.getY(); w = axis.getZ(); - double xPrime = u * (u * x + v * y + w * z) * (1d - Math.cos(theta)) + x * Math.cos(theta) + (-w * y + v * z) * Math.sin(theta); - double yPrime = v * (u * x + v * y + w * z) * (1d - Math.cos(theta)) + y * Math.cos(theta) + (w * x - u * z) * Math.sin(theta); - double zPrime = w * (u * x + v * y + w * z) * (1d - Math.cos(theta)) + z * Math.cos(theta) + (-v * x + u * y) * Math.sin(theta); + double f = u * x + v * y + w * z; + double xPrime = u * (f) * (1d - Math.cos(theta)) + x * Math.cos(theta) + (-w * y + v * z) * Math.sin(theta); + double yPrime = v * (f) * (1d - Math.cos(theta)) + y * Math.cos(theta) + (w * x - u * z) * Math.sin(theta); + double zPrime = w * (f) * (1d - Math.cos(theta)) + z * Math.cos(theta) + (-v * x + u * y) * Math.sin(theta); return clip(new Vector(xPrime, yPrime, zPrime), 4); } @@ -262,7 +259,7 @@ public class VectorMath { * @return multiple faces, or one if the face is already simple */ public static KList split(BlockFace f) { - KList faces = new KList(); + KList faces = new KList<>(); switch (f) { case DOWN: @@ -441,7 +438,7 @@ public class VectorMath { * @return the shifted vectors */ public static KList shift(Vector vector, KList vectors) { - return new KList(new GListAdapter() { + return new KList<>(new GListAdapter() { @Override public Vector onAdapt(Vector from) { return from.add(vector); diff --git a/src/main/java/com/volmit/iris/util/Violator.java b/src/main/java/com/volmit/iris/util/Violator.java index a8d0a1836..b00923800 100644 --- a/src/main/java/com/volmit/iris/util/Violator.java +++ b/src/main/java/com/volmit/iris/util/Violator.java @@ -25,7 +25,7 @@ import java.lang.reflect.Method; import java.util.concurrent.ConcurrentSkipListMap; public class Violator { - protected static ConcurrentSkipListMap nodes = new ConcurrentSkipListMap(); + protected static final ConcurrentSkipListMap nodes = new ConcurrentSkipListMap<>(); private static String id(Object o, Object h) { if (o instanceof Field) { @@ -40,34 +40,32 @@ public class Violator { return ((Class) o).getCanonicalName(); } - if (o instanceof Constructor) { - Constructor co = (Constructor) o; + if (o instanceof Constructor co) { - String mx = ""; + StringBuilder mx = new StringBuilder(); for (Class i : co.getParameterTypes()) { - mx += "," + i.getCanonicalName(); + mx.append(",").append(i.getCanonicalName()); } - mx = mx.length() >= 1 ? mx.substring(1) : mx; + mx = new StringBuilder(mx.length() >= 1 ? mx.substring(1) : mx.toString()); return id(co.getDeclaringClass(), null) + "(" + mx + ")"; } if (o instanceof Method) { - String mx = ""; + StringBuilder mx = new StringBuilder(); for (Class i : ((Method) o).getParameterTypes()) { - mx += "," + i.getCanonicalName(); + mx.append(",").append(i.getCanonicalName()); } - mx = mx.length() >= 1 ? mx.substring(1) : mx; + mx = new StringBuilder(mx.length() >= 1 ? mx.substring(1) : mx.toString()); return id(((Method) o).getDeclaringClass(), null) + "." + ((Method) o).getName() + "(" + mx + ")"; } - if (o instanceof Annotation) { - Annotation a = (Annotation) o; + if (o instanceof Annotation a) { return "@" + a.annotationType().getCanonicalName() + "[" + id(h, null) + "]"; } @@ -78,6 +76,7 @@ public class Violator { nodes.put(n, o); } + @SuppressWarnings("BooleanMethodIsAlwaysInverted") private static boolean h(String n) { return nodes.containsKey(n); } @@ -87,13 +86,13 @@ public class Violator { } public static Constructor getConstructor(Class c, Class... params) throws NoSuchMethodException, SecurityException { - String mx = ""; + StringBuilder mx = new StringBuilder(); for (Class i : params) { - mx += "," + i.getCanonicalName(); + mx.append(",").append(i.getCanonicalName()); } - mx = mx.length() >= 1 ? mx.substring(1) : mx; + mx = new StringBuilder(mx.length() >= 1 ? mx.substring(1) : mx.toString()); if (!h(id(c, null) + "(" + mx + ")")) { Constructor co = c.getConstructor(params); @@ -148,13 +147,13 @@ public class Violator { public static Method getMethod(Class c, String name, Class... pars) throws Throwable { String iv = ""; - String mx = ""; + StringBuilder mx = new StringBuilder(); for (Class i : pars) { - mx += "," + i.getCanonicalName(); + mx.append(",").append(i.getCanonicalName()); } - mx = mx.length() >= 1 ? mx.substring(1) : mx; + mx = new StringBuilder(mx.length() >= 1 ? mx.substring(1) : mx.toString()); iv = id(c, null) + "." + name + "(" + mx + ")"; if (!h(iv)) { @@ -168,14 +167,14 @@ public class Violator { @SuppressWarnings("unchecked") public static T construct(Class c, Object... parameters) { - KList> cv = new KList>(); + KList> cv = new KList<>(); for (Object i : parameters) { cv.add(i.getClass()); } try { - Constructor co = getConstructor(c, cv.toArray(new Class[cv.size()])); + Constructor co = getConstructor(c, cv.toArray(new Class[0])); return (T) co.newInstance(parameters); } catch (Exception e) { e.printStackTrace(); @@ -186,13 +185,13 @@ public class Violator { public static Method getDeclaredMethod(Class c, String name, Class... pars) throws Throwable { String iv = ""; - String mx = ""; + StringBuilder mx = new StringBuilder(); for (Class i : pars) { - mx += "," + i.getCanonicalName(); + mx.append(",").append(i.getCanonicalName()); } - mx = mx.length() >= 1 ? mx.substring(1) : mx; + mx = new StringBuilder(mx.length() >= 1 ? mx.substring(1) : mx.toString()); iv = id(c, null) + "." + name + "(" + mx + ")"; if (!h(iv)) { @@ -205,7 +204,7 @@ public class Violator { } @SuppressWarnings("unchecked") - public static T getAnnotation(Class c, Class a) throws Throwable { + public static T getAnnotation(Class c, Class a) { if (!h("@" + a.getCanonicalName() + "[" + c.getCanonicalName() + "]")) { T f = c.getAnnotation(a); p(id(f, c), f); @@ -215,7 +214,7 @@ public class Violator { } @SuppressWarnings("unchecked") - public static T getDeclaredAnnotation(Class c, Class a) throws Throwable { + public static T getDeclaredAnnotation(Class c, Class a) { if (!h("@" + a.getCanonicalName() + "[" + c.getCanonicalName() + "]")) { T f = c.getDeclaredAnnotation(a); p(id(f, c), f); @@ -225,7 +224,7 @@ public class Violator { } @SuppressWarnings("unchecked") - public static T getAnnotation(Field c, Class a) throws Throwable { + public static T getAnnotation(Field c, Class a) { if (!h("@" + a.getCanonicalName() + "[" + id(c, null) + "]")) { T f = c.getAnnotation(a); p(id(f, c), f); @@ -235,7 +234,7 @@ public class Violator { } @SuppressWarnings("unchecked") - public static T getDeclaredAnnotation(Field c, Class a) throws Throwable { + public static T getDeclaredAnnotation(Field c, Class a) { if (!h("@" + a.getCanonicalName() + "[" + id(c, null) + "]")) { T f = c.getDeclaredAnnotation(a); p(id(f, c), f); @@ -245,7 +244,7 @@ public class Violator { } @SuppressWarnings("unchecked") - public static T getAnnotation(Method c, Class a) throws Throwable { + public static T getAnnotation(Method c, Class a) { if (!h("@" + a.getCanonicalName() + "[" + id(c, null) + "]")) { T f = c.getAnnotation(a); p(id(f, c), f); @@ -255,7 +254,7 @@ public class Violator { } @SuppressWarnings("unchecked") - public static T getDeclaredAnnotation(Method c, Class a) throws Throwable { + public static T getDeclaredAnnotation(Method c, Class a) { if (!h("@" + a.getCanonicalName() + "[" + id(c, null) + "]")) { T f = c.getDeclaredAnnotation(a); p(id(f, c), f); diff --git a/src/main/java/com/volmit/iris/util/VirtualCommand.java b/src/main/java/com/volmit/iris/util/VirtualCommand.java index 72d8f875e..776cc1492 100644 --- a/src/main/java/com/volmit/iris/util/VirtualCommand.java +++ b/src/main/java/com/volmit/iris/util/VirtualCommand.java @@ -44,7 +44,7 @@ public class VirtualCommand { public VirtualCommand(ICommand command, String tag) { this.command = command; - children = new KMap, VirtualCommand>(); + children = new KMap<>(); this.tag = tag; for (Field i : command.getClass().getDeclaredFields()) { @@ -117,7 +117,7 @@ public class VirtualCommand { return true; } - return command.handle(vs, chain.toArray(new String[chain.size()])); + return command.handle(vs, chain.toArray(new String[0])); } public KList hitTab(CommandSender sender, KList chain, String label) { @@ -156,9 +156,10 @@ public class VirtualCommand { return null; } - return command.handleTab(vs, chain.toArray(new String[chain.size()])); + return command.handleTab(vs, chain.toArray(new String[0])); } + @SuppressWarnings("BooleanMethodIsAlwaysInverted") private boolean checkPermissions(CommandSender sender, ICommand command2) { boolean failed = false; diff --git a/src/main/java/com/volmit/iris/util/VoidOutputStream.java b/src/main/java/com/volmit/iris/util/VoidOutputStream.java index ece583f81..05b2bd0be 100644 --- a/src/main/java/com/volmit/iris/util/VoidOutputStream.java +++ b/src/main/java/com/volmit/iris/util/VoidOutputStream.java @@ -18,12 +18,11 @@ package com.volmit.iris.util; -import java.io.IOException; import java.io.OutputStream; public class VoidOutputStream extends OutputStream { @Override - public void write(int b) throws IOException { + public void write(int b) { // poof } } diff --git a/src/main/java/com/volmit/iris/util/VolmitPlugin.java b/src/main/java/com/volmit/iris/util/VolmitPlugin.java index 7c55cc353..d8b00ff1e 100644 --- a/src/main/java/com/volmit/iris/util/VolmitPlugin.java +++ b/src/main/java/com/volmit/iris/util/VolmitPlugin.java @@ -45,8 +45,9 @@ import java.util.List; import java.util.Map; import java.util.SortedSet; +@SuppressWarnings("EmptyMethod") public abstract class VolmitPlugin extends JavaPlugin implements Listener { - public static boolean bad = false; + public static final boolean bad = false; private KMap, VirtualCommand> commands; private KList commandCache; private KList permissionCache; @@ -70,14 +71,17 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { Field pluginsField = Bukkit.getPluginManager().getClass().getDeclaredField("plugins"); pluginsField.setAccessible(true); + //noinspection unchecked plugins = (List) pluginsField.get(getServer().getPluginManager()); Field lookupNamesField = Bukkit.getPluginManager().getClass().getDeclaredField("lookupNames"); lookupNamesField.setAccessible(true); + //noinspection unchecked names = (Map) lookupNamesField.get(getServer().getPluginManager()); try { Field listenersField = Bukkit.getPluginManager().getClass().getDeclaredField("listeners"); listenersField.setAccessible(true); + //noinspection unchecked listeners = (Map>) listenersField.get(getServer().getPluginManager()); } catch (Throwable ignored) { @@ -88,9 +92,10 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { commandMap = (SimpleCommandMap) commandMapField.get(getServer().getPluginManager()); Field knownCommandsField = SimpleCommandMap.class.getDeclaredField("knownCommands"); knownCommandsField.setAccessible(true); + //noinspection unchecked commands = (Map) knownCommandsField.get(commandMap); - } catch (Throwable e) { + } catch (Throwable ignored) { } @@ -106,8 +111,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { for (Iterator> it = commands.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = it.next(); - if (entry.getValue() instanceof PluginCommand) { - PluginCommand c = (PluginCommand) entry.getValue(); + if (entry.getValue() instanceof PluginCommand c) { if (c.getPlugin() == plugin) { c.unregister(commandMap); it.remove(); @@ -163,7 +167,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { registerCommands(); registerControllers(); Bukkit.getScheduler().scheduleSyncRepeatingTask(this, this::tickControllers, 0, 0); - J.a(() -> outputInfo()); + J.a(this::outputInfo); registerListener(this); start(); } @@ -183,7 +187,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { outputPluginInfo(); outputCommandInfo(); outputPermissionInfo(); - } catch (Throwable e) { + } catch (Throwable ignored) { } } @@ -199,7 +203,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { } private void chain(MortarPermission i, FileConfiguration fc) { - KList ff = new KList(); + KList ff = new KList<>(); for (MortarPermission j : i.getChildren()) { ff.add(j.getFullNode()); @@ -264,7 +268,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { for (org.bukkit.permissions.Permission i : computePermissions()) { try { Bukkit.getPluginManager().addPermission(i); - } catch (Throwable e) { + } catch (Throwable ignored) { } } @@ -482,7 +486,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { @Override public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) { - KList chain = new KList(); + KList chain = new KList<>(); for (String i : args) { if (i.trim().isEmpty()) { @@ -509,12 +513,12 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { } @Override - public boolean onCommand(CommandSender sender, org.bukkit.command.Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull org.bukkit.command.Command command, @NotNull String label, @NotNull String[] args) { if (bad) { return false; } - KList chain = new KList(); + KList chain = new KList<>(); chain.add(args); for (KList i : commands.k()) { @@ -619,7 +623,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { for (VirtualCommand i : commands.v()) { try { unregisterCommand(i.getCommand()); - } catch (Throwable e) { + } catch (Throwable ignored) { } } @@ -652,13 +656,13 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { } public File getDataFile(String... strings) { - File f = new File(getDataFolder(), new KList(strings).toString(File.separator)); + File f = new File(getDataFolder(), new KList<>(strings).toString(File.separator)); f.getParentFile().mkdirs(); return f; } public File getDataFileList(String pre, String[] strings) { - KList v = new KList(strings); + KList v = new KList<>(strings); v.add(0, pre); File f = new File(getDataFolder(), v.toString(File.separator)); f.getParentFile().mkdirs(); @@ -670,7 +674,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener { return super.getDataFolder(); } - File f = new File(getDataFolder(), new KList(strings).toString(File.separator)); + File f = new File(getDataFolder(), new KList<>(strings).toString(File.separator)); f.mkdirs(); return f; diff --git a/src/main/java/com/volmit/iris/util/WeightMap.java b/src/main/java/com/volmit/iris/util/WeightMap.java index 26bc4647f..1dda57598 100644 --- a/src/main/java/com/volmit/iris/util/WeightMap.java +++ b/src/main/java/com/volmit/iris/util/WeightMap.java @@ -52,7 +52,7 @@ public class WeightMap extends KMap { } modified = false; - Shrinkwrap s = new Shrinkwrap(0D); + Shrinkwrap s = new Shrinkwrap<>(0D); forEachKey(Integer.MAX_VALUE, (d) -> s.set(s.get() + 1)); lastWeight = s.get(); diff --git a/src/main/java/com/volmit/iris/util/Wrapper.java b/src/main/java/com/volmit/iris/util/Wrapper.java index 6d6301ae3..7cc405a75 100644 --- a/src/main/java/com/volmit/iris/util/Wrapper.java +++ b/src/main/java/com/volmit/iris/util/Wrapper.java @@ -49,11 +49,10 @@ public class Wrapper { if (obj == null) { return false; } - if (!(obj instanceof Wrapper)) { + if (!(obj instanceof Wrapper other)) { return false; } - Wrapper other = (Wrapper) obj; if (t == null) { return other.t == null; } else return t.equals(other.t); diff --git a/src/main/java/com/volmit/iris/util/XML.java b/src/main/java/com/volmit/iris/util/XML.java index aeac870e0..86c5eb232 100644 --- a/src/main/java/com/volmit/iris/util/XML.java +++ b/src/main/java/com/volmit/iris/util/XML.java @@ -93,23 +93,12 @@ public class XML { for (int i = 0, length = string.length(); i < length; i++) { char c = string.charAt(i); switch (c) { - case '&': - sb.append("&"); - break; - case '<': - sb.append("<"); - break; - case '>': - sb.append(">"); - break; - case '"': - sb.append("""); - break; - case '\'': - sb.append("'"); - break; - default: - sb.append(c); + case '&' -> sb.append("&"); + case '<' -> sb.append("<"); + case '>' -> sb.append(">"); + case '"' -> sb.append("""); + case '\'' -> sb.append("'"); + default -> sb.append(c); } } return sb.toString(); @@ -120,7 +109,6 @@ public class XML { * allowed in tagNames and attributes. * * @param string A string. - * @throws JSONException */ public static void noSpace(String string) throws JSONException { int i, length = string.length(); @@ -141,7 +129,6 @@ public class XML { * @param context The JSONObject that will include the new material. * @param name The tag name. * @return true if the close tag is processed. - * @throws JSONException */ private static boolean parse(XMLTokener x, JSONObject context, String name) throws JSONException { char c; @@ -340,7 +327,7 @@ public class XML { if (value.toString().equals(string)) { return value; } - } catch (Exception ignoreAlso) { + } catch (Exception ignored) { } } return string; @@ -359,7 +346,6 @@ public class XML { * * @param string The source string. * @return A JSONObject containing the structured data from the XML string. - * @throws JSONException */ public static JSONObject toJSONObject(String string) throws JSONException { JSONObject jo = new JSONObject(); @@ -375,7 +361,6 @@ public class XML { * * @param object A JSONObject. * @return A string. - * @throws JSONException */ public static String toString(Object object) throws JSONException { return toString(object, null); @@ -387,7 +372,6 @@ public class XML { * @param object A JSONObject. * @param tagName The optional name of the enclosing tag. * @return A string. - * @throws JSONException */ public static String toString(Object object, String tagName) throws JSONException { StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/com/volmit/iris/util/XMLTokener.java b/src/main/java/com/volmit/iris/util/XMLTokener.java index 26e4bcad5..02cb2e735 100644 --- a/src/main/java/com/volmit/iris/util/XMLTokener.java +++ b/src/main/java/com/volmit/iris/util/XMLTokener.java @@ -35,7 +35,7 @@ public class XMLTokener extends JSONTokener { public static final java.util.HashMap entity; static { - entity = new java.util.HashMap(8); + entity = new java.util.HashMap<>(8); entity.put("amp", XML.AMP); entity.put("apos", XML.APOS); entity.put("gt", XML.GT); @@ -83,7 +83,6 @@ public class XMLTokener extends JSONTokener { * * @return A string, or a '<' Character, or null if there is no more source * text. - * @throws JSONException */ public Object nextContent() throws JSONException { char c; @@ -187,17 +186,10 @@ public class XMLTokener extends JSONTokener { return Boolean.TRUE; } switch (c) { - case 0: - case '<': - case '>': - case '/': - case '=': - case '!': - case '?': - case '"': - case '\'': + case 0, '<', '>', '/', '=', '!', '?', '"', '\'' -> { back(); return Boolean.TRUE; + } } } } @@ -291,7 +283,6 @@ public class XMLTokener extends JSONTokener { * are left at the end of the source with a result of false. * * @param to A string to skip past. - * @throws JSONException */ public boolean skipPast(String to) throws JSONException { boolean b;