更改ModID

同步Fabric Mod Template那边的Kotlin DSL官方配置
移除main入口类的`@Deprecated`标记
( 我当初为什么要弃用它?
补全ChangeLog.md
( 已经彻底忘记它的存在了
更新Github Action配置
更新Gradle版本

由于本次更改不存在对玩家具有实质影响的内容,故合并到下一个Mod版本内一并发布
This commit is contained in:
TheWhiteDog9487
2026-06-01 15:14:22 +08:00
parent 37722dcd8f
commit 5cb7a45ff4
21 changed files with 148 additions and 132 deletions

View File

@@ -8,30 +8,23 @@ on: [pull_request, push]
jobs:
build:
strategy:
matrix:
# Use these Java versions
java: [
25, # Current Java LTS
]
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v4
uses: gradle/actions/wrapper-validation@v6
- name: setup jdk
uses: actions/setup-java@v5
with:
java-version: ${{ matrix.java }}
java-version: '25'
distribution: 'microsoft'
- name: make gradle wrapper executable
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ matrix.java == '21' }} # Only upload artifacts built from latest java
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: Artifacts
path: build/libs/
path: build/libs/

View File

@@ -1,16 +1,17 @@
plugins {
id("net.fabricmc.fabric-loom") version "1.15-SNAPSHOT"
id("maven-publish")
id("net.fabricmc.fabric-loom")
`maven-publish`
}
version = project.extra["mod_version"] as String
group = project.extra["maven_group"] as String
base {
archivesName.set(project.extra["archives_base_name"] as String)
}
version = providers.gradleProperty("mod_version").get()
group = providers.gradleProperty("maven_group").get()
repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
maven {
name = "Xander Maven"
url = uri("https://maven.isxander.dev/releases") }
@@ -25,68 +26,77 @@ loom {
splitEnvironmentSourceSets()
mods {
create("twd-sasf") {
sourceSet(sourceSets["main"])
sourceSet(sourceSets["client"])
register("serveraddressspacefix") {
sourceSet(sourceSets.main.get())
sourceSet(sourceSets.getByName("client"))
}
}
accessWidenerPath = file("src/main/resources/twd-sasf.classtweaker")
accessWidenerPath = file("src/main/resources/serveraddressspacefix.classtweaker")
}
dependencies {
// To change the versions see the gradle.properties file
minecraft("com.mojang:minecraft:${project.extra["minecraft_version"]}")
implementation("net.fabricmc:fabric-loader:${project.extra["loader_version"]}")
minecraft("com.mojang:minecraft:${providers.gradleProperty("minecraft_version").get()}")
implementation("net.fabricmc:fabric-loader:${providers.gradleProperty("loader_version").get()}")
// Fabric API. This is technically optional, but you probably want it anyway.
implementation("net.fabricmc.fabric-api:fabric-api:${project.extra["fabric_api_version"]}")
implementation("net.fabricmc.fabric-api:fabric-api:${providers.gradleProperty("fabric_api_version").get()}")
// Uncomment the following line to enable the deprecated Fabric API modules.
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
// "modImplementation"("net.fabricmc.fabric-api:fabric-api-deprecated:${project.extra["fabric_version"]}")
implementation("com.terraformersmc:modmenu:${project.extra["modmenu_version"]}")
implementation("dev.isxander:yet-another-config-lib:${project.extra["yacl_version"]}")
implementation("com.terraformersmc:modmenu:${providers.gradleProperty("modmenu_version").get()}")
implementation("dev.isxander:yet-another-config-lib:${providers.gradleProperty("yacl_version").get()}")
}
tasks.processResources {
inputs.property("version", project.version)
val version = version
inputs.property("version", version)
filesMatching("fabric.mod.json") {
expand("version" to project.version)
expand("version" to version)
}
}
tasks.withType<JavaCompile> {
options.release.set(25)
tasks.withType<JavaCompile>().configureEach {
options.release = 25
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_25
}
tasks.jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}" } }
val projectName = project.name
inputs.property("projectName", projectName)
// https://docs.gradle.org/current/dsl/org.gradle.api.tasks.bundling.Jar.html#org.gradle.api.tasks.bundling.Jar:archiveFileName
archiveFileName = "${project.base.archivesName.get()}-${project.version} mc${project.extra["compatible_with"]}.jar"}
from("LICENSE") {
rename { "${it}_$projectName" }
}
archiveFileName = "ServerAddressSpaceFix-${project.version} mc${providers.gradleProperty("compatible_with").get()}.jar"
}
tasks.named<Jar>("sourcesJar") {
archiveFileName = "${project.base.archivesName.get()}-${project.version} mc${project.extra["compatible_with"]}-sources.jar"}
archiveFileName = "ServerAddressSpaceFix-${project.version} mc${providers.gradleProperty("compatible_with").get()}-sources.jar"}
// configure the maven publication
publishing {
publications {
create<MavenPublication>("mavenJava") {
register<MavenPublication>("mavenJava") {
from(components["java"])
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
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.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}

View File

@@ -6,6 +6,7 @@ org.gradle.parallel=true
# check these on https://fabricmc.net/develop
minecraft_version=26.1
loader_version=0.18.4
loom_version=1.16-SNAPSHOT
# Mod Properties
mod_version=0.2.2

Binary file not shown.

View File

@@ -1,7 +1,9 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

27
gradlew vendored
View File

@@ -1,7 +1,7 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
@@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -112,7 +114,6 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -145,7 +146,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -153,7 +154,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -170,7 +171,6 @@ fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
@@ -202,16 +202,15 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.

54
gradlew.bat vendored
View File

@@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@@ -21,8 +23,8 @@
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Set local scope for the variables, and ensure extensions are enabled
setlocal EnableExtensions
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@@ -43,13 +45,13 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
"%COMSPEC%" /c exit 1
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
@@ -57,36 +59,24 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
"%COMSPEC%" /c exit 1
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
@rem which allows us to clear the local environment before executing the java command
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
:exitWithErrorLevel
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
"%COMSPEC%" /c exit %ERRORLEVEL%

View File

@@ -4,6 +4,9 @@ pluginManagement {
name = "Fabric"
url = uri("https://maven.fabricmc.net/")}
mavenCentral()
gradlePluginPortal()
}
}
gradlePluginPortal() }
plugins {
id("net.fabricmc.fabric-loom") version providers.gradleProperty("loom_version") } }
// Should match your modid
rootProject.name = "serveraddressspacefix"

