From 2e73746abe82aede1eb27fdf72f243a8cdae9e59 Mon Sep 17 00:00:00 2001 From: Matt <4009945+MattBDev@users.noreply.github.com> Date: Thu, 17 Sep 2020 16:31:55 -0400 Subject: [PATCH] Remove Kotlin (#625) Shrinks the jar size since we no longer must bundle the Kotlin library. The downside is that some classes grew in size compared to their Kotlin versions. Many contributors didn't care for Kotlin either. --- buildSrc/src/main/kotlin/PlatformConfig.kt | 4 +- worldedit-bukkit/build.gradle.kts | 3 +- worldedit-core/build.gradle.kts | 11 - .../com/boydti/fawe/beta/IBatchProcessor.java | 2 +- .../implementation/blocks/NullChunkGet.java | 109 ++++++++++ .../implementation/blocks/NullChunkGet.kt | 83 -------- .../beta/implementation/chunk/NullChunk.java | 189 ++++++++++++++++++ .../beta/implementation/chunk/NullChunk.kt | 178 ----------------- .../processors/BatchProcessorHolder.java | 2 +- .../processors/EmptyBatchProcessor.java | 37 ++++ .../processors/EmptyBatchProcessor.kt | 22 -- .../processors/MultiBatchProcessor.java | 2 +- .../processors/NullProcessor.java | 32 +++ .../processors/NullProcessor.kt | 19 -- .../queue/SingleThreadQueueExtent.java | 8 +- .../fawe/object/clipboard/EmptyClipboard.java | 104 ++++++++++ .../fawe/object/clipboard/EmptyClipboard.kt | 83 -------- .../object/clipboard/LazyClipboardHolder.java | 2 +- .../clipboard/MultiClipboardHolder.java | 6 +- .../worldedit/command/tool/BrushTool.java | 2 +- .../com/sk89q/worldedit/world/NullWorld.java | 2 +- worldedit-libs/core/build.gradle.kts | 1 - 22 files changed, 487 insertions(+), 414 deletions(-) create mode 100644 worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.java delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.kt create mode 100644 worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.java delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.kt create mode 100644 worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/EmptyBatchProcessor.java delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/EmptyBatchProcessor.kt create mode 100644 worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/NullProcessor.java delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/NullProcessor.kt create mode 100644 worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.java delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.kt diff --git a/buildSrc/src/main/kotlin/PlatformConfig.kt b/buildSrc/src/main/kotlin/PlatformConfig.kt index adf6e1577..47db67011 100644 --- a/buildSrc/src/main/kotlin/PlatformConfig.kt +++ b/buildSrc/src/main/kotlin/PlatformConfig.kt @@ -2,12 +2,10 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import org.gradle.api.JavaVersion import org.gradle.api.Project import org.gradle.api.plugins.JavaPluginConvention -import org.gradle.api.plugins.quality.CheckstyleExtension import org.gradle.api.tasks.bundling.Jar import org.gradle.api.tasks.compile.JavaCompile import org.gradle.api.tasks.javadoc.Javadoc import org.gradle.api.tasks.testing.Test -import org.gradle.external.javadoc.CoreJavadocOptions import org.gradle.external.javadoc.StandardJavadocDocletOptions import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.configure @@ -55,7 +53,7 @@ fun Project.applyPlatformAndCoreConfiguration() { } dependencies { - "compileOnly"("org.jetbrains:annotations:19.0.0") + "compileOnly"("org.jetbrains:annotations:20.1.0") "testImplementation"("org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT}") "testImplementation"("org.junit.jupiter:junit-jupiter-params:${Versions.JUNIT}") "testImplementation"("org.mockito:mockito-core:${Versions.MOCKITO}") diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts index 563861603..d592b694e 100644 --- a/worldedit-bukkit/build.gradle.kts +++ b/worldedit-bukkit/build.gradle.kts @@ -46,7 +46,8 @@ dependencies { exclude("junit", "junit") isTransitive = false } - "compileOnly"("org.jetbrains:annotations:20.0.0") + "compileOnly"("org.jetbrains:annotations:20.1.0") + "testCompileOnly"("org.jetbrains:annotations:20.1.0") "compileOnly"("org.spigotmc:spigot:1.16.2-R0.1-SNAPSHOT") "implementation"("io.papermc:paperlib:1.0.4") "compileOnly"("com.sk89q:dummypermscompat:1.10") { diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts index 54f81c92e..d9f5e8215 100644 --- a/worldedit-core/build.gradle.kts +++ b/worldedit-core/build.gradle.kts @@ -2,7 +2,6 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.mendhak.gradlecrowdin.DownloadTranslationsTask import com.mendhak.gradlecrowdin.UploadSourceFileTask import org.gradle.plugins.ide.idea.model.IdeaModel -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { id("java-library") @@ -10,7 +9,6 @@ plugins { id("net.ltgt.apt-idea") id("antlr") id("com.mendhak.gradlecrowdin") - kotlin("jvm") version "1.4.0" } repositories { @@ -61,7 +59,6 @@ dependencies { "compile"("com.plotsquared:PlotSquared-Core:5.12.2") { isTransitive = false } - implementation(kotlin("stdlib-jdk8", "1.4.0")) } tasks.named("test") { @@ -148,11 +145,3 @@ if (project.hasProperty(crowdinApiKey) && !gradle.startParameter.isOffline) { dependsOn("crowdinDownload") } } -val compileKotlin: KotlinCompile by tasks -compileKotlin.kotlinOptions { - jvmTarget = "1.8" -} -val compileTestKotlin: KotlinCompile by tasks -compileTestKotlin.kotlinOptions { - jvmTarget = "1.8" -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java index 1cd27670f..477420967 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java @@ -125,7 +125,7 @@ public interface IBatchProcessor { */ default IBatchProcessor remove(Class clazz) { if (clazz.isInstance(this)) { - return EmptyBatchProcessor.INSTANCE; + return EmptyBatchProcessor.getInstance(); } return this; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.java new file mode 100644 index 000000000..c8efade2d --- /dev/null +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.java @@ -0,0 +1,109 @@ +package com.boydti.fawe.beta.implementation.blocks; + +import com.boydti.fawe.FaweCache; +import com.boydti.fawe.beta.IBlocks; +import com.boydti.fawe.beta.IChunkGet; +import com.boydti.fawe.beta.IChunkSet; +import com.boydti.fawe.beta.implementation.lighting.HeightMapType; +import com.sk89q.jnbt.CompoundTag; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.biome.BiomeTypes; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.BlockTypes; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.Future; + +public final class NullChunkGet implements IChunkGet { + private static final NullChunkGet instance = new NullChunkGet(); + + public static NullChunkGet getInstance() { + return instance; + } + + @NotNull + public BaseBlock getFullBlock(int x, int y, int z) { + return BlockTypes.AIR.getDefaultState().toBaseBlock(); + } + + @Nullable + public BiomeType getBiomeType(int x, int y, int z) { + return BiomeTypes.FOREST; + } + + @NotNull + public BlockState getBlock(int x, int y, int z) { + return BlockTypes.AIR.getDefaultState(); + } + + @NotNull + public Map getTiles() { + return Collections.emptyMap(); + } + + @Nullable + public CompoundTag getTile(int x, int y, int z) { + return null; + } + + @Nullable + public Set getEntities() { + return null; + } + + @Nullable + public CompoundTag getEntity(@NotNull UUID uuid) { + return null; + } + + public boolean trim(boolean aggressive) { + return true; + } + + public boolean trim(boolean aggressive, int layer) { + return true; + } + + @Nullable + public > T call(@NotNull IChunkSet set, @NotNull Runnable finalize) { + return null; + } + + @NotNull + public char[] load(int layer) { + return FaweCache.IMP.EMPTY_CHAR_4096; + } + + public boolean hasSection(int layer) { + return false; + } + + public int getEmmittedLight(int x, int y, int z) { + return 15; + } + + public int getSkyLight(int x, int y, int z) { + return 15; + } + + @NotNull + public int[] getHeightMap(@Nullable HeightMapType type) { + return new int[256]; + } + + @Nullable + public IBlocks reset() { + return null; + } + + private NullChunkGet() { + } + +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.kt b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.kt deleted file mode 100644 index 86cbbe198..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.kt +++ /dev/null @@ -1,83 +0,0 @@ -package com.boydti.fawe.beta.implementation.blocks - -import com.boydti.fawe.FaweCache -import com.boydti.fawe.beta.IBlocks -import com.boydti.fawe.beta.IChunkGet -import com.boydti.fawe.beta.IChunkSet -import com.boydti.fawe.beta.implementation.lighting.HeightMapType -import com.sk89q.jnbt.CompoundTag -import com.sk89q.worldedit.math.BlockVector3 -import com.sk89q.worldedit.world.biome.BiomeType -import com.sk89q.worldedit.world.biome.BiomeTypes -import com.sk89q.worldedit.world.block.BaseBlock -import com.sk89q.worldedit.world.block.BlockState -import com.sk89q.worldedit.world.block.BlockTypes -import java.util.* -import java.util.concurrent.Future - -object NullChunkGet : IChunkGet { - - override fun getFullBlock(x: Int, y: Int, z: Int): BaseBlock { - return BlockTypes.AIR!!.defaultState.toBaseBlock() - } - - override fun getBiomeType(x: Int, y: Int, z: Int): BiomeType? { - return BiomeTypes.FOREST - } - - override fun getBlock(x: Int, y: Int, z: Int): BlockState { - return BlockTypes.AIR!!.defaultState - } - - override fun getTiles(): Map { - return emptyMap() - } - - override fun getTile(x: Int, y: Int, z: Int): CompoundTag? { - return null - } - - override fun getEntities(): Set? { - return null - } - - override fun getEntity(uuid: UUID): CompoundTag? { - return null - } - - override fun trim(aggressive: Boolean): Boolean { - return true - } - - override fun trim(aggressive: Boolean, layer: Int): Boolean { - return true - } - - override fun > call(set: IChunkSet, finalize: Runnable): T? { - return null - } - - override fun load(layer: Int): CharArray { - return FaweCache.IMP.EMPTY_CHAR_4096 - } - - override fun hasSection(layer: Int): Boolean { - return false - } - - override fun getEmmittedLight(x: Int, y: Int, z: Int): Int { - return 15 - } - - override fun getSkyLight(x: Int, y: Int, z: Int): Int { - return 15 - } - - override fun getHeightMap(type: HeightMapType?): IntArray { - return IntArray(256) - } - - override fun reset(): IBlocks? { - return null - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.java new file mode 100644 index 000000000..cd356bb1a --- /dev/null +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.java @@ -0,0 +1,189 @@ +package com.boydti.fawe.beta.implementation.chunk; + +import com.boydti.fawe.beta.Filter; +import com.boydti.fawe.beta.IChunkSet; +import com.boydti.fawe.beta.IQueueChunk; +import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; +import com.boydti.fawe.beta.implementation.lighting.HeightMapType; +import com.sk89q.jnbt.CompoundTag; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.regions.Region; +import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BlockTypes; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.Future; + +public final class NullChunk implements IQueueChunk { + private static final NullChunk instance = new NullChunk(); + + public static NullChunk getInstance() { + return instance; + } + + public int getX() { + return 0; + } + + public int getZ() { + return 0; + } + + public boolean isEmpty() { + return true; + } + + public Future call() { + return null; + } + + public void filterBlocks(@NotNull Filter filter, @NotNull ChunkFilterBlock block, @Nullable Region region, boolean full) { + } + + public boolean setBiome(int x, int y, int z, @NotNull BiomeType biome) { + return false; + } + + public boolean setTile(int x, int y, int z, @NotNull CompoundTag tag) { + return false; + } + + public void setEntity(@NotNull CompoundTag tag) { + } + + public void removeEntity(@NotNull UUID uuid) { + } + + @Nullable + public Set getEntityRemoves() { + return null; + } + + public int getSkyLight(int x, int y, int z) { + return 15; + } + + @NotNull + public char[][] getLight() { + return new char[0][]; + } + + @NotNull + public char[][] getSkyLight() { + return new char[0][]; + } + + @NotNull + public int[] getHeightMap(@Nullable HeightMapType type) { + return new int[256]; + } + + public int getEmmittedLight(int x, int y, int z) { + return 15; + } + + public void setSkyLight(int x, int y, int z, int value) { + } + + public void setHeightMap(@Nullable HeightMapType type, @Nullable int[] heightMap) { + } + + public boolean fullySupports3DBiomes() { + return false; + } + + public void setBlockLight(int x, int y, int z, int value) { + } + + public void setFullBright(int layer) { + } + + public void removeSectionLighting(int layer, boolean sky) { + } + + public void setSkyLightLayer(int layer, @Nullable char[] toSet) { + } + + public void setLightLayer(int layer, @Nullable char[] toSet) { + } + + @Nullable + public BiomeType[] getBiomes() { + return null; + } + + public > boolean setBlock(int x, int y, int z, T holder) { + return false; + } + + public void setBlocks(int layer, @NotNull char[] data) { + } + + @Nullable + public BiomeType getBiomeType(int x, int y, int z) { + return null; + } + + public boolean hasSection(int layer) { + return false; + } + + @NotNull + public BlockState getBlock(int x, int y, int z) { + return BlockTypes.__RESERVED__.getDefaultState(); + } + + @NotNull + public BaseBlock getFullBlock(int x, int y, int z) { + return BlockTypes.__RESERVED__.getDefaultState().toBaseBlock(); + } + + @NotNull + public Map getTiles() { + return Collections.emptyMap(); + } + + @Nullable + public CompoundTag getTile(int x, int y, int z) { + return null; + } + + @NotNull + public Set getEntities() { + return Collections.emptySet(); + } + + @Nullable + public char[] load(int layer) { + return null; + } + + @Nullable + public CompoundTag getEntity(@NotNull UUID uuid) { + return null; + } + + @Nullable + public > T call(@Nullable IChunkSet set, @Nullable Runnable finalize) { + return null; + } + + public boolean trim(boolean aggressive) { + return true; + } + + public boolean trim(boolean aggressive, int layer) { + return true; + } + + private NullChunk() { + } +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.kt b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.kt deleted file mode 100644 index 305877e07..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.kt +++ /dev/null @@ -1,178 +0,0 @@ -package com.boydti.fawe.beta.implementation.chunk - -import com.boydti.fawe.beta.Filter -import com.boydti.fawe.beta.IChunkSet -import com.boydti.fawe.beta.IQueueChunk -import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock -import com.boydti.fawe.beta.implementation.lighting.HeightMapType -import com.sk89q.jnbt.CompoundTag -import com.sk89q.worldedit.math.BlockVector3 -import com.sk89q.worldedit.regions.Region -import com.sk89q.worldedit.world.biome.BiomeType -import com.sk89q.worldedit.world.block.BaseBlock -import com.sk89q.worldedit.world.block.BlockState -import com.sk89q.worldedit.world.block.BlockStateHolder -import com.sk89q.worldedit.world.block.BlockTypes -import java.util.* -import java.util.concurrent.Future - -object NullChunk : IQueueChunk { - - override fun getX(): Int { - return 0 - } - - override fun getZ(): Int { - return 0 - } - - override fun isEmpty(): Boolean { - return true - } - - override fun call(): Nothing? { - return null - } - - override fun filterBlocks(filter: Filter, block: ChunkFilterBlock, region: Region?, full: Boolean) { - - } - - // @Override - // public void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) { - // - // } - - override fun setBiome(x: Int, y: Int, z: Int, biome: BiomeType): Boolean { - return false - } - - override fun setTile(x: Int, y: Int, z: Int, tag: CompoundTag): Boolean { - return false - } - - override fun setEntity(tag: CompoundTag) { - - } - - override fun removeEntity(uuid: UUID) { - - } - - override fun getEntityRemoves(): Set? { - return null - } - - override fun getSkyLight(x: Int, y: Int, z: Int): Int { - return 15 - } - - override fun getLight(): Array { - return emptyArray() - } - - override fun getSkyLight(): Array { - return emptyArray() - } - - override fun getHeightMap(type: HeightMapType?): IntArray { - return IntArray(256) - } - - override fun getEmmittedLight(x: Int, y: Int, z: Int): Int { - return 15 - } - - override fun setSkyLight(x: Int, y: Int, z: Int, value: Int) { - - } - - override fun setHeightMap(type: HeightMapType?, heightMap: IntArray?) { - - } - - override fun fullySupports3DBiomes(): Boolean { - return false - } - - override fun setBlockLight(x: Int, y: Int, z: Int, value: Int) { - - } - - override fun setFullBright(layer: Int) { - - } - - override fun removeSectionLighting(layer: Int, sky: Boolean) { - - } - - override fun setSkyLightLayer(layer: Int, toSet: CharArray?) { - - } - - override fun setLightLayer(layer: Int, toSet: CharArray?) { - - } - - override fun getBiomes(): Array? { - return null - } - - override fun > setBlock(x: Int, y: Int, z: Int, block: B): Boolean { - return false - } - - override fun setBlocks(layer: Int, data: CharArray) { - - } - - override fun getBiomeType(x: Int, y: Int, z: Int): BiomeType? { - return null - } - - override fun hasSection(layer: Int): Boolean { - return false - } - - override fun getBlock(x: Int, y: Int, z: Int): BlockState { - return BlockTypes.__RESERVED__!!.defaultState - } - - override fun getFullBlock(x: Int, y: Int, z: Int): BaseBlock { - return BlockTypes.__RESERVED__!!.defaultState.toBaseBlock() - } - - override fun getTiles(): Map { - return emptyMap() - } - - override fun getTile(x: Int, y: Int, z: Int): CompoundTag? { - return null - } - - override fun getEntities(): Set { - return emptySet() - } - - override fun load(layer: Int): CharArray? { - return null - } - - override fun getEntity(uuid: UUID): CompoundTag? { - return null - } - - override fun ?> call(set: IChunkSet?, finalize: Runnable?): T? { - return null - } - - override fun trim(aggressive: Boolean): Boolean { - return true - } - - override fun trim(aggressive: Boolean, layer: Int): Boolean { - return true - } -} - diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/BatchProcessorHolder.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/BatchProcessorHolder.java index 0bd4346db..e3d08fbf1 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/BatchProcessorHolder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/BatchProcessorHolder.java @@ -6,7 +6,7 @@ import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; public class BatchProcessorHolder implements IBatchProcessorHolder { - private IBatchProcessor processor = EmptyBatchProcessor.INSTANCE; + private IBatchProcessor processor = EmptyBatchProcessor.getInstance(); @Override public IBatchProcessor getProcessor() { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/EmptyBatchProcessor.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/EmptyBatchProcessor.java new file mode 100644 index 000000000..58af2692c --- /dev/null +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/EmptyBatchProcessor.java @@ -0,0 +1,37 @@ +package com.boydti.fawe.beta.implementation.processors; + +import com.boydti.fawe.beta.IBatchProcessor; +import com.boydti.fawe.beta.IChunk; +import com.boydti.fawe.beta.IChunkGet; +import com.boydti.fawe.beta.IChunkSet; +import com.sk89q.worldedit.extent.Extent; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public final class EmptyBatchProcessor implements IBatchProcessor { + private static final EmptyBatchProcessor instance = new EmptyBatchProcessor(); + + public static EmptyBatchProcessor getInstance() { + return instance; + } + + @NotNull + public Extent construct(@Nullable Extent child) { + return child; + } + + @NotNull + public IChunkSet processSet(@Nullable IChunk chunk, @Nullable IChunkGet get, @Nullable IChunkSet set) { + return set; + } + + @NotNull + public IBatchProcessor join(@Nullable IBatchProcessor other) { + return other; + } + + private EmptyBatchProcessor() { + } + +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/EmptyBatchProcessor.kt b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/EmptyBatchProcessor.kt deleted file mode 100644 index 024ff6a4d..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/EmptyBatchProcessor.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.boydti.fawe.beta.implementation.processors - -import com.boydti.fawe.beta.IBatchProcessor -import com.boydti.fawe.beta.IChunk -import com.boydti.fawe.beta.IChunkGet -import com.boydti.fawe.beta.IChunkSet -import com.sk89q.worldedit.extent.Extent - -object EmptyBatchProcessor : IBatchProcessor { - - override fun construct(child: Extent?): Extent { - return child!! - } - - override fun processSet(chunk: IChunk?, get: IChunkGet?, set: IChunkSet?): IChunkSet { - return set!! - } - - override fun join(other: IBatchProcessor?): IBatchProcessor { - return other!! - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/MultiBatchProcessor.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/MultiBatchProcessor.java index c5446271f..f3a6a3df1 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/MultiBatchProcessor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/MultiBatchProcessor.java @@ -29,7 +29,7 @@ public class MultiBatchProcessor implements IBatchProcessor { } switch (list.size()) { case 0: - return EmptyBatchProcessor.INSTANCE; + return EmptyBatchProcessor.getInstance(); case 1: return list.get(0); default: diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/NullProcessor.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/NullProcessor.java new file mode 100644 index 000000000..b9f327987 --- /dev/null +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/NullProcessor.java @@ -0,0 +1,32 @@ +package com.boydti.fawe.beta.implementation.processors; + +import com.boydti.fawe.beta.IBatchProcessor; +import com.boydti.fawe.beta.IChunk; +import com.boydti.fawe.beta.IChunkGet; +import com.boydti.fawe.beta.IChunkSet; +import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.extent.NullExtent; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public final class NullProcessor implements IBatchProcessor { + private static final NullProcessor instance = new NullProcessor(); + + public static NullProcessor getInstance() { + return instance; + } + + @Nullable + public IChunkSet processSet(@NotNull IChunk chunk, @NotNull IChunkGet get, @NotNull IChunkSet set) { + return null; + } + + @NotNull + public Extent construct(@NotNull Extent child) { + return new NullExtent(); + } + + private NullProcessor() { + } + +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/NullProcessor.kt b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/NullProcessor.kt deleted file mode 100644 index 2e85cd938..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/NullProcessor.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.boydti.fawe.beta.implementation.processors - -import com.boydti.fawe.beta.IBatchProcessor -import com.boydti.fawe.beta.IChunk -import com.boydti.fawe.beta.IChunkGet -import com.boydti.fawe.beta.IChunkSet -import com.sk89q.worldedit.extent.Extent -import com.sk89q.worldedit.extent.NullExtent - -object NullProcessor : IBatchProcessor { - - override fun processSet(chunk: IChunk, get: IChunkGet, set: IChunkSet): IChunkSet? { - return null - } - - override fun construct(child: Extent): Extent { - return NullExtent() - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java index 7e73f8c8d..571191418 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java @@ -109,7 +109,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen this.lastPair = Long.MAX_VALUE; this.currentThread = null; this.initialized = false; - this.setProcessor(EmptyBatchProcessor.INSTANCE); + this.setProcessor(EmptyBatchProcessor.getInstance()); } /** @@ -128,7 +128,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen } this.cacheGet = get; this.cacheSet = set; - this.setProcessor(EmptyBatchProcessor.INSTANCE); + this.setProcessor(EmptyBatchProcessor.getInstance()); initialized = true; } @@ -223,8 +223,8 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen } if (!processGet(x, z)) { lastPair = pair; - lastChunk = NullChunk.INSTANCE; - return NullChunk.INSTANCE; + lastChunk = NullChunk.getInstance(); + return NullChunk.getInstance(); } IQueueChunk chunk = chunks.get(pair); if (chunk != null) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.java new file mode 100644 index 000000000..68d130d4e --- /dev/null +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.java @@ -0,0 +1,104 @@ +package com.boydti.fawe.object.clipboard; + +import com.boydti.fawe.beta.implementation.lighting.HeightMapType; +import com.sk89q.jnbt.CompoundTag; +import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.entity.Entity; +import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.regions.CuboidRegion; +import com.sk89q.worldedit.regions.Region; +import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BlockTypes; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public final class EmptyClipboard implements Clipboard { + private static final EmptyClipboard instance = new EmptyClipboard(); + + public static EmptyClipboard getInstance() { + return instance; + } + + @NotNull + public Region getRegion() { + return new CuboidRegion(BlockVector3.ZERO, BlockVector3.ZERO); + } + + @NotNull + public BlockVector3 getDimensions() { + return BlockVector3.ZERO; + } + + @NotNull + public BlockVector3 getOrigin() { + return BlockVector3.ZERO; + } + + public void setOrigin(@NotNull BlockVector3 origin) { + } + + public void removeEntity(@NotNull Entity entity) { + } + + @NotNull + public BlockVector3 getMinimumPoint() { + return BlockVector3.ZERO; + } + + @NotNull + public BlockVector3 getMaximumPoint() { + return BlockVector3.ZERO; + } + + @NotNull + public BaseBlock getFullBlock(@NotNull BlockVector3 position) { + return BlockTypes.AIR.getDefaultState().toBaseBlock(); + } + + @NotNull + public BlockState getBlock(@NotNull BlockVector3 position) { + return BlockTypes.AIR.getDefaultState(); + } + + @Nullable + public BiomeType getBiome(@NotNull BlockVector3 position) { + return null; + } + + @NotNull + public int[] getHeightMap(@Nullable HeightMapType type) { + return new int[256]; + } + + public boolean setBlock(@NotNull BlockVector3 position, BlockStateHolder block) throws WorldEditException { + return false; + } + + public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException { + return false; + } + + public boolean setTile(int x, int y, int z, @NotNull CompoundTag tile) throws WorldEditException { + return false; + } + + public boolean setBiome(@NotNull BlockVector3 position, @NotNull BiomeType biome) { + return false; + } + + public boolean fullySupports3DBiomes() { + return false; + } + + public boolean setBiome(int x, int y, int z, @NotNull BiomeType biome) { + return false; + } + + private EmptyClipboard() { + } + +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.kt b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.kt deleted file mode 100644 index 95664bcbe..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.kt +++ /dev/null @@ -1,83 +0,0 @@ -package com.boydti.fawe.`object`.clipboard - -import com.boydti.fawe.beta.implementation.lighting.HeightMapType -import com.sk89q.jnbt.CompoundTag -import com.sk89q.worldedit.WorldEditException -import com.sk89q.worldedit.entity.Entity -import com.sk89q.worldedit.extent.clipboard.Clipboard -import com.sk89q.worldedit.math.BlockVector2 -import com.sk89q.worldedit.math.BlockVector3 -import com.sk89q.worldedit.regions.CuboidRegion -import com.sk89q.worldedit.regions.Region -import com.sk89q.worldedit.world.biome.BiomeType -import com.sk89q.worldedit.world.block.BaseBlock -import com.sk89q.worldedit.world.block.BlockState -import com.sk89q.worldedit.world.block.BlockStateHolder -import com.sk89q.worldedit.world.block.BlockTypes - -object EmptyClipboard : Clipboard { - override fun getRegion(): Region { - return CuboidRegion(BlockVector3.ZERO, BlockVector3.ZERO) - } - - override fun getDimensions(): BlockVector3 { - return BlockVector3.ZERO - } - - override fun getOrigin(): BlockVector3 { - return BlockVector3.ZERO - } - - override fun setOrigin(origin: BlockVector3) {} - override fun removeEntity(entity: Entity) {} - override fun getMinimumPoint(): BlockVector3 { - return BlockVector3.ZERO - } - - override fun getMaximumPoint(): BlockVector3 { - return BlockVector3.ZERO - } - - override fun getFullBlock(position: BlockVector3): BaseBlock { - return BlockTypes.AIR!!.defaultState.toBaseBlock() - } - - override fun getBlock(position: BlockVector3): BlockState { - return BlockTypes.AIR!!.defaultState - } - - override fun getBiome(position: BlockVector3): BiomeType? { - return null - } - - override fun getHeightMap(type: HeightMapType?): IntArray { - return IntArray(256) - } - - @Throws(WorldEditException::class) - override fun ?> setBlock(position: BlockVector3, block: T): Boolean { - return false - } - - @Throws(WorldEditException::class) - override fun ?> setBlock(x: Int, y: Int, z: Int, block: T): Boolean { - return false - } - - @Throws(WorldEditException::class) - override fun setTile(x: Int, y: Int, z: Int, tile: CompoundTag): Boolean { - return false - } - - override fun setBiome(position: BlockVector3, biome: BiomeType): Boolean { - return false - } - - override fun fullySupports3DBiomes(): Boolean { - return false - } - - override fun setBiome(x: Int, y: Int, z: Int, biome: BiomeType): Boolean { - return false - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/LazyClipboardHolder.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/LazyClipboardHolder.java index 9542f5fc3..1b85a50c2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/LazyClipboardHolder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/LazyClipboardHolder.java @@ -21,7 +21,7 @@ public class LazyClipboardHolder extends URIClipboardHolder { * */ public LazyClipboardHolder(URI uri, ByteSource source, ClipboardFormat format, UUID uuid) { - super(uri, EmptyClipboard.INSTANCE); + super(uri, EmptyClipboard.getInstance()); this.source = source; this.format = format; this.uuid = uuid != null ? uuid : UUID.randomUUID(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MultiClipboardHolder.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MultiClipboardHolder.java index c0d0a3ef9..8792062a3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MultiClipboardHolder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MultiClipboardHolder.java @@ -22,7 +22,7 @@ public class MultiClipboardHolder extends URIClipboardHolder { } public MultiClipboardHolder(URI uri) { - super(uri, EmptyClipboard.INSTANCE); + super(uri, EmptyClipboard.getInstance()); holders = new ArrayList<>(); } @@ -32,7 +32,7 @@ public class MultiClipboardHolder extends URIClipboardHolder { } public MultiClipboardHolder(Clipboard clipboard) { - super(URI.create(""), EmptyClipboard.INSTANCE); + super(URI.create(""), EmptyClipboard.getInstance()); holders = new ArrayList<>(); URI uri = URI.create(""); if (clipboard.getURI() != null) { @@ -140,7 +140,7 @@ public class MultiClipboardHolder extends URIClipboardHolder { cached = available = getClipboards().toArray(new Clipboard[0]); } switch (available.length) { - case 0: return EmptyClipboard.INSTANCE; + case 0: return EmptyClipboard.getInstance(); case 1: return available[0]; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java index 378e446b9..c9f52a524 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java @@ -614,7 +614,7 @@ public class BrushTool newVisualExtent.init(chunkExtent); editSession.addProcessor(newVisualExtent); - editSession.addProcessor(NullProcessor.INSTANCE); + editSession.addProcessor(NullProcessor.getInstance()); BlockVector3 position = getPosition(editSession, player); if (position != null) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java index e652a4544..e4c89b2ab 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java @@ -166,7 +166,7 @@ public class NullWorld extends AbstractWorld { @Override public IChunkGet get(int x, int z) { - return NullChunkGet.INSTANCE; + return NullChunkGet.getInstance(); } @Override diff --git a/worldedit-libs/core/build.gradle.kts b/worldedit-libs/core/build.gradle.kts index b2cda871d..915c530b5 100644 --- a/worldedit-libs/core/build.gradle.kts +++ b/worldedit-libs/core/build.gradle.kts @@ -14,5 +14,4 @@ dependencies { "shade"("org.enginehub.piston:core:${Versions.PISTON}") "shade"("org.enginehub.piston.core-ap:runtime:${Versions.PISTON}") "shade"("org.enginehub.piston:default-impl:${Versions.PISTON}") - "shade"("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.0") }