diff --git a/core/music/play/PlayRuntime.java b/core/music/play/PlayRuntime.java index 879c1063..66360772 100644 --- a/core/music/play/PlayRuntime.java +++ b/core/music/play/PlayRuntime.java @@ -216,12 +216,10 @@ public class PlayRuntime { if (PlayMusic.getListSize() == 0) { if (PlayMusic.error >= 10) { Thread.sleep(1000); - } else if (PlayMusic.getIdleListSize() > 0) { - if (AllMusic.side.needPlay(true)) { - String id = PlayMusic.getIdleMusic(); - if (id != null) { - PlayMusic.addMusic(null, id, AllMusic.getMessage().custom.idle, true); - } + } else if (AllMusic.side.needPlay(true) && PlayMusic.getIdleListSize() > 0) { + String id = PlayMusic.getIdleMusic(); + if (id != null) { + PlayMusic.addMusic(null, id, AllMusic.getMessage().custom.idle, true); } } Thread.sleep(1000); diff --git a/core/sql/DataSql.java b/core/sql/DataSql.java index d6c5f8a6..9b036843 100644 --- a/core/sql/DataSql.java +++ b/core/sql/DataSql.java @@ -356,7 +356,6 @@ public class DataSql { */ public static int getListSize() { try { - AllMusic.log.info("正在读取空闲歌单"); if (connection.isReadOnly() || connection.isClosed()) { init(); } diff --git a/neoforge_1_21/build.gradle b/neoforge_1_21/build.gradle index 71568d02..218612b4 100644 --- a/neoforge_1_21/build.gradle +++ b/neoforge_1_21/build.gradle @@ -1,9 +1,16 @@ plugins { id 'java-library' - id 'eclipse' - id 'idea' id 'maven-publish' - id 'net.neoforged.gradle.userdev' version '7.0.142' + id 'net.neoforged.gradle.userdev' version '7.0.184' +} + +tasks.named('wrapper', Wrapper).configure { + // Define wrapper values here so as to not have to always do so when updating gradlew.properties. + // Switching this to Wrapper.DistributionType.ALL will download the full gradle sources that comes with + // documentation attached on cursor hover of gradle classes and methods. However, this comes with increased + // file size for Gradle. If you do switch this to ALL, run the Gradle wrapper task twice afterwards. + // (Verify by checking gradle/wrapper/gradle-wrapper.properties to see if distributionUrl now points to `-all`) + distributionType = Wrapper.DistributionType.BIN } def getVersionFromFile() { diff --git a/neoforge_1_21/gradle.properties b/neoforge_1_21/gradle.properties index 5d8d76b4..59dc9aae 100644 --- a/neoforge_1_21/gradle.properties +++ b/neoforge_1_21/gradle.properties @@ -5,8 +5,8 @@ org.gradle.debug=false #read more on this at https://github.com/neoforged/NeoGradle/blob/NG_7.0/README.md#apply-parchment-mappings # you can also find the latest versions at: https://parchmentmc.org/docs/getting-started -neogradle.subsystems.parchment.minecraftVersion=1.20.6 -neogradle.subsystems.parchment.mappingsVersion=2024.05.01 +neogradle.subsystems.parchment.minecraftVersion=1.21 +neogradle.subsystems.parchment.mappingsVersion=2024.11.10 # Environment Properties # You can find the latest versions here: https://projects.neoforged.net/neoforged/neoforge # The Minecraft version must agree with the Neo version to get a valid artifact @@ -16,11 +16,11 @@ minecraft_version=1.21 # as they do not follow standard versioning conventions. minecraft_version_range=[1.21,1.21.1) # The Neo version must agree with the Minecraft version to get a valid artifact -neo_version=21.0.0-beta +neo_version=21.0.167 # The Neo version range can use any version of Neo as bounds -neo_version_range=[21.0.0-beta,) +neo_version_range=[21.0.167,) # The loader version range can only use the major version of FML as bounds -loader_version_range=[4,) +loader_version_range=[1,) ## Mod Properties diff --git a/neoforge_1_21/gradle/wrapper/gradle-wrapper.properties b/neoforge_1_21/gradle/wrapper/gradle-wrapper.properties index 81c736bb..adda1f21 100644 --- a/neoforge_1_21/gradle/wrapper/gradle-wrapper.properties +++ b/neoforge_1_21/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/neoforge_1_21/src/main/java/com/coloryr/allmusic/server/AllMusicForge.java b/neoforge_1_21/src/main/java/com/coloryr/allmusic/server/AllMusicForge.java index 43acb26c..91aadac8 100644 --- a/neoforge_1_21/src/main/java/com/coloryr/allmusic/server/AllMusicForge.java +++ b/neoforge_1_21/src/main/java/com/coloryr/allmusic/server/AllMusicForge.java @@ -6,7 +6,6 @@ import com.coloryr.allmusic.server.side.forge.LogForge; import com.coloryr.allmusic.server.side.forge.PackData; import com.coloryr.allmusic.server.side.forge.SideForge; import com.mojang.brigadier.CommandDispatcher; -import net.minecraft.client.Minecraft; import net.minecraft.commands.CommandSourceStack; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; @@ -59,14 +58,15 @@ public class AllMusicForge { new AllMusic().init(new File(path)); } - @SubscribeEvent public void register(final RegisterPayloadHandlersEvent event) { + LOGGER.info("注册插件信道"); final PayloadRegistrar registrar = event.registrar("1.0"); registrar.optional().playToClient(PackData.TYPE, PackData.CODEC, new HandelPack()); } @SubscribeEvent public void onRegisterCommands(RegisterCommandsEvent event) { + LOGGER.info("注册指令"); CommandDispatcher dispatcher = event.getDispatcher(); CommandForge.instance.register(dispatcher); } diff --git a/neoforge_1_21_4/build.gradle b/neoforge_1_21_4/build.gradle index 40fbf5c8..3ed4a138 100644 --- a/neoforge_1_21_4/build.gradle +++ b/neoforge_1_21_4/build.gradle @@ -1,8 +1,16 @@ plugins { id 'java-library' id 'maven-publish' - id 'net.neoforged.moddev' version '2.0.77' - id 'idea' + id 'net.neoforged.gradle.userdev' version '7.0.184' +} + +tasks.named('wrapper', Wrapper).configure { + // Define wrapper values here so as to not have to always do so when updating gradlew.properties. + // Switching this to Wrapper.DistributionType.ALL will download the full gradle sources that comes with + // documentation attached on cursor hover of gradle classes and methods. However, this comes with increased + // file size for Gradle. If you do switch this to ALL, run the Gradle wrapper task twice afterwards. + // (Verify by checking gradle/wrapper/gradle-wrapper.properties to see if distributionUrl now points to `-all`) + distributionType = Wrapper.DistributionType.BIN } def getVersionFromFile() { @@ -20,6 +28,12 @@ group = mod_group_id repositories { mavenLocal() + + maven { + name = 'Kotlin for Forge' + url = 'https://thedarkcolour.github.io/KotlinForForge/' + content { includeGroup "thedarkcolour" } + } } base { @@ -30,77 +44,52 @@ base { java.toolchain.languageVersion = JavaLanguageVersion.of(21) // Enable the Jar-in-Jar system for your mod -//jarJar.enable() +jarJar.enable() -neoForge { - // Specify the version of NeoForge to use. - version = project.neo_version - parchment { - mappingsVersion = project.parchment_mappings_version - minecraftVersion = project.parchment_minecraft_version +// 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 } - // This line is optional. Access Transformers are automatically detected - // accessTransformers = project.files('src/main/resources/META-INF/accesstransformer.cfg') - - // Default run configurations. - // These can be tweaked, removed, or duplicated as needed. - runs { - client { - client() - - // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. - systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id - } - - server { - server() - programArgument '--nogui' - systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id - } - - // 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 { - type = "gameTestServer" - systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id - } - - data { - clientData() - - // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it - // gameDirectory = 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() - } - - // applies to all the run configs above - 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 - logLevel = org.slf4j.event.Level.DEBUG - } + client { + // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id } - mods { - // define mod <-> source bindings - // these are used to tell the game which sources are for which mod - // multi mod projects should define one per mod - "${mod_id}" { - sourceSet(sourceSets.main) - } + server { + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id + argument '--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 'neoforge.enabledGameTestNamespaces', project.mod_id + } + + clientData { + // 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. + arguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() } } @@ -115,12 +104,6 @@ configurations { runtimeClasspath.extendsFrom localRuntime } -// Configure the 'jarJar' task -// 'all' is the default classifier -tasks.named('jarJar') { - // ... -} - 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. @@ -139,12 +122,12 @@ dependencies { implementation 'com.squareup.okhttp3:okhttp:4.12.0' implementation 'org.xerial:sqlite-jdbc:3.48.0.0' -// implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.+" + implementation "thedarkcolour:kotlinforforge:$kff_version" - jarJar (group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk8', version: '[2.0, 2.1)') - jarJar (group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk7', version: '[2.0, 2.1)') - jarJar (group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: '[2.0, 2.1)') - jarJar (group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-common', version: '[2.0, 2.1)') +// jarJar (group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk8', version: '[2.0, 2.1)') +// jarJar (group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk7', version: '[2.0, 2.1)') +// jarJar (group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: '[2.0, 2.1)') +// jarJar (group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-common', version: '[2.0, 2.1)') jarJar (group: 'com.squareup.okhttp3', name: 'okhttp', version: '[4.12, 5.0)') jarJar (group: 'com.squareup.okio', name: 'okio-jvm', version: '[3.9, 4.0)') jarJar (group: 'org.xerial', name: 'sqlite-jdbc', version: '[3.46, 4.0)') @@ -167,7 +150,9 @@ dependencies { // 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. -var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) { +// 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, @@ -182,15 +167,11 @@ var generateModMetadata = tasks.register("generateModMetadata", ProcessResources mod_description : mod_description ] inputs.properties replaceProperties - expand replaceProperties - from "src/main/templates" - into "build/generated/sources/modMetadata" + + filesMatching(['META-INF/neoforge.mods.toml']) { + expand replaceProperties + } } -// Include the output of "generateModMetadata" as an input directory for the build -// this works with both building through Gradle and the IDE. -sourceSets.main.resources.srcDir generateModMetadata -// To avoid having to run "generateModMetadata" manually, make it run on every project reload -neoForge.ideSyncTask generateModMetadata // Example configuration to allow publishing using the maven-publish plugin publishing { diff --git a/neoforge_1_21_4/gradle.properties b/neoforge_1_21_4/gradle.properties index 65f7a7bd..fef14817 100644 --- a/neoforge_1_21_4/gradle.properties +++ b/neoforge_1_21_4/gradle.properties @@ -24,6 +24,8 @@ neo_version_range=[21.4.79-beta,) # The loader version range can only use the major version of FML as bounds loader_version_range=[1,) +kff_version=5.7.0 + ## Mod Properties file_name = [neoforge-1.21.4]AllMusic_Server diff --git a/neoforge_1_21_4/src/main/java/com/coloryr/allmusic/server/AllMusicForge.java b/neoforge_1_21_4/src/main/java/com/coloryr/allmusic/server/AllMusicForge.java index 43acb26c..91aadac8 100644 --- a/neoforge_1_21_4/src/main/java/com/coloryr/allmusic/server/AllMusicForge.java +++ b/neoforge_1_21_4/src/main/java/com/coloryr/allmusic/server/AllMusicForge.java @@ -6,7 +6,6 @@ import com.coloryr.allmusic.server.side.forge.LogForge; import com.coloryr.allmusic.server.side.forge.PackData; import com.coloryr.allmusic.server.side.forge.SideForge; import com.mojang.brigadier.CommandDispatcher; -import net.minecraft.client.Minecraft; import net.minecraft.commands.CommandSourceStack; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; @@ -59,14 +58,15 @@ public class AllMusicForge { new AllMusic().init(new File(path)); } - @SubscribeEvent public void register(final RegisterPayloadHandlersEvent event) { + LOGGER.info("注册插件信道"); final PayloadRegistrar registrar = event.registrar("1.0"); registrar.optional().playToClient(PackData.TYPE, PackData.CODEC, new HandelPack()); } @SubscribeEvent public void onRegisterCommands(RegisterCommandsEvent event) { + LOGGER.info("注册指令"); CommandDispatcher dispatcher = event.getDispatcher(); CommandForge.instance.register(dispatcher); }