diff --git a/build.gradle b/build.gradle index 958567a..d18229a 100644 --- a/build.gradle +++ b/build.gradle @@ -3,36 +3,37 @@ import org.apache.tools.ant.types.Parameter buildscript { repositories { - maven { url = 'https://files.minecraftforge.net/maven' } - jcenter() + // These repositories are only for Gradle plugins, put any other repositories in the repository block further below + maven { url = 'https://maven.minecraftforge.net' } mavenCentral() } dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true } } plugins { - id 'maven-publish' id 'eclipse' + id 'maven-publish' } - apply plugin: 'net.minecraftforge.gradle' // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. -version = '2.1.0' +version = '3.0.0' group = 'serversync.forge.loader' // http://maven.apache.org/guides/mini/guide-naming-conventions.html -archivesBaseName = 'serversync-forge-loader' +archivesBaseName = 'serversync_forge_loader' -sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. +//sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '17' // Need this here so eclipse task generates correctly. +java.toolchain.languageVersion = JavaLanguageVersion.of(17) +println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { // The mappings can be changed at any time, and must be in the following format. // snapshot_YYYYMMDD Snapshot are built nightly. // stable_# Stables are built at the discretion of the MCP team. // Use non-default mappings at your own risk. they may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. - mappings channel: 'snapshot', version: '20200514-1.16' + mappings channel: 'official', version: '1.18.2' // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') @@ -81,7 +82,7 @@ minecraft { // Recommended logging level for the console property 'forge.logging.console.level', 'debug' - args '--mod', 'serversync-forge-loader', '--all', '--output', file('src/generated/resources/') + args '--mod', 'serversync_forge_loader', '--all', '--output', file('src/generated/resources/') mods { serversyncforgeloader { @@ -92,11 +93,13 @@ minecraft { } } +sourceSets.main.resources { srcDir 'src/generated/resources' } + dependencies { // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. // The userdev artifact is a special name and will get all sorts of transformations applied to it. - minecraft 'net.minecraftforge:forge:1.16.3-34.1.0' + minecraft 'net.minecraftforge:forge:1.18.2-40.1.80' // You may put jars on which you depend on in ./libs or you may define them like so.. // compile "some.group:artifact:version:classifier" @@ -126,7 +129,7 @@ jar { "Specification-Vendor" : "serversyncforgeloader", "Specification-Version" : "1", // We are version 1 of ourselves "Implementation-Title" : project.name, - "Implementation-Version" : "${version}", + "Implementation-Version" : project.jar.archiveVersion, "Implementation-Vendor" : "serversyncforgeloader", "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) @@ -137,16 +140,20 @@ jar { // we define a custom artifact that is sourced from the reobfJar output task // and then declare that to be published // Note you'll need to add a repository here -def reobfFile = file("$buildDir/reobfJar/output.jar") -def reobfArtifact = artifacts.add('default', reobfFile) { - type 'jar' - builtBy 'reobfJar' -} +// def reobfFile = file("$buildDir/reobfJar/output.jar") +// def reobfArtifact = artifacts.add('default', reobfFile) { +// type 'jar' +// builtBy 'reobfJar' +// } +jar.finalizedBy('reobfJar') publishing { publications { - gpr(MavenPublication) { - from components.java + // gpr(MavenPublication) { + // from components.java + // } + mavenJava(MavenPublication) { + artifact jar } } repositories { @@ -205,4 +212,4 @@ processResources { line.replaceAll('\\s*#.*', '') } } -} \ No newline at end of file +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b72a415..a2c0da0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ #Thu Mar 26 18:01:34 NZDT 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists diff --git a/src/main/java/serversync/forge/loader/ServerSyncLoader.java b/src/main/java/serversync/forge/loader/ServerSyncLoader.java index 2dcadd9..9788bc0 100644 --- a/src/main/java/serversync/forge/loader/ServerSyncLoader.java +++ b/src/main/java/serversync/forge/loader/ServerSyncLoader.java @@ -3,8 +3,8 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent; -import net.minecraftforge.fml.event.server.FMLServerStoppingEvent; +import net.minecraftforge.event.server.ServerAboutToStartEvent; +import net.minecraftforge.event.server.ServerStoppingEvent; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import serversync.generated.Reference; @@ -33,7 +33,7 @@ public ServerSyncLoader() { } @SubscribeEvent - public void onServerAboutToStart(FMLServerAboutToStartEvent event) { + public void onServerAboutToStart(ServerAboutToStartEvent event) { // ** We should be in the root folder for Minecraft as our CWD when forge loads. try (Stream fileStream = Files.list(Paths.get(""))) { @@ -68,12 +68,13 @@ public void onServerAboutToStart(FMLServerAboutToStartEvent event) { serverThread = (Thread) runServer.invoke(ssi); } catch (IOException | ClassNotFoundException | NoSuchMethodException | NoSuchFieldException | IllegalAccessException | InvocationTargetException | InstantiationException e) { // Filth!!, but meh + LOGGER.error("Failed to run ServerSync!"); e.printStackTrace(); } } @SubscribeEvent - public void onServerStopping(FMLServerStoppingEvent event) { + public void onServerStopping(ServerStoppingEvent event) { serverThread.interrupt(); } } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index ceea88a..7b0378b 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -15,7 +15,7 @@ license="MIT" # A list of mods - how many allowed here is determined by the individual mod loader [[mods]] #mandatory # The modid of the mod -modId="serversync-forge-loader" #mandatory +modId="serversync_forge_loader" #mandatory # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it version="${version}" #mandatory # A display name for the mod