Skip to content

Commit

Permalink
feat: added fabric support
Browse files Browse the repository at this point in the history
  • Loading branch information
confuser committed Jan 4, 2025
1 parent 2eb8f0b commit b3e7b50
Show file tree
Hide file tree
Showing 44 changed files with 2,312 additions and 127 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ logger.lifecycle("""
""")

plugins {
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id("io.freefair.aggregate-javadoc") version "6.3.0"
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
id("io.freefair.aggregate-javadoc") version "8.11"
}

nexusPublishing {
Expand Down
13 changes: 9 additions & 4 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ repositories {
name = "sponge"
url = uri("https://repo.spongepowered.org/repository/maven-public/")
}
maven {
name = "Fabric"
url = uri("https://maven.fabricmc.net/")
}
}

dependencies {
implementation(gradleApi())
implementation("com.github.jengelman.gradle.plugins:shadow:6.1.0")
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.21.0")
implementation("org.spongepowered:spongegradle-plugin-development:2.0.0")
}
implementation("com.gradleup.shadow:com.gradleup.shadow.gradle.plugin:9.0.0-beta4")
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:5.2.5")
implementation("org.spongepowered:spongegradle-plugin-development:2.3.0")
implementation("fabric-loom:fabric-loom.gradle.plugin:1.9-SNAPSHOT")
}
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/CommonConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ fun Project.applyCommonConfiguration() {
}

dependencies {
"compileOnly"("org.projectlombok:lombok:1.18.22")
"annotationProcessor"("org.projectlombok:lombok:1.18.22")
"compileOnly"("org.projectlombok:lombok:1.18.36")
"annotationProcessor"("org.projectlombok:lombok:1.18.36")

"testCompileOnly"("org.projectlombok:lombok:1.18.22")
"testAnnotationProcessor"("org.projectlombok:lombok:1.18.22")
"testCompileOnly"("org.projectlombok:lombok:1.18.36")
"testAnnotationProcessor"("org.projectlombok:lombok:1.18.36")
}