View File

@@ -13,13 +13,13 @@ public class ModMenu implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> YetAnotherConfigLib.createBuilder()
.title(Component.translatable("title.twd-sasf.config"))
.title(Component.translatable("title.serveraddressspacefix.config"))
.category(ConfigCategory.createBuilder()
.name(Component.translatable("config.twd-sasf.category.general"))
.name(Component.translatable("config.serveraddressspacefix.category.general"))
.option(Option.<Boolean>createBuilder()
.name(Component.translatable("option.twd-sasf.ModEnabled"))
.name(Component.translatable("option.serveraddressspacefix.ModEnabled"))
.binding(true, () -> Settings.ModEnabled, newVal -> Settings.ModEnabled = newVal)
.description(OptionDescription.of(Component.translatable("option.twd-sasf.ModEnabled.description")))
.description(OptionDescription.of(Component.translatable("option.serveraddressspacefix.ModEnabled.description")))
.controller(TickBoxControllerBuilder::create)
.build())
.build())

View File

@@ -4,8 +4,9 @@ import net.fabricmc.api.ClientModInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static xyz.thewhitedog9487.ServerAddressSpaceFix.ModID;
public class ServerAddressSpaceFixClient implements ClientModInitializer {
public static final String ModID = "twd-sasf";
public static final Logger LOGGER = LoggerFactory.getLogger(ModID);
@Override

View File

@@ -5,12 +5,12 @@ import net.fabricmc.api.ModInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated
public class ServerAddressSpaceFix implements ModInitializer {
// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final Logger LOGGER = LoggerFactory.getLogger("twd-sasf");
public static final String ModID = "serveraddressspacefix";
public static final Logger LOGGER = LoggerFactory.getLogger(ModID);
@Override
public void onInitialize() {

View File

Before

Width:  |  Height:  |  Size: 453 B

After

Width:  |  Height:  |  Size: 453 B

View File

@@ -0,0 +1,10 @@
{
"modmenu.nameTranslation.serveraddressspacefix": "ServerAddressSpaceFix",
"modmenu.descriptionTranslation.serveraddressspacefix": "Fixed the \"unknown host\" bug caused by the server address containing spaces at the beginning and end of the server address when adding a server or connecting directly\nTip: If you need to use the configuration menu, install the YetAnotherConfigLib mod",
"serveraddressspacefix.bilibili": "Bilibili",
"serveraddressspacefix.blog": "Blog",
"title.serveraddressspacefix.config": "ServerAddressSpaceFix",
"config.serveraddressspacefix.category.general": "General",
"option.serveraddressspacefix.ModEnabled": "Whether To Enable The Mod Feature",
"option.serveraddressspacefix.ModEnabled.description": "There is no need to restart the game, and the modification will take effect immediately after it is saved"
}

View File

@@ -0,0 +1,10 @@
{
"modmenu.nameTranslation.serveraddressspacefix": "服务器地址首尾空格修复",
"modmenu.descriptionTranslation.serveraddressspacefix": "修复添加服务器或直接连接时服务器地址首尾包含空格导致的“未知的主机”Bug\n提示如果需要使用配置菜单请安装YetAnotherConfigLib模组",
"serveraddressspacefix.bilibili": "哔哩哔哩主页",
"serveraddressspacefix.blog": "TheWhiteDog9487的博客",
"title.serveraddressspacefix.config": "服务器地址首尾空格修复",
"config.serveraddressspacefix.category.general": "通用",
"option.serveraddressspacefix.ModEnabled": "是否启用模组功能",
"option.serveraddressspacefix.ModEnabled.description": "无需重启游戏,修改并保存后立刻生效"
}

View File

@@ -1,10 +0,0 @@
{
"modmenu.nameTranslation.twd-sasf": "ServerAddressSpaceFix",
"modmenu.descriptionTranslation.twd-sasf": "Fixed the \"unknown host\" bug caused by the server address containing spaces at the beginning and end of the server address when adding a server or connecting directly\nTip: If you need to use the configuration menu, install the YetAnotherConfigLib mod",
"twd-sasf.bilibili": "Bilibili",
"twd-sasf.blog": "Blog",
"title.twd-sasf.config": "ServerAddressSpaceFix",
"config.twd-sasf.category.general": "General",
"option.twd-sasf.ModEnabled": "Whether To Enable The Mod Feature",
"option.twd-sasf.ModEnabled.description": "There is no need to restart the game, and the modification will take effect immediately after it is saved"
}

View File

@@ -1,10 +0,0 @@
{
"modmenu.nameTranslation.twd-sasf": "服务器地址首尾空格修复",
"modmenu.descriptionTranslation.twd-sasf": "修复添加服务器或直接连接时服务器地址首尾包含空格导致的“未知的主机”Bug\n提示如果需要使用配置菜单请安装YetAnotherConfigLib模组",
"twd-sasf.bilibili": "哔哩哔哩主页",
"twd-sasf.blog": "TheWhiteDog9487的博客",
"title.twd-sasf.config": "服务器地址首尾空格修复",
"config.twd-sasf.category.general": "通用",
"option.twd-sasf.ModEnabled": "是否启用模组功能",
"option.twd-sasf.ModEnabled.description": "无需重启游戏,修改并保存后立刻生效"
}

View File

@@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"id": "twd-sasf",
"id": "serveraddressspacefix",
"version": "${version}",
"name": "ServerAddressSpaceFix",
"description": "服务器地址首尾空格修复",
@@ -13,16 +13,16 @@
"issues": "https://github.com/TheWhiteDog9487/ServerAddressSpaceFix/issues"
},
"license": "WTFPL",
"icon": "assets/twd-sasf/icon.png",
"icon": "assets/serveraddressspacefix/icon.png",
"environment": "client",
"entrypoints": {
"client": [ "xyz.thewhitedog9487.ServerAddressSpaceFixClient" ],
"modmenu": [ "xyz.thewhitedog9487.ModMenu" ]
},
"mixins": [
"twd-sasf.mixins.json",
"serveraddressspacefix.mixins.json",
{
"config": "twd-sasf.client.mixins.json",
"config": "serveraddressspacefix.client.mixins.json",
"environment": "client"
}
],
@@ -38,11 +38,11 @@
"custom": {
"modmenu": {
"links": {
"twd-sasf.bilibili": "https://space.bilibili.com/401746666",
"twd-sasf.blog": "www.thewhitedog9487.xyz"},
"serveraddressspacefix.bilibili": "https://space.bilibili.com/401746666",
"serveraddressspacefix.blog": "www.thewhitedog9487.xyz"},
"update_checker": true}},
"contributors": [
"JustAlittleWolf"
],
"accessWidener": "twd-sasf.classtweaker"
"accessWidener": "serveraddressspacefix.classtweaker"
}

View File

@@ -1,3 +1,20 @@
# 0.2.2
时间2026 03 26
1. 新到Minecraft 26.1
2. 由于源码变更,更换了一个新的实现方案,稍微测试了一下没太大毛病,应该还行
# 0.2.1
时间2024 10 30
主要内容:
加大剂量,以前不会对服务器列表中已经保存的服务器地址进行处理,现在只要模组处于启用状态会直接对所有地址进行消除空格替换,确保不留死角。
说人话:未安装或未启用本模组时添加的服务器地址如果有空格,在启用本模组之后会在打开“多人游戏”窗口时被处理掉。
# 0.2.0
时间2024 06 14
主要内容:
1. 更新适配的游戏版本到1.21/1.21.x
2. 翻译键移除thewhitedog9487的命名空间
# 0.1.4
时间2024 01 15
主要内容: