diff --git a/.gitignore b/.gitignore index c02ff0042..55e79e03e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,11 +2,12 @@ /classes /logs /build +/projects/*/build /buildSrc/build /out /doc/out/ /node_modules -/.jqwik-database +.jqwik-database # Runtime directories /run diff --git a/build.gradle.kts b/build.gradle.kts index ed59fe649..87c59def3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,6 @@ plugins { alias(libs.plugins.librarian) alias(libs.plugins.shadow) // Publishing - `maven-publish` alias(libs.plugins.curseForgeGradle) alias(libs.plugins.githubRelease) alias(libs.plugins.minotaur) @@ -19,6 +18,7 @@ plugins { id("cc-tweaked.illuaminate") id("cc-tweaked.node") id("cc-tweaked.gametest") + id("cc-tweaked.publishing") id("cc-tweaked") } @@ -26,9 +26,10 @@ val isStable = true val modVersion: String by extra val mcVersion: String by extra -group = "org.squiddev" -version = modVersion -base.archivesName.set("cc-tweaked-$mcVersion") +val allProjects = listOf(":core-api").map { evaluationDependsOn(it) } +cct { + allProjects.forEach { externalSources(it) } +} java.registerFeature("extraMods") { usingSourceSet(sourceSets.main.get()) } @@ -52,7 +53,11 @@ minecraft { forceExit = false - mods.register("computercraft") { source(sourceSets.main.get()) } + mods.register("computercraft") { + cct.sourceDirectories.get().forEach { + if (it.classes) sources(it.sourceSet) + } + } } val client by registering { @@ -149,6 +154,7 @@ dependencies { "extraModsRuntimeOnly"(fg.deobf("mezz.jei:jei-1.19.2-forge:11.3.0.262")) "extraModsCompileOnly"(fg.deobf("maven.modrinth:oculus:1.2.5")) + implementation(project(":core-api")) "shade"(libs.cobalt) "shade"("io.netty:netty-codec-http:4.1.76.Final") @@ -170,7 +176,6 @@ illuaminate { tasks.javadoc { include("dan200/computercraft/api/**/*.java") - (options as StandardJavadocDocletOptions).links("https://docs.oracle.com/en/java/javase/17/docs/api/") } val apiJar by tasks.registering(Jar::class) { @@ -216,21 +221,10 @@ tasks.processResources { } tasks.jar { - isReproducibleFileOrder = true - isPreserveFileTimestamps = false finalizedBy("reobfJar") archiveClassifier.set("slim") - manifest { - attributes( - "Specification-Title" to "computercraft", - "Specification-Vendor" to "SquidDev", - "Specification-Version" to "1", - "Implementation-Title" to "cctweaked", - "Implementation-Version" to modVersion, - "Implementation-Vendor" to "SquidDev", - ) - } + from(allProjects.map { zipTree(it.tasks.jar.get().archiveFile) }) } tasks.shadowJar { @@ -374,7 +368,8 @@ val publishCurseForge by tasks.registering(TaskPublishCurseForge::class) { val mainFile = upload("282001", tasks.shadowJar.get().archiveFile) dependsOn(tasks.shadowJar) // Ughr. - mainFile.changelog = "Release notes can be found on the [GitHub repository](https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v$mcVersion-$modVersion)." + mainFile.changelog = + "Release notes can be found on the [GitHub repository](https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v$mcVersion-$modVersion)." mainFile.changelogType = "markdown" mainFile.releaseType = if (isStable) "release" else "alpha" mainFile.gameVersions.add(mcVersion) @@ -420,41 +415,9 @@ tasks.publish { dependsOn(tasks.githubRelease) } publishing { publications { - register("maven") { - artifactId = base.archivesName.get() - from(components["java"]) + named("maven", MavenPublication::class) { artifact(apiJar) fg.component(this) - - pom { - name.set("CC: Tweaked") - description.set("CC: Tweaked is a fork of ComputerCraft, adding programmable computers, turtles and more to Minecraft.") - url.set("https://github.com/cc-tweaked/CC-Tweaked") - - scm { - url.set("https://github.com/cc-tweaked/CC-Tweaked.git") - } - - issueManagement { - system.set("github") - url.set("https://github.com/cc-tweaked/CC-Tweaked/issues") - } - - licenses { - license { - name.set("ComputerCraft Public License, Version 1.0") - url.set("https://github.com/cc-tweaked/CC-Tweaked/blob/HEAD/LICENSE") - } - } - } - } - } - - repositories { - maven("https://squiddev.cc/maven") { - name = "SquidDev" - - credentials(PasswordCredentials::class) } } } diff --git a/buildSrc/src/main/kotlin/cc-tweaked.java-convention.gradle.kts b/buildSrc/src/main/kotlin/cc-tweaked.java-convention.gradle.kts index e52bbf060..0fa97dc73 100644 --- a/buildSrc/src/main/kotlin/cc-tweaked.java-convention.gradle.kts +++ b/buildSrc/src/main/kotlin/cc-tweaked.java-convention.gradle.kts @@ -11,6 +11,17 @@ plugins { id("com.diffplug.spotless") } +val modVersion: String by extra +val mcVersion: String by extra + +group = "cc.tweaked" +version = modVersion + +base.archivesName.convention( + // TODO: Remove this (and the one below) once we've no longer got a root project! + if (project.path == rootProject.path) "cc-tweaked-$mcVersion" else "cc-tweaked-$mcVersion-${project.name}", +) + java { toolchain { languageVersion.set(CCTweakedPlugin.JAVA_VERSION) @@ -53,6 +64,31 @@ tasks.withType(JavaCompile::class.java).configureEach { options.encoding = "UTF-8" } +tasks.jar { + isReproducibleFileOrder = true + isPreserveFileTimestamps = false + archiveClassifier.set("slim") + + manifest { + attributes( + "Specification-Title" to "computercraft", + "Specification-Vendor" to "SquidDev", + "Specification-Version" to "1", + "Implementation-Title" to (if (project.path == rootProject.path) "cctweaked" else "cctweaked-${project.name}"), + "Implementation-Version" to modVersion, + "Implementation-Vendor" to "SquidDev", + ) + } +} + +tasks.javadoc { + options { + val stdOptions = this as StandardJavadocDocletOptions + stdOptions.addBooleanOption("Xdoclint:all,-missing", true) + stdOptions.links("https://docs.oracle.com/en/java/javase/17/docs/api/") + } +} + tasks.test { finalizedBy("jacocoTestReport") @@ -78,8 +114,8 @@ spotless { } val licenser = LicenseHeader.create( - api = file("config/license/api.txt"), - main = file("config/license/main.txt"), + api = rootProject.file("config/license/api.txt"), + main = rootProject.file("config/license/main.txt"), ) java { diff --git a/buildSrc/src/main/kotlin/cc-tweaked.publishing.gradle.kts b/buildSrc/src/main/kotlin/cc-tweaked.publishing.gradle.kts new file mode 100644 index 000000000..b1f27fe9c --- /dev/null +++ b/buildSrc/src/main/kotlin/cc-tweaked.publishing.gradle.kts @@ -0,0 +1,45 @@ +import org.gradle.kotlin.dsl.`maven-publish` + +plugins { + `java-library` + `maven-publish` +} + +publishing { + publications { + register("maven") { + artifactId = base.archivesName.get() + from(components["java"]) + + pom { + name.set("CC: Tweaked") + description.set("CC: Tweaked is a fork of ComputerCraft, adding programmable computers, turtles and more to Minecraft.") + url.set("https://github.com/cc-tweaked/CC-Tweaked") + + scm { + url.set("https://github.com/cc-tweaked/CC-Tweaked.git") + } + + issueManagement { + system.set("github") + url.set("https://github.com/cc-tweaked/CC-Tweaked/issues") + } + + licenses { + license { + name.set("ComputerCraft Public License, Version 1.0") + url.set("https://github.com/cc-tweaked/CC-Tweaked/blob/HEAD/LICENSE") + } + } + } + } + } + + repositories { + maven("https://squiddev.cc/maven") { + name = "SquidDev" + + credentials(PasswordCredentials::class) + } + } +} diff --git a/buildSrc/src/main/kotlin/cc/tweaked/gradle/CCTweakedExtension.kt b/buildSrc/src/main/kotlin/cc/tweaked/gradle/CCTweakedExtension.kt index e87d3acab..782c178b5 100644 --- a/buildSrc/src/main/kotlin/cc/tweaked/gradle/CCTweakedExtension.kt +++ b/buildSrc/src/main/kotlin/cc/tweaked/gradle/CCTweakedExtension.kt @@ -5,6 +5,7 @@ import org.gradle.api.attributes.TestSuiteType import org.gradle.api.file.FileSystemOperations import org.gradle.api.provider.Provider +import org.gradle.api.provider.SetProperty import org.gradle.api.reporting.ReportingExtension import org.gradle.api.tasks.JavaExec import org.gradle.api.tasks.SourceSetContainer @@ -31,7 +32,8 @@ abstract class CCTweakedExtension( /** Get the current git branch. */ val gitBranch: Provider = gitProvider(project, "") { - ProcessHelpers.captureOut("git", "-C", project.projectDir.absolutePath, "rev-parse", "--abbrev-ref", "HEAD").trim() + ProcessHelpers.captureOut("git", "-C", project.projectDir.absolutePath, "rev-parse", "--abbrev-ref", "HEAD") + .trim() } /** Get a list of all contributors to the project. */ @@ -64,6 +66,30 @@ abstract class CCTweakedExtension( contributors.sortedWith(String.CASE_INSENSITIVE_ORDER) } + /** + * References to other sources + */ + val sourceDirectories: SetProperty = + project.objects.setProperty(SourceSetReference::class.java) + + /** All source sets referenced by this project. */ + val sourceSets = sourceDirectories.map { x -> x.map { it.sourceSet } } + + init { + sourceDirectories.finalizeValueOnRead() + } + + /** + * Mark this project as consuming another project. Its [sourceDirectories] are added, ensuring tasks are set up + * correctly. + */ + fun externalSources(project: Project) { + val otherCct = project.extensions.getByType(CCTweakedExtension::class.java) + for (sourceSet in otherCct.sourceSets.get()) { + sourceDirectories.add(SourceSetReference.external(sourceSet)) + } + } + fun jacoco(task: NamedDomainObjectProvider) { val classDump = project.buildDir.resolve("jacocoClassDump/${task.name}") val reportTaskName = "jacoco${task.name.capitalized()}Report" diff --git a/buildSrc/src/main/kotlin/cc/tweaked/gradle/CCTweakedPlugin.kt b/buildSrc/src/main/kotlin/cc/tweaked/gradle/CCTweakedPlugin.kt index 19716208f..8286c12d0 100644 --- a/buildSrc/src/main/kotlin/cc/tweaked/gradle/CCTweakedPlugin.kt +++ b/buildSrc/src/main/kotlin/cc/tweaked/gradle/CCTweakedPlugin.kt @@ -2,14 +2,28 @@ import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.api.tasks.SourceSetContainer import org.gradle.jvm.toolchain.JavaLanguageVersion +import org.gradle.testing.jacoco.tasks.JacocoReport /** * Configures projects to match a shared configuration. */ class CCTweakedPlugin : Plugin { override fun apply(project: Project) { - project.extensions.create("cct", CCTweakedExtension::class.java) + val sourceSets = project.extensions.getByType(SourceSetContainer::class.java) + + val cct = project.extensions.create("cct", CCTweakedExtension::class.java) + cct.sourceDirectories.add(SourceSetReference.internal(sourceSets.getByName("main"))) + + project.afterEvaluate { + cct.sourceDirectories.disallowChanges() + } + + // Set up jacoco to read from /all/ our source directories. + project.tasks.named("jacocoTestReport", JacocoReport::class.java) { + for (ref in cct.sourceSets.get()) sourceDirectories.from(ref.allSource.sourceDirectories) + } } companion object { diff --git a/buildSrc/src/main/kotlin/cc/tweaked/gradle/SourceSetReference.kt b/buildSrc/src/main/kotlin/cc/tweaked/gradle/SourceSetReference.kt new file mode 100644 index 000000000..1668162cd --- /dev/null +++ b/buildSrc/src/main/kotlin/cc/tweaked/gradle/SourceSetReference.kt @@ -0,0 +1,20 @@ +package cc.tweaked.gradle + +import org.gradle.api.tasks.SourceSet + +data class SourceSetReference( + val sourceSet: SourceSet, + val classes: Boolean, + val external: Boolean, +) { + companion object { + /** A source set in the current project. */ + fun internal(sourceSet: SourceSet) = SourceSetReference(sourceSet, classes = true, external = false) + + /** A source set from another project. */ + fun external(sourceSet: SourceSet) = SourceSetReference(sourceSet, classes = true, external = true) + + /** A source set which is inlined into the current project. */ + fun inline(sourceSet: SourceSet) = SourceSetReference(sourceSet, classes = false, external = false) + } +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0ebd7d478..df8a5b486 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,11 +6,20 @@ forge = "43.1.1" parchment = "2022.10.16" parchmentMc = "1.19.2" +asm = "9.3" autoService = "1.0.1" +checkerFramework = "3.12.0" cobalt = { strictly = "[0.5.8,0.6.0)", prefer = "0.5.8" } +fastutil = "8.5.6" +guava = "31.0.1-jre" jetbrainsAnnotations = "23.0.0" +jsr305 = "3.0.2" kotlin = "1.7.10" kotlin-coroutines = "1.6.0" +logback = "1.2.11" +netty = { strictly = "[4.1.77.Final,5.0)", prefer = "4.1.77.Final" } +nightConfig = "3.6.5" +slf4j = "1.7.36" # Testing hamcrest = "2.2" @@ -32,11 +41,18 @@ spotless = "6.8.0" taskTree = "2.1.0" [libraries] +asm = { module = "org.ow2.asm:asm", version.ref = "asm" } autoService = { module = "com.google.auto.service:auto-service", version.ref = "autoService" } +checkerFramework = { module = "org.checkerframework:checker-qual", version.ref = "checkerFramework" } cobalt = { module = "org.squiddev:Cobalt", version.ref = "cobalt" } +fastutil = { module = "it.unimi.dsi:fastutil", version.ref = "fastutil" } +guava = { module = "com.google.guava:guava", version.ref = "guava" } jetbrainsAnnotations = { module = "org.jetbrains:annotations", version.ref = "jetbrainsAnnotations" } +jsr305 = { module = "com.google.code.findbugs:jsr305", version.ref = "jsr305" } kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlin-coroutines" } kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" } +netty-http = { module = "io.netty:netty-codec-http", version.ref = "netty" } +slf4j = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" } # Testing hamcrest = { module = "org.hamcrest:hamcrest", version.ref = "hamcrest" } diff --git a/projects/core-api/build.gradle.kts b/projects/core-api/build.gradle.kts new file mode 100644 index 000000000..919d98909 --- /dev/null +++ b/projects/core-api/build.gradle.kts @@ -0,0 +1,27 @@ +plugins { + id("cc-tweaked.java-convention") + id("cc-tweaked.publishing") + id("cc-tweaked") +} + +java { + withJavadocJar() +} + +// Due to the slightly circular nature of our API, add the main API jars to the javadoc classpath. +val docApi by configurations.registering { + isTransitive = false +} + +dependencies { + compileOnly(project(":mc-stubs")) + compileOnlyApi(libs.jsr305) + compileOnlyApi(libs.checkerFramework) + + "docApi"(project(":")) +} + +tasks.javadoc { + // Depend on + classpath += docApi +} diff --git a/src/main/java/dan200/computercraft/api/filesystem/FileAttributes.java b/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/FileAttributes.java similarity index 100% rename from src/main/java/dan200/computercraft/api/filesystem/FileAttributes.java rename to projects/core-api/src/main/java/dan200/computercraft/api/filesystem/FileAttributes.java diff --git a/src/main/java/dan200/computercraft/api/filesystem/FileOperationException.java b/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/FileOperationException.java similarity index 97% rename from src/main/java/dan200/computercraft/api/filesystem/FileOperationException.java rename to projects/core-api/src/main/java/dan200/computercraft/api/filesystem/FileOperationException.java index 24632b9cf..2f8e21d05 100644 --- a/src/main/java/dan200/computercraft/api/filesystem/FileOperationException.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/FileOperationException.java @@ -8,6 +8,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.io.IOException; +import java.io.Serial; import java.util.Objects; /** @@ -16,6 +17,7 @@ * This may be thrown from a {@link IMount} or {@link IWritableMount} to give more information about a failure. */ public class FileOperationException extends IOException { + @Serial private static final long serialVersionUID = -8809108200853029849L; private final String filename; diff --git a/src/main/java/dan200/computercraft/api/filesystem/IFileSystem.java b/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/IFileSystem.java similarity index 100% rename from src/main/java/dan200/computercraft/api/filesystem/IFileSystem.java rename to projects/core-api/src/main/java/dan200/computercraft/api/filesystem/IFileSystem.java diff --git a/src/main/java/dan200/computercraft/api/filesystem/IMount.java b/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/IMount.java similarity index 88% rename from src/main/java/dan200/computercraft/api/filesystem/IMount.java rename to projects/core-api/src/main/java/dan200/computercraft/api/filesystem/IMount.java index d98f195c4..c1b5bf6f3 100644 --- a/src/main/java/dan200/computercraft/api/filesystem/IMount.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/IMount.java @@ -5,9 +5,7 @@ */ package dan200.computercraft.api.filesystem; -import dan200.computercraft.api.ComputerCraftAPI; import dan200.computercraft.api.peripheral.IComputerAccess; -import net.minecraft.world.level.Level; import javax.annotation.Nonnull; import java.io.IOException; @@ -19,12 +17,9 @@ * Represents a read only part of a virtual filesystem that can be mounted onto a computer using * {@link IComputerAccess#mount(String, IMount)}. *

