diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 4edc17e3..ca715239 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -10,14 +10,14 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 1.8 + - name: Set up JDK 17 uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: '8' + java-version: '17' cache: 'gradle' - - name: Build with Maven + - name: Build with Gradle run: ./gradlew build - name: Archive artifacts (Floodgate Bungee) @@ -27,6 +27,13 @@ jobs: name: Floodgate Bungee path: bungee/build/libs/floodgate-bungee.jar + - name: Archive artifacts (Floodgate Fabric) + uses: actions/upload-artifact@v2 + if: success() + with: + name: Floodgate Fabric + path: fabric/build/libs/floodgate-fabric.jar + - name: Archive artifacts (Floodgate Spigot) uses: actions/upload-artifact@v2 if: success() diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index 64ac14db..516b8a36 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -11,7 +11,11 @@ repositories { dependencies { implementation("net.kyori", "indra-common", "2.0.6") implementation("org.jfrog.buildinfo", "build-info-extractor-gradle", "4.26.1") - implementation("gradle.plugin.com.github.johnrengelman", "shadow", "7.1.1") + implementation("gradle.plugin.com.github.johnrengelman", "shadow", "7.1.2") + + // Within the gradle plugin classpath, there is a version conflict between loom and some other + // plugin for databind. This fixes it: minimum 1.13.2 is required by loom. + implementation("com.fasterxml.jackson.core:jackson-databind:2.13.3") } tasks.withType { diff --git a/build-logic/src/main/kotlin/floodgate.base-conventions.gradle.kts b/build-logic/src/main/kotlin/floodgate.base-conventions.gradle.kts index 0dba1832..5cd68282 100644 --- a/build-logic/src/main/kotlin/floodgate.base-conventions.gradle.kts +++ b/build-logic/src/main/kotlin/floodgate.base-conventions.gradle.kts @@ -11,7 +11,7 @@ dependencies { tasks { processResources { - filesMatching(listOf("plugin.yml", "bungee.yml", "velocity-plugin.json")) { + filesMatching(listOf("plugin.yml", "bungee.yml", "velocity-plugin.json", "fabric.mod.json")) { expand( "id" to "floodgate", "name" to "floodgate", diff --git a/build.gradle.kts b/build.gradle.kts index b64f35aa..5d6c9f55 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,12 +2,50 @@ plugins { `java-library` id("floodgate.build-logic") id("io.freefair.lombok") version "6.3.0" apply false + id("fabric-loom") version "1.0-SNAPSHOT" apply false } allprojects { group = "org.geysermc.floodgate" version = "2.2.0-SNAPSHOT" description = "Allows Bedrock players to join Java edition servers while keeping the server in online mode" + + repositories { +// mavenLocal() + + // Geyser, Cumulus etc. + maven("https://repo.opencollab.dev/maven-releases") { + mavenContent { releasesOnly() } + } + maven("https://repo.opencollab.dev/maven-snapshots") { + mavenContent { snapshotsOnly() } + } + + // Spigot, BungeeCord + maven("https://oss.sonatype.org/content/repositories/snapshots") { + mavenContent { snapshotsOnly() } + } + + // Paper, Velocity + maven("https://repo.papermc.io/repository/maven-public") { + content { + includeGroupByRegex( + "(io\\.papermc\\..*|com\\.destroystokyo\\..*|com\\.velocitypowered)" + ) + } + } + + maven("https://libraries.minecraft.net") { + name = "minecraft" + mavenContent { releasesOnly() } + } + + mavenCentral() + + maven("https://jitpack.io") { + content { includeGroupByRegex("com\\.github\\..*") } + } + } } val deployProjects = setOf( @@ -15,6 +53,7 @@ val deployProjects = setOf( // for future Floodgate integration + Fabric projects.core, projects.bungee, + projects.fabric, projects.spigot, projects.velocity ).map { it.dependencyProject } diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts new file mode 100644 index 00000000..02453da4 --- /dev/null +++ b/fabric/build.gradle.kts @@ -0,0 +1,100 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import net.fabricmc.loom.task.RemapJarTask + +val minecraftVersion = "1.19" +val loaderVersion = "0.14.6" +val fabricVersion = "0.55.3+1.19" + +plugins { + id("fabric-loom") //version "1.0-SNAPSHOT" + id("java") + id("maven-publish") +} + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(17)) + } +} + +tasks.withType { + options.encoding = "UTF-8" + sourceCompatibility = "17" + targetCompatibility = "17" + options.release.set(17) +} + +loom { + accessWidenerPath.set(file("src/main/resources/floodgate.accesswidener")) +} + +// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task +// if it is present. +// If you remove this task, sources will not be generated. +//val sourcesJar = tasks.create("sourcesJar") { + //archiveClassifier.set("sources") + //from(sourceSets["main"].allSource) +//} + +// This is easier than what is immediately above? +java { + withSourcesJar() +} + +tasks { + shadowJar { + configurations = listOf(project.configurations.shadow.get()) + } +} + +val remappedShadowJar = tasks.create("remappedShadowJar") { + dependsOn(tasks.shadowJar) + input.set(tasks.shadowJar.get().archiveFile) //fixme: deprecated + addNestedDependencies.set(true) + archiveFileName.set("floodgate-fabric.jar") +} + +tasks.assemble { + dependsOn(remappedShadowJar) +} + +artifacts { + archives(remappedShadowJar) + shadow(tasks.shadowJar) +} + +repositories { + // specifically for adventure-platform-fabric:5.4.0-SNAPSHOT + maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") { + name = "sonatype-oss-snapshots1" + mavenContent { snapshotsOnly() } + } +} + +// todo: perform exclusions using floodgate build logic +dependencies { + api(projects.core) { + exclude("com.google.guava", "guava") + exclude("com.google.code.gson", "gson") + exclude("org.slf4j", "slf4j-api") + exclude("net.kyori", "*") // Let Adventure-Platform provide its desired Adventure version + exclude("it.unimi.dsi.fastutil", "*") + } + + minecraft("com.mojang", "minecraft", minecraftVersion) + mappings(loom.officialMojangMappings()) + + modImplementation("net.fabricmc", "fabric-loader", loaderVersion) + modImplementation("net.fabricmc.fabric-api", "fabric-api", fabricVersion) + + include(modImplementation("cloud.commandframework", "cloud-fabric", "1.7.0-SNAPSHOT") { + because("Commands library implementation for Fabric") + }) + + include(modImplementation("net.kyori", "adventure-platform-fabric", "5.4.0-SNAPSHOT") { + because("Chat library implementation for Fabric that includes methods for communicating with the server") + // Thanks to zml for this fix + // The package modifies Brigadier which causes a LinkageError at runtime if included + exclude("ca.stellardrift", "colonel") + }) +} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json new file mode 100644 index 00000000..7f2a1fcd --- /dev/null +++ b/fabric/src/main/resources/fabric.mod.json @@ -0,0 +1,31 @@ +{ + "schemaVersion": 1, + "id": "floodgate", + "version": "${version}", + "name": "Floodgate-Fabric", + "description": "", + "authors": [ + "GeyserMC" + ], + "contact": { + "website": "https://geysermc.org", + "repo": "https://github.com/GeyserMC/Floodgate-Fabric" + }, + "license": "MIT", + "icon": "assets/floodgate/icon.png", + "environment": "*", + "entrypoints": { + "main": [ + "org.geysermc.floodgate.FabricMod" + ] + }, + "accessWidener": "floodgate.accesswidener", + "mixins": [ + "floodgate.mixins.json" + ], + "depends": { + "fabricloader": ">=0.14.6", + "fabric": "*", + "minecraft": ">=1.19" + } +} diff --git a/fabric/src/main/resources/floodgate.accesswidener b/fabric/src/main/resources/floodgate.accesswidener new file mode 100644 index 00000000..4b266731 --- /dev/null +++ b/fabric/src/main/resources/floodgate.accesswidener @@ -0,0 +1,6 @@ +accessWidener v1 named + +# To change login state +accessible class net/minecraft/server/network/ServerLoginPacketListenerImpl$State +# For player skin refreshing +accessible class net/minecraft/server/level/ChunkMap$TrackedEntity diff --git a/fabric/src/main/resources/floodgate.mixins.json b/fabric/src/main/resources/floodgate.mixins.json new file mode 100644 index 00000000..8d29fb4d --- /dev/null +++ b/fabric/src/main/resources/floodgate.mixins.json @@ -0,0 +1,16 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "org.geysermc.floodgate.mixin", + "compatibilityLevel": "JAVA_16", + "mixins": [ + "ChunkMapMixin", + "ClientIntentionPacketMixin", + "ConnectionMixin", + "ServerConnectionListenerMixin", + "ServerLoginPacketListenerImplMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/gradle.properties b/gradle.properties index af7d8325..51ac4495 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,6 @@ org.gradle.configureondemand=true org.gradle.caching=true -org.gradle.parallel=true \ No newline at end of file +org.gradle.parallel=true + +# Done to increase the memory available to gradle. +org.gradle.jvmargs=-Xmx2G \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f..41d9927a 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e6e5897..aa991fce 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle.kts b/settings.gradle.kts index bcd33b65..dc8f9884 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,57 +1,8 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") -dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) - repositories { -// mavenLocal() - - // Geyser, Cumulus etc. - maven("https://repo.opencollab.dev/maven-releases") { - mavenContent { releasesOnly() } - } - maven("https://repo.opencollab.dev/maven-snapshots") { - mavenContent { snapshotsOnly() } - } - - // Paper, Velocity -// maven("https://repo.papermc.io/repository/maven-releases") { -// mavenContent { releasesOnly() } -// } -// maven("https://repo.papermc.io/repository/maven-snapshots") { -// mavenContent { snapshotsOnly() } -// } - maven("https://repo.papermc.io/repository/maven-public") { - content { - includeGroupByRegex( - "(io\\.papermc\\..*|com\\.destroystokyo\\..*|com\\.velocitypowered)" - ) - } - } - // Spigot - maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots") { - mavenContent { snapshotsOnly() } - } - - // BungeeCord - maven("https://oss.sonatype.org/content/repositories/snapshots") { - mavenContent { snapshotsOnly() } - } - - maven("https://libraries.minecraft.net") { - name = "minecraft" - mavenContent { releasesOnly() } - } - - mavenCentral() - - maven("https://jitpack.io") { - content { includeGroupByRegex("com\\.github\\..*") } - } - } -} - pluginManagement { repositories { + maven("https://maven.fabricmc.net") { name = "Fabric" } gradlePluginPortal() } plugins { @@ -66,6 +17,7 @@ include(":api") include(":ap") include(":core") include(":bungee") +include(":fabric") include(":spigot") include(":velocity") include(":sqlite")