From 9ba90d8c83f71af01c0a33ac31f027b981aa240c Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 9 Jan 2022 10:55:16 +0100 Subject: [PATCH] refactor: Drop custom snakeyaml implementation (#1523) * refactor: Drop custom snakeyaml implementation * Merge branch 'main' into chore/main/remove-snakeyaml-wannabe-abstraction --- .../v1_17_R1_2/PaperweightFaweAdapter.java | 5 +- .../PaperweightFaweWorldNativeAccess.java | 4 +- .../fawe/v1_17_R1_2/PaperweightGetBlocks.java | 23 +- .../v1_17_R1_2/PaperweightGetBlocks_Copy.java | 1 + .../PaperweightPlatformAdapter.java | 2 + .../PaperweightStarlightRelighter.java | 1 + .../PaperweightStarlightRelighterFactory.java | 1 + .../nbt/PaperweightLazyCompoundTag.java | 3 + .../v1_17_R1_2/regen/PaperweightRegen.java | 14 +- .../PaperweightFaweWorldNativeAccess.java | 4 +- .../fawe/v1_18_R1/PaperweightGetBlocks.java | 3 + .../v1_18_R1/PaperweightGetBlocks_Copy.java | 1 + .../v1_18_R1/PaperweightPlatformAdapter.java | 27 +- .../PaperweightStarlightRelighter.java | 1 + .../PaperweightStarlightRelighterFactory.java | 1 + .../nbt/PaperweightLazyCompoundTag.java | 3 + .../fawe/v1_18_R1/regen/PaperweightRegen.java | 2 + .../bukkit/adapter/BukkitQueueHandler.java | 2 - .../bukkit/listener/BrushListener.java | 3 +- .../bukkit/regions/WorldGuardFeature.java | 3 +- .../FaweDelegateRegionManager.java | 1 + .../FaweDelegateSchematicHandler.java | 1 + .../plotsquared/FaweQueueCoordinator.java | 1 + .../regions/plotsquared/PlotSetBiome.java | 1 + .../fastasyncworldedit/core/FaweCache.java | 12 +- .../core/command/tool/brush/AngleBrush.java | 8 +- .../core/command/tool/brush/BlobBrush.java | 14 +- .../command/tool/brush/CatenaryBrush.java | 3 +- .../core/command/tool/brush/CircleBrush.java | 25 +- .../core/command/tool/brush/CommandBrush.java | 3 +- .../core/command/tool/brush/ImageBrush.java | 5 +- .../core/command/tool/brush/InspectBrush.java | 2 - .../command/tool/brush/PopulateSchem.java | 14 +- .../core/command/tool/brush/RecurseBrush.java | 8 +- .../core/command/tool/brush/RockBrush.java | 12 +- .../command/tool/brush/ScatterCommand.java | 3 +- .../core/command/tool/brush/SplineBrush.java | 57 -- .../core/command/tool/brush/StencilBrush.java | 3 +- .../tool/brush/SurfaceSphereBrush.java | 1 - .../core/command/tool/scroll/Scroll.java | 2 - .../command/tool/sweep/ClipboardSpline.java | 3 - .../core/command/tool/sweep/Spline.java | 17 +- .../core/command/tool/sweep/SweepBrush.java | 9 +- .../core/configuration/Caption.java | 5 +- .../core/configuration/Config.java | 31 - .../InvalidConfigurationException.java | 1 - .../core/configuration/MemorySection.java | 21 +- .../core/configuration/Settings.java | 2 + .../core/configuration/Yaml.java | 607 ------------------ .../configuration/file/YamlConfiguration.java | 7 +- .../ConfigurationSerialization.java | 43 +- .../core/entity/LazyBaseEntity.java | 1 - .../core/entity/MapMetadatable.java | 4 + .../core/event/extent/PasteEvent.java | 3 +- .../factory/parser/mask/RichMaskParser.java | 20 +- .../factory/parser/mask/YAxisMaskParser.java | 2 +- .../parser/pattern/Linear2DPatternParser.java | 14 +- .../parser/pattern/Linear3DPatternParser.java | 15 +- .../parser/pattern/LinearPatternParser.java | 15 +- .../parser/pattern/MaskedPatternParser.java | 14 +- .../parser/pattern/OffsetPatternParser.java | 15 +- .../pattern/RandomOffsetPatternParser.java | 15 +- .../SolidRandomOffsetPatternParser.java | 15 +- .../SurfaceRandomOffsetPatternParser.java | 13 +- .../transform/RandomTransformParser.java | 4 +- .../extension/platform/binding/Bindings.java | 1 + .../platform/binding/CommandBindings.java | 1 + .../platform/binding/ConsumeBindings.java | 1 + .../platform/binding/PrimitiveBindings.java | 79 +-- .../platform/binding/ProvideBindings.java | 3 +- .../core/extent/DisallowedBlocksExtent.java | 1 + .../core/extent/StripNBTExtent.java | 4 +- .../core/extent/TransformExtent.java | 2 + .../clipboard/CPUOptimizedClipboard.java | 2 +- .../clipboard/DiskOptimizedClipboard.java | 2 +- .../extent/clipboard/LinearClipboard.java | 36 +- .../clipboard/MemoryOptimizedClipboard.java | 7 +- .../clipboard/MultiClipboardHolder.java | 3 +- .../clipboard/ResizableClipboardBuilder.java | 6 +- .../clipboard/io/FastSchematicReader.java | 3 +- .../io/schematic/MinecraftStructure.java | 2 +- .../core/extent/filter/ForkedFilter.java | 1 + .../extent/filter/block/DelegateFilter.java | 1 + .../processor/IBatchProcessorHolder.java | 2 - .../extent/processor/MultiBatchProcessor.java | 13 +- .../processor/lighting/NMSRelighter.java | 6 +- .../core/function/generator/OreGen.java | 2 - .../core/function/mask/ABlockMask.java | 6 +- .../core/function/mask/BlockMaskBuilder.java | 48 +- .../core/function/mask/ExtremaMask.java | 1 - .../core/function/mask/MaskUnion.java | 13 +- .../function/mask/SingleBlockStateMask.java | 3 +- .../core/function/mask/YAxisMask.java | 5 +- .../function/pattern/PatternTraverser.java | 1 + .../core/function/visitor/DFSVisitor.java | 20 +- .../visitor/IntersectRegionFunction.java | 8 +- .../history/change/MutableEntityChange.java | 1 + .../core/jnbt/CompressedCompoundTag.java | 4 +- .../core/jnbt/JSON2NBT.java | 18 +- .../core/jnbt/streamer/StreamDelegate.java | 1 + .../core/limit/PropertyRemap.java | 11 +- .../core/math/BitArray.java | 10 +- .../core/math/BitArrayUnstretched.java | 12 +- .../core/math/BlockVectorSet.java | 6 +- .../core/math/FastBitSet.java | 103 +-- .../fastasyncworldedit/core/math/IntPair.java | 10 +- .../core/math/IntTriple.java | 29 +- .../core/math/LocalBlockVectorSet.java | 6 +- .../core/math/heightmap/HeightMap.java | 42 +- .../math/heightmap/ScalableHeightMap.java | 11 +- .../core/math/random/NoiseRandom.java | 9 +- .../core/math/transform/RoundedTransform.java | 8 +- .../fastasyncworldedit/core/queue/Filter.java | 8 - .../fastasyncworldedit/core/queue/IChunk.java | 4 - .../core/queue/IChunkExtent.java | 16 +- .../core/queue/IQueueChunk.java | 5 - .../implementation/ParallelQueueExtent.java | 6 +- .../queue/implementation/QueueHandler.java | 5 +- .../SingleThreadQueueExtent.java | 3 - .../implementation/blocks/BitSetBlocks.java | 3 +- .../core/regions/FuzzyRegion.java | 2 +- .../regions/selector/FuzzyRegionSelector.java | 1 + .../core/registry/state/PropertyGroup.java | 1 + .../core/registry/state/PropertyKey.java | 1 + .../core/util/BrushCache.java | 4 +- .../core/util/ExtentTraverser.java | 4 + .../core/util/MainUtil.java | 49 -- .../core/util/Permission.java | 4 +- .../core/util/ReflectionUtils.java | 15 +- .../core/util/TextureUtil.java | 2 +- .../core/util/collection/AdaptedMap.java | 3 +- .../core/util/collection/IAdaptedMap.java | 2 +- .../core/util/collection/MemBlockSet.java | 109 ++-- .../util/collection/SummedColorTable.java | 12 +- .../core/util/collection/YieldIterable.java | 1 + .../util/progress/DefaultProgressTracker.java | 11 +- .../com/sk89q/util/yaml/YAMLProcessor.java | 2 +- 137 files changed, 371 insertions(+), 1642 deletions(-) delete mode 100644 worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Yaml.java diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweAdapter.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweAdapter.java index 0ff2fb4b0..ecdd507f9 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweAdapter.java @@ -141,6 +141,7 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements return parent; } + @SuppressWarnings("unchecked") private synchronized boolean init() { if (ibdToStateOrdinal != null && ibdToStateOrdinal[1] != 0) { return false; @@ -159,10 +160,9 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements try { for (Field field : BlockStateProperties.class.getDeclaredFields()) { Object obj = field.get(null); - if (!(obj instanceof net.minecraft.world.level.block.state.properties.Property)) { + if (!(obj instanceof net.minecraft.world.level.block.state.properties.Property state)) { continue; } - net.minecraft.world.level.block.state.properties.Property state = (net.minecraft.world.level.block.state.properties.Property) obj; Property property; if (state instanceof net.minecraft.world.level.block.state.properties.BooleanProperty) { property = new BooleanProperty( @@ -288,6 +288,7 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements return SideEffectSet.defaults().getSideEffectsToApply(); } + @SuppressWarnings("rawtypes") public boolean setBlock(org.bukkit.Chunk chunk, int x, int y, int z, BlockStateHolder state, boolean update) { CraftChunk craftChunk = (CraftChunk) chunk; LevelChunk levelChunk = craftChunk.getHandle(); diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweWorldNativeAccess.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweWorldNativeAccess.java index 1873a6310..282a6b505 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweWorldNativeAccess.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweWorldNativeAccess.java @@ -246,7 +246,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess value = getTag.getValue(); CompoundTag getParts = (CompoundTag) value.get("UUID"); UUID getUUID = new UUID(getParts.getLong("Most"), getParts.getLong("Least")); @@ -388,17 +390,10 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc @NotNull @Override public Iterator iterator() { - Iterable result = Iterables.transform( - Iterables.concat(slices), - new com.google.common.base.Function() { - @Nullable - @Override - public CompoundTag apply(@Nullable Entity input) { - net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag(); - return (CompoundTag) adapter.toNative(input.saveWithoutId(tag)); - } - } - ); + Iterable result = StreamSupport.stream(Iterables.concat(slices).spliterator(), false).map(input -> { + net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag(); + return (CompoundTag) adapter.toNative(input.saveWithoutId(tag)); + }).collect(Collectors.toList()); return result.iterator(); } }; @@ -842,6 +837,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc * @return the given array to be filled with data, or a new array if null is given. */ @Override + @SuppressWarnings("unchecked") public char[] update(int layer, char[] data, boolean aggressive) { LevelChunkSection section = getSections(aggressive)[layer]; // Section is null, return empty array @@ -1005,6 +1001,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc } @Override + @SuppressWarnings("unchecked") public synchronized boolean trim(boolean aggressive) { skyLight = new DataLayer[getSectionCount()]; blockLight = new DataLayer[getSectionCount()]; diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks_Copy.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks_Copy.java index 63ecb5776..68d284305 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks_Copy.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks_Copy.java @@ -67,6 +67,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet { return tiles.get(BlockVector3.at(x, y, z)); } + @SuppressWarnings({"unchecked", "rawtypes"}) protected void storeEntity(Entity entity) { BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); net.minecraft.nbt.CompoundTag compoundTag = new net.minecraft.nbt.CompoundTag(); diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightPlatformAdapter.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightPlatformAdapter.java index b8b791e88..12392d931 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightPlatformAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightPlatformAdapter.java @@ -227,6 +227,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { } } + @SuppressWarnings("unchecked") public static void sendChunk(ServerLevel nmsWorld, int chunkX, int chunkZ, boolean lighting) { ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ); if (chunkHolder == null) { @@ -412,6 +413,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { return BiomeTypes.get(resourceLocation.toString().toLowerCase(Locale.ROOT)); } + @SuppressWarnings("unchecked") static void removeBeacon(BlockEntity beacon, LevelChunk levelChunk) { try { // Do the method ourselves to avoid trying to reflect generic method parameters diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightStarlightRelighter.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightStarlightRelighter.java index d51b3a6fc..8298be6f1 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightStarlightRelighter.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightStarlightRelighter.java @@ -70,6 +70,7 @@ public class PaperweightStarlightRelighter implements Relighter { private final ReentrantLock areaLock = new ReentrantLock(); private final NMSRelighter delegate; + @SuppressWarnings("rawtypes") public PaperweightStarlightRelighter(ServerLevel serverLevel, IQueueExtent queue) { this.serverLevel = serverLevel; this.delegate = new NMSRelighter(queue); diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightStarlightRelighterFactory.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightStarlightRelighterFactory.java index d8d6a92fd..2672c5b62 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightStarlightRelighterFactory.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightStarlightRelighterFactory.java @@ -16,6 +16,7 @@ public class PaperweightStarlightRelighterFactory implements RelighterFactory { @Override public @Nonnull + @SuppressWarnings("rawtypes") Relighter createRelighter(RelightMode relightMode, World world, IQueueExtent queue) { org.bukkit.World w = Bukkit.getWorld(world.getName()); if (w == null) { diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/nbt/PaperweightLazyCompoundTag.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/nbt/PaperweightLazyCompoundTag.java index f71a3954e..21bc0fe72 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/nbt/PaperweightLazyCompoundTag.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/nbt/PaperweightLazyCompoundTag.java @@ -35,6 +35,7 @@ public class PaperweightLazyCompoundTag extends LazyCompoundTag { } @Override + @SuppressWarnings("unchecked") public Map getValue() { if (compoundTag == null) { compoundTag = (CompoundTag) WorldEditPlugin.getInstance().getBukkitImplAdapter().toNative(compoundTagSupplier.get()); @@ -92,6 +93,7 @@ public class PaperweightLazyCompoundTag extends LazyCompoundTag { return 0; } + @SuppressWarnings("unchecked") public List getList(String key) { net.minecraft.nbt.Tag tag = compoundTagSupplier.get().get(key); if (tag instanceof net.minecraft.nbt.ListTag nbtList) { @@ -108,6 +110,7 @@ public class PaperweightLazyCompoundTag extends LazyCompoundTag { return Collections.emptyList(); } + @SuppressWarnings("unchecked") public ListTag getListTag(String key) { net.minecraft.nbt.Tag tag = compoundTagSupplier.get().get(key); if (tag instanceof net.minecraft.nbt.ListTag) { diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/regen/PaperweightRegen.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/regen/PaperweightRegen.java index 12a12d059..c74acac2c 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/regen/PaperweightRegen.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/regen/PaperweightRegen.java @@ -402,6 +402,7 @@ public class PaperweightRegen extends Regenerator { try { @@ -421,6 +422,7 @@ public class PaperweightRegen extends Regenerator sharedMap; - - public FastAreaLazy(ConcurrentHashMap sharedMap, PixelTransformer transformer) { - this.sharedMap = sharedMap; - this.transformer = transformer; - } + private record FastAreaLazy(ConcurrentHashMap sharedMap, PixelTransformer transformer) implements Area { @Override public int get(int x, int z) { diff --git a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightFaweWorldNativeAccess.java b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightFaweWorldNativeAccess.java index ac24e82d0..0ffdf02e7 100644 --- a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightFaweWorldNativeAccess.java +++ b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightFaweWorldNativeAccess.java @@ -246,7 +246,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess { - - private final int size; - - FakeIdMapBlock(int size) { - this.size = size; - } + record FakeIdMapBlock(int size) implements IdMap { @Override public int getId(final net.minecraft.world.level.block.state.BlockState entry) { @@ -613,11 +608,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { return null; } - @Override - public int size() { - return size; - } - @NotNull @Override public Iterator iterator() { @@ -626,13 +616,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { } - static class FakeIdMapBiome implements IdMap { - - private final int size; - - FakeIdMapBiome(int size) { - this.size = size; - } + record FakeIdMapBiome(int size) implements IdMap { @Override public int getId(final Biome entry) { @@ -645,11 +629,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { return null; } - @Override - public int size() { - return size; - } - @NotNull @Override public Iterator iterator() { diff --git a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightStarlightRelighter.java b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightStarlightRelighter.java index 999faecb0..c367e1553 100644 --- a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightStarlightRelighter.java +++ b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightStarlightRelighter.java @@ -70,6 +70,7 @@ public class PaperweightStarlightRelighter implements Relighter { private final ReentrantLock areaLock = new ReentrantLock(); private final NMSRelighter delegate; + @SuppressWarnings("rawtypes") public PaperweightStarlightRelighter(ServerLevel serverLevel, IQueueExtent queue) { this.serverLevel = serverLevel; this.delegate = new NMSRelighter(queue); diff --git a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightStarlightRelighterFactory.java b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightStarlightRelighterFactory.java index a7da862fa..c495c2fd4 100644 --- a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightStarlightRelighterFactory.java +++ b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightStarlightRelighterFactory.java @@ -16,6 +16,7 @@ public class PaperweightStarlightRelighterFactory implements RelighterFactory { @Override public @Nonnull + @SuppressWarnings("rawtypes") Relighter createRelighter(RelightMode relightMode, World world, IQueueExtent queue) { org.bukkit.World w = Bukkit.getWorld(world.getName()); if (w == null) { diff --git a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/nbt/PaperweightLazyCompoundTag.java b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/nbt/PaperweightLazyCompoundTag.java index 042c1f0e9..3f7de0bf9 100644 --- a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/nbt/PaperweightLazyCompoundTag.java +++ b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/nbt/PaperweightLazyCompoundTag.java @@ -35,6 +35,7 @@ public class PaperweightLazyCompoundTag extends LazyCompoundTag { } @Override + @SuppressWarnings("unchecked") public Map getValue() { if (compoundTag == null) { compoundTag = (CompoundTag) WorldEditPlugin.getInstance().getBukkitImplAdapter().toNative(compoundTagSupplier.get()); @@ -92,6 +93,7 @@ public class PaperweightLazyCompoundTag extends LazyCompoundTag { return 0; } + @SuppressWarnings("unchecked") public List getList(String key) { net.minecraft.nbt.Tag tag = compoundTagSupplier.get().get(key); if (tag instanceof net.minecraft.nbt.ListTag nbtList) { @@ -108,6 +110,7 @@ public class PaperweightLazyCompoundTag extends LazyCompoundTag { return Collections.emptyList(); } + @SuppressWarnings("unchecked") public ListTag getListTag(String key) { net.minecraft.nbt.Tag tag = compoundTagSupplier.get().get(key); if (tag instanceof net.minecraft.nbt.ListTag) { diff --git a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/regen/PaperweightRegen.java b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/regen/PaperweightRegen.java index 4269b48a5..2ba1cf48d 100644 --- a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/regen/PaperweightRegen.java +++ b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/regen/PaperweightRegen.java @@ -184,6 +184,7 @@ public class PaperweightRegen extends Regenerator { try { diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/BukkitQueueHandler.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/BukkitQueueHandler.java index f3e9e16e7..6e1bb1f9e 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/BukkitQueueHandler.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/BukkitQueueHandler.java @@ -11,8 +11,6 @@ import java.lang.reflect.Method; public class BukkitQueueHandler extends QueueHandler { - private static final Logger LOGGER = LogManagerCompat.getLogger(); - private volatile boolean timingsEnabled; private static boolean alertTimingsChange = true; diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/listener/BrushListener.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/listener/BrushListener.java index 6af0b2d2b..38764c77c 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/listener/BrushListener.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/listener/BrushListener.java @@ -34,7 +34,7 @@ public class BrushListener implements Listener { BukkitPlayer player = BukkitAdapter.adapt(bukkitPlayer); LocalSession session = player.getSession(); Tool tool = session.getTool(player); - if (tool instanceof ScrollTool) { + if (tool instanceof ScrollTool scrollable) { final int slot = event.getNewSlot(); final int oldSlot = event.getPreviousSlot(); final int ri; @@ -43,7 +43,6 @@ public class BrushListener implements Listener { } else { ri = -1; } - ScrollTool scrollable = (ScrollTool) tool; if (scrollable.increment(player, ri)) { bukkitPlayer.getInventory().setHeldItemSlot(oldSlot); } diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/WorldGuardFeature.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/WorldGuardFeature.java index bab2b3b91..ade2d8258 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/WorldGuardFeature.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/WorldGuardFeature.java @@ -53,8 +53,7 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener { if (region instanceof GlobalProtectedRegion) { return RegionWrapper.GLOBAL(); } - if (region instanceof ProtectedPolygonalRegion) { - ProtectedPolygonalRegion casted = (ProtectedPolygonalRegion) region; + if (region instanceof ProtectedPolygonalRegion casted) { BlockVector3 max = region.getMaximumPoint(); BlockVector3 min = region.getMinimumPoint(); return new Polygonal2DRegion(null, casted.getPoints(), min.getBlockY(), max.getBlockY()); diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateRegionManager.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateRegionManager.java index d50300106..b117825b0 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateRegionManager.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateRegionManager.java @@ -43,6 +43,7 @@ import java.util.UUID; import static org.bukkit.Bukkit.getWorld; +@SuppressWarnings("unused") public class FaweDelegateRegionManager { public boolean setCuboids( diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java index 2195980c8..4511633e7 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java @@ -50,6 +50,7 @@ import java.util.UUID; import java.util.concurrent.atomic.AtomicBoolean; import java.util.zip.GZIPInputStream; +@SuppressWarnings("unused") public class FaweDelegateSchematicHandler { private static final Logger LOGGER = LogManagerCompat.getLogger(); diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweQueueCoordinator.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweQueueCoordinator.java index 9c8888a8e..5e7025d05 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweQueueCoordinator.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweQueueCoordinator.java @@ -25,6 +25,7 @@ import java.util.List; import java.util.Set; import java.util.function.Consumer; +@SuppressWarnings({"unused", "rawtypes"}) public class FaweQueueCoordinator extends QueueCoordinator { public final IQueueExtent instance; diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/PlotSetBiome.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/PlotSetBiome.java index 87db6655a..cb007bfb3 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/PlotSetBiome.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/PlotSetBiome.java @@ -33,6 +33,7 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ThreadLocalRandom; import java.util.stream.Collectors; +@SuppressWarnings("unused") @CommandDeclaration(command = "generatebiome", permission = "plots.generatebiome", category = CommandCategory.APPEARANCE, diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java index 087402810..bb3d0d04f 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java @@ -120,7 +120,7 @@ public enum FaweCache implements Trimable { } public LoadingCache createCache(Supplier withInitial) { - return CacheBuilder.newBuilder().build(new CacheLoader() { + return CacheBuilder.newBuilder().build(new CacheLoader<>() { @Override public V load(@Nonnull T key) { return withInitial.get(); @@ -129,7 +129,7 @@ public enum FaweCache implements Trimable { } public LoadingCache createCache(Function withInitial) { - return CacheBuilder.newBuilder().build(new CacheLoader() { + return CacheBuilder.newBuilder().build(new CacheLoader<>() { @Override public V load(@Nonnull T key) { return withInitial.apply(key); @@ -246,9 +246,6 @@ public enum FaweCache implements Trimable { /** * Convert raw char array to palette - * - * @param layerOffset - * @param blocks * @return palette */ public Palette toPalette(int layerOffset, char[] blocks) { @@ -257,9 +254,6 @@ public enum FaweCache implements Trimable { /** * Convert raw int array to palette - * - * @param layerOffset - * @param blocks * @return palette */ public Palette toPalette(int layerOffset, int[] blocks) { @@ -344,8 +338,6 @@ public enum FaweCache implements Trimable { /** * Convert raw int array to unstretched palette (1.16) * - * @param layerOffset - * @param blocks * @return palette */ public Palette toPaletteUnstretched(int layerOffset, char[] blocks) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/AngleBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/AngleBrush.java index 623722878..253f9f402 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/AngleBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/AngleBrush.java @@ -9,13 +9,7 @@ import com.sk89q.worldedit.function.mask.SolidBlockMask; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; -public class AngleBrush implements Brush { - - private final int distance; - - public AngleBrush(int distance) { - this.distance = distance; - } +public record AngleBrush(int distance) implements Brush { @Override public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/BlobBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/BlobBrush.java index c729f414a..f5c8e2bc2 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/BlobBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/BlobBrush.java @@ -7,19 +7,7 @@ import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; -public class BlobBrush implements Brush { - - private final double amplitude; - private final double frequency; - private final Vector3 radius; - private final double sphericity; - - public BlobBrush(Vector3 radius, double frequency, double amplitude, double sphericity) { - this.frequency = frequency; - this.amplitude = amplitude; - this.radius = radius; - this.sphericity = sphericity; - } +public record BlobBrush(Vector3 radius, double frequency, double amplitude, double sphericity) implements Brush { @Override public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CatenaryBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CatenaryBrush.java index 67a401c3c..e380e74b0 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CatenaryBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CatenaryBrush.java @@ -38,10 +38,9 @@ public class CatenaryBrush implements Brush, ResettableTool { public void build(EditSession editSession, BlockVector3 pos2, final Pattern pattern, double size) throws MaxChangedBlocksException { Actor actor = editSession.getActor(); - if (!(actor instanceof Player)) { + if (!(actor instanceof Player player)) { throw FaweCache.PLAYER_ONLY; } - Player player = (Player) actor; if (pos1 == null || pos2.equals(pos1)) { pos1 = pos2; actor.print(Caption.of("fawe.worldedit.brush.brush.line.primary", pos2)); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CircleBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CircleBrush.java index 73c0ee3b7..3719e4889 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CircleBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CircleBrush.java @@ -11,38 +11,17 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.AffineTransform; -public class CircleBrush implements Brush { - - private final boolean filled; - - public CircleBrush(boolean filled) { - - this.filled = filled; - } +public record CircleBrush(boolean filled) implements Brush { @Override public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException { Actor actor = editSession.getActor(); - if (!(actor instanceof Player)) { + if (!(actor instanceof Player player)) { throw FaweCache.PLAYER_ONLY; } - Player player = (Player) actor; Vector3 normal = position.toVector3().subtract(player.getLocation()); editSession.makeCircle(position, pattern, size, size, size, filled, normal); } - private Vector3 any90Rotate(Vector3 normal) { - normal = normal.normalize(); - if (normal.getX() == 1 || normal.getY() == 1 || normal.getZ() == 1) { - return Vector3.at(normal.getZ(), normal.getX(), normal.getY()); - } - AffineTransform affine = new AffineTransform(); - affine = affine.rotateX(90); - affine = affine.rotateY(90); - affine = affine.rotateZ(90); - Vector3 random = affine.apply(normal); - return random.cross(normal).normalize(); - } - } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CommandBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CommandBrush.java index 13edebfeb..4072828bf 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CommandBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CommandBrush.java @@ -43,10 +43,9 @@ public class CommandBrush implements Brush { .replace("{size}", Integer.toString(radius)); Actor actor = editSession.getActor(); - if (!(actor instanceof Player)) { + if (!(actor instanceof Player player)) { throw FaweCache.PLAYER_ONLY; } - Player player = (Player) actor; //Use max world height to allow full coverage of the world height Location face = player.getBlockTraceFace(editSession.getWorld().getMaxY(), true); if (face == null) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ImageBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ImageBrush.java index bcaddb262..acd9216e0 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ImageBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ImageBrush.java @@ -39,7 +39,7 @@ public class ImageBrush implements Brush { private final ColorFunction colorFunction; - public ImageBrush(BufferedImage image, LocalSession session, boolean alpha /*, boolean glass */) throws IOException { + public ImageBrush(BufferedImage image, LocalSession session, boolean alpha /*, boolean glass */) { this.session = session; this.table = new SummedColorTable(image, alpha); this.width = image.getWidth(); @@ -89,10 +89,9 @@ public class ImageBrush implements Brush { double scale = Math.max(width, height) / sizeDouble; Actor actor = editSession.getActor(); - if (!(actor instanceof Player)) { + if (!(actor instanceof Player player)) { throw FaweCache.PLAYER_ONLY; } - Player player = (Player) actor; Location loc = player.getLocation(); float yaw = loc.getYaw(); float pitch = loc.getPitch(); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/InspectBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/InspectBrush.java index f0de661a1..662212981 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/InspectBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/InspectBrush.java @@ -34,8 +34,6 @@ import java.util.function.Supplier; public class InspectBrush extends BrushTool { - private static final Logger LOGGER = LogManagerCompat.getLogger(); - /** * Construct the tool. */ diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/PopulateSchem.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/PopulateSchem.java index 7df98ddfb..b28d7536b 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/PopulateSchem.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/PopulateSchem.java @@ -14,19 +14,7 @@ import com.sk89q.worldedit.session.ClipboardHolder; import java.util.List; -public class PopulateSchem implements Brush { - - private final Mask mask; - private final boolean randomRotate; - private final List clipboards; - private final int rarity; - - public PopulateSchem(Mask mask, List clipboards, int rarity, boolean randomRotate) { - this.mask = mask; - this.clipboards = clipboards; - this.rarity = rarity; - this.randomRotate = randomRotate; - } +public record PopulateSchem(Mask mask, List clipboards, int rarity, boolean randomRotate) implements Brush { @Override public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/RecurseBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/RecurseBrush.java index 97bf3fa0e..869d45150 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/RecurseBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/RecurseBrush.java @@ -14,13 +14,7 @@ import com.sk89q.worldedit.function.visitor.RecursiveVisitor; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockState; -public class RecurseBrush implements Brush { - - private final boolean dfs; - - public RecurseBrush(boolean dfs) { - this.dfs = dfs; - } +public record RecurseBrush(boolean dfs) implements Brush { @Override public void build(EditSession editSession, BlockVector3 position, Pattern to, double size) throws MaxChangedBlocksException { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/RockBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/RockBrush.java index ed72fa52f..4196a7e11 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/RockBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/RockBrush.java @@ -10,17 +10,7 @@ import com.sk89q.worldedit.math.Vector3; import java.util.concurrent.ThreadLocalRandom; -public class RockBrush implements Brush { - - private final double amplitude; - private final double frequency; - private final Vector3 radius; - - public RockBrush(Vector3 radius, double frequency, double amplitude) { - this.frequency = frequency; - this.amplitude = amplitude; - this.radius = radius; - } +public record RockBrush(double amplitude, double frequency, Vector3 radius) implements Brush { @Override public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterCommand.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterCommand.java index e2f2f52de..81be2640c 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterCommand.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterCommand.java @@ -50,10 +50,9 @@ public class ScatterCommand extends ScatterBrush { .replace("{size}", Integer.toString(radius)); Actor actor = editSession.getActor(); - if (!(actor instanceof Player)) { + if (!(actor instanceof Player player)) { throw FaweCache.PLAYER_ONLY; } - Player player = (Player) actor; player.setSelection(selector); List cmds = StringMan.split(replaced, ';'); for (String cmd : cmds) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SplineBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SplineBrush.java index 3f6d1cf16..aa5e0243e 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SplineBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SplineBrush.java @@ -137,61 +137,4 @@ public class SplineBrush implements Brush, ResettableTool { return sum.multiply(1.0 / points.size()); } - private BlockVector3 normal(Collection points, BlockVector3 centroid) { - int n = points.size(); - switch (n) { - case 1: - return null; - case 2: - return null; - } - - // Calc full 3x3 covariance matrix, excluding symmetries: - double xx = 0.0; - double xy = 0.0; - double xz = 0.0; - double yy = 0.0; - double yz = 0.0; - double zz = 0.0; - - MutableVector3 r = new MutableVector3(); - for (BlockVector3 p : points) { - r.mutX(p.getX() - centroid.getX()); - r.mutY(p.getY() - centroid.getY()); - r.mutZ(p.getZ() - centroid.getZ()); - xx += r.getX() * r.getX(); - xy += r.getX() * r.getY(); - xz += r.getX() * r.getZ(); - yy += r.getY() * r.getY(); - yz += r.getY() * r.getZ(); - zz += r.getZ() * r.getZ(); - } - - double det_x = yy * zz - yz * yz; - double det_y = xx * zz - xz * xz; - double det_z = xx * yy - xy * xy; - - double det_max = Math.max(Math.max(det_x, det_y), det_z); - if (det_max <= 0.0) { - return null; - } - - // Pick path with best conditioning: - BlockVector3 dir; - if (det_max == det_x) { - double a = (xz * yz - xy * zz) / det_x; - double b = (xy * yz - xz * yy) / det_x; - dir = BlockVector3.at(1.0, a, b); - } else if (det_max == det_y) { - double a = (yz * xz - xy * zz) / det_y; - double b = (xy * xz - yz * xx) / det_y; - dir = BlockVector3.at(a, 1.0, b); - } else { - double a = (yz * xy - xz * yy) / det_z; - double b = (xz * xy - yz * xx) / det_z; - dir = BlockVector3.at(a, b, 1.0); - } - return dir.normalize(); - } - } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/StencilBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/StencilBrush.java index db4205b60..131402a40 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/StencilBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/StencilBrush.java @@ -51,10 +51,9 @@ public class StencilBrush extends HeightBrush { final SolidBlockMask solid = new SolidBlockMask(editSession); Actor actor = editSession.getActor(); - if (!(actor instanceof Player)) { + if (!(actor instanceof Player player)) { throw FaweCache.PLAYER_ONLY; } - Player player = (Player) actor; Location loc = player.getLocation(); float yaw = loc.getYaw(); float pitch = loc.getPitch(); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SurfaceSphereBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SurfaceSphereBrush.java index 26b654957..631b4653b 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SurfaceSphereBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SurfaceSphereBrush.java @@ -21,7 +21,6 @@ public class SurfaceSphereBrush implements Brush { public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException { SurfaceMask surface = new SurfaceMask(editSession); - final SolidBlockMask solid = new SolidBlockMask(editSession); final RadiusMask radius = new RadiusMask(0, (int) size); RecursiveVisitor visitor = new RecursiveVisitor( new MaskIntersection(surface, radius), diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/scroll/Scroll.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/scroll/Scroll.java index ca32cc5f6..dd7c23984 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/scroll/Scroll.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/scroll/Scroll.java @@ -52,8 +52,6 @@ public abstract class Scroll implements ScrollTool { parserContext.setWorld(player.getWorld()); parserContext.setSession(session); switch (mode) { - case NONE: - return null; case CLIPBOARD: if (arguments.size() != 2) { if (message) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/ClipboardSpline.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/ClipboardSpline.java index e2b29cd54..87f1495f5 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/ClipboardSpline.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/ClipboardSpline.java @@ -18,9 +18,6 @@ import com.sk89q.worldedit.session.ClipboardHolder; /** * An implementation of a {@link Spline} using a Clipboard as source for the structure. - * - * @author Schuwi - * @version 1.0 */ public class ClipboardSpline extends Spline { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/Spline.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/Spline.java index 9926492c3..945c10f5a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/Spline.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/Spline.java @@ -15,9 +15,6 @@ import java.util.List; * Embodies an abstract implementation for pasting structures along a spline.
* A curve is being interpolated by the provided {@link Interpolation} implementation * and the structure is pasted along this curve by the specific Spline implementation. - * - * @author Schuwi - * @version 1.0 */ public abstract class Spline { @@ -202,19 +199,7 @@ public abstract class Spline { return finalPosition; } - private class Section { - - final double uniStart; - final double uniLength; - final double flexStart; - final double flexLength; - - Section(double uniStart, double uniLength, double flexStart, double flexLength) { - this.uniStart = uniStart; - this.uniLength = uniLength; - this.flexStart = flexStart; - this.flexLength = flexLength; - } + private record Section(double uniStart, double uniLength, double flexStart, double flexLength) { } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/SweepBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/SweepBrush.java index 6e9b1cc47..fa4bb971c 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/SweepBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/SweepBrush.java @@ -90,23 +90,20 @@ public class SweepBrush implements Brush, ResettableTool { } switch (copies) { - case 1: { + case 1 -> { spline.pastePosition(0D); - break; } - case -1: { + case -1 -> { double length = interpol.arcLength(0, 1); double step = 1 / (length * quality); for (double pos = 0; pos <= 1; pos += step) { spline.pastePosition(pos); } - break; } - default: { + default -> { for (double pos = 0D; pos <= 1D; pos += 1D / (copies - 1)) { spline.pastePosition(pos); } - break; } } actor.print(Caption.of("fawe.worldedit.brush.spline.secondary")); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Caption.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Caption.java index 72ad879d4..9f086bb25 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Caption.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Caption.java @@ -42,7 +42,7 @@ public class Caption { private static Component color(TextComponent text) { String content = text.content(); if (colorCodes.matcher(content).find()) { - TextComponent legacy = LegacyComponentSerializer.INSTANCE.deserialize(content, '&'); + TextComponent legacy = LegacyComponentSerializer.legacy().deserialize(content, '&'); legacy.style().merge(text.style(), Style.Merge.Strategy.IF_ABSENT_ON_TARGET); if (!text.children().isEmpty()) { text = TextComponent.builder().append(legacy).append(text.children()).build(); @@ -86,8 +86,7 @@ public class Caption { if (children != (children = color(parent, children))) { parent = parent.children(children); } - if (parent instanceof TranslatableComponent) { - TranslatableComponent tc = (TranslatableComponent) parent; + if (parent instanceof TranslatableComponent tc) { List args = tc.args(); if (args != (args = color(parent, args))) { parent = tc.args(args); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Config.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Config.java index 83dd34d95..bc300d584 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Config.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Config.java @@ -100,7 +100,6 @@ public class Config { * Set all values in the file (load first to avoid overwriting). */ public void save(File file) { - Class root = getClass(); try { if (!file.exists()) { File parent = file.getParentFile(); @@ -198,23 +197,6 @@ public class Config { } - /** - * Get the static fields in a section. - */ - private Map getFields(Class clazz) { - HashMap map = new HashMap<>(); - for (Field field : clazz.getFields()) { - if (Modifier.isStatic(field.getModifiers())) { - try { - map.put(toNodeName(field.getName()), field.get(null)); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - } - } - return map; - } - private String toYamlString(Object value, String spacing) { if (value instanceof List) { Collection listValue = (Collection) value; @@ -314,19 +296,6 @@ public class Config { } } - /** - * Get the field for a specific config node. - * - * @param split the node (split by period) - */ - private Field getField(String[] split, Class root) { - Object instance = getInstance(split, root); - if (instance == null) { - return null; - } - return getField(split, instance); - } - /** * Get the field for a specific config node and instance. *

diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/InvalidConfigurationException.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/InvalidConfigurationException.java index b22705c8f..8e3d2816e 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/InvalidConfigurationException.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/InvalidConfigurationException.java @@ -3,7 +3,6 @@ package com.fastasyncworldedit.core.configuration; /** * Exception thrown when attempting to load an invalid {@link Configuration} */ -@SuppressWarnings("serial") public class InvalidConfigurationException extends Exception { /** diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/MemorySection.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/MemorySection.java index 18f9b624a..ecec3a8cf 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/MemorySection.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/MemorySection.java @@ -76,8 +76,7 @@ public class MemorySection implements ConfigurationSection { return Double.parseDouble((String) obj); } catch (NumberFormatException ignored) { } - } else if (obj instanceof List) { - List val = (List) obj; + } else if (obj instanceof List val) { if (!val.isEmpty()) { return toDouble(val.get(0), def); } @@ -94,8 +93,7 @@ public class MemorySection implements ConfigurationSection { return Integer.parseInt((String) obj); } catch (NumberFormatException ignored) { } - } else if (obj instanceof List) { - List val = (List) obj; + } else if (obj instanceof List val) { if (!val.isEmpty()) { return toInt(val.get(0), def); } @@ -112,8 +110,7 @@ public class MemorySection implements ConfigurationSection { return Long.parseLong((String) obj); } catch (NumberFormatException ignored) { } - } else if (obj instanceof List) { - List val = (List) obj; + } else if (obj instanceof List val) { if (!val.isEmpty()) { return toLong(val.get(0), def); } @@ -706,8 +703,7 @@ public class MemorySection implements ConfigurationSection { for (Object object : list) { if (object instanceof Character) { result.add((Character) object); - } else if (object instanceof String) { - String str = (String) object; + } else if (object instanceof String str) { if (str.length() == 1) { result.add(str.charAt(0)); @@ -797,14 +793,12 @@ public class MemorySection implements ConfigurationSection { } protected void mapChildrenKeys(Set output, ConfigurationSection section, boolean deep) { - if (section instanceof MemorySection) { - MemorySection sec = (MemorySection) section; + if (section instanceof MemorySection sec) { for (Map.Entry entry : sec.map.entrySet()) { output.add(createPath(section, entry.getKey(), this)); - if (deep && (entry.getValue() instanceof ConfigurationSection)) { - ConfigurationSection subsection = (ConfigurationSection) entry.getValue(); + if (deep && (entry.getValue() instanceof ConfigurationSection subsection)) { mapChildrenKeys(output, subsection, deep); } } @@ -818,8 +812,7 @@ public class MemorySection implements ConfigurationSection { } protected void mapChildrenValues(Map output, ConfigurationSection section, boolean deep) { - if (section instanceof MemorySection) { - MemorySection sec = (MemorySection) section; + if (section instanceof MemorySection sec) { for (Map.Entry entry : sec.map.entrySet()) { output.put(createPath(section, entry.getKey(), this), entry.getValue()); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java index 4b43c0376..04551e11b 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java @@ -31,8 +31,10 @@ public class Settings extends Config { public boolean PROTOCOL_SUPPORT_FIX = false; @Comment("These first 6 aren't configurable") // This is a comment @Final // Indicates that this value isn't configurable + @SuppressWarnings("unused") public String ISSUES = "https://github.com/IntellectualSites/FastAsyncWorldEdit/issues"; @Final + @SuppressWarnings("unused") public String WIKI = "https://github.com/IntellectualSites/FastAsyncWorldEdit-Documentation/wiki"; @Final public String DATE; // These values are set from FAWE before loading diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Yaml.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Yaml.java deleted file mode 100644 index ebcd286d9..000000000 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Yaml.java +++ /dev/null @@ -1,607 +0,0 @@ -package com.fastasyncworldedit.core.configuration; - -import org.yaml.snakeyaml.DumperOptions; -import org.yaml.snakeyaml.DumperOptions.FlowStyle; -import org.yaml.snakeyaml.composer.Composer; -import org.yaml.snakeyaml.constructor.BaseConstructor; -import org.yaml.snakeyaml.constructor.Constructor; -import org.yaml.snakeyaml.emitter.Emitable; -import org.yaml.snakeyaml.emitter.Emitter; -import org.yaml.snakeyaml.error.YAMLException; -import org.yaml.snakeyaml.events.Event; -import org.yaml.snakeyaml.introspector.BeanAccess; -import org.yaml.snakeyaml.nodes.Node; -import org.yaml.snakeyaml.nodes.Tag; -import org.yaml.snakeyaml.parser.Parser; -import org.yaml.snakeyaml.parser.ParserImpl; -import org.yaml.snakeyaml.reader.StreamReader; -import org.yaml.snakeyaml.reader.UnicodeReader; -import org.yaml.snakeyaml.representer.Representer; -import org.yaml.snakeyaml.resolver.Resolver; -import org.yaml.snakeyaml.serializer.Serializer; - -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.regex.Pattern; - -/** - * Public YAML interface. Each Thread must have its own instance. - */ -public class Yaml { - - protected final Resolver resolver; - protected BaseConstructor constructor; - protected Representer representer; - protected DumperOptions dumperOptions; - private String name; - - /** - * Create Yaml instance. It is safe to create a few instances and use them - * in different Threads. - */ - public Yaml() { - this(new Constructor(), new Representer(), new DumperOptions(), new Resolver()); - } - - /** - * Create Yaml instance. - * - * @param dumperOptions DumperOptions to configure outgoing objects - */ - public Yaml(DumperOptions dumperOptions) { - this(new Constructor(), new Representer(), dumperOptions); - } - - /** - * Create Yaml instance. It is safe to create a few instances and use them - * in different Threads. - * - * @param representer Representer to emit outgoing objects - */ - public Yaml(Representer representer) { - this(new Constructor(), representer); - } - - /** - * Create Yaml instance. It is safe to create a few instances and use them - * in different Threads. - * - * @param constructor BaseConstructor to construct incoming documents - */ - public Yaml(BaseConstructor constructor) { - this(constructor, new Representer()); - } - - /** - * Create Yaml instance. It is safe to create a few instances and use them - * in different Threads. - * - * @param constructor BaseConstructor to construct incoming documents - * @param representer Representer to emit outgoing objects - */ - public Yaml(BaseConstructor constructor, Representer representer) { - this(constructor, representer, new DumperOptions()); - } - - /** - * Create Yaml instance. It is safe to create a few instances and use them - * in different Threads. - * - * @param representer Representer to emit outgoing objects - * @param dumperOptions DumperOptions to configure outgoing objects - */ - public Yaml(Representer representer, DumperOptions dumperOptions) { - this(new Constructor(), representer, dumperOptions, new Resolver()); - } - - /** - * Create Yaml instance. It is safe to create a few instances and use them - * in different Threads. - * - * @param constructor BaseConstructor to construct incoming documents - * @param representer Representer to emit outgoing objects - * @param dumperOptions DumperOptions to configure outgoing objects - */ - public Yaml(BaseConstructor constructor, Representer representer, DumperOptions dumperOptions) { - this(constructor, representer, dumperOptions, new Resolver()); - } - - /** - * Create Yaml instance. It is safe to create a few instances and use them - * in different Threads. - * - * @param constructor BaseConstructor to construct incoming documents - * @param representer Representer to emit outgoing objects - * @param dumperOptions DumperOptions to configure outgoing objects - * @param resolver Resolver to detect implicit type - */ - public Yaml(BaseConstructor constructor, Representer representer, DumperOptions dumperOptions, Resolver resolver) { - if (!constructor.isExplicitPropertyUtils()) { - constructor.setPropertyUtils(representer.getPropertyUtils()); - } else if (!representer.isExplicitPropertyUtils()) { - representer.setPropertyUtils(constructor.getPropertyUtils()); - } - this.constructor = constructor; - representer.setDefaultFlowStyle(dumperOptions.getDefaultFlowStyle()); - representer.setDefaultScalarStyle(dumperOptions.getDefaultScalarStyle()); - representer.getPropertyUtils().setAllowReadOnlyProperties(dumperOptions.isAllowReadOnlyProperties()); - representer.setTimeZone(dumperOptions.getTimeZone()); - this.representer = representer; - this.dumperOptions = dumperOptions; - this.resolver = resolver; - this.name = "Yaml:" + System.identityHashCode(this); - } - - /** - * Serialize a Java object into a YAML String. - * - * @param data Java object to be Serialized to YAML - * @return YAML String - */ - public String dump(Object data) { - List list = new ArrayList<>(1); - list.add(data); - return dumpAll(list.iterator()); - } - - /** - * Produce the corresponding representation tree for a given Object. - * - * @param data instance to build the representation tree for - * @return representation tree - * @see Figure 3.1. Processing - * Overview - */ - public Node represent(Object data) { - return representer.represent(data); - } - - /** - * Serialize a sequence of Java objects into a YAML String. - * - * @param data Iterator with Objects - * @return YAML String with all the objects in proper sequence - */ - public String dumpAll(Iterator data) { - StringWriter buffer = new StringWriter(); - dumpAll(data, buffer, null); - return buffer.toString(); - } - - /** - * Serialize a Java object into a YAML stream. - * - * @param data Java object to be serialized to YAML - * @param output stream to write to - */ - public void dump(Object data, Writer output) { - List list = new ArrayList<>(1); - list.add(data); - dumpAll(list.iterator(), output, null); - } - - /** - * Serialize a sequence of Java objects into a YAML stream. - * - * @param data Iterator with Objects - * @param output stream to write to - */ - public void dumpAll(Iterator data, Writer output) { - dumpAll(data, output, null); - } - - private void dumpAll(Iterator data, Writer output, Tag rootTag) { - Serializer serializer = new Serializer(new Emitter(output, dumperOptions), resolver, dumperOptions, rootTag); - try { - serializer.open(); - while (data.hasNext()) { - Node node = representer.represent(data.next()); - serializer.serialize(node); - } - serializer.close(); - } catch (IOException e) { - throw new YAMLException(e); - } - } - - /** - *

- * Serialize a Java object into a YAML string. Override the default root tag - * with {@code rootTag}. - *

- * - *

- * This method is similar to {@code Yaml.dump(data)} except that the - * root tag for the whole document is replaced with the given tag. This has - * two main uses. - *

- * - *

- * First, if the root tag is replaced with a standard YAML tag, such as - * {@code Tag.MAP}, then the object will be dumped as a map. The root - * tag will appear as {@code !!map}, or blank (implicit !!map). - *

- * - *

- * Second, if the root tag is replaced by a different custom tag, then the - * document appears to be a different type when loaded. For example, if an - * instance of MyClass is dumped with the tag !!YourClass, then it will be - * handled as an instance of YourClass when loaded. - *

- * - * @param data Java object to be serialized to YAML - * @param rootTag the tag for the whole YAML document. The tag should be Tag.MAP - * for a JavaBean to make the tag disappear (to use implicit tag - * !!map). If {@code null} is provided then the standard tag - * with the full class name is used. - * @param flowStyle flow style for the whole document. See Chapter 10. Collection - * Styles http://yaml.org/spec/1.1/#id930798. If - * {@code null} is provided then the flow style from - * DumperOptions is used. - * @return YAML String - */ - public String dumpAs(Object data, Tag rootTag, FlowStyle flowStyle) { - FlowStyle oldStyle = representer.getDefaultFlowStyle(); - if (flowStyle != null) { - representer.setDefaultFlowStyle(flowStyle); - } - List list = new ArrayList<>(1); - list.add(data); - StringWriter buffer = new StringWriter(); - dumpAll(list.iterator(), buffer, rootTag); - representer.setDefaultFlowStyle(oldStyle); - return buffer.toString(); - } - - /** - *

- * Serialize a Java object into a YAML string. Override the default root tag - * with {@code Tag.MAP}. - *

- *

- * This method is similar to {@code Yaml.dump(data)} except that the - * root tag for the whole document is replaced with {@code Tag.MAP} tag - * (implicit !!map). - *

- *

- * Block Mapping is used as the collection style. See 10.2.2. Block Mappings - * (http://yaml.org/spec/1.1/#id934537) - *

- * - * @param data Java object to be serialized to YAML - * @return YAML String - */ - public String dumpAsMap(Object data) { - return dumpAs(data, Tag.MAP, FlowStyle.BLOCK); - } - - /** - * Serialize the representation tree into Events. - * - * @param data representation tree - * @return Event list - * @see Processing Overview - */ - public List serialize(Node data) { - SilentEmitter emitter = new SilentEmitter(); - Serializer serializer = new Serializer(emitter, resolver, dumperOptions, null); - try { - serializer.open(); - serializer.serialize(data); - serializer.close(); - } catch (IOException e) { - throw new YAMLException(e); - } - return emitter.getEvents(); - } - - /** - * Parse the only YAML document in a String and produce the corresponding - * Java object. (Because the encoding in known BOM is not respected.) - * - * @param yaml YAML data to load from (BOM must not be present) - * @return parsed object - */ - public Object load(String yaml) { - return loadFromReader(new StreamReader(yaml), Object.class); - } - - /** - * Parse the only YAML document in a stream and produce the corresponding - * Java object. - * - * @param io data to load from (BOM is respected and removed) - * @return parsed object - */ - public Object load(InputStream io) { - return loadFromReader(new StreamReader(new UnicodeReader(io)), Object.class); - } - - /** - * Parse the only YAML document in a stream and produce the corresponding - * Java object. - * - * @param io data to load from (BOM must not be present) - * @return parsed object - */ - public Object load(Reader io) { - return loadFromReader(new StreamReader(io), Object.class); - } - - /** - * Parse the only YAML document in a stream and produce the corresponding - * Java object. - * - * @param Class is defined by the second argument - * @param io data to load from (BOM must not be present) - * @param type Class of the object to be created - * @return parsed object - */ - @SuppressWarnings("unchecked") - public T loadAs(Reader io, Class type) { - return (T) loadFromReader(new StreamReader(io), type); - } - - /** - * Parse the only YAML document in a String and produce the corresponding - * Java object. (Because the encoding in known BOM is not respected.) - * - * @param Class is defined by the second argument - * @param yaml YAML data to load from (BOM must not be present) - * @param type Class of the object to be created - * @return parsed object - */ - @SuppressWarnings("unchecked") - public T loadAs(String yaml, Class type) { - return (T) loadFromReader(new StreamReader(yaml), type); - } - - /** - * Parse the only YAML document in a stream and produce the corresponding - * Java object. - * - * @param Class is defined by the second argument - * @param input data to load from (BOM is respected and removed) - * @param type Class of the object to be created - * @return parsed object - */ - @SuppressWarnings("unchecked") - public T loadAs(InputStream input, Class type) { - return (T) loadFromReader(new StreamReader(new UnicodeReader(input)), type); - } - - private Object loadFromReader(StreamReader sreader, Class type) { - Composer composer = new Composer(new ParserImpl(sreader), resolver); - constructor.setComposer(composer); - return constructor.getSingleData(type); - } - - /** - * Parse all YAML documents in a String and produce corresponding Java - * objects. The documents are parsed only when the iterator is invoked. - * - * @param yaml YAML data to load from (BOM must not be present) - * @return an iterator over the parsed Java objects in this String in proper - * sequence - */ - public Iterable loadAll(Reader yaml) { - Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver); - constructor.setComposer(composer); - Iterator result = new Iterator() { - public boolean hasNext() { - return constructor.checkData(); - } - - public Object next() { - return constructor.getData(); - } - - public void remove() { - throw new UnsupportedOperationException(); - } - }; - return new YamlIterable(result); - } - - /** - * Parse all YAML documents in a String and produce corresponding Java - * objects. (Because the encoding in known BOM is not respected.) The - * documents are parsed only when the iterator is invoked. - * - * @param yaml YAML data to load from (BOM must not be present) - * @return an iterator over the parsed Java objects in this String in proper - * sequence - */ - public Iterable loadAll(String yaml) { - return loadAll(new StringReader(yaml)); - } - - /** - * Parse all YAML documents in a stream and produce corresponding Java - * objects. The documents are parsed only when the iterator is invoked. - * - * @param yaml YAML data to load from (BOM is respected and ignored) - * @return an iterator over the parsed Java objects in this stream in proper - * sequence - */ - public Iterable loadAll(InputStream yaml) { - return loadAll(new UnicodeReader(yaml)); - } - - /** - * Parse the first YAML document in a stream and produce the corresponding - * representation tree. (This is the opposite of the represent() method) - * - * @param yaml YAML document - * @return parsed root Node for the specified YAML document - * @see Figure 3.1. Processing - * Overview - */ - public Node compose(Reader yaml) { - Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver); - constructor.setComposer(composer); - return composer.getSingleNode(); - } - - /** - * Parse all YAML documents in a stream and produce corresponding - * representation trees. - * - * @param yaml stream of YAML documents - * @return parsed root Nodes for all the specified YAML documents - * @see Processing Overview - */ - public Iterable composeAll(Reader yaml) { - final Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver); - constructor.setComposer(composer); - Iterator result = new Iterator() { - public boolean hasNext() { - return composer.checkNode(); - } - - public Node next() { - return composer.getNode(); - } - - public void remove() { - throw new UnsupportedOperationException(); - } - }; - return new NodeIterable(result); - } - - /** - * Add an implicit scalar detector. If an implicit scalar value matches the - * given regexp, the corresponding tag is assigned to the scalar. - * - * @param tag tag to assign to the node - * @param regexp regular expression to match against - * @param first a sequence of possible initial characters or null (which means any). - */ - public void addImplicitResolver(Tag tag, Pattern regexp, String first) { - resolver.addImplicitResolver(tag, regexp, first); - } - - @Override - public String toString() { - return name; - } - - /** - * Get a meaningful name. It simplifies debugging in a multi-threaded - * environment. If nothing is set explicitly the address of the instance is - * returned. - * - * @return human readable name - */ - public String getName() { - return name; - } - - /** - * Set a meaningful name to be shown in {@code toString()}. - * - * @param name human readable name - */ - public void setName(String name) { - this.name = name; - } - - /** - * Parse a YAML stream and produce parsing events. - * - * @param yaml YAML document(s) - * @return parsed events - * @see Processing Overview - */ - public Iterable parse(Reader yaml) { - final Parser parser = new ParserImpl(new StreamReader(yaml)); - Iterator result = new Iterator() { - public boolean hasNext() { - return parser.peekEvent() != null; - } - - public Event next() { - return parser.getEvent(); - } - - public void remove() { - throw new UnsupportedOperationException(); - } - }; - return new EventIterable(result); - } - - public void setBeanAccess(BeanAccess beanAccess) { - constructor.getPropertyUtils().setBeanAccess(beanAccess); - representer.getPropertyUtils().setBeanAccess(beanAccess); - } - - - private static class SilentEmitter implements Emitable { - - private final List events = new ArrayList<>(100); - - public List getEvents() { - return events; - } - - public void emit(Event event) throws IOException { - events.add(event); - } - - } - - - private static class YamlIterable implements Iterable { - - private final Iterator iterator; - - public YamlIterable(Iterator iterator) { - this.iterator = iterator; - } - - public Iterator iterator() { - return iterator; - } - - } - - - private static class NodeIterable implements Iterable { - - private final Iterator iterator; - - public NodeIterable(Iterator iterator) { - this.iterator = iterator; - } - - public Iterator iterator() { - return iterator; - } - - } - - - private static class EventIterable implements Iterable { - - private final Iterator iterator; - - public EventIterable(Iterator iterator) { - this.iterator = iterator; - } - - public Iterator iterator() { - return iterator; - } - - } - -} diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/file/YamlConfiguration.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/file/YamlConfiguration.java index b1570963a..1e2d5b0c4 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/file/YamlConfiguration.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/file/YamlConfiguration.java @@ -3,10 +3,10 @@ package com.fastasyncworldedit.core.configuration.file; import com.fastasyncworldedit.core.configuration.Configuration; import com.fastasyncworldedit.core.configuration.ConfigurationSection; import com.fastasyncworldedit.core.configuration.InvalidConfigurationException; -import com.fastasyncworldedit.core.configuration.Yaml; import com.sk89q.worldedit.internal.util.LogManagerCompat; import org.apache.logging.log4j.Logger; import org.yaml.snakeyaml.DumperOptions; +import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.error.YAMLException; import org.yaml.snakeyaml.representer.Representer; @@ -127,7 +127,7 @@ public class YamlConfiguration extends FileConfiguration { Map input; try { - input = (Map) yaml.load(contents); + input = yaml.load(contents); } catch (final YAMLException e) { throw new InvalidConfigurationException(e); } catch (final ClassCastException e) { @@ -193,8 +193,7 @@ public class YamlConfiguration extends FileConfiguration { if (options().copyHeader()) { final Configuration def = getDefaults(); - if (def != null && def instanceof FileConfiguration) { - final FileConfiguration filedefaults = (FileConfiguration) def; + if (def != null && def instanceof final FileConfiguration filedefaults) { final String defaultsHeader = filedefaults.buildHeader(); if ((defaultsHeader != null) && !defaultsHeader.isEmpty()) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/serialization/ConfigurationSerialization.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/serialization/ConfigurationSerialization.java index 536a393d1..4e26c665d 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/serialization/ConfigurationSerialization.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/serialization/ConfigurationSerialization.java @@ -27,28 +27,6 @@ public class ConfigurationSerialization { this.clazz = clazz; } - /** - * Attempts to deserialize the given arguments into a new instance of the - * given class. - *

- *

The class must implement {@link ConfigurationSerializable}, including - * the extra methods as specified in the javadoc of - * ConfigurationSerializable.

- *

- *

If a new instance could not be made, an example being the class not - * fully implementing the interface, null will be returned.

- * - * @param args Arguments for deserialization - * @param clazz Class to deserialize into - * @return New instance of the specified class - */ - public static ConfigurationSerializable deserializeObject( - Map args, - Class clazz - ) { - return new ConfigurationSerialization(clazz).deserialize(args); - } - /** * Attempts to deserialize the given arguments into a new instance of the *

@@ -66,7 +44,7 @@ public class ConfigurationSerialization { * @return New instance of the specified class */ public static ConfigurationSerializable deserializeObject(Map args) { - Class clazz = null; + Class clazz; if (args.containsKey(SERIALIZED_TYPE_KEY)) { try { @@ -116,25 +94,6 @@ public class ConfigurationSerialization { aliases.put(alias, clazz); } - /** - * Unregisters the specified alias to a {@link ConfigurationSerializable} - * - * @param alias Alias to unregister - */ - public static void unregisterClass(String alias) { - aliases.remove(alias); - } - - /** - * Unregisters any aliases for the specified {@link ConfigurationSerializable} class. - * - * @param clazz Class to unregister - */ - public static void unregisterClass(Class clazz) { - while (aliases.values().remove(clazz)) { - } - } - /** * Attempts to get a registered {@link ConfigurationSerializable} class by * its alias. diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/entity/LazyBaseEntity.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/entity/LazyBaseEntity.java index 8eb221269..f591cf826 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/entity/LazyBaseEntity.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/entity/LazyBaseEntity.java @@ -2,7 +2,6 @@ package com.fastasyncworldedit.core.entity; import com.fastasyncworldedit.core.Fawe; import com.fastasyncworldedit.core.util.TaskManager; -import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.util.nbt.CompoundBinaryTag; import com.sk89q.worldedit.world.entity.EntityType; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/entity/MapMetadatable.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/entity/MapMetadatable.java index 3cfd9735c..46947efe4 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/entity/MapMetadatable.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/entity/MapMetadatable.java @@ -20,6 +20,7 @@ public interface MapMetadatable extends Metadatable { * {@inheritDoc} */ @Override + @SuppressWarnings("unchecked") default T getAndSetMeta(String key, T value) { return (T) getRawMeta().put(key, value); } @@ -40,6 +41,7 @@ public interface MapMetadatable extends Metadatable { * {@inheritDoc} */ @Override + @SuppressWarnings("unchecked") default V getMeta(String key) { return (V) getRawMeta().get(key); } @@ -49,6 +51,7 @@ public interface MapMetadatable extends Metadatable { */ @Nonnull @Override + @SuppressWarnings("unchecked") default V getMeta(String key, @Nonnull V def) { V value = (V) getRawMeta().get(key); return value == null ? def : value; @@ -58,6 +61,7 @@ public interface MapMetadatable extends Metadatable { * {@inheritDoc} */ @Override + @SuppressWarnings("unchecked") default V deleteMeta(String key) { return (V) getRawMeta().remove(key); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/event/extent/PasteEvent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/event/extent/PasteEvent.java index de538f937..3f841bb1d 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/event/extent/PasteEvent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/event/extent/PasteEvent.java @@ -65,8 +65,7 @@ public class PasteEvent extends Event implements Cancellable { * @return a new event */ public PasteEvent clone(Stage stage) { - PasteEvent clone = new PasteEvent(actor, clipboard, uri, extent, to); - return clone; + return new PasteEvent(actor, clipboard, uri, extent, to); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/mask/RichMaskParser.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/mask/RichMaskParser.java index 75bbc6bf1..c4257c73f 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/mask/RichMaskParser.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/mask/RichMaskParser.java @@ -109,17 +109,13 @@ public class RichMaskParser extends FaweParser { // Legacy syntax if (charMask) { switch (char0) { - case '\\': - case '/': - case '{': - case '|': - case '~': { + case '\\', '/', '{', '|', '~' -> { String value = command.substring(1) + ((entry.getValue().isEmpty()) ? "" : "[" + StringMan.join( - entry.getValue(), - "][" - ) + "]"); + entry.getValue(), + "][" + ) + "]"); if (value.contains(":")) { if (value.charAt(0) == ':') { value = value.replaceFirst(":", ""); @@ -127,15 +123,11 @@ public class RichMaskParser extends FaweParser { value = value.replaceAll(":", "]["); } mask = parseFromInput(char0 + "[" + value + "]", context); - break; } - case '%': - case '$': - case '<': - case '>': - case '!': + case '%', '$', '<', '>', '!' -> { input = input.substring(input.indexOf(char0) + 1); mask = parseFromInput(char0 + "[" + input + "]", context); + } } } if (mask == null) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/mask/YAxisMaskParser.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/mask/YAxisMaskParser.java index 8c4b38073..14aadade3 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/mask/YAxisMaskParser.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/mask/YAxisMaskParser.java @@ -24,7 +24,7 @@ public class YAxisMaskParser extends SimpleInputParser { @Override public Mask parseFromSimpleInput(String input, ParserContext context) { - return new YAxisMask(context.getExtent()); + return new YAxisMask(); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/Linear2DPatternParser.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/Linear2DPatternParser.java index de3e725d4..5a310f60a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/Linear2DPatternParser.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/Linear2DPatternParser.java @@ -30,15 +30,11 @@ public class Linear2DPatternParser extends RichParser { @Override protected Stream getSuggestions(String argumentInput, int index) { - switch (index) { - case 0: - return this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream(); - case 1: - case 2: - return SuggestionHelper.suggestPositiveIntegers(argumentInput); - default: - return Stream.empty(); - } + return switch (index) { + case 0 -> this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream(); + case 1, 2 -> SuggestionHelper.suggestPositiveIntegers(argumentInput); + default -> Stream.empty(); + }; } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/Linear3DPatternParser.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/Linear3DPatternParser.java index 859afdafc..ef45e8faa 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/Linear3DPatternParser.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/Linear3DPatternParser.java @@ -30,16 +30,11 @@ public class Linear3DPatternParser extends RichParser { @Override protected Stream getSuggestions(String argumentInput, int index) { - switch (index) { - case 0: - return this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream(); - case 1: - case 2: - case 3: - return SuggestionHelper.suggestPositiveIntegers(argumentInput); - default: - return Stream.empty(); - } + return switch (index) { + case 0 -> this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream(); + case 1, 2, 3 -> SuggestionHelper.suggestPositiveIntegers(argumentInput); + default -> Stream.empty(); + }; } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/LinearPatternParser.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/LinearPatternParser.java index 32d63cbba..785e8261d 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/LinearPatternParser.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/LinearPatternParser.java @@ -29,16 +29,11 @@ public class LinearPatternParser extends RichParser { @Override protected Stream getSuggestions(String argumentInput, int index) { - switch (index) { - case 0: - return this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream(); - case 1: - case 2: - case 3: - return SuggestionHelper.suggestPositiveIntegers(argumentInput); - default: - return Stream.empty(); - } + return switch (index) { + case 0 -> this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream(); + case 1, 2, 3 -> SuggestionHelper.suggestPositiveIntegers(argumentInput); + default -> Stream.empty(); + }; } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/MaskedPatternParser.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/MaskedPatternParser.java index 426754675..3aed039c3 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/MaskedPatternParser.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/MaskedPatternParser.java @@ -26,15 +26,11 @@ public class MaskedPatternParser extends RichParser { @Override protected Stream getSuggestions(String argumentInput, int index) { - switch (index) { - case 0: - return this.worldEdit.getMaskFactory().getSuggestions(argumentInput).stream(); - case 1: - case 2: - return this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream(); - default: - return Stream.empty(); - } + return switch (index) { + case 0 -> this.worldEdit.getMaskFactory().getSuggestions(argumentInput).stream(); + case 1, 2 -> this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream(); + default -> Stream.empty(); + }; } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/OffsetPatternParser.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/OffsetPatternParser.java index c40d74c8e..6ae72c7a0 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/OffsetPatternParser.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/OffsetPatternParser.java @@ -26,16 +26,11 @@ public class OffsetPatternParser extends RichParser { @Override protected Stream getSuggestions(String argumentInput, int index) { - switch (index) { - case 0: - return this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream(); - case 1: - case 2: - case 3: - return SuggestionHelper.suggestPositiveIntegers(argumentInput); - default: - return Stream.empty(); - } + return switch (index) { + case 0 -> this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream(); + case 1, 2, 3 -> SuggestionHelper.suggestPositiveIntegers(argumentInput); + default -> Stream.empty(); + }; } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/RandomOffsetPatternParser.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/RandomOffsetPatternParser.java index a827c20f7..2486ef119 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/RandomOffsetPatternParser.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/RandomOffsetPatternParser.java @@ -26,16 +26,11 @@ public class RandomOffsetPatternParser extends RichParser { @Override protected Stream getSuggestions(String argumentInput, int index) { - switch (index) { - case 0: - return this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream(); - case 1: - case 2: - case 3: - return SuggestionHelper.suggestPositiveIntegers(argumentInput); - default: - return Stream.empty(); - } + return switch (index) { + case 0 -> this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream(); + case 1, 2, 3 -> SuggestionHelper.suggestPositiveIntegers(argumentInput); + default -> Stream.empty(); + }; } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/SolidRandomOffsetPatternParser.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/SolidRandomOffsetPatternParser.java index ef6c3b2c4..618c463d6 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/SolidRandomOffsetPatternParser.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/SolidRandomOffsetPatternParser.java @@ -26,16 +26,11 @@ public class SolidRandomOffsetPatternParser extends RichParser { @Override protected Stream getSuggestions(String argumentInput, int index) { - switch (index) { - case 0: - return this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream(); - case 1: - case 2: - case 3: - return SuggestionHelper.suggestPositiveIntegers(argumentInput); - default: - return Stream.empty(); - } + return switch (index) { + case 0 -> this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream(); + case 1, 2, 3 -> SuggestionHelper.suggestPositiveIntegers(argumentInput); + default -> Stream.empty(); + }; } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/SurfaceRandomOffsetPatternParser.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/SurfaceRandomOffsetPatternParser.java index 7bb255332..aa28b11d8 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/SurfaceRandomOffsetPatternParser.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/SurfaceRandomOffsetPatternParser.java @@ -26,14 +26,11 @@ public class SurfaceRandomOffsetPatternParser extends RichParser { @Override protected Stream getSuggestions(String argumentInput, int index) { - switch (index) { - case 0: - return this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream(); - case 1: - return SuggestionHelper.suggestPositiveIntegers(argumentInput); - default: - return Stream.empty(); - } + return switch (index) { + case 0 -> this.worldEdit.getPatternFactory().getSuggestions(argumentInput).stream(); + case 1 -> SuggestionHelper.suggestPositiveIntegers(argumentInput); + default -> Stream.empty(); + }; } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/transform/RandomTransformParser.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/transform/RandomTransformParser.java index b21834812..b7bcfb56a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/transform/RandomTransformParser.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/transform/RandomTransformParser.java @@ -50,8 +50,8 @@ public class RandomTransformParser extends InputParser { return null; } RandomTransform randomTransform = new RandomTransform(); - for (int i = 0; i < split.size(); i++) { - ResettableExtent transform = worldEdit.getTransformFactory().parseFromInput(split.get(i), context); + for (String s : split) { + ResettableExtent transform = worldEdit.getTransformFactory().parseFromInput(s, context); randomTransform.add(transform, 1d); } return randomTransform; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/Bindings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/Bindings.java index 249361736..e66d173e2 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/Bindings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/Bindings.java @@ -22,6 +22,7 @@ import java.lang.reflect.Method; import java.util.Optional; import java.util.function.Function; +@SuppressWarnings({"rawtypes", "unchecked"}) public class Bindings { private static final Logger LOGGER = LogManagerCompat.getLogger(); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/CommandBindings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/CommandBindings.java index 364cef5e5..d1b0b25d3 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/CommandBindings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/CommandBindings.java @@ -2,6 +2,7 @@ package com.fastasyncworldedit.core.extension.platform.binding; import com.sk89q.worldedit.WorldEdit; +@SuppressWarnings("unused") public class CommandBindings extends Bindings { public CommandBindings(WorldEdit worldEdit) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ConsumeBindings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ConsumeBindings.java index 3c7ad1f4d..c1997bb0d 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ConsumeBindings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ConsumeBindings.java @@ -32,6 +32,7 @@ import org.enginehub.piston.inject.InjectedValueAccess; import java.util.UUID; +@SuppressWarnings("unused") public class ConsumeBindings extends Bindings { private final PlatformCommandManager manager; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/PrimitiveBindings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/PrimitiveBindings.java index 904b3608f..110bb576c 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/PrimitiveBindings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/PrimitiveBindings.java @@ -15,6 +15,7 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent; import javax.annotation.Nullable; import java.util.Locale; +@SuppressWarnings("unused") public class PrimitiveBindings extends Bindings { public PrimitiveBindings(WorldEdit worldEdit) { @@ -48,26 +49,12 @@ public class PrimitiveBindings extends Bindings { */ @Binding public Boolean getBoolean(String argument) { - switch (argument.toLowerCase(Locale.ROOT)) { - case "": - throw new InputParseException(Caption.of("fawe.error.input-parser-exception")); - case "true": - case "yes": - case "on": - case "y": - case "1": - case "t": - return true; - case "false": - case "no": - case "off": - case "f": - case "n": - case "0": - return false; - default: - throw new InputParseException(Caption.of("fawe.error.invalid-boolean", TextComponent.of(argument))); - } + return switch (argument.toLowerCase(Locale.ROOT)) { + case "" -> throw new InputParseException(Caption.of("fawe.error.input-parser-exception")); + case "true", "yes", "on", "y", "1", "t" -> true; + case "false", "no", "off", "f", "n", "0" -> false; + default -> throw new InputParseException(Caption.of("fawe.error.invalid-boolean", TextComponent.of(argument))); + }; } /** @@ -84,18 +71,13 @@ public class PrimitiveBindings extends Bindings { final double radiusY; final double radiusZ; switch (radii.length) { - case 1: - radiusX = radiusY = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]); - break; - - case 3: + case 1 -> radiusX = radiusY = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]); + case 3 -> { radiusX = PrimitiveBindings.parseNumericInput(radii[0]); radiusY = PrimitiveBindings.parseNumericInput(radii[1]); radiusZ = PrimitiveBindings.parseNumericInput(radii[2]); - break; - - default: - throw new InputParseException("You must either specify 1 or 3 radius values."); + } + default -> throw new InputParseException("You must either specify 1 or 3 radius values."); } return Vector3.at(radiusX, radiusY, radiusZ); } @@ -115,17 +97,12 @@ public class PrimitiveBindings extends Bindings { final double radiusX; final double radiusZ; switch (radii.length) { - case 1: - radiusX = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]); - break; - - case 2: + case 1 -> radiusX = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]); + case 2 -> { radiusX = PrimitiveBindings.parseNumericInput(radii[0]); radiusZ = PrimitiveBindings.parseNumericInput(radii[1]); - break; - - default: - throw new InputParseException("You must either specify 1 or 2 radius values."); + } + default -> throw new InputParseException("You must either specify 1 or 2 radius values."); } return Vector2.at(radiusX, radiusZ); } @@ -145,18 +122,13 @@ public class PrimitiveBindings extends Bindings { final double radiusY; final double radiusZ; switch (radii.length) { - case 1: - radiusX = radiusY = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]); - break; - - case 3: + case 1 -> radiusX = radiusY = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]); + case 3 -> { radiusX = PrimitiveBindings.parseNumericInput(radii[0]); radiusY = PrimitiveBindings.parseNumericInput(radii[1]); radiusZ = PrimitiveBindings.parseNumericInput(radii[2]); - break; - - default: - throw new InputParseException("You must either specify 1 or 3 radius values."); + } + default -> throw new InputParseException("You must either specify 1 or 3 radius values."); } return BlockVector3.at(radiusX, radiusY, radiusZ); } @@ -175,17 +147,12 @@ public class PrimitiveBindings extends Bindings { final double radiusX; final double radiusZ; switch (radii.length) { - case 1: - radiusX = radiusZ = parseNumericInput(radii[0]); - break; - - case 2: + case 1 -> radiusX = radiusZ = parseNumericInput(radii[0]); + case 2 -> { radiusX = parseNumericInput(radii[0]); radiusZ = parseNumericInput(radii[1]); - break; - - default: - throw new InputParseException("You must either specify 1 or 2 radius values."); + } + default -> throw new InputParseException("You must either specify 1 or 2 radius values."); } return BlockVector2.at(radiusX, radiusZ); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ProvideBindings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ProvideBindings.java index 8a5b25058..bc1e2bfbf 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ProvideBindings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ProvideBindings.java @@ -125,8 +125,7 @@ public class ProvideBindings extends Bindings { return extent; } EditSession editSession = editSession(getLocalSession(actor), actor, access); - if (access instanceof InjectedValueStore) { - InjectedValueStore store = (InjectedValueStore) access; + if (access instanceof InjectedValueStore store) { store.injectValue(Key.of(EditSession.class), ValueProvider.constant(editSession)); } return editSession; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/DisallowedBlocksExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/DisallowedBlocksExtent.java index d12c97343..3443c3e33 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/DisallowedBlocksExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/DisallowedBlocksExtent.java @@ -101,6 +101,7 @@ public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IB return super.setBlock(x, y, z, block); } + @SuppressWarnings("unchecked") private > B checkBlock(B block) { if (blockedBlocks != null) { if (blockedBlocks.contains(block.getBlockType().getId())) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/StripNBTExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/StripNBTExtent.java index cb4db9a48..b6cb3ef96 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/StripNBTExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/StripNBTExtent.java @@ -65,11 +65,11 @@ public class StripNBTExtent extends AbstractDelegateExtent implements IBatchProc return super.createEntity(location, stripEntityNBT(entity)); } + @SuppressWarnings("unchecked") public > B stripBlockNBT(B block) { - if (!(block instanceof BaseBlock)) { + if (!(block instanceof BaseBlock localBlock)) { return block; } - BaseBlock localBlock = (BaseBlock) block; if (!localBlock.hasNbtData()) { return block; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/TransformExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/TransformExtent.java index d948fe4be..91b99b025 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/TransformExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/TransformExtent.java @@ -93,6 +93,7 @@ public class TransformExtent extends BlockTransformExtent { } @Override + @SuppressWarnings("unchecked") public > boolean setBlock(int x, int y, int z, T block) throws WorldEditException { return super.setBlock(getPos(x, y, z), transformInverse(block)); @@ -100,6 +101,7 @@ public class TransformExtent extends BlockTransformExtent { @Override + @SuppressWarnings("unchecked") public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { return super.setBlock(getPos(location), transformInverse(block)); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/CPUOptimizedClipboard.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/CPUOptimizedClipboard.java index 5049741c9..fc2122b07 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/CPUOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/CPUOptimizedClipboard.java @@ -107,7 +107,7 @@ public class CPUOptimizedClipboard extends LinearClipboard { } for (Map.Entry entry : nbtMapLoc.entrySet()) { IntTriple key = entry.getKey(); - setTile(getIndex(key.getX(), key.getY(), key.getZ()), entry.getValue()); + setTile(getIndex(key.x(), key.y(), key.z()), entry.getValue()); } nbtMapLoc.clear(); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java index 40e2b86d0..6b791d4f4 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java @@ -379,7 +379,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable nbt = null; for (Map.Entry entry : nbtMap.entrySet()) { IntTriple key = entry.getKey(); - int index = getIndex(key.getX(), key.getY(), key.getZ()); + int index = getIndex(key.x(), key.y(), key.z()); if (index == i) { nbt = entry.getValue(); break; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/LinearClipboard.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/LinearClipboard.java index 6b0614d7e..491ef5687 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/LinearClipboard.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/LinearClipboard.java @@ -42,8 +42,6 @@ public abstract class LinearClipboard extends SimpleClipboard { /** * The locations provided are relative to the clipboard min - * - * @param task */ public abstract void streamBiomes(IntValueReader task); @@ -63,27 +61,25 @@ public abstract class LinearClipboard extends SimpleClipboard { @Override public Iterator iterator(Order order) { Region region = getRegion(); - switch (order) { - case YZX: - if (region instanceof CuboidRegion) { - Iterator iter = ((CuboidRegion) region).iterator_old(); - LinearFilter filter = new LinearFilter(); + if (order == Order.YZX) { + if (region instanceof CuboidRegion) { + Iterator iter = ((CuboidRegion) region).iterator_old(); + LinearFilter filter = new LinearFilter(); - return new ForwardingIterator() { - @Override - protected Iterator delegate() { - return iter; - } + return new ForwardingIterator<>() { + @Override + protected Iterator delegate() { + return iter; + } - @Override - public BlockVector3 next() { - return filter.next(super.next()); - } - }; - } - default: - return order.create(region); + @Override + public BlockVector3 next() { + return filter.next(super.next()); + } + }; + } } + return order.create(region); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/MemoryOptimizedClipboard.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/MemoryOptimizedClipboard.java index 6823acc97..28dc1d3cc 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/MemoryOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/MemoryOptimizedClipboard.java @@ -215,7 +215,7 @@ public class MemoryOptimizedClipboard extends LinearClipboard { nbt = null; for (Map.Entry entry : nbtMap.entrySet()) { IntTriple trio = entry.getKey(); - int index = getIndex(trio.getX(), trio.getY(), trio.getZ()); + int index = getIndex(trio.x(), trio.y(), trio.z()); if (index == i) { nbt = entry.getValue(); break; @@ -308,10 +308,9 @@ public class MemoryOptimizedClipboard extends LinearClipboard { @Override public List getEntities(Region region) { - return new ArrayList<>(entities + return entities .stream() - .filter(e -> region.contains(e.getLocation().toBlockPoint())) - .collect(Collectors.toList())); + .filter(e -> region.contains(e.getLocation().toBlockPoint())).collect(Collectors.toList()); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/MultiClipboardHolder.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/MultiClipboardHolder.java index de739adf8..b50102de2 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/MultiClipboardHolder.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/MultiClipboardHolder.java @@ -69,8 +69,7 @@ public class MultiClipboardHolder extends URIClipboardHolder { @Override public URI getURI(Clipboard clipboard) { for (ClipboardHolder holder : getHolders()) { - if (holder instanceof URIClipboardHolder) { - URIClipboardHolder uriHolder = (URIClipboardHolder) holder; + if (holder instanceof URIClipboardHolder uriHolder) { URI uri = uriHolder.getURI(clipboard); if (uri != null) { return uri; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/ResizableClipboardBuilder.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/ResizableClipboardBuilder.java index b713fed8f..05089a111 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/ResizableClipboardBuilder.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/ResizableClipboardBuilder.java @@ -66,12 +66,10 @@ public class ResizableClipboardBuilder extends MemoryOptimizedHistory { try { while (iterator.hasNext()) { Change change = iterator.next(); - if (change instanceof MutableBlockChange) { - MutableBlockChange blockChange = (MutableBlockChange) change; + if (change instanceof MutableBlockChange blockChange) { BlockState block = BlockState.getFromOrdinal(blockChange.ordinal); clipboard.setBlock(blockChange.x, blockChange.y, blockChange.z, block); - } else if (change instanceof MutableTileChange) { - MutableTileChange tileChange = (MutableTileChange) change; + } else if (change instanceof MutableTileChange tileChange) { int x = tileChange.tag.getInt("x"); int y = tileChange.tag.getInt("y"); int z = tileChange.tag.getInt("z"); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicReader.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicReader.java index 87ca68044..d884e0151 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicReader.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicReader.java @@ -275,8 +275,7 @@ public class FastSchematicReader extends NBTSchematicReader { if (blocksOut != null && blocksOut.getSize() != 0) { try (FaweInputStream fis = new FaweInputStream(new LZ4BlockInputStream(new FastByteArraysInputStream(blocksOut.toByteArrays())))) { - if (clipboard instanceof LinearClipboard) { - LinearClipboard linear = (LinearClipboard) clipboard; + if (clipboard instanceof LinearClipboard linear) { int volume = width * height * length; if (palette.length < 128) { for (int index = 0; index < volume; index++) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/MinecraftStructure.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/MinecraftStructure.java index 79d5f8186..66deefeb7 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/MinecraftStructure.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/MinecraftStructure.java @@ -99,7 +99,7 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter { for (Map.Entry entry : properties.getValue().entrySet()) { String key = entry.getKey(); String value = ((StringTag) entry.getValue()).getValue(); - Property property = type.getProperty(key); + Property property = type.getProperty(key); state = state.with(property, property.getValueFor(value)); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/ForkedFilter.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/ForkedFilter.java index 28d57ef34..3f6e03ce3 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/ForkedFilter.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/ForkedFilter.java @@ -9,6 +9,7 @@ public abstract class ForkedFilter> implements Filter protected final Map children; + @SuppressWarnings("unchecked") public ForkedFilter(T root) { if (root != null) { children = root.children; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/DelegateFilter.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/DelegateFilter.java index b2dfb42ae..3d35d7651 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/DelegateFilter.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/DelegateFilter.java @@ -12,6 +12,7 @@ public abstract class DelegateFilter implements IDelegateFilte } @Override + @SuppressWarnings("unchecked") public final T getParent() { return (T) parent; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/IBatchProcessorHolder.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/IBatchProcessorHolder.java index ff7968e57..a192e9748 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/IBatchProcessorHolder.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/IBatchProcessorHolder.java @@ -20,8 +20,6 @@ public interface IBatchProcessorHolder extends IBatchProcessor { /** * Set the held processor - * - * @param set */ void setProcessor(IBatchProcessor set); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/MultiBatchProcessor.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/MultiBatchProcessor.java index ca463f911..f40047e60 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/MultiBatchProcessor.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/MultiBatchProcessor.java @@ -55,14 +55,11 @@ public class MultiBatchProcessor implements IBatchProcessor { list.add(processor); } } - switch (list.size()) { - case 0: - return EmptyBatchProcessor.getInstance(); - case 1: - return list.get(0); - default: - return new MultiBatchProcessor(list.toArray(new IBatchProcessor[0])); - } + return switch (list.size()) { + case 0 -> EmptyBatchProcessor.getInstance(); + case 1 -> list.get(0); + default -> new MultiBatchProcessor(list.toArray(new IBatchProcessor[0])); + }; } public void addBatchProcessor(IBatchProcessor processor) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/lighting/NMSRelighter.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/lighting/NMSRelighter.java index ef8b73f21..97a97f9a7 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/lighting/NMSRelighter.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/lighting/NMSRelighter.java @@ -34,6 +34,7 @@ import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.locks.ReentrantLock; +@SuppressWarnings("rawtypes") public class NMSRelighter implements Relighter { private static final int DISPATCH_SIZE = 64; @@ -988,11 +989,10 @@ public class NMSRelighter implements Relighter { return; } switch (reason) { - case SkipReason.SOLID: { + case SkipReason.SOLID -> { Arrays.fill(mask, (byte) 0); - return; } - case SkipReason.AIR: { + case SkipReason.AIR -> { int index = 0; for (int z = 0; z < 16; z++) { for (int x = 0; x < 16; x++) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/OreGen.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/OreGen.java index 73262f306..9ed44fe0d 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/OreGen.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/OreGen.java @@ -26,8 +26,6 @@ public class OreGen implements Resource { private final double ONE_8 = 1 / 8F; private final double ONE_16 = 1 / 16F; - public int laced = 0; - public OreGen(Extent extent, Mask mask, Pattern pattern, int size, int minY, int maxY) { this.maxSize = size; this.maxSizeO8 = size * ONE_8; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ABlockMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ABlockMask.java index 48593a6e0..1f0b88bfa 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ABlockMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ABlockMask.java @@ -55,8 +55,7 @@ public abstract class ABlockMask extends AbstractExtentMask { @Override public Mask tryCombine(Mask mask) { - if (mask instanceof ABlockMask) { - ABlockMask other = (ABlockMask) mask; + if (mask instanceof ABlockMask other) { BlockMask newMask = new BlockMask(getExtent()); for (BlockState state : BlockTypesCache.states) { if (state != null) { @@ -76,8 +75,7 @@ public abstract class ABlockMask extends AbstractExtentMask { @Override public Mask tryOr(Mask mask) { - if (mask instanceof ABlockMask) { - ABlockMask other = (ABlockMask) mask; + if (mask instanceof ABlockMask other) { BlockMask newMask = new BlockMask(getExtent()); for (BlockState state : BlockTypesCache.states) { if (state != null) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/BlockMaskBuilder.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/BlockMaskBuilder.java index 509f693d0..f16ebe766 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/BlockMaskBuilder.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/BlockMaskBuilder.java @@ -161,16 +161,13 @@ public class BlockMaskBuilder { for (int i = last; i < length; i++) { char c = input.charAt(i); switch (c) { - case '[': - case '{': - case '(': + case '[', '{', '(' -> { int next = StringMan.findMatchingBracket(input, i); if (next != -1) { i = next; } - break; - case ']': - case ',': { + } + case ']', ',' -> { charSequence.setSubstring(last, i); if (key == null && PropertyKey.getByName(charSequence) == null) { suggest( @@ -218,35 +215,21 @@ public class BlockMaskBuilder { key = null; operator = null; last = i + 1; - break; } - case '~': - case '!': - case '=': - case '<': - case '>': { + case '~', '!', '=', '<', '>' -> { charSequence.setSubstring(last, i); boolean extra = input.charAt(i + 1) == '='; if (extra) { i++; } - switch (c) { - case '~': - operator = EQUAL_OR_NULL; - break; - case '!': - operator = NOT; - break; - case '=': - operator = EQUAL; - break; - case '<': - operator = extra ? LESS_EQUAL : LESS; - break; - case '>': - operator = extra ? GREATER_EQUAL : GREATER; - break; - } + operator = switch (c) { + case '~' -> EQUAL_OR_NULL; + case '!' -> NOT; + case '=' -> EQUAL; + case '<' -> extra ? LESS_EQUAL : LESS; + case '>' -> extra ? GREATER_EQUAL : GREATER; + default -> operator; + }; if (charSequence.length() > 0 || key == null) { key = PropertyKey.getByName(charSequence); if (key == null) { @@ -258,10 +241,9 @@ public class BlockMaskBuilder { } } last = i + 1; - break; } - default: - break; + default -> { + } } } } else { @@ -395,6 +377,7 @@ public class BlockMaskBuilder { return this; } + @SuppressWarnings({"unchecked", "rawtypes"}) public BlockMaskBuilder filter( Predicate typePredicate, BiPredicate, T>> allowed @@ -491,6 +474,7 @@ public class BlockMaskBuilder { return this; } + @SuppressWarnings({"unchecked", "rawtypes"}) public BlockMaskBuilder addAll( Predicate typePredicate, BiPredicate, ?>> propPredicate diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ExtremaMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ExtremaMask.java index 36ee67d61..380bf301e 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ExtremaMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ExtremaMask.java @@ -13,7 +13,6 @@ public class ExtremaMask extends AngleMask { protected boolean testSlope(Extent extent, int x, int y, int z) { double slope; double tmp; - boolean aboveMin; lastY = y; int base = getHeight(extent, x, y, z); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/MaskUnion.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/MaskUnion.java index 20bab9bbd..381754a3c 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/MaskUnion.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/MaskUnion.java @@ -55,14 +55,11 @@ public class MaskUnion extends MaskIntersection { } } } - switch (set.size()) { - case 0: - return Masks.alwaysTrue(); - case 1: - return set.iterator().next(); - default: - return new MaskUnion(masks).optimize(); - } + return switch (set.size()) { + case 0 -> Masks.alwaysTrue(); + case 1 -> set.iterator().next(); + default -> new MaskUnion(masks).optimize(); + }; } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SingleBlockStateMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SingleBlockStateMask.java index c0ea93198..32d853bda 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SingleBlockStateMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SingleBlockStateMask.java @@ -51,8 +51,7 @@ public class SingleBlockStateMask extends ABlockMask { @Override public Mask tryCombine(Mask mask) { - if (mask instanceof ABlockMask) { - ABlockMask other = (ABlockMask) mask; + if (mask instanceof ABlockMask other) { if (other.test(BlockState.getFromOrdinal(ordinal))) { return this; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/YAxisMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/YAxisMask.java index 8dace5fee..ee852e70e 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/YAxisMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/YAxisMask.java @@ -1,6 +1,5 @@ package com.fastasyncworldedit.core.function.mask; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; @@ -9,7 +8,7 @@ public class YAxisMask extends AbstractMask implements ResettableMask { private transient int layer = -1; - public YAxisMask(Extent extent) { + public YAxisMask() { } @Override @@ -27,7 +26,7 @@ public class YAxisMask extends AbstractMask implements ResettableMask { @Override public Mask copy() { - return new YAxisMask(null); + return new YAxisMask(); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/PatternTraverser.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/PatternTraverser.java index 262204af6..b01b782b2 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/PatternTraverser.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/PatternTraverser.java @@ -19,6 +19,7 @@ public class PatternTraverser { reset(pattern, newExtent); } + @SuppressWarnings({"unchecked"}) private void reset(Object pattern, Extent newExtent) { if (pattern == null) { return; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/DFSVisitor.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/DFSVisitor.java index d6c9dc7ed..6eba1d7dc 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/DFSVisitor.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/DFSVisitor.java @@ -95,9 +95,9 @@ public abstract class DFSVisitor implements Operation { int countAdd = 0; int countAttempt = 0; for (IntTriple direction : dirs) { - mutable2.mutX(from.getX() + direction.getX()); - mutable2.mutY(from.getY() + direction.getY()); - mutable2.mutZ(from.getZ() + direction.getZ()); + mutable2.mutX(from.getX() + direction.x()); + mutable2.mutY(from.getY() + direction.y()); + mutable2.mutZ(from.getZ() + direction.z()); if (isVisitable(mutable, mutable2)) { Node adjacent = new Node(mutable2.getBlockX(), mutable2.getBlockY(), mutable2.getBlockZ()); if (!adjacent.equals(current.from)) { @@ -175,7 +175,7 @@ public abstract class DFSVisitor implements Operation { } @Override - public final int hashCode() { + public int hashCode() { return (x ^ (z << 12)) ^ (y << 24); } @@ -208,17 +208,7 @@ public abstract class DFSVisitor implements Operation { } - public static class NodePair { - - public final Node to; - public final Node from; - private final int depth; - - NodePair(Node from, Node to, int depth) { - this.from = from; - this.to = to; - this.depth = depth; - } + public record NodePair(Node from, Node to, int depth) { } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/IntersectRegionFunction.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/IntersectRegionFunction.java index 913b813e0..32a62505a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/IntersectRegionFunction.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/IntersectRegionFunction.java @@ -4,13 +4,7 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.math.BlockVector3; -public class IntersectRegionFunction implements RegionFunction { - - private final RegionFunction[] functions; - - public IntersectRegionFunction(RegionFunction... functions) { - this.functions = functions; - } +public record IntersectRegionFunction(RegionFunction... functions) implements RegionFunction { @Override public boolean apply(BlockVector3 position) throws WorldEditException { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/change/MutableEntityChange.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/change/MutableEntityChange.java index 16311a5a0..2aeca60d3 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/change/MutableEntityChange.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/change/MutableEntityChange.java @@ -50,6 +50,7 @@ public class MutableEntityChange implements Change { } } + @SuppressWarnings({"unchecked"}) public void delete(UndoContext context) { Map map = tag.getValue(); long most; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/jnbt/CompressedCompoundTag.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/jnbt/CompressedCompoundTag.java index bcb4d11ad..85bdddf09 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/jnbt/CompressedCompoundTag.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/jnbt/CompressedCompoundTag.java @@ -38,9 +38,7 @@ public abstract class CompressedCompoundTag extends CompoundTag { CompoundTag tag = (CompoundTag) nbtIn.readTag(); Map value = tag.getValue(); Map raw = super.getValue(); - for (Map.Entry entry : value.entrySet()) { - raw.put(entry.getKey(), entry.getValue()); - } + raw.putAll(value); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/jnbt/JSON2NBT.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/jnbt/JSON2NBT.java index 14f9fc5d1..8b942895d 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/jnbt/JSON2NBT.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/jnbt/JSON2NBT.java @@ -21,6 +21,7 @@ import java.util.Iterator; import java.util.Stack; import java.util.regex.Pattern; +@SuppressWarnings({"unchecked", "rawtypes"}) public class JSON2NBT { private static final Pattern INT_ARRAY_MATCHER = Pattern.compile("\\[[-+\\d|,\\s]+\\]"); @@ -56,11 +57,11 @@ public class JSON2NBT { } } else if (!flag) { if (c0 != 123 && c0 != 91) { - if (c0 == 125 && (stack.isEmpty() || ((Character) stack.pop()).charValue() != 123)) { + if (c0 == 125 && (stack.isEmpty() || (Character) stack.pop() != 123)) { throw new NBTException("Unbalanced curly brackets {}: " + str); } - if (c0 == 93 && (stack.isEmpty() || ((Character) stack.pop()).charValue() != 91)) { + if (c0 == 93 && (stack.isEmpty() || (Character) stack.pop() != 91)) { throw new NBTException("Unbalanced square brackets []: " + str); } } else { @@ -68,7 +69,7 @@ public class JSON2NBT { ++i; } - stack.push(Character.valueOf(c0)); + stack.push(c0); } } } @@ -93,7 +94,6 @@ public class JSON2NBT { private static JSON2NBT.Any nameValueToNBT(String key, String value) throws NBTException { value = value.trim(); String s; - boolean c0; char c01; if (value.startsWith("{")) { value = value.substring(1, value.length() - 1); @@ -102,7 +102,6 @@ public class JSON2NBT { for (JSON2NBT$list1 = new JSON2NBT.Compound(key); value.length() > 0; value = value.substring(s.length() + 1)) { s = nextNameValuePair(value, true); if (s.length() > 0) { - c0 = false; JSON2NBT$list1.tagList.add(getTagFromNameValue(s, false)); } @@ -124,7 +123,6 @@ public class JSON2NBT { for (JSON2NBT$list = new JSON2NBT.List(key); value.length() > 0; value = value.substring(s.length() + 1)) { s = nextNameValuePair(value, false); if (s.length() > 0) { - c0 = true; JSON2NBT$list.tagList.add(getTagFromNameValue(s, true)); } @@ -392,10 +390,8 @@ public class JSON2NBT { public Tag parse() throws NBTException { ArrayList list = new ArrayList<>(); - Iterator var2 = this.tagList.iterator(); - while (var2.hasNext()) { - JSON2NBT.Any JSON2NBT$any = (JSON2NBT.Any) var2.next(); + for (Any JSON2NBT$any : this.tagList) { list.add(JSON2NBT$any.parse()); } Class tagType = list.isEmpty() ? CompoundTag.class : list.get(0).getClass(); @@ -414,10 +410,8 @@ public class JSON2NBT { public Tag parse() throws NBTException { HashMap map = new HashMap<>(); - Iterator var2 = this.tagList.iterator(); - while (var2.hasNext()) { - JSON2NBT.Any JSON2NBT$any = (JSON2NBT.Any) var2.next(); + for (Any JSON2NBT$any : this.tagList) { map.put(JSON2NBT$any.json, JSON2NBT$any.parse()); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/jnbt/streamer/StreamDelegate.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/jnbt/streamer/StreamDelegate.java index 18343f88e..8b4e0dcda 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/jnbt/streamer/StreamDelegate.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/jnbt/streamer/StreamDelegate.java @@ -8,6 +8,7 @@ import org.apache.logging.log4j.Logger; import java.io.DataInputStream; import java.io.IOException; +@SuppressWarnings({"unchecked", "rawtypes"}) public class StreamDelegate { private static final Logger LOGGER = LogManagerCompat.getLogger(); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/PropertyRemap.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/PropertyRemap.java index 18fbb8c5e..d1d8a6e69 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/PropertyRemap.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/PropertyRemap.java @@ -4,11 +4,7 @@ import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; -public class PropertyRemap { - - private final Property property; - private final T oldValue; - private final T newValue; +public record PropertyRemap(Property property, T oldValue, T newValue) { /** * New instance @@ -17,10 +13,7 @@ public class PropertyRemap { * @param oldValue value to remap from * @param newValue value to remap to */ - public PropertyRemap(Property property, T oldValue, T newValue) { - this.property = property; - this.oldValue = oldValue; - this.newValue = newValue; + public PropertyRemap { } /** diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BitArray.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BitArray.java index 7897899f4..9e2059b87 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BitArray.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BitArray.java @@ -32,7 +32,7 @@ public final class BitArray { return data; } - public final void set(int index, int value) { + public void set(int index, int value) { if (longLen == 0) { return; } @@ -70,7 +70,7 @@ public final class BitArray { return longLen; } - public final void fromRaw(int[] arr) { + public void fromRaw(int[] arr) { final long[] data = this.data; final int bitsPerEntry = this.bitsPerEntry; final int maxSeqLocIndex = this.maxSeqLocIndex; @@ -106,11 +106,11 @@ public final class BitArray { } } - public final int[] toRaw() { + public int[] toRaw() { return toRaw(new int[4096]); } - public final int[] toRaw(int[] buffer) { + public int[] toRaw(int[] buffer) { final long[] data = this.data; final int dataLength = longLen; final int bitsPerEntry = this.bitsPerEntry; @@ -143,7 +143,7 @@ public final class BitArray { return buffer; } - public final char[] toRaw(char[] buffer) { + public char[] toRaw(char[] buffer) { final long[] data = this.data; final int dataLength = longLen; final int bitsPerEntry = this.bitsPerEntry; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BitArrayUnstretched.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BitArrayUnstretched.java index c49eb61fa..94f124925 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BitArrayUnstretched.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BitArrayUnstretched.java @@ -39,7 +39,7 @@ public final class BitArrayUnstretched { return data; } - public final void set(int index, int value) { + public void set(int index, int value) { if (longLen == 0) { return; } @@ -49,7 +49,7 @@ public final class BitArrayUnstretched { this.data[longIndexStart] = this.data[longIndexStart] & ~(mask << localBitIndexStart) | (long) value << localBitIndexStart; } - public final int get(int index) { + public int get(int index) { if (longLen == 0) { return 0; } @@ -65,7 +65,7 @@ public final class BitArrayUnstretched { return longLen; } - public final void fromRaw(int[] arr) { + public void fromRaw(int[] arr) { final long[] data = this.data; final int bitsPerEntry = this.bitsPerEntry; final int maxSeqLocIndex = this.maxSeqLocIndex; @@ -85,11 +85,11 @@ public final class BitArrayUnstretched { } } - public final int[] toRaw() { + public int[] toRaw() { return toRaw(new int[4096]); } - public final int[] toRaw(int[] buffer) { + public int[] toRaw(int[] buffer) { final long[] data = this.data; final int bitsPerEntry = this.bitsPerEntry; final int maxSeqLocIndex = this.maxSeqLocIndex; @@ -108,7 +108,7 @@ public final class BitArrayUnstretched { return buffer; } - public final char[] toRaw(char[] buffer) { + public char[] toRaw(char[] buffer) { final long[] data = this.data; final int bitsPerEntry = this.bitsPerEntry; final int maxSeqLocIndex = this.maxSeqLocIndex; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BlockVectorSet.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BlockVectorSet.java index c573dfc00..98078b123 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BlockVectorSet.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BlockVectorSet.java @@ -77,8 +77,7 @@ public class BlockVectorSet extends AbstractCollection implements @Override public boolean contains(Object o) { - if (o instanceof BlockVector3) { - BlockVector3 v = (BlockVector3) o; + if (o instanceof BlockVector3 v) { return contains(v.getBlockX(), v.getBlockY(), v.getBlockZ()); } return false; @@ -161,8 +160,7 @@ public class BlockVectorSet extends AbstractCollection implements @Override public boolean remove(Object o) { - if (o instanceof BlockVector3) { - BlockVector3 v = (BlockVector3) o; + if (o instanceof BlockVector3 v) { return remove(v.getBlockX(), v.getBlockY(), v.getBlockZ()); } return false; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/FastBitSet.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/FastBitSet.java index d68263cce..92754b669 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/FastBitSet.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/FastBitSet.java @@ -2,7 +2,7 @@ package com.fastasyncworldedit.core.math; import java.util.Arrays; -public final class FastBitSet { +public class FastBitSet { private final int size; private final long[] bits; @@ -69,16 +69,6 @@ public final class FastBitSet { Arrays.fill(bits, -1L); } - public static void clearAll(long[] bits) { - Arrays.fill(bits, 0L); - } - - public static void invertAll(long[] bits) { - for (int i = 0; i < bits.length; ++i) { - bits[i] = ~bits[i]; - } - } - public static void and(long[] bits, final long[] other) { final int end = Math.min(other.length, bits.length); for (int i = 0; i < end; ++i) { @@ -93,55 +83,25 @@ public final class FastBitSet { } } - public static void nand(long[] bits, final long[] other) { - final int end = Math.min(other.length, bits.length); - for (int i = 0; i < end; ++i) { - bits[i] = ~(bits[i] & other[i]); - } - } - - public static void nor(long[] bits, final long[] other) { - final int end = Math.min(other.length, bits.length); - for (int i = 0; i < end; ++i) { - bits[i] = ~(bits[i] | other[i]); - } - } - - public static void xor(long[] bits, final long[] other) { - final int end = Math.min(other.length, bits.length); - for (int i = 0; i < end; ++i) { - bits[i] ^= other[i]; - } - } - - public static long memoryUsage(long[] bits) { - return 8L * bits.length; - } - private static void fill(final long[] a, final int b, final int e, final long l) { for (int i = b; i < e; ++i) { a[i] = l; } } - public static long calculateMemoryUsage(int entries) { - final int numLongs = (entries + 64) >> 6; - return 8L * numLongs; - } - - public final boolean get(final int i) { + public boolean get(final int i) { return (bits[i >> 6] & (1L << (i & 0x3F))) != 0; } - public final void set(final int i) { + public void set(final int i) { bits[i >> 6] |= (1L << (i & 0x3F)); } - public final void clear(final int i) { + public void clear(final int i) { bits[i >> 6] &= ~(1L << (i & 0x3F)); } - public final void set(final int i, final boolean v) { + public void set(final int i, final boolean v) { if (v) { set(i); } else { @@ -149,7 +109,7 @@ public final class FastBitSet { } } - public final void setRange(final int b, final int e) { + public void setRange(final int b, final int e) { final int bt = b >> 6; final int et = e >> 6; if (bt != et) { @@ -161,7 +121,7 @@ public final class FastBitSet { } } - public final void clearRange(final int b, final int e) { + public void clearRange(final int b, final int e) { final int bt = b >> 6; final int et = e >> 6; if (bt != et) { @@ -173,56 +133,21 @@ public final class FastBitSet { } } - public final void setAll() { - Arrays.fill(bits, -1L); - } - - public final void clearAll() { - Arrays.fill(bits, 0L); - } - - public final void invertAll() { - for (int i = 0; i < bits.length; ++i) { - bits[i] = ~bits[i]; - } - } - - public final void and(final FastBitSet other) { + public void and(final FastBitSet other) { final int end = Math.min(other.bits.length, bits.length); for (int i = 0; i < end; ++i) { bits[i] &= other.bits[i]; } } - public final void or(final FastBitSet other) { + public void or(final FastBitSet other) { final int end = Math.min(other.bits.length, bits.length); for (int i = 0; i < end; ++i) { bits[i] |= other.bits[i]; } } - public final void nand(final FastBitSet other) { - final int end = Math.min(other.bits.length, bits.length); - for (int i = 0; i < end; ++i) { - bits[i] = ~(bits[i] & other.bits[i]); - } - } - - public final void nor(final FastBitSet other) { - final int end = Math.min(other.bits.length, bits.length); - for (int i = 0; i < end; ++i) { - bits[i] = ~(bits[i] | other.bits[i]); - } - } - - public final void xor(final FastBitSet other) { - final int end = Math.min(other.bits.length, bits.length); - for (int i = 0; i < end; ++i) { - bits[i] ^= other.bits[i]; - } - } - - public final int cardinality() { + public int cardinality() { if (size == 0) { return 0; } @@ -233,19 +158,15 @@ public final class FastBitSet { return count + Long.bitCount(bits[bits.length - 1] & ~(-1L << (size & 0x3F))); } - public final int size() { + public int size() { return size; } - public final long memoryUsage() { - return 8L * bits.length; - } - public IntIterator iterator() { return new IntIterator(); } - public final class IntIterator { + public class IntIterator { int index = 0; long bitBuffer = 0; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/IntPair.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/IntPair.java index 69d41bc38..f7f451e79 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/IntPair.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/IntPair.java @@ -1,14 +1,6 @@ package com.fastasyncworldedit.core.math; -public final class IntPair { - - public int x; - public int z; - - public IntPair(final int x, final int z) { - this.x = x; - this.z = z; - } +public record IntPair(int x, int z) { @Override public int hashCode() { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/IntTriple.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/IntTriple.java index 31ffa3ccc..32c12627b 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/IntTriple.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/IntTriple.java @@ -1,34 +1,12 @@ package com.fastasyncworldedit.core.math; -public final class IntTriple { - - private final int x; - private final int y; - private final int z; - - public IntTriple(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } +public record IntTriple(int x, int y, int z) { @Override - public final int hashCode() { + public int hashCode() { return x ^ (z << 12) ^ (y << 24); } - public final int getX() { - return x; - } - - public final int getY() { - return y; - } - - public final int getZ() { - return z; - } - @Override public String toString() { return x + "," + y + "," + z; @@ -36,8 +14,7 @@ public final class IntTriple { @Override public boolean equals(Object obj) { - if (obj instanceof IntTriple) { - IntTriple other = (IntTriple) obj; + if (obj instanceof IntTriple other) { return other.x == x && other.z == z && other.y == y; } return false; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/LocalBlockVectorSet.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/LocalBlockVectorSet.java index 94fabe2fc..882c4ee43 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/LocalBlockVectorSet.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/LocalBlockVectorSet.java @@ -71,8 +71,7 @@ public class LocalBlockVectorSet implements Set { @Override public boolean contains(Object o) { - if (o instanceof BlockVector3) { - BlockVector3 v = (BlockVector3) o; + if (o instanceof BlockVector3 v) { return contains(v.getBlockX(), v.getBlockY(), v.getBlockZ()); } return false; @@ -89,7 +88,6 @@ public class LocalBlockVectorSet implements Set { * @param x x radius center * @param y y radius center * @param z z radius center - * @param radius * @return if radius is contained by the set */ public boolean containsRadius(int x, int y, int z, int radius) { @@ -163,7 +161,7 @@ public class LocalBlockVectorSet implements Set { @Nonnull @Override public Iterator iterator() { - return new Iterator() { + return new Iterator<>() { final MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0); int index = set.nextSetBit(0); int previous = -1; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/HeightMap.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/HeightMap.java index f97e20ba5..b4ed72d11 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/HeightMap.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/HeightMap.java @@ -104,21 +104,12 @@ public interface HeightMap { for (int z = -size; z <= size; z++) { int index = (z + size) * diameter + (x + size); int zz = centerZ + z; - double raise; - switch (rotationMode) { - default: - raise = getHeight(x, z); - break; - case 1: - raise = getHeight(z, x); - break; - case 2: - raise = getHeight(-x, -z); - break; - case 3: - raise = getHeight(-z, -x); - break; - } + double raise = switch (rotationMode) { + default -> getHeight(x, z); + case 1 -> getHeight(z, x); + case 2 -> getHeight(-x, -z); + case 3 -> getHeight(-z, -x); + }; int height; if (layers) { height = tmpY = session.getNearestSurfaceLayer(xx, zz, tmpY, minY, maxY); @@ -153,21 +144,12 @@ public interface HeightMap { for (int z = -size; z <= size; z++) { int index = (z + size) * diameter + (x + size); int zz = centerZ + z; - double raise; - switch (rotationMode) { - default: - raise = getHeight(x, z); - break; - case 1: - raise = getHeight(z, x); - break; - case 2: - raise = getHeight(-x, -z); - break; - case 3: - raise = getHeight(-z, -x); - break; - } + double raise = switch (rotationMode) { + default -> getHeight(x, z); + case 1 -> getHeight(z, x); + case 2 -> getHeight(-x, -z); + case 3 -> getHeight(-z, -x); + }; if (layers) { height = session.getNearestSurfaceLayer(xx, zz, height, minY, maxY); } else { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/ScalableHeightMap.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/ScalableHeightMap.java index 1ce85c377..d6ce8f682 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/ScalableHeightMap.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/ScalableHeightMap.java @@ -56,13 +56,10 @@ public class ScalableHeightMap implements HeightMap { } public static ScalableHeightMap fromShape(Shape shape, int minY, int maxY) { - switch (shape) { - default: - case CONE: - return new ScalableHeightMap(minY, maxY); - case CYLINDER: - return new FlatScalableHeightMap(minY, maxY); - } + return switch (shape) { + case CONE -> new ScalableHeightMap(minY, maxY); + case CYLINDER -> new FlatScalableHeightMap(minY, maxY); + }; } public static ScalableHeightMap fromClipboard(Clipboard clipboard, int minY, int maxY) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/random/NoiseRandom.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/random/NoiseRandom.java index 1bb0abd13..264805b16 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/random/NoiseRandom.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/random/NoiseRandom.java @@ -3,10 +3,7 @@ package com.fastasyncworldedit.core.math.random; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.noise.NoiseGenerator; -public class NoiseRandom implements SimpleRandom { - - private final NoiseGenerator generator; - private final double scale; +public record NoiseRandom(NoiseGenerator generator, double scale) implements SimpleRandom { /** * Create a new NoiseRandom instance using a specific {@link NoiseGenerator} and a scale. @@ -14,9 +11,7 @@ public class NoiseRandom implements SimpleRandom { * @param generator The generator to use for the noise * @param scale The scale of the noise */ - public NoiseRandom(NoiseGenerator generator, double scale) { - this.generator = generator; - this.scale = scale; + public NoiseRandom { } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/transform/RoundedTransform.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/transform/RoundedTransform.java index af2312a48..c4fefed5f 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/transform/RoundedTransform.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/transform/RoundedTransform.java @@ -3,13 +3,7 @@ package com.fastasyncworldedit.core.math.transform; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.Transform; -public class RoundedTransform implements Transform { - - private final Transform transform; - - public RoundedTransform(Transform transform) { - this.transform = transform; - } +public record RoundedTransform(Transform transform) implements Transform { @Override public boolean isIdentity() { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/Filter.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/Filter.java index d12f2d801..19fa1293a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/Filter.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/Filter.java @@ -16,7 +16,6 @@ public interface Filter { * * @param chunkX the x coordinate in the chunk * @param chunkZ the z coordinate in the chunk - * @return */ default boolean appliesChunk( @Range(from = 0, to = 15) int chunkX, @@ -28,9 +27,6 @@ public interface Filter { /** * Do something with the IChunk
- Return null if you don't want to filter blocks
- * Return the chunk if you do want to filter blocks
- * - * @param chunk - * @return */ default T applyChunk(T chunk, @Nullable Region region) { return chunk; @@ -43,16 +39,12 @@ public interface Filter { /** * Make changes to the block here
- e.g., block.setId(...)
- Note: Performance is * critical here
- * - * @param block */ default void applyBlock(FilterBlock block) { } /** * Do something with the IChunk after block filtering. - * - * @param chunk */ default void finishChunk(IChunk chunk) { } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunk.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunk.java index 207ce6314..126a5cd13 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunk.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunk.java @@ -16,10 +16,6 @@ public interface IChunk extends Trimable, IChunkGet, IChunkSet { * Initialize at the location * (allows for reuse) * - It's expected initialization will clear any set fields - * - * @param extent - * @param x - * @param z */ default void init(IQueueExtent extent, int x, int z) { } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkExtent.java index d61d40c45..e71680515 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkExtent.java @@ -29,8 +29,6 @@ public interface IChunkExtent extends Extent { /** * Get the IChunk at a position (and cache it if it's not already) * - * @param chunkX - * @param chunkZ * @return IChunk */ T getOrCreateChunk(int chunkX, int chunkZ); @@ -157,19 +155,7 @@ public interface IChunkExtent extends Extent { chunk.removeEntity(uuid); } - class IChunkEntity implements Entity { - - private final Extent extent; - private final Location location; - private final UUID uuid; - private final BaseEntity base; - - public IChunkEntity(Extent extent, Location location, UUID uuid, BaseEntity base) { - this.extent = extent; - this.location = location; - this.uuid = uuid; - this.base = base; - } + record IChunkEntity(Extent extent, Location location, UUID uuid, BaseEntity base) implements Entity { @Override public BaseEntity getState() { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IQueueChunk.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IQueueChunk.java index fbbb2d3b5..72732378d 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IQueueChunk.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IQueueChunk.java @@ -8,8 +8,6 @@ public interface IQueueChunk> extends IChunk, Callable { /** * Reset (defaults to just calling init) - * - * @return */ @Override default IQueueChunk reset() { @@ -30,9 +28,6 @@ public interface IQueueChunk> extends IChunk, Callable { /** * Call and join * - Should be done async, if at all - * - * @throws ExecutionException - * @throws InterruptedException */ default void join() throws ExecutionException, InterruptedException { T future = call(); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/ParallelQueueExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/ParallelQueueExtent.java index 89c3b549f..054001a71 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/ParallelQueueExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/ParallelQueueExtent.java @@ -74,6 +74,7 @@ public class ParallelQueueExtent extends PassthroughExtent { } @Override + @SuppressWarnings({"unchecked", "rawtypes"}) public IQueueExtent getExtent() { return (IQueueExtent) super.getExtent(); } @@ -88,11 +89,13 @@ public class ParallelQueueExtent extends PassthroughExtent { return false; } + @SuppressWarnings("rawtypes") private IQueueExtent getNewQueue() { return handler.getQueue(world, this.processor, this.postProcessor); } @Override + @SuppressWarnings("rawtypes") public T apply(Region region, T filter, boolean full) { // The chunks positions to iterate over final Set chunks = region.getChunks(); @@ -219,9 +222,6 @@ public class ParallelQueueExtent extends PassthroughExtent { /** * Lazily copy a region - * - * @param region - * @return */ @Override public Clipboard lazyCopy(Region region) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/QueueHandler.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/QueueHandler.java index cd731d10b..49ebd84ca 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/QueueHandler.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/QueueHandler.java @@ -36,7 +36,7 @@ import java.util.function.Supplier; /** * Class which handles all the queues {@link IQueueExtent} */ -@SuppressWarnings("UnstableApiUsage") +@SuppressWarnings({"unchecked", "rawtypes"}) public abstract class QueueHandler implements Trimable, Runnable { private final ForkJoinPool forkJoinPoolPrimary = new ForkJoinPool(); @@ -238,9 +238,6 @@ public abstract class QueueHandler implements Trimable, Runnable { /** * Get or create the WorldChunkCache for a world - * - * @param world - * @return */ public IChunkCache getOrCreateWorldCache(World world) { world = WorldWrapper.unwrap(world); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/SingleThreadQueueExtent.java index 97513aa69..85a1760aa 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/SingleThreadQueueExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/SingleThreadQueueExtent.java @@ -230,9 +230,6 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen /** * Submit without first checking that it has been removed from the chunk map - * - * @param chunk - * @return */ private > V submitUnchecked(IQueueChunk chunk) { if (chunk.isEmpty()) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/BitSetBlocks.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/BitSetBlocks.java index 3e01ecc40..ae976777c 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/BitSetBlocks.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/BitSetBlocks.java @@ -127,9 +127,8 @@ public class BitSetBlocks implements IChunkSet { layer -= minSectionPosition; char[] arr = FaweCache.INSTANCE.SECTION_BITS_TO_CHAR.get(); MemBlockSet.IRow nullRowY = row.getRow(layer); - if (nullRowY instanceof MemBlockSet.RowY) { + if (nullRowY instanceof MemBlockSet.RowY rowY) { char value = blockState.getOrdinalChar(); - MemBlockSet.RowY rowY = (MemBlockSet.RowY) nullRowY; long[] bits = rowY.getBits(); for (int y = 0, longIndex = 0, blockIndex = 0; y < 16; y++) { for (int z = 0; z < 16; z += 4, longIndex++, blockIndex += 64) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/FuzzyRegion.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/FuzzyRegion.java index 15565ceed..58061bfa0 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/FuzzyRegion.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/FuzzyRegion.java @@ -67,7 +67,7 @@ public class FuzzyRegion extends AbstractRegion { return set.iterator(); } - private final void setMinMax(int x, int y, int z) { + private void setMinMax(int x, int y, int z) { if (x > maxX) { maxX = x; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/selector/FuzzyRegionSelector.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/selector/FuzzyRegionSelector.java index 0ea04e976..2bf66058b 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/selector/FuzzyRegionSelector.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/selector/FuzzyRegionSelector.java @@ -48,6 +48,7 @@ public class FuzzyRegionSelector extends PassthroughExtent implements RegionSele } @Override + @SuppressWarnings({"unchecked", "rawtypes"}) public void setWorld(@Nullable World world) { EditSession extent = WorldEdit.getInstance().newEditSessionBuilder().world(world) .actor(actor) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/registry/state/PropertyGroup.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/registry/state/PropertyGroup.java index c6e3d15fc..5cc731294 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/registry/state/PropertyGroup.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/registry/state/PropertyGroup.java @@ -10,6 +10,7 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Function; +@SuppressWarnings({"unchecked", "rawtypes"}) public class PropertyGroup { public static final PropertyGroup LEVEL = new PropertyGroupBuilder() diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/registry/state/PropertyKey.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/registry/state/PropertyKey.java index 5c7cdc34b..baba00a6b 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/registry/state/PropertyKey.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/registry/state/PropertyKey.java @@ -9,6 +9,7 @@ import java.util.Map; /** * This class will be generated at runtime - these are just example values. */ +@SuppressWarnings("unused") public class PropertyKey implements Comparable { // needs to be declared before constants diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/BrushCache.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/BrushCache.java index fd008f13d..afab331a7 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/BrushCache.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/BrushCache.java @@ -19,7 +19,7 @@ public final class BrushCache { private static final WeakHashMap brushCache = new WeakHashMap<>(); private static final Gson gson = new GsonBuilder().setPrettyPrinting().create(); - private static final CompoundTag getNBT(BaseItem item) { + private static CompoundTag getNBT(BaseItem item) { return item.hasNbtData() ? item.getNbtData() : null; } @@ -29,7 +29,7 @@ public final class BrushCache { private static final ThreadLocal RECURSION = new ThreadLocal<>(); - public static final BrushTool getTool(Player player, LocalSession session, BaseItem item) { + public static BrushTool getTool(Player player, LocalSession session, BaseItem item) { if (!item.hasNbtData()) { return null; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/ExtentTraverser.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/ExtentTraverser.java index c81db3e9a..b4822863c 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/ExtentTraverser.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/ExtentTraverser.java @@ -49,11 +49,13 @@ public class ExtentTraverser { return last; } + @SuppressWarnings("unchecked") public U findAndGet(Class clazz) { ExtentTraverser traverser = find(clazz); return (traverser != null) ? (U) traverser.get() : null; } + @SuppressWarnings("unchecked") public ExtentTraverser find(Class clazz) { try { ExtentTraverser value = this; @@ -70,6 +72,7 @@ public class ExtentTraverser { } } + @SuppressWarnings("unchecked") public ExtentTraverser find(Object object) { try { ExtentTraverser value = this; @@ -90,6 +93,7 @@ public class ExtentTraverser { return parent; } + @SuppressWarnings("unchecked") public ExtentTraverser next() { try { if (root instanceof AbstractDelegateExtent) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MainUtil.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MainUtil.java index ae64b274e..911576616 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MainUtil.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MainUtil.java @@ -104,15 +104,6 @@ public class MainUtil { return suggestions; } - public static T getOf(Object[] arr, Class ofType) { - for (Object a : arr) { - if (a != null && a.getClass() == ofType) { - return (T) a; - } - } - return null; - } - public static long getTotalSize(Path path) { final AtomicLong size = new AtomicLong(0); traverse(path, new RunnableVal2<>() { @@ -178,26 +169,6 @@ public class MainUtil { return out.toString(); } - public static void forEachFile(Path path, final RunnableVal2 onEach, Comparator comparator) { - File dir = path.toFile(); - if (!dir.exists()) { - return; - } - File[] files = path.toFile().listFiles(); - if (comparator != null) { - Arrays.sort(files, comparator); - } - for (File file : files) { - Path filePath = file.toPath(); - try { - BasicFileAttributes attr = Files.readAttributes(filePath, BasicFileAttributes.class); - onEach.run(file.toPath(), attr); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - public static int getMaxFileId(File folder) { final int[] max = new int[1]; folder.listFiles(pathname -> { @@ -276,26 +247,6 @@ public class MainUtil { return written; } - public static byte[] decompress(byte[] bytes, byte[] buffer, Inflater inflater) throws DataFormatException { - if (buffer == null) { - buffer = new byte[8192]; - } - if (inflater == null) { - inflater = new Inflater(false); - } else { - inflater.reset(); - } - inflater.setInput(bytes); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - while (!inflater.finished()) { - int n = inflater.inflate(buffer); - if (n != 0) { - baos.write(buffer, 0, n); - } - } - return baos.toByteArray(); - } - public static byte[] compress(byte[] bytes, byte[] buffer, int level) { if (level == 0) { return bytes; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/Permission.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/Permission.java index a99461a2f..26377fd00 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/Permission.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/Permission.java @@ -10,8 +10,8 @@ public enum Permission { */ ADMIN("fawe.admin", "admin"); - public String permission; - public String cat; + public final String permission; + public final String cat; Permission(String permission, String category) { this.permission = permission; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/ReflectionUtils.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/ReflectionUtils.java index 87fdf1d90..607117535 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/ReflectionUtils.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/ReflectionUtils.java @@ -33,8 +33,7 @@ public class ReflectionUtils { return t.isInstance(o) ? t.cast(o) : null; } - public static void setAccessibleNonFinal(Field field) throws IllegalAccessException, NoSuchMethodException, - InvocationTargetException { + public static void setAccessibleNonFinal(Field field) { // let's make the field accessible field.setAccessible(true); @@ -56,8 +55,7 @@ public class ReflectionUtils { } } - public static void setFailsafeFieldValue(Field field, Object target, Object value) throws IllegalAccessException, - NoSuchMethodException, InvocationTargetException { + public static void setFailsafeFieldValue(Field field, Object target, Object value) throws IllegalAccessException { setAccessibleNonFinal(field); field.set(target, value); } @@ -93,11 +91,6 @@ public class ReflectionUtils { } } - public static Field[] sortFields(Field[] fields) { - Arrays.sort(fields, Comparator.comparing(Field::getName)); - return fields; - } - public static T setAccessible(T ao) { ao.setAccessible(true); return ao; @@ -129,10 +122,6 @@ public class ReflectionUtils { } } - public static void unsafeSet(Object base, long offset, Object value) { - UNSAFE.putObject(base, offset, value); - } - public static void unsafeSet(Field field, Object base, Object value) { UNSAFE.putObject(base, UNSAFE.objectFieldOffset(field), value); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/TextureUtil.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/TextureUtil.java index 2a7da6939..c5da6d571 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/TextureUtil.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/TextureUtil.java @@ -882,7 +882,7 @@ public class TextureUtil implements TextureHolder { if (value instanceof String) { models.add((String) value); } else if (value instanceof Map) { - value = ((Map) value).get("model"); + value = ((Map) value).get("model"); if (value != null) { models.add((String) value); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/AdaptedMap.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/AdaptedMap.java index 2336152ca..e74e4dac6 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/AdaptedMap.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/AdaptedMap.java @@ -7,6 +7,7 @@ import java.util.Objects; import java.util.Set; import java.util.function.Function; +@SuppressWarnings({"unchecked", "rawtypes"}) public class AdaptedMap implements IAdaptedMap { private final Map parent; @@ -84,7 +85,7 @@ public class AdaptedMap implements IAdaptedMap { } return new AdaptedSetCollection<>( getParent().entrySet(), - new com.google.common.base.Function, Entry>() { + new com.google.common.base.Function<>() { private final AdaptedPair entry = new AdaptedPair(); @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/IAdaptedMap.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/IAdaptedMap.java index 3bf98e316..ac23562a1 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/IAdaptedMap.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/IAdaptedMap.java @@ -94,7 +94,7 @@ public interface IAdaptedMap extends Map { if (isEmpty()) { return Collections.emptySet(); } - return new AdaptedSetCollection<>(getParent().entrySet(), new Function, Entry>() { + return new AdaptedSetCollection<>(getParent().entrySet(), new Function<>() { private final MutablePair entry = new MutablePair<>(); @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/MemBlockSet.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/MemBlockSet.java index 50512235c..178b0052e 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/MemBlockSet.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/MemBlockSet.java @@ -107,8 +107,7 @@ public final class MemBlockSet extends BlockSet { private void init() { for (; X < rows.length; X++) { IRow nullRowX = rows[X]; - if (nullRowX instanceof RowX) { - RowX rowx = (RowX) nullRowX; + if (nullRowX instanceof RowX rowx) { for (; Z < rowx.rows.length; Z++) { IRow nullRowZ = rowx.rows[Z]; if (nullRowZ instanceof RowZ) { @@ -148,8 +147,7 @@ public final class MemBlockSet extends BlockSet { public int size() { int size = 0; for (IRow nullRowX : rows) { - if (nullRowX instanceof RowX) { - RowX rowx = (RowX) nullRowX; + if (nullRowX instanceof RowX rowx) { for (int Z = 0; Z < rowx.rows.length; Z++) { IRow nullRowZ = rowx.rows[Z]; if (nullRowZ instanceof RowZ) { @@ -168,8 +166,7 @@ public final class MemBlockSet extends BlockSet { @Override public boolean contains(Object o) { - if (o instanceof BlockVector2) { - BlockVector2 other = (BlockVector2) o; + if (o instanceof BlockVector2 other) { IRow rowx = rows[other.getX() - getChunkOffsetX()]; if (rowx instanceof RowX) { return ((RowX) rowx).rows[other.getZ() - getChunkOffsetZ()] instanceof RowZ; @@ -201,12 +198,10 @@ public final class MemBlockSet extends BlockSet { private void init() { for (; X < rows.length; X++) { IRow nullRowX = rows[X]; - if (nullRowX instanceof RowX) { - RowX rowx = (RowX) nullRowX; + if (nullRowX instanceof RowX rowx) { for (; Z < rowx.rows.length; Z++) { IRow nullRowZ = rowx.rows[Z]; - if (nullRowZ instanceof RowZ) { - RowZ rowz = (RowZ) nullRowZ; + if (nullRowZ instanceof RowZ rowz) { for (; Y < rowz.rows.length; Y++) { IRow nullRowY = rowz.rows[Y]; if (nullRowY instanceof RowY) { @@ -214,7 +209,6 @@ public final class MemBlockSet extends BlockSet { setY = Y; setZ = Z; Z++; - hasNext = true; } } Y = 0; @@ -250,12 +244,10 @@ public final class MemBlockSet extends BlockSet { public int size() { int size = 0; for (IRow nullRowX : rows) { - if (nullRowX instanceof RowX) { - RowX rowx = (RowX) nullRowX; + if (nullRowX instanceof RowX rowx) { for (int Z = 0; Z < rowx.rows.length; Z++) { IRow nullRowZ = rowx.rows[Z]; - if (nullRowZ instanceof RowZ) { - RowZ rowz = (RowZ) nullRowZ; + if (nullRowZ instanceof RowZ rowz) { for (int Y = 0; Y < rowz.rows.length; Y++) { IRow nullRowY = rowz.rows[Y]; if (nullRowY instanceof RowY) { @@ -276,8 +268,7 @@ public final class MemBlockSet extends BlockSet { @Override public boolean contains(Object o) { - if (o instanceof BlockVector3) { - BlockVector3 other = (BlockVector3) o; + if (o instanceof BlockVector3 other) { IRow rowx = rows[other.getX() - getChunkOffsetX()]; if (rowx instanceof RowX) { IRow rowz = ((RowX) rowx).rows[other.getZ()]; @@ -297,23 +288,20 @@ public final class MemBlockSet extends BlockSet { int maxy = 16; int by = Integer.MAX_VALUE; for (IRow nullRowX : rows) { - if (!(nullRowX instanceof RowX)) { + if (!(nullRowX instanceof RowX rowx)) { continue; } - RowX rowx = (RowX) nullRowX; for (int Z = 0; Z < rowx.rows.length; Z++) { IRow nullRowZ = rowx.rows[Z]; - if (!(nullRowZ instanceof RowZ)) { + if (!(nullRowZ instanceof RowZ rowz)) { continue; } - RowZ rowz = (RowZ) nullRowZ; outer: for (int Y = 0; Y <= maxY; Y++) { IRow nullRowY = rowz.rows[Y]; - if (!(nullRowY instanceof RowY)) { + if (!(nullRowY instanceof RowY rowY)) { continue; } - RowY rowY = (RowY) nullRowY; int localMaxy = Y == maxY ? maxy : 15; for (int y = 0, i = 0; y < localMaxy; y++) { for (int xz = 0; xz < 4; xz++, i++) { @@ -346,23 +334,20 @@ public final class MemBlockSet extends BlockSet { int maxy = 0; int by = Integer.MIN_VALUE; for (IRow nullRowX : rows) { - if (!(nullRowX instanceof RowX)) { + if (!(nullRowX instanceof RowX rowx)) { continue; } - RowX rowx = (RowX) nullRowX; for (int Z = 0; Z < rowx.rows.length; Z++) { IRow nullRowZ = rowx.rows[Z]; - if (!(nullRowZ instanceof RowZ)) { + if (!(nullRowZ instanceof RowZ rowz)) { continue; } - RowZ rowz = (RowZ) nullRowZ; outer: for (int Y = maxSectionPosition; Y >= maxY; Y--) { IRow nullRowY = rowz.rows[Y]; - if (!(nullRowY instanceof RowY)) { + if (!(nullRowY instanceof RowY rowY)) { continue; } - RowY rowY = (RowY) nullRowY; int localMaxy = Y == maxY ? maxy : 0; for (int y = 15, i = 63; y >= localMaxy; y--) { for (int xz = 3; xz >= 0; xz--, i--) { @@ -395,27 +380,24 @@ public final class MemBlockSet extends BlockSet { int tz = Integer.MIN_VALUE; for (int X = rows.length - 1; X >= 0; X--) { IRow nullRowX = rows[X]; - if (!(nullRowX instanceof RowX)) { + if (!(nullRowX instanceof RowX rowx)) { continue; } - RowX rowx = (RowX) nullRowX; outer: for (int Z = rowx.rows.length - 1; Z >= maxChunkZ; Z--) { IRow nullRowZ = rowx.rows[Z]; - if (!(nullRowZ instanceof RowZ)) { + if (!(nullRowZ instanceof RowZ rowz)) { continue; } - RowZ rowz = (RowZ) nullRowZ; if (Z != maxChunkZ) { maxChunkZ = Z; maxz = -1; } for (int Y = rowz.rows.length - 1; Y >= 0; Y--) { IRow nullRowY = rowz.rows[Y]; - if (!(nullRowY instanceof RowY)) { + if (!(nullRowY instanceof RowY rowY)) { continue; } - RowY rowY = (RowY) nullRowY; for (int y = 15, i1 = 63; y >= 0; y--, i1 -= 4) { for (int z = 12, i = i1; z > maxz - 3; z -= 4, i--) { long bitBuffer = rowY.bits[i]; @@ -443,24 +425,21 @@ public final class MemBlockSet extends BlockSet { public int getMaxX() { for (int X = rows.length - 1; X >= 0; X--) { IRow nullRowX = rows[X]; - if (!(nullRowX instanceof RowX)) { + if (!(nullRowX instanceof RowX rowx)) { continue; } int tx = (X << 4); - RowX rowx = (RowX) nullRowX; long or = 0; for (int Z = rowx.rows.length - 1; Z >= 0; Z--) { IRow nullRowZ = rowx.rows[Z]; - if (!(nullRowZ instanceof RowZ)) { + if (!(nullRowZ instanceof RowZ rowz)) { continue; } - RowZ rowz = (RowZ) nullRowZ; for (int Y = rowz.rows.length - 1; Y >= 0; Y--) { IRow nullRowY = rowz.rows[Y]; - if (!(nullRowY instanceof RowY)) { + if (!(nullRowY instanceof RowY rowY)) { continue; } - RowY rowY = (RowY) nullRowY; or |= Arrays.stream(rowY.bits).reduce(0, (a, b) -> a | b); or = (or & 0xFFFF) | ((or >> 16) & 0xFFFF) | ((or >> 32) & 0xFFFF) | ((or >> 48) & 0xFFFF); if (highestBit(or) == 15) { @@ -481,27 +460,24 @@ public final class MemBlockSet extends BlockSet { int maxz = 16; int bz = Integer.MAX_VALUE; for (IRow nullRowX : rows) { - if (!(nullRowX instanceof RowX)) { + if (!(nullRowX instanceof RowX rowx)) { continue; } - RowX rowx = (RowX) nullRowX; outer: for (int Z = 0; Z <= maxChunkZ; Z++) { IRow nullRowZ = rowx.rows[Z]; - if (!(nullRowZ instanceof RowZ)) { + if (!(nullRowZ instanceof RowZ rowz)) { continue; } - RowZ rowz = (RowZ) nullRowZ; if (Z != maxChunkZ) { maxChunkZ = Z; maxz = 16; } for (int Y = 0; Y < rowz.rows.length; Y++) { IRow nullRowY = rowz.rows[Y]; - if (!(nullRowY instanceof RowY)) { + if (!(nullRowY instanceof RowY rowY)) { continue; } - RowY rowY = (RowY) nullRowY; for (int y = 0, i1 = 0; y < 16; y++, i1 += 4) { for (int z = 0, i = i1; z < maxz; z += 4, i++) { long bitBuffer = rowY.bits[i]; @@ -529,24 +505,21 @@ public final class MemBlockSet extends BlockSet { public int getMinX() { for (int X = 0; X < rows.length; X++) { IRow nullRowX = rows[X]; - if (!(nullRowX instanceof RowX)) { + if (!(nullRowX instanceof RowX rowx)) { continue; } int bx = X << 4; - RowX rowx = (RowX) nullRowX; long or = 0; for (int Z = 0; Z < rowx.rows.length; Z++) { IRow nullRowZ = rowx.rows[Z]; - if (!(nullRowZ instanceof RowZ)) { + if (!(nullRowZ instanceof RowZ rowz)) { continue; } - RowZ rowz = (RowZ) nullRowZ; for (int Y = 0; Y < rowz.rows.length; Y++) { IRow nullRowY = rowz.rows[Y]; - if (!(nullRowY instanceof RowY)) { + if (!(nullRowY instanceof RowY rowY)) { continue; } - RowY rowY = (RowY) nullRowY; or |= Arrays.stream(rowY.bits).reduce(0, (a, b) -> a | b); or = (or & 0xFFFF) | ((or >> 16) & 0xFFFF) | ((or >> 32) & 0xFFFF) | ((or >> 48) & 0xFFFF); if (lowestBit(or) == 0) { @@ -565,25 +538,22 @@ public final class MemBlockSet extends BlockSet { public void iterate(BlockIterator iterator) { for (int X = 0; X < rows.length; X++) { IRow nullRowX = rows[X]; - if (!(nullRowX instanceof RowX)) { + if (!(nullRowX instanceof RowX rowx)) { continue; } int bx = getBlockOffsetX() + (X << 4); - RowX rowx = (RowX) nullRowX; for (int Z = 0; Z < rowx.rows.length; Z++) { IRow nullRowZ = rowx.rows[Z]; - if (!(nullRowZ instanceof RowZ)) { + if (!(nullRowZ instanceof RowZ rowz)) { continue; } int bz = getBlockOffsetZ() + (Z << 4); - RowZ rowz = (RowZ) nullRowZ; for (int Y = 0; Y < rowz.rows.length; Y++) { IRow nullRowY = rowz.rows[Y]; - if (!(nullRowY instanceof RowY)) { + if (!(nullRowY instanceof RowY rowY)) { continue; } int by = ((Y - minSectionPosition) << 4); - RowY rowY = (RowY) nullRowY; for (int y = 0, i = 0; y < 16; y++) { for (int z = 0; z < 16; z += 4, i++) { long bitBuffer = rowY.bits[i]; @@ -673,8 +643,7 @@ public final class MemBlockSet extends BlockSet { while (yIndex < rowZ.rows.length) { by = yIndex << 4; IRow nullRowY = rowZ.rows[yIndex++]; - if (nullRowY instanceof RowY) { - RowY rowY = (RowY) nullRowY; + if (nullRowY instanceof RowY rowY) { bits = rowY.bits; return true; } @@ -729,22 +698,19 @@ public final class MemBlockSet extends BlockSet { @Override public boolean isEmpty() { for (IRow nullRowX : rows) { - if (!(nullRowX instanceof RowX)) { + if (!(nullRowX instanceof RowX rowx)) { continue; } - RowX rowx = (RowX) nullRowX; for (int Z = 0; Z < rowx.rows.length; Z++) { IRow nullRowZ = rowx.rows[Z]; - if (!(nullRowZ instanceof RowZ)) { + if (!(nullRowZ instanceof RowZ rowz)) { continue; } - RowZ rowz = (RowZ) nullRowZ; for (int Y = 0; Y < 16; Y++) { IRow nullRowY = rowz.rows[Y]; - if (!(nullRowY instanceof RowY)) { + if (!(nullRowY instanceof RowY rowY)) { continue; } - RowY rowY = (RowY) nullRowY; for (long bit : rowY.bits) { if (bit != 0) { return true; @@ -766,22 +732,19 @@ public final class MemBlockSet extends BlockSet { long lastBit = 0; int lastCount = 0; for (IRow nullRowX : rows) { - if (!(nullRowX instanceof RowX)) { + if (!(nullRowX instanceof RowX rowx)) { continue; } - RowX rowx = (RowX) nullRowX; for (int z = 0; z < rowx.rows.length; z++) { IRow nullRowZ = rowx.rows[z]; - if (!(nullRowZ instanceof RowZ)) { + if (!(nullRowZ instanceof RowZ rowz)) { continue; } - RowZ rowz = (RowZ) nullRowZ; for (int y = 0; y < 16; y++) { IRow nullRowY = rowz.rows[y]; - if (!(nullRowY instanceof RowY)) { + if (!(nullRowY instanceof RowY rowY)) { continue; } - RowY rowY = (RowY) nullRowY; for (long bit : rowY.bits) { if (bit == 0) { continue; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/SummedColorTable.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/SummedColorTable.java index 9a26d7112..e0b08e345 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/SummedColorTable.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/SummedColorTable.java @@ -46,19 +46,17 @@ public class SummedColorTable { int green; int blue; switch (alpha) { - case 0: - red = green = blue = 0; - break; - case 255: + case 0 -> red = green = blue = 0; + case 255 -> { red = (color >> 16) & 0xFF; green = (color >> 8) & 0xFF; blue = (color >> 0) & 0xFF; - break; - default: + } + default -> { red = (((color >> 16) & 0xFF) * alpha) >> 8; green = (((color >> 8) & 0xFF) * alpha) >> 8; blue = (((color >> 0) & 0xFF) * alpha) >> 8; - break; + } } this.reds[index] = getVal(i, j, index, red, this.reds); this.greens[index] = getVal(i, j, index, green, this.greens); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/YieldIterable.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/YieldIterable.java index 8f4138b17..74439a66b 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/YieldIterable.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/YieldIterable.java @@ -67,6 +67,7 @@ public class YieldIterable implements Iterable, Consumer, Closeable { } @Override + @SuppressWarnings("unchecked") public void close() { queue.add((T) END_MARKER); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/progress/DefaultProgressTracker.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/progress/DefaultProgressTracker.java index c14ca93eb..4aa846fc3 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/progress/DefaultProgressTracker.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/progress/DefaultProgressTracker.java @@ -65,20 +65,21 @@ public class DefaultProgressTracker implements BiConsumer { amountDispatch++; amountQueue = amount; - break; - case QUEUE: + } + case QUEUE -> { totalQueue++; amountQueue = amount; - break; - case DONE: + } + case DONE -> { if (totalQueue > 64 && !done) { done = true; done(); } return; + } } // Only send a message after 64 chunks (i.e. ignore smaller edits) long now = System.currentTimeMillis(); diff --git a/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLProcessor.java b/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLProcessor.java index a273252f3..cc7f2d937 100644 --- a/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLProcessor.java +++ b/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLProcessor.java @@ -19,9 +19,9 @@ package com.sk89q.util.yaml; -import com.fastasyncworldedit.core.configuration.Yaml; import com.sk89q.util.StringUtil; import org.yaml.snakeyaml.DumperOptions; +import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.SafeConstructor; import org.yaml.snakeyaml.nodes.Tag; import org.yaml.snakeyaml.reader.UnicodeReader;