- * Ready made implementations of this interface can be created using - * {@link ComputerCraftAPI#createSaveDirMount(Level, String, long)} or - * {@link ComputerCraftAPI#createResourceMount(String, String)}, or you're free to implement it yourselves! + * Typically you will not need to implement this interface yourself, and can use the factory methods from the + * {@linkplain dan200.computercraft.api.ComputerCraftAPI the main ComputerCraft API}. * - * @see ComputerCraftAPI#createSaveDirMount(Level, String, long) - * @see ComputerCraftAPI#createResourceMount(String, String) * @see IComputerAccess#mount(String, IMount) * @see IWritableMount */ diff --git a/src/main/java/dan200/computercraft/api/filesystem/IWritableMount.java b/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/IWritableMount.java similarity index 91% rename from src/main/java/dan200/computercraft/api/filesystem/IWritableMount.java rename to projects/core-api/src/main/java/dan200/computercraft/api/filesystem/IWritableMount.java index 7542702a7..618dd9ecd 100644 --- a/src/main/java/dan200/computercraft/api/filesystem/IWritableMount.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/IWritableMount.java @@ -5,9 +5,7 @@ */ package dan200.computercraft.api.filesystem; -import dan200.computercraft.api.ComputerCraftAPI; import dan200.computercraft.api.peripheral.IComputerAccess; -import net.minecraft.world.level.Level; import javax.annotation.Nonnull; import java.io.IOException; @@ -19,10 +17,9 @@ * Represents a part of a virtual filesystem that can be mounted onto a computer using {@link IComputerAccess#mount(String, IMount)} * or {@link IComputerAccess#mountWritable(String, IWritableMount)}, that can also be written to. *

- * Ready made implementations of this interface can be created using - * {@link ComputerCraftAPI#createSaveDirMount(Level, String, long)}, or you're free to implement it yourselves! + * Typically you will not need to implement this interface yourself, and can use the factory methods from the + * {@linkplain dan200.computercraft.api.ComputerCraftAPI the main ComputerCraft API}. * - * @see ComputerCraftAPI#createSaveDirMount(Level, String, long) * @see IComputerAccess#mount(String, IMount) * @see IComputerAccess#mountWritable(String, IWritableMount) * @see IMount diff --git a/src/main/java/dan200/computercraft/api/lua/GenericSource.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/GenericSource.java similarity index 58% rename from src/main/java/dan200/computercraft/api/lua/GenericSource.java rename to projects/core-api/src/main/java/dan200/computercraft/api/lua/GenericSource.java index 32f7b1eda..2ebdd2197 100644 --- a/src/main/java/dan200/computercraft/api/lua/GenericSource.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/lua/GenericSource.java @@ -5,31 +5,26 @@ */ package dan200.computercraft.api.lua; -import dan200.computercraft.api.ComputerCraftAPI; -import dan200.computercraft.api.ForgeComputerCraftAPI; +import dan200.computercraft.api.peripheral.GenericPeripheral; import dan200.computercraft.api.peripheral.IPeripheral; -import dan200.computercraft.api.peripheral.IPeripheralProvider; -import dan200.computercraft.core.asm.LuaMethod; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.items.IItemHandler; import javax.annotation.Nonnull; /** - * A generic source of {@link LuaMethod} functions. + * A generic source of {@link LuaFunction} functions. *

* Unlike normal objects ({@link IDynamicLuaObject} or {@link IPeripheral}), methods do not target this object but * instead are defined as {@code static} and accept their target as the first parameter. This allows you to inject - * methods onto objects you do not own, as well as declaring methods for a specific "trait" (for instance, a - * {@link Capability}). + * methods onto objects you do not own, as well as declaring methods for a specific "trait" (for instance, a Forge + * capability or Fabric block lookup interface). *

- * Currently the "generic peripheral" system is incompatible with normal peripherals. Normal {@link IPeripheralProvider} - * or {@link IPeripheral} implementations take priority. Tile entities which use this system are given a peripheral name - * determined by their id, rather than any peripheral provider. This will hopefully change in the future, once a suitable - * design has been established. + * Currently the "generic peripheral" system is incompatible with normal peripherals. Peripherals explicitly provided + * by capabilities/the block lookup API take priority. Block entities which use this system are given a peripheral name + * determined by their id, rather than any peripheral provider, though additional types may be provided by overriding + * {@link GenericPeripheral#getType()}. *

- * For example, the main CC: Tweaked mod defines a generic source for inventories, which works on {@link IItemHandler}s: + * For example, the main CC: Tweaked mod defines a generic source for inventories, which works on {@code IItemHandler}s: * *

{@code
  * public class InventoryMethods implements GenericSource {
@@ -42,9 +37,10 @@
  * }
  * }
* - * @see ComputerCraftAPI#registerGenericSource(GenericSource) - * @see ForgeComputerCraftAPI#registerGenericCapability(Capability) New capabilities (those not built into Forge) must be - * explicitly given to the generic peripheral system, as there is no way to enumerate all capabilities. + * @see dan200.computercraft.api.ComputerCraftAPI#registerGenericSource(GenericSource) + * @see dan200.computercraft.api.ForgeComputerCraftAPI#registerGenericCapability New capabilities (those not + * built into Forge) must be explicitly given to the generic peripheral system, as there is no way to enumerate all + * capabilities. */ public interface GenericSource { /** diff --git a/src/main/java/dan200/computercraft/api/lua/IArguments.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/IArguments.java similarity index 99% rename from src/main/java/dan200/computercraft/api/lua/IArguments.java rename to projects/core-api/src/main/java/dan200/computercraft/api/lua/IArguments.java index 10dea4627..5c00b099a 100644 --- a/src/main/java/dan200/computercraft/api/lua/IArguments.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/lua/IArguments.java @@ -11,8 +11,6 @@ import java.util.Map; import java.util.Optional; -import static dan200.computercraft.api.lua.LuaValues.checkFinite; - /** * The arguments passed to a function. */ @@ -102,7 +100,7 @@ default long getLong(int index) throws LuaException { * @throws LuaException If the value is not finite. */ default double getFiniteDouble(int index) throws LuaException { - return checkFinite(index, getDouble(index)); + return LuaValues.checkFinite(index, getDouble(index)); } /** diff --git a/src/main/java/dan200/computercraft/api/lua/IComputerSystem.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/IComputerSystem.java similarity index 100% rename from src/main/java/dan200/computercraft/api/lua/IComputerSystem.java rename to projects/core-api/src/main/java/dan200/computercraft/api/lua/IComputerSystem.java diff --git a/src/main/java/dan200/computercraft/api/lua/IDynamicLuaObject.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/IDynamicLuaObject.java similarity index 100% rename from src/main/java/dan200/computercraft/api/lua/IDynamicLuaObject.java rename to projects/core-api/src/main/java/dan200/computercraft/api/lua/IDynamicLuaObject.java diff --git a/src/main/java/dan200/computercraft/api/lua/ILuaAPI.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaAPI.java similarity index 91% rename from src/main/java/dan200/computercraft/api/lua/ILuaAPI.java rename to projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaAPI.java index ed08183a2..fb9905297 100644 --- a/src/main/java/dan200/computercraft/api/lua/ILuaAPI.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaAPI.java @@ -5,8 +5,6 @@ */ package dan200.computercraft.api.lua; -import dan200.computercraft.api.ComputerCraftAPI; - /** * Represents a Lua object which is stored as a global variable on computer startup. This must either provide * {@link LuaFunction} annotated functions or implement {@link IDynamicLuaObject}. @@ -14,8 +12,7 @@ * Before implementing this interface, consider alternative methods of providing methods. It is generally preferred * to use peripherals to provide functionality to users. * - * @see ILuaAPIFactory - * @see ComputerCraftAPI#registerAPIFactory(ILuaAPIFactory) + * @see ILuaAPIFactory For providing custom APIs to computers. */ public interface ILuaAPI { /** diff --git a/src/main/java/dan200/computercraft/api/lua/ILuaAPIFactory.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaAPIFactory.java similarity index 87% rename from src/main/java/dan200/computercraft/api/lua/ILuaAPIFactory.java rename to projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaAPIFactory.java index 503ec6949..ea29e03eb 100644 --- a/src/main/java/dan200/computercraft/api/lua/ILuaAPIFactory.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaAPIFactory.java @@ -5,8 +5,6 @@ */ package dan200.computercraft.api.lua; -import dan200.computercraft.api.ComputerCraftAPI; - import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -14,7 +12,7 @@ * Construct an {@link ILuaAPI} for a specific computer. * * @see ILuaAPI - * @see ComputerCraftAPI#registerAPIFactory(ILuaAPIFactory) + * @see dan200.computercraft.api.ComputerCraftAPI#registerAPIFactory(ILuaAPIFactory) */ @FunctionalInterface public interface ILuaAPIFactory { diff --git a/src/main/java/dan200/computercraft/api/lua/ILuaCallback.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaCallback.java similarity index 100% rename from src/main/java/dan200/computercraft/api/lua/ILuaCallback.java rename to projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaCallback.java diff --git a/src/main/java/dan200/computercraft/api/lua/ILuaContext.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaContext.java similarity index 100% rename from src/main/java/dan200/computercraft/api/lua/ILuaContext.java rename to projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaContext.java diff --git a/src/main/java/dan200/computercraft/api/lua/ILuaFunction.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaFunction.java similarity index 100% rename from src/main/java/dan200/computercraft/api/lua/ILuaFunction.java rename to projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaFunction.java diff --git a/src/main/java/dan200/computercraft/api/lua/ILuaTask.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaTask.java similarity index 100% rename from src/main/java/dan200/computercraft/api/lua/ILuaTask.java rename to projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaTask.java diff --git a/src/main/java/dan200/computercraft/api/lua/LuaException.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaException.java similarity index 97% rename from src/main/java/dan200/computercraft/api/lua/LuaException.java rename to projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaException.java index 1bd62c025..5b588b4ba 100644 --- a/src/main/java/dan200/computercraft/api/lua/LuaException.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaException.java @@ -6,11 +6,13 @@ package dan200.computercraft.api.lua; import javax.annotation.Nullable; +import java.io.Serial; /** * An exception representing an error in Lua, like that raised by the {@code error()} function. */ public class LuaException extends Exception { + @Serial private static final long serialVersionUID = -6136063076818512651L; private final boolean hasLevel; private final int level; diff --git a/src/main/java/dan200/computercraft/api/lua/LuaFunction.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaFunction.java similarity index 100% rename from src/main/java/dan200/computercraft/api/lua/LuaFunction.java rename to projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaFunction.java diff --git a/src/main/java/dan200/computercraft/api/lua/LuaTable.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaTable.java similarity index 91% rename from src/main/java/dan200/computercraft/api/lua/LuaTable.java rename to projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaTable.java index 82a80c316..2833acb35 100644 --- a/src/main/java/dan200/computercraft/api/lua/LuaTable.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaTable.java @@ -11,6 +11,13 @@ import static dan200.computercraft.api.lua.LuaValues.*; +/** + * A view of a Lua table, which may be able to access table elements in a more optimised manner than + * {@link IArguments#getTable(int)}. + * + * @param The type of keys in a table, will typically be a wildcard. + * @param The type of values in a table, will typically be a wildcard. + */ public interface LuaTable extends Map { /** * Compute the length of the array part of this table. @@ -77,7 +84,6 @@ default int getInt(String key) throws LuaException { return (int) getLong(key); } - @Nullable @Override default V put(K o, V o2) { diff --git a/src/main/java/dan200/computercraft/api/lua/LuaValues.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaValues.java similarity index 100% rename from src/main/java/dan200/computercraft/api/lua/LuaValues.java rename to projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaValues.java diff --git a/src/main/java/dan200/computercraft/api/lua/MethodResult.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/MethodResult.java similarity index 100% rename from src/main/java/dan200/computercraft/api/lua/MethodResult.java rename to projects/core-api/src/main/java/dan200/computercraft/api/lua/MethodResult.java diff --git a/src/main/java/dan200/computercraft/api/lua/ObjectArguments.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/ObjectArguments.java similarity index 100% rename from src/main/java/dan200/computercraft/api/lua/ObjectArguments.java rename to projects/core-api/src/main/java/dan200/computercraft/api/lua/ObjectArguments.java diff --git a/src/main/java/dan200/computercraft/api/lua/ObjectLuaTable.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/ObjectLuaTable.java similarity index 94% rename from src/main/java/dan200/computercraft/api/lua/ObjectLuaTable.java rename to projects/core-api/src/main/java/dan200/computercraft/api/lua/ObjectLuaTable.java index 1d39ee958..52e4a9753 100644 --- a/src/main/java/dan200/computercraft/api/lua/ObjectLuaTable.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/lua/ObjectLuaTable.java @@ -11,6 +11,9 @@ import java.util.Map; import java.util.Set; +/** + * An implementation of {@link LuaTable} based on a standard Java {@link Map}. + */ public class ObjectLuaTable implements LuaTable { private final Map map; diff --git a/src/main/java/dan200/computercraft/api/lua/TaskCallback.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/TaskCallback.java similarity index 100% rename from src/main/java/dan200/computercraft/api/lua/TaskCallback.java rename to projects/core-api/src/main/java/dan200/computercraft/api/lua/TaskCallback.java diff --git a/src/main/java/dan200/computercraft/api/peripheral/GenericPeripheral.java b/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/GenericPeripheral.java similarity index 84% rename from src/main/java/dan200/computercraft/api/peripheral/GenericPeripheral.java rename to projects/core-api/src/main/java/dan200/computercraft/api/peripheral/GenericPeripheral.java index 31b3f9f9e..1e0531230 100644 --- a/src/main/java/dan200/computercraft/api/peripheral/GenericPeripheral.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/GenericPeripheral.java @@ -6,8 +6,6 @@ package dan200.computercraft.api.peripheral; import dan200.computercraft.api.lua.GenericSource; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraftforge.items.IItemHandler; import javax.annotation.Nonnull; @@ -15,14 +13,14 @@ * A {@link GenericSource} which provides methods for a peripheral. *

* Unlike a {@link GenericSource}, all methods should target the same type, for instance a - * {@link BlockEntity} subclass or a capability interface. This is not currently enforced. + * block entity subclass. This is not currently enforced. */ public interface GenericPeripheral extends GenericSource { /** * Get the type of the exposed peripheral. *

* Unlike normal {@link IPeripheral}s, {@link GenericPeripheral} do not have to have a type. By default, the - * resulting peripheral uses the resource name of the wrapped {@link BlockEntity} (for instance {@code minecraft:chest}). + * resulting peripheral uses the resource name of the wrapped block entity (for instance {@code minecraft:chest}). *

* However, in some cases it may be more appropriate to specify a more readable name. Overriding this method allows * you to do so. @@ -31,7 +29,7 @@ public interface GenericPeripheral extends GenericSource { * lexicographically smallest will be chosen. In order to avoid this conflict, this method should only be * implemented when your peripheral targets a single tile entity AND it's likely that you're the * only mod to do so. Similarly this should NOT be implemented when your methods target a - * capability or other interface (i.e. {@link IItemHandler}). + * capability or other interface (such as Forge's {@code IItemHandler}). * * @return The type of this peripheral or {@link PeripheralType#untyped()}. * @see IPeripheral#getType() diff --git a/src/main/java/dan200/computercraft/api/peripheral/IComputerAccess.java b/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/IComputerAccess.java similarity index 94% rename from src/main/java/dan200/computercraft/api/peripheral/IComputerAccess.java rename to projects/core-api/src/main/java/dan200/computercraft/api/peripheral/IComputerAccess.java index b306bedc5..5c8a0ac05 100644 --- a/src/main/java/dan200/computercraft/api/peripheral/IComputerAccess.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/IComputerAccess.java @@ -5,14 +5,12 @@ */ package dan200.computercraft.api.peripheral; -import dan200.computercraft.api.ComputerCraftAPI; import dan200.computercraft.api.filesystem.IMount; import dan200.computercraft.api.filesystem.IWritableMount; import dan200.computercraft.api.lua.ILuaCallback; import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.ILuaTask; import dan200.computercraft.api.lua.MethodResult; -import net.minecraft.world.level.Level; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -32,8 +30,6 @@ public interface IComputerAccess { * @return The location on the computer's file system where you the mount mounted, or {@code null} if there was already a * file in the desired location. Store this value if you wish to unmount the mount later. * @throws NotAttachedException If the peripheral has been detached. - * @see ComputerCraftAPI#createSaveDirMount(Level, String, long) - * @see ComputerCraftAPI#createResourceMount(String, String) * @see #mount(String, IMount, String) * @see #mountWritable(String, IWritableMount) * @see #unmount(String) @@ -53,8 +49,6 @@ default String mount(@Nonnull String desiredLocation, @Nonnull IMount mount) { * @return The location on the computer's file system where you the mount mounted, or {@code null} if there was already a * file in the desired location. Store this value if you wish to unmount the mount later. * @throws NotAttachedException If the peripheral has been detached. - * @see ComputerCraftAPI#createSaveDirMount(Level, String, long) - * @see ComputerCraftAPI#createResourceMount(String, String) * @see #mount(String, IMount) * @see #mountWritable(String, IWritableMount) * @see #unmount(String) @@ -71,8 +65,6 @@ default String mount(@Nonnull String desiredLocation, @Nonnull IMount mount) { * @return The location on the computer's file system where you the mount mounted, or null if there was already a * file in the desired location. Store this value if you wish to unmount the mount later. * @throws NotAttachedException If the peripheral has been detached. - * @see ComputerCraftAPI#createSaveDirMount(Level, String, long) - * @see ComputerCraftAPI#createResourceMount(String, String) * @see #mount(String, IMount) * @see #unmount(String) * @see IMount @@ -91,8 +83,6 @@ default String mountWritable(@Nonnull String desiredLocation, @Nonnull IWritable * @return The location on the computer's file system where you the mount mounted, or null if there was already a * file in the desired location. Store this value if you wish to unmount the mount later. * @throws NotAttachedException If the peripheral has been detached. - * @see ComputerCraftAPI#createSaveDirMount(Level, String, long) - * @see ComputerCraftAPI#createResourceMount(String, String) * @see #mount(String, IMount) * @see #unmount(String) * @see IMount diff --git a/src/main/java/dan200/computercraft/api/peripheral/IDynamicPeripheral.java b/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/IDynamicPeripheral.java similarity index 100% rename from src/main/java/dan200/computercraft/api/peripheral/IDynamicPeripheral.java rename to projects/core-api/src/main/java/dan200/computercraft/api/peripheral/IDynamicPeripheral.java diff --git a/src/main/java/dan200/computercraft/api/peripheral/IPeripheral.java b/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/IPeripheral.java similarity index 93% rename from src/main/java/dan200/computercraft/api/peripheral/IPeripheral.java rename to projects/core-api/src/main/java/dan200/computercraft/api/peripheral/IPeripheral.java index f129b3a83..83b867e0a 100644 --- a/src/main/java/dan200/computercraft/api/peripheral/IPeripheral.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/IPeripheral.java @@ -6,7 +6,6 @@ package dan200.computercraft.api.peripheral; import dan200.computercraft.api.lua.LuaFunction; -import net.minecraftforge.common.capabilities.Capability; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -16,8 +15,8 @@ /** * The interface that defines a peripheral. *

- * In order to expose a peripheral for your block or tile entity, you may either attach a {@link Capability}, or - * register a {@link IPeripheralProvider}. This cannot be implemented {@link IPeripheral} directly on the tile. + * In order to expose a peripheral for your block or block entity, you should either attach a capability (Forge) or + * use the block lookup API (Fabric). This interface cannot be implemented directly on the block entity. *

* Peripherals should provide a series of methods to the user, either using {@link LuaFunction} or by implementing * {@link IDynamicPeripheral}. diff --git a/src/main/java/dan200/computercraft/api/peripheral/IWorkMonitor.java b/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/IWorkMonitor.java similarity index 100% rename from src/main/java/dan200/computercraft/api/peripheral/IWorkMonitor.java rename to projects/core-api/src/main/java/dan200/computercraft/api/peripheral/IWorkMonitor.java diff --git a/src/main/java/dan200/computercraft/api/peripheral/NotAttachedException.java b/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/NotAttachedException.java similarity index 95% rename from src/main/java/dan200/computercraft/api/peripheral/NotAttachedException.java rename to projects/core-api/src/main/java/dan200/computercraft/api/peripheral/NotAttachedException.java index c36d84ebd..cc3748e38 100644 --- a/src/main/java/dan200/computercraft/api/peripheral/NotAttachedException.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/NotAttachedException.java @@ -5,11 +5,14 @@ */ package dan200.computercraft.api.peripheral; +import java.io.Serial; + /** * Thrown when performing operations on {@link IComputerAccess} when the current peripheral is no longer attached to * the computer. */ public class NotAttachedException extends IllegalStateException { + @Serial private static final long serialVersionUID = 1221244785535553536L; public NotAttachedException() { diff --git a/src/main/java/dan200/computercraft/api/peripheral/PeripheralType.java b/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/PeripheralType.java similarity index 78% rename from src/main/java/dan200/computercraft/api/peripheral/PeripheralType.java rename to projects/core-api/src/main/java/dan200/computercraft/api/peripheral/PeripheralType.java index 5bf80b644..0792c95f6 100644 --- a/src/main/java/dan200/computercraft/api/peripheral/PeripheralType.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/PeripheralType.java @@ -5,9 +5,6 @@ */ package dan200.computercraft.api.peripheral; -import com.google.common.base.Strings; -import com.google.common.collect.ImmutableSet; - import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.Collection; @@ -29,8 +26,8 @@ public final class PeripheralType { public PeripheralType(String type, Set additionalTypes) { this.type = type; this.additionalTypes = additionalTypes; - if (additionalTypes.contains(null)) { - throw new IllegalArgumentException("All additional types must be non-null"); + for (var item : additionalTypes) { + if (item == null) throw new NullPointerException("All additional types must be non-null"); } } @@ -50,7 +47,7 @@ public static PeripheralType untyped() { * @return The constructed peripheral type. */ public static PeripheralType ofType(@Nonnull String type) { - if (Strings.isNullOrEmpty(type)) throw new IllegalArgumentException("type cannot be null or empty"); + checkTypeName("type cannot be null or empty"); return new PeripheralType(type, Collections.emptySet()); } @@ -62,8 +59,8 @@ public static PeripheralType ofType(@Nonnull String type) { * @return The constructed peripheral type. */ public static PeripheralType ofType(@Nonnull String type, Collection additionalTypes) { - if (Strings.isNullOrEmpty(type)) throw new IllegalArgumentException("type cannot be null or empty"); - return new PeripheralType(type, ImmutableSet.copyOf(additionalTypes)); + checkTypeName("type cannot be null or empty"); + return new PeripheralType(type, getTypes(additionalTypes)); } /** @@ -74,8 +71,8 @@ public static PeripheralType ofType(@Nonnull String type, Collection add * @return The constructed peripheral type. */ public static PeripheralType ofType(@Nonnull String type, @Nonnull String... additionalTypes) { - if (Strings.isNullOrEmpty(type)) throw new IllegalArgumentException("type cannot be null or empty"); - return new PeripheralType(type, ImmutableSet.copyOf(additionalTypes)); + checkTypeName(type); + return new PeripheralType(type, Set.of(additionalTypes)); } /** @@ -85,7 +82,7 @@ public static PeripheralType ofType(@Nonnull String type, @Nonnull String... add * @return The constructed peripheral type. */ public static PeripheralType ofAdditional(Collection additionalTypes) { - return new PeripheralType(null, ImmutableSet.copyOf(additionalTypes)); + return new PeripheralType(null, getTypes(additionalTypes)); } /** @@ -95,7 +92,7 @@ public static PeripheralType ofAdditional(Collection additionalTypes) { * @return The constructed peripheral type. */ public static PeripheralType ofAdditional(@Nonnull String... additionalTypes) { - return new PeripheralType(null, ImmutableSet.copyOf(additionalTypes)); + return new PeripheralType(null, Set.of(additionalTypes)); } /** @@ -117,4 +114,14 @@ public String getPrimaryType() { public Set getAdditionalTypes() { return additionalTypes; } + + private static void checkTypeName(@Nullable String type) { + if (type == null || type.isEmpty()) throw new IllegalArgumentException("type cannot be null or empty"); + } + + private static Set getTypes(Collection types) { + if (types.isEmpty()) return Collections.emptySet(); + if (types.size() == 1) return Collections.singleton(types.iterator().next()); + return Set.copyOf(types); + } } diff --git a/projects/mc-stubs/build.gradle.kts b/projects/mc-stubs/build.gradle.kts new file mode 100644 index 000000000..7dd63a3b1 --- /dev/null +++ b/projects/mc-stubs/build.gradle.kts @@ -0,0 +1,8 @@ +plugins { + id("cc-tweaked.java-convention") +} + +// Skip checkstyle here, it's going to be deleted soon anyway! +tasks.checkstyleMain { + enabled = false +} diff --git a/projects/mc-stubs/src/main/java/net/minecraft/resources/ResourceLocation.java b/projects/mc-stubs/src/main/java/net/minecraft/resources/ResourceLocation.java new file mode 100644 index 000000000..b7697ab2c --- /dev/null +++ b/projects/mc-stubs/src/main/java/net/minecraft/resources/ResourceLocation.java @@ -0,0 +1,14 @@ +/* + * This file is part of ComputerCraft - http://www.computercraft.info + * Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission. + * Send enquiries to dratcliffe@gmail.com + */ +package net.minecraft.resources; + +/** + * Placeholder class so we can preserve API compatibility for this release. + */ +public final class ResourceLocation { + private ResourceLocation() { + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 998bf3e4c..0adfc4d4e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -15,3 +15,10 @@ pluginManagement { val mcVersion: String by settings rootProject.name = "cc-tweaked-$mcVersion" + +include(":mc-stubs") +include(":core-api") + +for (project in rootProject.children) { + project.projectDir = file("projects/${project.name}") +} diff --git a/src/main/java/dan200/computercraft/core/apis/FastLuaException.java b/src/main/java/dan200/computercraft/core/apis/FastLuaException.java index b983028d9..b7f2d21da 100644 --- a/src/main/java/dan200/computercraft/core/apis/FastLuaException.java +++ b/src/main/java/dan200/computercraft/core/apis/FastLuaException.java @@ -8,11 +8,13 @@ import dan200.computercraft.api.lua.LuaException; import javax.annotation.Nullable; +import java.io.Serial; /** * A Lua exception which does not contain its stack trace. */ public class FastLuaException extends LuaException { + @Serial private static final long serialVersionUID = 5957864899303561143L; public FastLuaException(@Nullable String message) { diff --git a/src/main/java/dan200/computercraft/core/apis/http/HTTPRequestException.java b/src/main/java/dan200/computercraft/core/apis/http/HTTPRequestException.java index 837e8585d..ca544c8ed 100644 --- a/src/main/java/dan200/computercraft/core/apis/http/HTTPRequestException.java +++ b/src/main/java/dan200/computercraft/core/apis/http/HTTPRequestException.java @@ -5,7 +5,10 @@ */ package dan200.computercraft.core.apis.http; +import java.io.Serial; + public class HTTPRequestException extends Exception { + @Serial private static final long serialVersionUID = 7591208619422744652L; public HTTPRequestException(String s) { diff --git a/src/main/java/dan200/computercraft/core/filesystem/FileSystemException.java b/src/main/java/dan200/computercraft/core/filesystem/FileSystemException.java index cf50bffe6..37bbd976f 100644 --- a/src/main/java/dan200/computercraft/core/filesystem/FileSystemException.java +++ b/src/main/java/dan200/computercraft/core/filesystem/FileSystemException.java @@ -5,7 +5,10 @@ */ package dan200.computercraft.core.filesystem; +import java.io.Serial; + public class FileSystemException extends Exception { + @Serial private static final long serialVersionUID = -2500631644868104029L; FileSystemException(String s) { diff --git a/src/main/java/dan200/computercraft/core/lua/CobaltLuaMachine.java b/src/main/java/dan200/computercraft/core/lua/CobaltLuaMachine.java index 5824c79a5..faab9f49d 100644 --- a/src/main/java/dan200/computercraft/core/lua/CobaltLuaMachine.java +++ b/src/main/java/dan200/computercraft/core/lua/CobaltLuaMachine.java @@ -30,6 +30,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.io.InputStream; +import java.io.Serial; import java.nio.ByteBuffer; import java.util.*; import java.util.concurrent.SynchronousQueue; @@ -444,6 +445,7 @@ private void handlePause(DebugState ds, DebugFrame di) throws LuaError, UnwindTh } private static final class HardAbortError extends Error { + @Serial private static final long serialVersionUID = 7954092008586367501L; static final HardAbortError INSTANCE = new HardAbortError(); diff --git a/src/main/java/dan200/computercraft/impl/ServiceException.java b/src/main/java/dan200/computercraft/impl/ServiceException.java index 6db2f7a1c..fa97dea8c 100644 --- a/src/main/java/dan200/computercraft/impl/ServiceException.java +++ b/src/main/java/dan200/computercraft/impl/ServiceException.java @@ -8,6 +8,7 @@ import org.jetbrains.annotations.ApiStatus; import javax.annotation.Nullable; +import java.io.Serial; /** * A ComputerCraft-related service failed to load. @@ -16,6 +17,7 @@ */ @ApiStatus.Internal class ServiceException extends RuntimeException { + @Serial private static final long serialVersionUID = -8392300691666423882L; ServiceException(String message, @Nullable Throwable cause) {