Working Release

This commit is contained in:
2025-06-05 21:05:42 -04:00
parent 4e04aada7a
commit dd78f89164
3 changed files with 76 additions and 83 deletions

View File

@@ -1,115 +1,101 @@
plugins { plugins {
id 'fabric-loom' version "${loom_version}" id 'fabric-loom' version "${loom_version}"
id 'maven-publish' id 'maven-publish'
id "org.jetbrains.kotlin.jvm" version "2.1.20" id "org.jetbrains.kotlin.jvm" version "2.1.20" // Ensure your kotlin_version in gradle.properties matches or is compatible
} }
version = project.mod_version version = project.mod_version
group = project.maven_group group = project.maven_group
base { base {
archivesName = project.archives_base_name archivesName = project.archives_base_name
} }
repositories { repositories {
mavenCentral() mavenCentral()
maven { url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/' }
maven { maven { url 'https://maven.impactdev.net/repository/development/' }
url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/' maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
maven {
url 'https://maven.impactdev.net/repository/development/'
}
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
} }
loom { loom {
splitEnvironmentSourceSets() splitEnvironmentSourceSets()
mods {
"cobblesync" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}
mods {
"cobblesync" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}
} }
fabricApi { fabricApi {
configureDataGeneration { configureDataGeneration {
client = true client = true
} }
} }
dependencies { dependencies {
// To change the versions see the gradle.properties file // Minecraft & Fabric Loader
minecraft "com.mojang:minecraft:${project.minecraft_version}" minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.officialMojangMappings() mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Fabric API. This is technically optional, but you probably want it anyway. // Fabric API
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Fabric Kotlin Language Adapter
modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}" modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}"
// Other Mod Dependencies (e.g., Cobblemon)
modImplementation "com.cobblemon:fabric:1.6.0+1.21.1-SNAPSHOT" modImplementation "com.cobblemon:fabric:1.6.0+1.21.1-SNAPSHOT"
// JSON and GSON dependencies - add implementation first, then include
implementation "org.json:json:20231013"
include "org.json:json:20231013"
implementation "com.google.code.gson:gson:2.10.1" implementation "com.google.code.gson:gson:2.10.1"
implementation "org.json:json:20231013" // Or the latest version include "com.google.code.gson:gson:2.10.1"
} }
processResources { processResources {
inputs.property "version", project.version inputs.property "version", project.version
filesMatching("fabric.mod.json") { filesMatching("fabric.mod.json") {
expand "version": inputs.properties.version expand "version": inputs.properties.version
} }
} }
tasks.withType(JavaCompile).configureEach { tasks.withType(JavaCompile).configureEach {
it.options.release = 21 it.options.release = 21
} }
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions { kotlinOptions {
jvmTarget = 21 jvmTarget = "21" // Ensure jvmTarget is a string
} }
} }
java { java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task withSourcesJar()
// if it is present. sourceCompatibility = JavaVersion.VERSION_21
// If you remove this line, sources will not be generated. targetCompatibility = JavaVersion.VERSION_21
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
} }
jar { jar {
inputs.property "archivesName", project.base.archivesName inputs.property "archivesName", project.base.archivesName
from("LICENSE") {
from("LICENSE") { rename { "${it}_${inputs.properties.archivesName}"}
rename { "${it}_${inputs.properties.archivesName}"} }
}
} }
// configure the maven publication
publishing { publishing {
publications { publications {
create("mavenJava", MavenPublication) { create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name artifactId = project.archives_base_name
from components.java from components.java
} }
} }
repositories {
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. // Add your publishing repositories here
repositories { }
// Add repositories to publish to here. }
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}

View File

@@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory
object CobbleSync : ModInitializer { object CobbleSync : ModInitializer {
private val logger = LoggerFactory.getLogger("cobblesync") private val logger = LoggerFactory.getLogger("cobblesync")
private val request = Request("http://localhost:5173") private val request = Request("https://authserver.sirblob.co")
override fun onInitialize() { override fun onInitialize() {
@@ -64,27 +64,24 @@ object CobbleSync : ModInitializer {
return@Command 1 return@Command 1
} }
var obj = box30.saveToJSON(JsonObject(), player.registryAccess())
val payload = JSONObject()
.put("pokemon", obj.toString())
.put("count", pokemonCount)
logger.info("/api/cobblesync/" + player.uuid.toString())
try { try {
var obj = box30.saveToJSON(JsonObject(), player.registryAccess())
val payload = JSONObject()
.put("pokemon", obj.toString())
.put("count", pokemonCount)
var response = request.POST("/api/cobblesync/" + player.uuid.toString(), payload) var response = request.POST("/api/cobblesync/" + player.uuid.toString(), payload)
if (response.getInt("status") != 200) { logger.info(response.toString())
player.sendSystemMessage(Component.literal("Failed to sync box 1!").red())
return@Command 1
}
player.sendSystemMessage(Component.literal("Box 1 synced successfully!").green()) player.sendSystemMessage(Component.literal("Box 30 synced successfully!").green())
} catch (e: HTTPException) { } catch (e: HTTPException) {
logger.error("HTTP Exception: ${e.message}") logger.error("HTTP Exception: ${e.message}")
player.sendSystemMessage(Component.literal("Error syncing box 1!").red()) player.sendSystemMessage(Component.literal("Error syncing box 30!").red())
return@Command 1 return@Command 1
} catch (e: Exception) { } catch (e: Exception) {
logger.error("Exception: ${e.message}") logger.error("Exception: ${e.message}")
@@ -105,6 +102,16 @@ object CobbleSync : ModInitializer {
var box1 = pc.boxes.get(0) var box1 = pc.boxes.get(0)
var pokemonCount = 0
box1.pc.forEach({ _ ->
pokemonCount++
})
if (pokemonCount > 0) {
player.sendSystemMessage(Component.literal("[Load Failed] Box 1 is not empty!").red())
return@Command 1
}
try { try {
var response = request.GET("/api/cobblesync/" + player.uuid.toString()) var response = request.GET("/api/cobblesync/" + player.uuid.toString())

View File

@@ -5,7 +5,7 @@
"name": "CobbleSync", "name": "CobbleSync",
"description": "This is an example description! Tell everyone what your mod is about!", "description": "This is an example description! Tell everyone what your mod is about!",
"authors": [ "authors": [
"Me!" "Sir_Blob_"
], ],
"contact": { "contact": {
"homepage": "https://fabricmc.net/", "homepage": "https://fabricmc.net/",