configurations.all {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/LibsConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fun Project.applyLibrariesConfiguration() {
apply(plugin = "java-base")
apply(plugin = "maven-publish")
apply(plugin = "signing")
apply(plugin = "com.github.johnrengelman.shadow")
apply(plugin = "com.gradleup.shadow")

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/PlatformConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fun Project.applyPlatformAndCoreConfiguration() {
}

fun Project.applyShadowConfiguration() {
apply(plugin = "com.github.johnrengelman.shadow")
apply(plugin = "com.gradleup.shadow")
tasks.named<ShadowJar>("shadowJar") {
archiveClassifier.set("dist")
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,19 @@ public final void enable() throws Exception {
results2.close();
}

try {
metrics.submitStorageType(config.getLocalDb().getStorageType());
metrics.submitDiscordMode(discordConfig.isHooksEnabled());
metrics.submitGeoMode(geoIpConfig.isEnabled());
metrics.submitGlobalMode(config.getGlobalDb().isEnabled());
metrics.submitOnlineMode(config.isOnlineMode());
if (storageVersion != null) {
metrics.submitStorageVersion(storageVersion);
if (metrics != null) {
try {
metrics.submitStorageType(config.getLocalDb().getStorageType());
metrics.submitDiscordMode(discordConfig.isHooksEnabled());
metrics.submitGeoMode(geoIpConfig.isEnabled());
metrics.submitGlobalMode(config.getGlobalDb().isEnabled());
metrics.submitOnlineMode(config.isOnlineMode());
if (storageVersion != null) {
metrics.submitStorageVersion(storageVersion);
}
} catch (Exception e) {
logger.warning("Failed to submit stats, ignoring");
}
} catch (Exception e) {
logger.warning("Failed to submit stats, ignoring");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ public CommandParser getParser(String[] args) throws NoSuchMethodException, Ille
args, start);
}

public CommandParser getParser(List<String> args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
return getParser(args.toArray(new String[0]));
}

public List<String> handlePlayerNameTabComplete(CommonSender sender, String[] args) {
ArrayList<String> mostLike = new ArrayList<>();
if(args.length == 1) {
Expand Down
141 changes: 141 additions & 0 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import net.fabricmc.loom.task.RemapJarTask

plugins {
`java-library`
`maven-publish`
`signing`
`fabric-loom`
}

applyPlatformAndCoreConfiguration()
applyShadowConfiguration()

publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])

pom {
name.set("BanManagerFabric")
description.set("BanManager for Fabric")
url.set("https://github.com/BanManagement/BanManager/")
licenses {
license {
name.set("Creative Commons Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales")
url.set("https://github.com/BanManagement/BanManager/blob/master/LICENCE")
}
}
developers {
developer {
id.set("confuser")
name.set("James Mortemore")
email.set("jamesmortemore@gmail.com")
}
}
scm {
connection.set("scm:git:git://github.com/BanManagement/BanManager.git")
developerConnection.set("scm:git:ssh://git@github.com/BanManagement/BanManager.git")
url.set("https://github.com/BanManagement/BanManager/")
}
}
}
}
}

signing {
if (project.findProperty("signingKey")?.toString()?.toBoolean() == true) {
useInMemoryPgpKeys(findProperty("signingKey")?.toString(), findProperty("signingPassword")?.toString())

sign(publishing.publications["mavenJava"])
}
}

repositories {
maven {
name = "Fabric"
url = uri("https://maven.fabricmc.net/")
}
}

configurations {
compileClasspath.get().extendsFrom(create("shadeOnly"))
}

dependencies {
minecraft("com.mojang:minecraft:1.21.4")
mappings("net.fabricmc:yarn:1.21.4+build.1:v2")
modImplementation("net.fabricmc:fabric-loader:0.16.9")

val modules = listOf(
"fabric-api-base",
"fabric-command-api-v2",
"fabric-events-interaction-v0",
"fabric-lifecycle-events-v1",
"fabric-message-api-v1",
"fabric-networking-api-v1",
"fabric-entity-events-v1"
)

modules.forEach {
modImplementation(fabricApi.module(it, "0.111.0+1.21.4"))
}

modImplementation("me.lucko:fabric-permissions-api:0.3.1")

api(project(":BanManagerCommon"))
}

tasks.named<Copy>("processResources") {
val internalVersion = project.ext["internalVersion"]

inputs.property("internalVersion", internalVersion)

filesMatching(listOf("plugin.yml", "fabric.mod.json")) {
expand("internalVersion" to internalVersion, "mainPath" to "me.confuser.banmanager.fabric.BMFabricPlugin")
}
}

tasks.named<Jar>("jar") {
val projectVersion = project.version
inputs.property("projectVersion", projectVersion)
manifest {
attributes("Implementation-Version" to projectVersion)
}
}

tasks.named<ShadowJar>("shadowJar") {
configurations = listOf(project.configurations["shadeOnly"], project.configurations["runtimeClasspath"])

archiveBaseName.set("BanManagerFabric")
archiveClassifier.set("")
archiveVersion.set("")

dependencies {
include(dependency(":BanManagerCommon"))
include(dependency(":BanManagerLibs"))
}
exclude("GradleStart**")
exclude(".cache");
exclude("LICENSE*")
exclude("META-INF/services/**")
exclude("META-INF/maven/**")
exclude("org/intellij/**")
exclude("org/jetbrains/**")
exclude("/mappings/*")

minimize()
}

tasks.named<RemapJarTask>("remapJar") {
dependsOn(tasks.named<ShadowJar>("shadowJar"))

inputFile.set(tasks.named<ShadowJar>("shadowJar").get().archiveFile)
archiveBaseName.set("BanManagerFabric")
archiveClassifier.set("")
archiveVersion.set("")
}

tasks.named("assemble").configure {
dependsOn("shadowJar")
}
Loading

0 comments on commit b3e7b50

Please sign in to comment.