diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9a53625..d40b116 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,6 @@ name: Build -on: [push, pull_request] +on: [ push, pull_request ] jobs: build: @@ -22,7 +22,7 @@ jobs: uses: gradle/actions/setup-gradle@v3 with: arguments: build - + - name: Upload build artifacts uses: actions/upload-artifact@v4 with: diff --git a/build.gradle b/build.gradle index 216d93c..c4ee37f 100644 --- a/build.gradle +++ b/build.gradle @@ -49,19 +49,15 @@ subprojects { minecraft "net.minecraft:minecraft:$rootProject.minecraft_version" mappings loom.officialMojangMappings() - shadowBundle(implementation ("io.prometheus:simpleclient:0.14.1")) - shadowBundle(implementation ("io.prometheus:simpleclient_httpserver:0.14.1")) - shadowBundle(implementation ("io.prometheus:simpleclient_common:0.14.1")) - shadowBundle(implementation ("io.prometheus:simpleclient_hotspot:0.14.1")) - shadowBundle(implementation ("com.electronwill.night-config:core:3.6.4")) - shadowBundle(implementation ("com.electronwill.night-config:toml:3.6.4")) - - - + shadowBundle(implementation("io.prometheus:simpleclient:0.14.1")) + shadowBundle(implementation("io.prometheus:simpleclient_httpserver:0.14.1")) + shadowBundle(implementation("io.prometheus:simpleclient_common:0.14.1")) + shadowBundle(implementation("io.prometheus:simpleclient_hotspot:0.14.1")) tasks.withType(ProcessResources).configureEach { var replaceProperties = [ minecraft_version : minecraft_version, + architectury_api_version: architectury_api_version, mod_id : mod_id, mod_name : mod_name, mod_license : mod_license, @@ -69,44 +65,23 @@ subprojects { mod_authors : mod_authors, mod_description : mod_description, maven_group : maven_group, - mod_contact : mod_contact, + mod_contact : mod_contact, mod_git : mod_git, - //Quilt - quilt_architectury : quilt_architectury, - quilt_minecraft : quilt_minecraft, - quilt_quiltloader : quilt_quiltloader, - quilt_quiltbase : quilt_quiltbase, - //Fabric - fabric_fabricloader : fabric_fabricloader, - fabric_minecraft : fabric_minecraft, - fabric_java : fabric_java, - fabric_architectury : fabric_architectury, - fabric_fabricapi : fabric_fabricapi, - - //ForgeLikes - forge_loaderversion : forge_loaderversion, - forge_loaderrange : forge_loaderrange, - forge_forgeside : forge_forgeside, - forge_minecraftrange : forge_minecraftrange, - forge_architecturyrange: forge_architecturyrange, - forge_architecturyside : forge_architecturyside, + fabric_java : fabric_java, + fabric_fabricapi : fabric_fabricapi, + fabric_api_version : fabric_api_version, + fabric_loader_version : fabric_loader_version, //NeoForge neoforge_loaderversion : neoforge_loaderversion, neoforge_loaderrange : neoforge_loaderrange, - neoforge_neoforgeside : neoforge_neoforgeside, - neoforge_minecraftrange: neoforge_minecraftrange, - neoforge_architecturyrange: neoforge_architecturyrange, - neoforge_architecturyside: neoforge_architecturyside - - - + neoforge_version : neoforge_version, ] inputs.properties replaceProperties - filesMatching(['META-INF/mods.toml', 'quilt.mod.json', 'fabric.mod.json'] ) { + filesMatching(['META-INF/neoforge.mods.toml', 'fabric.mod.json']) { expand replaceProperties } } @@ -116,16 +91,12 @@ subprojects { configurations = [project.configurations.shadowBundle] archiveClassifier = 'dev-shadow' - // relocate 'redis.clients', 'net.stonebound.shaded.redis.clients' relocate 'io.prometheus', 'net.stonebound.sbprometheus.shaded.io.prometheus' - relocate 'com.electronwill', 'net.stonebound.sbprometheus.shaded.com.electronwill' - dependencies { exclude(dependency("org.slf4j:.*:.*")) exclude(dependency("org.jetbrains:.*:.*")) - } } @@ -135,12 +106,12 @@ subprojects { // If you remove this line, sources will not be generated. withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } tasks.withType(JavaCompile).configureEach { - it.options.release = 17 + it.options.release = 21 } // Configure Maven publishing. diff --git a/common/build.gradle b/common/build.gradle index 816616f..c1fc3d3 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -10,4 +10,6 @@ dependencies { // Architectury API. This is optional, and you can comment it out if you don't need it. modImplementation "dev.architectury:architectury:$rootProject.architectury_api_version" + + api("com.electronwill.night-config:toml:$rootProject.nightconfig_version") } diff --git a/common/src/main/java/net/stonebound/sbprometheus/SbPrometheus.java b/common/src/main/java/net/stonebound/sbprometheus/SbPrometheus.java index 4ebfd49..9c9f3c7 100644 --- a/common/src/main/java/net/stonebound/sbprometheus/SbPrometheus.java +++ b/common/src/main/java/net/stonebound/sbprometheus/SbPrometheus.java @@ -13,7 +13,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; - public class SbPrometheus { private HTTPServer server; @@ -46,9 +45,10 @@ public SbPrometheus() { LifecycleEvent.SERVER_STOPPING.register(this::onServerStop); LifecycleEvent.SERVER_STOPPED.register(this::onServerStopped); TickEvent.SERVER_POST.register(this::onServerTick); + LifecycleEvent.SERVER_STARTING.register(Config::serverStarting); + LifecycleEvent.SERVER_STOPPING.register(Config::serverStopping); } - public void onServerStarted(MinecraftServer instance) { try { server = new HTTPServer(Config.jettysport, false); @@ -59,7 +59,6 @@ public void onServerStarted(MinecraftServer instance) { } } - public void onServerStop(MinecraftServer instance) { if (server != null) { try { @@ -83,7 +82,6 @@ public void onServerStopped(MinecraftServer instance) { private int serverTicks = 0; - public void onServerTick(MinecraftServer instance) { if (serverTicks % 600 == 0) { @@ -107,7 +105,7 @@ public void onServerTick(MinecraftServer instance) { } double meanTickTime = mean(instance.getTickTimesNanos()) * 1.0E-6D; - tps.labels("tps").set(Math.min(1000.0/meanTickTime, 20)); + tps.labels("tps").set(Math.min(1000.0 / meanTickTime, 20)); tps.labels("meanticktime").set(meanTickTime); memory.labels("max").set(Runtime.getRuntime().maxMemory()); memory.labels("free").set(Runtime.getRuntime().freeMemory()); @@ -116,12 +114,10 @@ public void onServerTick(MinecraftServer instance) { serverTicks++; } - private static long mean(long[] values) - { + private static long mean(long[] values) { long sum = 0l; - for (long v : values) - { - sum+=v; + for (long v : values) { + sum += v; } return sum / values.length; diff --git a/common/src/main/java/net/stonebound/sbprometheus/SbPrometheusCommon.java b/common/src/main/java/net/stonebound/sbprometheus/SbPrometheusCommon.java index 2ce8b29..20c0340 100644 --- a/common/src/main/java/net/stonebound/sbprometheus/SbPrometheusCommon.java +++ b/common/src/main/java/net/stonebound/sbprometheus/SbPrometheusCommon.java @@ -2,17 +2,11 @@ import dev.architectury.platform.Platform; import dev.architectury.utils.Env; -import net.stonebound.sbprometheus.config.Config; public final class SbPrometheusCommon { public static final String MOD_ID = "sbprometheus"; - public static SbPrometheus sbprometheus; public static void init() { - // Write common init code here. - if (Platform.getEnvironment() == Env.SERVER) { - Config.Start(); - sbprometheus = new SbPrometheus(); - } + new SbPrometheus(); } } diff --git a/common/src/main/java/net/stonebound/sbprometheus/config/CommentedConfigSpec.java b/common/src/main/java/net/stonebound/sbprometheus/config/CommentedConfigSpec.java index ef2088b..57ef148 100644 --- a/common/src/main/java/net/stonebound/sbprometheus/config/CommentedConfigSpec.java +++ b/common/src/main/java/net/stonebound/sbprometheus/config/CommentedConfigSpec.java @@ -14,34 +14,34 @@ //ripped from phit's cwl public class CommentedConfigSpec extends ConfigSpec { - private final Map, String> comments = new HashMap<>(); - - public void comment(List path, String comment) { - comments.put(path, comment); - } - - public void comment(String path, String comment) { - comment(split(path, '.'), comment); - } - - @Override - public int correct(Config config) { - return correct(config, (action, path, incorrectValue, correctedValue) -> { - }); - } - - @Override - public int correct(Config config, CorrectionListener listener) { - int corrections = super.correct(config, listener); - if (config instanceof CommentedConfig) { - insertComments((CommentedConfig) config); - } - return corrections; - } - - private void insertComments(CommentedConfig config) { - for (Map.Entry, String> entry : comments.entrySet()) { - config.setComment(entry.getKey(), entry.getValue()); - } - } + private final Map, String> comments = new HashMap<>(); + + public void comment(List path, String comment) { + comments.put(path, comment); + } + + public void comment(String path, String comment) { + comment(split(path, '.'), comment); + } + + @Override + public int correct(Config config) { + return correct(config, (action, path, incorrectValue, correctedValue) -> { + }); + } + + @Override + public int correct(Config config, CorrectionListener listener) { + int corrections = super.correct(config, listener); + if (config instanceof CommentedConfig) { + insertComments((CommentedConfig) config); + } + return corrections; + } + + private void insertComments(CommentedConfig config) { + for (Map.Entry, String> entry : comments.entrySet()) { + config.setComment(entry.getKey(), entry.getValue()); + } + } } \ No newline at end of file diff --git a/common/src/main/java/net/stonebound/sbprometheus/config/Config.java b/common/src/main/java/net/stonebound/sbprometheus/config/Config.java index 4f4810c..2b69ef9 100644 --- a/common/src/main/java/net/stonebound/sbprometheus/config/Config.java +++ b/common/src/main/java/net/stonebound/sbprometheus/config/Config.java @@ -15,85 +15,86 @@ //ripped from phit's cwl public final class Config { - public static int jettysport = 9200; - public static final CommentedConfigSpec commonSpec; - public static CommentedFileConfig commonConfig; - - private static final Path commonPath = Platform.getConfigFolder().resolve("sbprometheus-common.toml"); - - private Config() { - } - - static { - System.setProperty("nightconfig.preserveInsertionOrder", "true"); - - commonSpec = new CommentedConfigSpec(); - - commonSpec.comment("jettysport", - "jettysport"); - commonSpec.defineInRange("jettysport", jettysport, 1, 32000); - } - - private static final FileNotFoundAction MAKE_DIRECTORIES_AND_FILE = (file, configFormat) -> { - Files.createDirectories(file.getParent()); - Files.createFile(file); - configFormat.initEmptyFile(file); - return false; - }; - - private static CommentedFileConfig buildFileConfig(Path path) { - return CommentedFileConfig.builder(path) - .onFileNotFound(MAKE_DIRECTORIES_AND_FILE) - .preserveInsertionOrder() - .build(); - } - - private static void saveConfig(UnmodifiableConfig config, CommentedConfigSpec spec, Path path) { - try (CommentedFileConfig fileConfig = buildFileConfig(path)) { - fileConfig.putAll(config); - spec.correct(fileConfig); - fileConfig.save(); - } - } - - public static void save() { - if (commonConfig != null) { - saveConfig(commonConfig, commonSpec, commonPath); - } - } - - public static void Start() { - try (CommentedFileConfig config = buildFileConfig(commonPath)) { - config.load(); - commonSpec.correct(config, Config::correctionListener); - config.save(); - commonConfig = config; - sync(); - } - } - - public static void serverStopping(MinecraftServer server) { - commonConfig = null; - } - - private static void correctionListener(ConfigSpec.CorrectionAction action, List path, Object incorrectValue, - Object correctedValue) { - String key = String.join(".", path); - switch (action) { - case ADD: - SbPrometheus.LOGGER.warn("Config key {} missing -> added default value.", key); - break; - case REMOVE: - SbPrometheus.LOGGER.warn("Config key {} not defined -> removed from config.", key); - break; - case REPLACE: - SbPrometheus.LOGGER.warn("Config key {} not valid -> replaced with default value.", key); - } - } - - public static void sync() { - if (commonConfig != null) { - Config.jettysport = commonConfig.get("jettysport"); - } - } + public static int jettysport = 9200; + public static final CommentedConfigSpec commonSpec; + public static CommentedFileConfig commonConfig; + + private static final Path commonPath = Platform.getConfigFolder().resolve("sbprometheus-common.toml"); + + private Config() { + } + + static { + System.setProperty("nightconfig.preserveInsertionOrder", "true"); + + commonSpec = new CommentedConfigSpec(); + + commonSpec.comment("jettysport", + "jettysport"); + commonSpec.defineInRange("jettysport", jettysport, 1, 32000); + } + + private static final FileNotFoundAction MAKE_DIRECTORIES_AND_FILE = (file, configFormat) -> { + Files.createDirectories(file.getParent()); + Files.createFile(file); + configFormat.initEmptyFile(file); + return false; + }; + + private static CommentedFileConfig buildFileConfig(Path path) { + return CommentedFileConfig.builder(path) + .onFileNotFound(MAKE_DIRECTORIES_AND_FILE) + .preserveInsertionOrder() + .sync() + .build(); + } + + private static void saveConfig(UnmodifiableConfig config, CommentedConfigSpec spec, Path path) { + try (CommentedFileConfig fileConfig = buildFileConfig(path)) { + fileConfig.putAll(config); + spec.correct(fileConfig); + fileConfig.save(); + } + } + + public static void save() { + if (commonConfig != null) { + saveConfig(commonConfig, commonSpec, commonPath); + } + } + + public static void serverStarting(MinecraftServer server) { + try (CommentedFileConfig config = buildFileConfig(commonPath)) { + config.load(); + commonSpec.correct(config, Config::correctionListener); + config.save(); + commonConfig = config; + sync(); + } + } + + public static void serverStopping(MinecraftServer server) { + commonConfig = null; + } + + private static void correctionListener(ConfigSpec.CorrectionAction action, List path, Object incorrectValue, + Object correctedValue) { + String key = String.join(".", path); + switch (action) { + case ADD: + SbPrometheus.LOGGER.warn("Config key {} missing -> added default value.", key); + break; + case REMOVE: + SbPrometheus.LOGGER.warn("Config key {} not defined -> removed from config.", key); + break; + case REPLACE: + SbPrometheus.LOGGER.warn("Config key {} not valid -> replaced with default value.", key); + } + } + + public static void sync() { + if (commonConfig != null) { + Config.jettysport = commonConfig.get("jettysport"); + } + } } \ No newline at end of file diff --git a/common/src/main/resources/sbprometheus.mixins.json b/common/src/main/resources/sbprometheus.mixins.json deleted file mode 100644 index 1152c2e..0000000 --- a/common/src/main/resources/sbprometheus.mixins.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "required": true, - "package": "net.stonebound.sbprometheus.mixin", - "compatibilityLevel": "JAVA_17", - "minVersion": "0.8", - "client": [ - ], - "mixins": [ - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/fabric/build.gradle b/fabric/build.gradle index 515f503..7dcc102 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -35,6 +35,9 @@ dependencies { common(project(path: ':common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':common', configuration: 'transformProductionFabric') + + shadowBundle(implementation("com.electronwill.night-config:core:$rootProject.nightconfig_version")) + shadowBundle(implementation("com.electronwill.night-config:toml:$rootProject.nightconfig_version")) } processResources { @@ -48,6 +51,13 @@ processResources { shadowJar { configurations = [project.configurations.shadowBundle] archiveClassifier = 'dev-shadow' + + relocate 'com.electronwill', 'net.stonebound.SimpleIRCBridge.shaded.com.electronwill' + + dependencies { + exclude(dependency("org.slf4j:.*:.*")) + exclude(dependency("org.jetbrains:.*:.*")) + } } remapJar { diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index abaa86e..5f5697c 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -19,17 +19,11 @@ "net.stonebound.sbprometheus.fabric.SbPrometheusFabric" ] }, - "mixins": [ - "sbprometheus.mixins.json" - ], "depends": { - "fabricloader": "${fabric_fabricloader}", - "minecraft": "${fabric_minecraft}", + "fabricloader": ">=${fabric_loader_version}", + "minecraft": "~${minecraft_version}", "java": "${fabric_java}", - "architectury": "${fabric_architectury}", + "architectury": ">=${architectury_api_version}", "fabric-api": "${fabric_fabricapi}" - }, - "suggests": { - "another-mod": "*" } } diff --git a/forge/build.gradle b/forge/build.gradle deleted file mode 100644 index 30f8b16..0000000 --- a/forge/build.gradle +++ /dev/null @@ -1,58 +0,0 @@ -plugins { - id 'com.github.johnrengelman.shadow' -} - -loom { - forge { - mixinConfig "sbprometheus.mixins.json" - } -} - -architectury { - platformSetupLoomIde() - forge() -} - -configurations { - common { - canBeResolved = true - canBeConsumed = false - } - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentForge.extendsFrom common - - // Files in this configuration will be bundled into your mod using the Shadow plugin. - // Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files. - shadowBundle { - canBeResolved = true - canBeConsumed = false - } -} - -dependencies { - forge "net.minecraftforge:forge:$rootProject.forge_version" - - // Architectury API. This is optional, and you can comment it out if you don't need it. - modImplementation "dev.architectury:architectury-forge:$rootProject.architectury_api_version" - - common(project(path: ':common', configuration: 'namedElements')) { transitive false } - shadowBundle project(path: ':common', configuration: 'transformProductionForge') -} - -processResources { - inputs.property 'version', project.version - - filesMatching('META-INF/mods.toml') { - expand version: project.version - } -} - -shadowJar { - configurations = [project.configurations.shadowBundle] - archiveClassifier = 'dev-shadow' -} - -remapJar { - input.set shadowJar.archiveFile -} diff --git a/forge/gradle.properties b/forge/gradle.properties deleted file mode 100644 index a58ba14..0000000 --- a/forge/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -loom.platform = forge diff --git a/forge/src/main/java/net/stonebound/sbprometheus/forge/SbPrometheusForge.java b/forge/src/main/java/net/stonebound/sbprometheus/forge/SbPrometheusForge.java deleted file mode 100644 index 8271be1..0000000 --- a/forge/src/main/java/net/stonebound/sbprometheus/forge/SbPrometheusForge.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.stonebound.sbprometheus.forge; - -import dev.architectury.platform.forge.EventBuses; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; - -import net.stonebound.sbprometheus.SbPrometheusCommon; - -@Mod(SbPrometheusCommon.MOD_ID) -public final class SbPrometheusForge { - public SbPrometheusForge() { - // Submit our event bus to let Architectury API register our content on the right time. - EventBuses.registerModEventBus(SbPrometheusCommon.MOD_ID, FMLJavaModLoadingContext.get().getModEventBus()); - - // Run our common setup. - SbPrometheusCommon.init(); - } -} diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml deleted file mode 100644 index ff36d93..0000000 --- a/forge/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,33 +0,0 @@ -modLoader = "javafml" -loaderVersion = "${forge_loaderversion}" -issueTrackerURL = "${mod_git}" -license = "${mod_license}" - -[[mods]] -modId = "${mod_id}" -version = "${mod_version}" -displayName = "${mod_name}" -authors = "${mod_authors}" -description = "${mod_description}" -#logoFile = "" - -[[dependencies."${mod_id}"]] -modId = "forge" -mandatory = true -versionRange = "${forge_loaderrange}" -ordering = "NONE" -side = "${forge_forgeside}" - -[[dependencies."${mod_id}"]] -modId = "minecraft" -mandatory = true -versionRange = "${forge_minecraftrange}" -ordering = "NONE" -side = "BOTH" - -[[dependencies."${mod_id}"]] -modId = "architectury" -mandatory = true -versionRange = "${forge_architecturyrange}" -ordering = "AFTER" -side = "${forge_architecturyside}" diff --git a/forge/src/main/resources/pack.mcmeta b/forge/src/main/resources/pack.mcmeta deleted file mode 100644 index 5a8e45f..0000000 --- a/forge/src/main/resources/pack.mcmeta +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pack": { - "description": "Stonebound Prometheus", - "pack_format": 22 - } -} diff --git a/gradle.properties b/gradle.properties index 25faea2..6d1dcf9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,61 +1,29 @@ # Done to increase the memory available to Gradle. org.gradle.jvmargs=-Xmx2G org.gradle.parallel=true - # Generic properties -mod_version = 2.0.0 -maven_group = net.stonebound.sbprometheus -archives_name = sbprometheus -enabled_platforms = fabric,forge,neoforge,quilt -mod_description = stonebound prometheus -mod_id = sbprometheus +mod_version=2.1.0 +maven_group=net.stonebound.sbprometheus +archives_name=sbprometheus +enabled_platforms=fabric,neoforge +mod_description=stonebound prometheus +mod_id=sbprometheus mod_name=Stonebound Prometheus Exporter mod_license=All Rights Reserved mod_authors=phit mod_contact=https://stonebound.net mod_git=https://github.com/Stonebound/sbprometheusforge - - - -#Forge TOML Properties -forge_loaderversion = [49,) -forge_loaderrange = [49,) -forge_forgeside = BOTH -forge_minecraftrange = [1.20.4,) -forge_architecturyrange = [11.1.17,) -forge_architecturyside = BOTH - - -#Neoforge TOML Properties -neoforge_loaderversion = [2,) -neoforge_loaderrange = [20.4,) -neoforge_neoforgeside = BOTH -neoforge_minecraftrange = [1.20.4,) -neoforge_architecturyrange = [11.1.17,) -neoforge_architecturyside = BOTH - - - -#Quilt & Fabric JSON Properties -quilt_architectury= >=11.1.17 -quilt_minecraft= >=1.20.4 -quilt_quiltloader = * -quilt_quiltbase = * -#yes its cursed -fabric_fabricloader = >=0.15.11 -fabric_minecraft = ~1.20.4 -fabric_java = >=17 -fabric_architectury = >=11.1.17 -fabric_fabricapi = * - - - +# Neoforge TOML Properties +neoforge_loaderversion=[4,) +neoforge_loaderrange=[20.4,) +# Fabric JSON Properties +fabric_java=>=21 +fabric_fabricapi=* # Compile Dependencies -minecraft_version = 1.20.4 -architectury_api_version = 11.1.17 -fabric_loader_version = 0.15.11 -fabric_api_version = 0.97.1+1.20.4 -forge_version = 1.20.4-49.1.2 -neoforge_version = 20.4.237 -quilt_loader_version = 0.26.1-beta.1 -quilted_fabric_api_version = 9.0.0-alpha.8+0.97.0-1.20.4 +minecraft_version=1.21.1 +architectury_api_version=13.0.6 +fabric_loader_version=0.16.2 +fabric_api_version=0.102.1+1.21.1 +neoforge_version=21.1.23 +nightconfig_version=3.8.0 + diff --git a/neoforge/gradle.properties b/neoforge/gradle.properties index 2e6ed76..7da18ea 100644 --- a/neoforge/gradle.properties +++ b/neoforge/gradle.properties @@ -1 +1 @@ -loom.platform = neoforge +loom.platform=neoforge diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml similarity index 74% rename from neoforge/src/main/resources/META-INF/mods.toml rename to neoforge/src/main/resources/META-INF/neoforge.mods.toml index f5e669a..47930d6 100644 --- a/neoforge/src/main/resources/META-INF/mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -16,21 +16,18 @@ modId = "neoforge" type = "required" versionRange = "${neoforge_loaderrange}" ordering = "NONE" -side = "${neoforge_neoforgeside}" +side = "BOTH" [[dependencies."${mod_id}"]] modId = "minecraft" type = "required" -versionRange = "${neoforge_minecraftrange}" +versionRange = "[${minecraft_version},)" ordering = "NONE" side = "BOTH" [[dependencies."${mod_id}"]] modId = "architectury" type = "required" -versionRange = "${neoforge_architecturyrange}" +versionRange = "[${architectury_api_version},)" ordering = "AFTER" -side = "${neoforge_architecturyside}" - -[[mixins]] -config = "sbprometheus.mixins.json" +side = "BOTH" diff --git a/originals/build.gradle b/originals/build.gradle deleted file mode 100644 index 47eaa1f..0000000 --- a/originals/build.gradle +++ /dev/null @@ -1,190 +0,0 @@ -plugins { - id 'java-library' - id 'eclipse' - id 'idea' - id 'maven-publish' - id 'net.neoforged.gradle.userdev' version '7.0.97' - id 'com.github.johnrengelman.shadow' version '8.1.1' -} - -version = mod_version -group = mod_group_id - -repositories { - mavenLocal() -} - -base { - archivesName = mod_id -} - -// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. -java.toolchain.languageVersion = JavaLanguageVersion.of(17) - -//minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg') -//minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager - -configurations { - runtimeClasspath.extendsFrom localRuntime - libraries {} - shadow.extendsFrom libraries -} - -// Default run configurations. -// These can be tweaked, removed, or duplicated as needed. -runs { - // applies to all the run configs below - configureEach { - // Recommended logging data for a userdev environment - // The markers can be added/remove as needed separated by commas. - // "SCAN": For mods scan. - // "REGISTRIES": For firing of registry events. - // "REGISTRYDUMP": For getting the contents of all registries. - systemProperty 'forge.logging.markers', 'REGISTRIES' - - // Recommended logging level for the console - // You can set various levels here. - // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels - systemProperty 'forge.logging.console.level', 'debug' - - modSource project.sourceSets.main - - dependencies { - runtime project.configurations.libraries - } - } - - client { - // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. - systemProperty 'forge.enabledGameTestNamespaces', project.mod_id - } - - server { - systemProperty 'forge.enabledGameTestNamespaces', project.mod_id - programArgument '--nogui' - } - - // This run config launches GameTestServer and runs all registered gametests, then exits. - // By default, the server will crash when no gametests are provided. - // The gametest system is also enabled by default for other run configs under the /test command. - gameTestServer { - systemProperty 'forge.enabledGameTestNamespaces', project.mod_id - } - - data { - // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it - // workingDirectory project.file('run-data') - - // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. - programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() - } -} - -// Include resources generated by data generators. -sourceSets.main.resources { srcDir 'src/generated/resources' } - -dependencies { - // Specify the version of Minecraft to use. - // Depending on the plugin applied there are several options. We will assume you applied the userdev plugin as shown above. - // The group for userdev is net.neoforged, the module name is neoforge, and the version is the same as the neoforge version. - // You can however also use the vanilla plugin (net.neoforged.gradle.vanilla) to use a version of Minecraft without the neoforge loader. - // And its provides the option to then use net.minecraft as the group, and one of; client, server or joined as the module name, plus the game version as version. - // For all intends and purposes: You can treat this dependency as if it is a normal library you would use. - implementation "net.neoforged:neoforge:${neo_version}" - - // Example optional mod dependency with JEI - // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime - // compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}" - // compileOnly "mezz.jei:jei-${mc_version}-neoforge-api:${jei_version}" - // We add the full version to localRuntime, not runtimeOnly, so that we do not publish a dependency on it - // localRuntime "mezz.jei:jei-${mc_version}-neoforge:${jei_version}" - - // Example mod dependency using a mod jar from ./libs with a flat dir repository - // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar - // The group id is ignored when searching -- in this case, it is "blank" - // implementation "blank:coolmod-${mc_version}:${coolmod_version}" - - // Example mod dependency using a file as dependency - // implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar") - - // Example project dependency using a sister or child project: - // implementation project(":myproject") - - // For more info: - // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html - // http://www.gradle.org/docs/current/userguide/dependency_management.html - libraries group: 'io.prometheus', name: 'simpleclient', version: '0.14.1' - libraries group: 'io.prometheus', name: 'simpleclient_httpserver', version: '0.14.1' - libraries group: 'io.prometheus', name: 'simpleclient_hotspot', version: '0.14.1' -} - -jar.dependsOn(shadowJar) - -shadowJar { - configurations = [project.configurations.shadow] -} - -// This block of code expands all declared replace properties in the specified resource targets. -// A missing property will result in an error. Properties are expanded using ${} Groovy notation. -// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments. -// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html -tasks.withType(ProcessResources).configureEach { - var replaceProperties = [ - minecraft_version : minecraft_version, - minecraft_version_range: minecraft_version_range, - neo_version : neo_version, - neo_version_range : neo_version_range, - loader_version_range : loader_version_range, - mod_id : mod_id, - mod_name : mod_name, - mod_license : mod_license, - mod_version : mod_version, - mod_authors : mod_authors, - mod_description : mod_description - ] - inputs.properties replaceProperties - - filesMatching(['META-INF/mods.toml']) { - expand replaceProperties - } -} - -shadowJar { - configurations = [project.configurations.shadow] - relocate 'io.prometheus', 'net.stonebound.shaded.prometheus' - - dependencies { - include dependency("io.prometheus:simpleclient:0.14.1") - include dependency("io.prometheus:simpleclient_httpserver:0.14.1") - include dependency("io.prometheus:simpleclient_common:0.14.1") - include dependency("io.prometheus:simpleclient_hotspot:0.14.1") - } - archiveClassifier.set("full") -} - -// Example configuration to allow publishing using the maven-publish plugin -publishing { - publications { - register('mavenJava', MavenPublication) { - from components.java - } - } - repositories { - maven { - url "file://${project.projectDir}/repo" - } - } -} - -build.dependsOn(shadowJar) -tasks.withType(JavaCompile).configureEach { - options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation -} - -// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior. -idea { - module { - downloadSources = true - downloadJavadoc = true - } -} diff --git a/quilt/build.gradle b/quilt/build.gradle deleted file mode 100644 index 06ee562..0000000 --- a/quilt/build.gradle +++ /dev/null @@ -1,64 +0,0 @@ -plugins { - id 'com.github.johnrengelman.shadow' -} - -repositories { - maven { url 'https://maven.quiltmc.org/repository/release/' } -} - -architectury { - platformSetupLoomIde() - loader('quilt') -} - -configurations { - common { - canBeResolved = true - canBeConsumed = false - } - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentQuilt.extendsFrom common - - // Files in this configuration will be bundled into your mod using the Shadow plugin. - // Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files. - shadowBundle { - canBeResolved = true - canBeConsumed = false - } -} - -dependencies { - modImplementation "org.quiltmc:quilt-loader:$rootProject.quilt_loader_version" - - // Quilt Standard Libraries and QSL. - modImplementation "org.quiltmc.quilted-fabric-api:quilted-fabric-api:$rootProject.quilted_fabric_api_version" - - // Architectury API. This is optional, and you can comment it out if you don't need it. - modImplementation("dev.architectury:architectury-fabric:$rootProject.architectury_api_version") { - // We must not pull Fabric Loader and Fabric API from Architectury Fabric. - exclude group: 'net.fabricmc' - exclude group: 'net.fabricmc.fabric-api' - } - - common(project(path: ':common', configuration: 'namedElements')) { transitive false } - shadowBundle project(path: ':common', configuration: 'transformProductionQuilt') -} - -processResources { - inputs.property 'group', project.group - inputs.property 'version', project.version - - filesMatching('quilt.mod.json') { - expand group: project.group, version: project.version - } -} - -shadowJar { - configurations = [project.configurations.shadowBundle] - archiveClassifier = 'dev-shadow' -} - -remapJar { - input.set shadowJar.archiveFile -} diff --git a/quilt/gradle.properties b/quilt/gradle.properties deleted file mode 100644 index 56fe802..0000000 --- a/quilt/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -loom.platform = quilt diff --git a/quilt/src/main/java/net/stonebound/sbprometheus/quilt/SbPrometheusQuilt.java b/quilt/src/main/java/net/stonebound/sbprometheus/quilt/SbPrometheusQuilt.java deleted file mode 100644 index 331edb5..0000000 --- a/quilt/src/main/java/net/stonebound/sbprometheus/quilt/SbPrometheusQuilt.java +++ /dev/null @@ -1,14 +0,0 @@ -package net.stonebound.sbprometheus.quilt; - -import org.quiltmc.loader.api.ModContainer; -import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; - -import net.stonebound.sbprometheus.SbPrometheusCommon; - -public final class SbPrometheusQuilt implements ModInitializer { - @Override - public void onInitialize(ModContainer mod) { - // Run our common setup. - SbPrometheusCommon.init(); - } -} diff --git a/quilt/src/main/resources/quilt.mod.json b/quilt/src/main/resources/quilt.mod.json deleted file mode 100644 index 74bcecd..0000000 --- a/quilt/src/main/resources/quilt.mod.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "schema_version": 1, - "quilt_loader": { - "group": "${maven_group}", - "id": "${mod_id}", - "version": "${mod_version}", - "metadata": { - "name": "${mod_name}", - "description": "${mod_description}", - "contributors": { - "Me!": "${mod_authors}" - }, - "icon": "assets/sbprometheus/icon.png" - }, - "intermediate_mappings": "net.fabricmc:intermediary", - "entrypoints": { - "init": [ - "net.stonebound.sbprometheus.quilt.SbPrometheusQuilt" - ] - }, - "depends": [ - { - "id": "quilt_loader", - "version": "${quilt_quiltloader}" - }, - { - "id": "quilt_base", - "version": "${quilt_quiltbase}" - }, - { - "id": "minecraft", - "version": "${quilt_minecraft}" - }, - { - "id": "architectury", - "version": "${quilt_architectury}" - } - ] - }, - "mixin": [ - "sbprometheus.mixins.json" - ] -} diff --git a/settings.gradle b/settings.gradle index 66eb0b5..c40deee 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,6 +11,4 @@ rootProject.name = 'sbprometheus' include 'common' include 'fabric' -include 'forge' include 'neoforge' -include 'quilt' diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml deleted file mode 100644 index 360e758..0000000 --- a/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,100 +0,0 @@ -# This is an example mods.toml file. It contains the data relating to the loading mods. -# There are several mandatory fields (#mandatory), and many more that are optional (#optional). -# The overall format is standard TOML format, v0.5.0. -# Note that there are a couple of TOML lists in this file. -# Find more information on toml format here: https://github.com/toml-lang/toml -# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml -modLoader="javafml" #mandatory - -# A version range to match for said mod loader - for regular FML @Mod it will be the the FML version. This is currently 47. -loaderVersion="${loader_version_range}" #mandatory - -# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. -# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. -license="${mod_license}" - -# A URL to refer people to when problems occur with this mod -#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional - -# A list of mods - how many allowed here is determined by the individual mod loader -[[mods]] #mandatory - -# The modid of the mod -modId="${mod_id}" #mandatory - -# The version number of the mod -version="${mod_version}" #mandatory - -# A display name for the mod -displayName="${mod_name}" #mandatory - -# A URL to query for updates for this mod. See the JSON update specification https://docs.neoforged.net/docs/misc/updatechecker/ -#updateJSONURL="https://change.me.example.invalid/updates.json" #optional - -# A URL for the "homepage" for this mod, displayed in the mod UI -displayURL="https://www.stonebound.net/" #optional - -# A file name (in the root of the mod JAR) containing a logo for display -#logoFile="examplemod.png" #optional - -# A text field displayed in the mod UI -#credits="" #optional - -# A text field displayed in the mod UI -authors="${mod_authors}" #optional - -# Display Test controls the display for your mod in the server connection screen -# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod. -# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod. -# IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component. -# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value. -# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself. -#displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional) - -# The description text for the mod (multi line!) (#mandatory) -description='''${mod_description}''' - -# The [[mixins]] block allows you to declare your mixin config to FML so that it gets loaded. -#[[mixins]] -#config="${mod_id}.mixins.json" - -# The [[accessTransformers]] block allows you to declare where your AT file is. -# If this block is omitted, a fallback attempt will be made to load an AT from META-INF/accesstransformer.cfg -#[[accessTransformers]] -#file="META-INF/accesstransformer.cfg" - -# The coremods config file path is not configurable and is always loaded from META-INF/coremods.json - -# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. -[[dependencies.${mod_id}]] #optional - # the modid of the dependency - modId="neoforge" #mandatory - # The type of the dependency. Can be one of "required", "optional", "incompatible" or "discouraged" (case insensitive). - # 'required' requires the mod to exist, 'optional' does not - # 'incompatible' will prevent the game from loading when the mod exists, and 'discouraged' will show a warning - type="required" #mandatory - # Optional field describing why the dependency is required or why it is incompatible - # reason="..." - # The version range of the dependency - versionRange="${neo_version_range}" #mandatory - # An ordering relationship for the dependency. - # BEFORE - This mod is loaded BEFORE the dependency - # AFTER - This mod is loaded AFTER the dependency - ordering="NONE" - # Side this dependency is applied on - BOTH, CLIENT, or SERVER - side="BOTH" - -# Here's another dependency -[[dependencies.${mod_id}]] - modId="minecraft" - type="required" - # This version range declares a minimum of the current minecraft version up to but not including the next major version - versionRange="${minecraft_version_range}" - ordering="NONE" - side="BOTH" - -# Features are specific properties of the game environment, that you may want to declare you require. This example declares -# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't -# stop your mod loading on the server for example. -#[features.${mod_id}] -#openGLVersion="[3.2,)"