mirror of
https://github.com/CPTProgrammer/ChatPlus.git
synced 2026-09-22 00:23:36 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ffbc28baf6 | ||
|
|
70e249ca21 | ||
|
|
d9df910db4 | ||
|
|
e1ef1dd38f | ||
|
|
7b166bd3ba | ||
|
|
186fe5a58f | ||
|
|
b6f91ae87f | ||
|
|
1ae838b4e9 | ||
|
|
43e582fbe6 | ||
|
|
edaf3115bb | ||
|
|
11e09bf0fb | ||
|
|
aaf4b64e6e | ||
|
|
1494ae1e2e | ||
|
|
74b909fe84 | ||
|
|
36a7c48531 | ||
|
|
a9e4fb14b8 | ||
|
|
3b9e607f24 | ||
|
|
09dcc04430 | ||
|
|
888b801ac7 |
@@ -11,13 +11,13 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
- name: validate gradle wrapper
|
||||
uses: gradle/actions/wrapper-validation@v4
|
||||
uses: gradle/actions/wrapper-validation@v6
|
||||
- name: setup jdk
|
||||
uses: actions/setup-java@v4
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: '21'
|
||||
java-version: '25'
|
||||
distribution: 'microsoft'
|
||||
- name: make gradle wrapper executable
|
||||
run: chmod +x ./gradlew
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Chat Plus
|
||||
|
||||

|
||||

|
||||
<a href="https://modrinth.com/mod/chatplus">
|
||||
<img src="https://img.shields.io/badge/Modrinth-Chat_Plus-%234e910e?style=flat" />
|
||||
</a>
|
||||
@@ -42,7 +42,8 @@ _* Other mods may work without explicit support. Report compatibility requests v
|
||||
| 1.19.3 | 1.19.3 - 1.19.4 |
|
||||
| 1.20 | 1.20 - 1.20.2 |
|
||||
| 1.20.3 | 1.20.3 - 1.20.6 |
|
||||
| 1.21 | 1.21 - 1.21.6 |
|
||||
| 1.21 | 1.21 - 1.21.11 |
|
||||
| 26.1 | 26.1 - 26.2 |
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +51,7 @@ _* Other mods may work without explicit support. Report compatibility requests v
|
||||
|
||||
#### Environment
|
||||
|
||||
- Java 21 or higher
|
||||
- Java 25 or higher
|
||||
- (Optional) Java IDE with Manifold support (e.g., IntelliJ IDEA)<br>
|
||||
_* If using IntelliJ IDEA, the Manifold plugin should be installed_
|
||||
|
||||
@@ -111,4 +112,3 @@ To build JARs for all Minecraft versions defined in `./properties`:
|
||||
|
||||
- [@SAGUMEDREAM](https://github.com/SAGUMEDREAM) for advice on mixin development.
|
||||
- [Distant-Horizons-Team/Distant Horizons](https://gitlab.com/distant-horizons-team/distant-horizons/) for inspiring the build configuration design.
|
||||
|
||||
|
||||
+39
-12
@@ -2,7 +2,8 @@ import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
|
||||
import java.nio.file.Paths
|
||||
|
||||
plugins {
|
||||
id "fabric-loom" version "1.10-SNAPSHOT"
|
||||
id "net.fabricmc.fabric-loom-remap" version "1.17-SNAPSHOT" apply false
|
||||
id "net.fabricmc.fabric-loom" version "1.17-SNAPSHOT" apply false
|
||||
id "maven-publish"
|
||||
|
||||
// Manifold preprocessor
|
||||
@@ -12,6 +13,15 @@ plugins {
|
||||
// Transfer gradle extra properties to root project extra properties
|
||||
gradle.ext.properties.each { prop -> project.ext.set(prop.key, prop.value) }
|
||||
|
||||
def loomRemapStr = project.findProperty("fabric_loom_remap")?.toString()
|
||||
assert loomRemapStr in ["true", "false"] :
|
||||
"${loomRemapStr == null ? "Missing" : "Invalid"} property in ${Paths.get(version_properties_path, "${project.targetVersion}.properties")} : " +
|
||||
"fabric_loom_remap${loomRemapStr == null ? "" : "=$loomRemapStr"}"
|
||||
def loomRemap = loomRemapStr.toBoolean()
|
||||
apply plugin: loomRemap ? "net.fabricmc.fabric-loom-remap" : "net.fabricmc.fabric-loom"
|
||||
|
||||
boolean hasNewVersionScheme = project.targetVersion.tokenize(".")*.toInteger()[0] >= 26
|
||||
|
||||
generateBuildProperties(project.minecraftVersions, project.targetVersion)
|
||||
|
||||
version = "${project.mod_version}-mc${project.targetVersion}"
|
||||
@@ -64,24 +74,41 @@ loom {
|
||||
// }
|
||||
}
|
||||
|
||||
configurations {
|
||||
remappableImplementation
|
||||
remappableCompileOnly
|
||||
remappableLocalRuntime
|
||||
}
|
||||
|
||||
if (loomRemap) {
|
||||
configurations.modImplementation.extendsFrom(configurations.remappableImplementation)
|
||||
configurations.modCompileOnly.extendsFrom(configurations.remappableCompileOnly)
|
||||
configurations.modLocalRuntime.extendsFrom(configurations.remappableLocalRuntime)
|
||||
} else {
|
||||
configurations.implementation.extendsFrom(configurations.remappableImplementation)
|
||||
configurations.compileOnly.extendsFrom(configurations.remappableCompileOnly)
|
||||
configurations.localRuntime.extendsFrom(configurations.remappableLocalRuntime)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// To change the versions see the gradle.properties file or the ./properties/${minecraftVersion}.properties file
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}"
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}+${project.targetVersion}"
|
||||
if (loomRemap) mappings loom.officialMojangMappings()
|
||||
remappableImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}"
|
||||
|
||||
def resolvedFabricApiVersion = "${project.fabric_api_version}+${project.targetVersion}"
|
||||
// Override Fabric API version for local testing (runClient/runServer)
|
||||
if (project.hasProperty("test_fabric_api_version"))
|
||||
modLocalRuntime "net.fabricmc.fabric-api:fabric-api:${project.test_fabric_api_version}"
|
||||
resolvedFabricApiVersion = "${project.test_fabric_api_version}"
|
||||
remappableImplementation "net.fabricmc.fabric-api:fabric-api:${resolvedFabricApiVersion}"
|
||||
|
||||
// Mod Compatibility
|
||||
if (project.hasProperty("mod_dynmap_version"))
|
||||
modCompileOnly "maven.modrinth:dynmap:${project.mod_dynmap_version}"
|
||||
if (project.hasProperty("mod_styled_chat_version"))
|
||||
modCompileOnly "maven.modrinth:styled-chat:${project.mod_styled_chat_version}"
|
||||
if (project.hasProperty("mod_styled_chat_placeholder_api_version"))
|
||||
modCompileOnly "eu.pb4:placeholder-api:${project.mod_styled_chat_placeholder_api_version}"
|
||||
if (project.hasProperty("mod_dynmap_version") && !project.mod_dynmap_version.allWhitespace)
|
||||
remappableCompileOnly "maven.modrinth:dynmap:${project.mod_dynmap_version}"
|
||||
if (project.hasProperty("mod_styled_chat_version") && !project.mod_styled_chat_version.allWhitespace)
|
||||
remappableCompileOnly "maven.modrinth:styled-chat:${project.mod_styled_chat_version}"
|
||||
if (project.hasProperty("mod_styled_chat_placeholder_api_version") && !project.mod_styled_chat_placeholder_api_version.allWhitespace)
|
||||
remappableCompileOnly "eu.pb4:placeholder-api:${project.mod_styled_chat_placeholder_api_version}"
|
||||
|
||||
// Manifold
|
||||
annotationProcessor "systems.manifold:manifold-preprocessor:${project.manifold_version}"
|
||||
@@ -94,7 +121,7 @@ processResources {
|
||||
def expandProperties = [
|
||||
"version": mod_version,
|
||||
"group": maven_group,
|
||||
"minecraft_version": minecraft_version,
|
||||
"minecraft_version_range": "${hasNewVersionScheme ? "^" : "~"}${targetVersion}",
|
||||
"java_version": java_version,
|
||||
"fabric_loader_version": fabric_loader_version,
|
||||
"fabric_loader_version_range": hasProperty("min_fabric_loader_version") && !min_fabric_loader_version.allWhitespace ? ">=${min_fabric_loader_version}" : "*",
|
||||
|
||||
+2
-2
@@ -6,12 +6,12 @@ org.gradle.parallel=true
|
||||
version_properties_path=./properties
|
||||
|
||||
# Mod Properties
|
||||
mod_version=1.0.1
|
||||
mod_version=1.1.1
|
||||
maven_group=cn.revaria.chatplus
|
||||
archives_base_name=chat-plus
|
||||
|
||||
# Minecraft
|
||||
minecraft_version=1.21
|
||||
minecraft_version=26.1
|
||||
|
||||
# Override Fabric API version for local testing (runClient/runServer)
|
||||
#test_fabric_api_version=
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+3
-1
@@ -1,7 +1,9 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
|
||||
networkTimeout=10000
|
||||
retries=0
|
||||
retryBackOffMs=500
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -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.
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
# gradlew start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
@@ -29,7 +29,7 @@
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
# ksh gradlew
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
@@ -57,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/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/.
|
||||
@@ -114,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.
|
||||
@@ -172,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" )
|
||||
|
||||
@@ -205,15 +203,14 @@ fi
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# * 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.
|
||||
|
||||
Vendored
+12
-24
@@ -19,12 +19,12 @@
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem gradlew startup script for Windows
|
||||
@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=.
|
||||
@@ -51,7 +51,7 @@ 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:"=%
|
||||
@@ -65,30 +65,18 @@ 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 Execute gradlew
|
||||
@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%
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
java_version=17
|
||||
|
||||
# Fabric Loom
|
||||
# - For Minecraft versions <26.1: enable remap
|
||||
# - For Minecraft versions >=26.1: disable remap
|
||||
fabric_loom_remap=true
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
yarn_mappings=1.19.1+build.6
|
||||
fabric_loader_version=0.16.10
|
||||
min_fabric_loader_version=
|
||||
fabric_api_version=0.58.4
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
java_version=17
|
||||
|
||||
# Fabric Loom
|
||||
# - For Minecraft versions <26.1: enable remap
|
||||
# - For Minecraft versions >=26.1: disable remap
|
||||
fabric_loom_remap=true
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
yarn_mappings=1.19.3+build.5
|
||||
fabric_loader_version=0.16.10
|
||||
min_fabric_loader_version=
|
||||
fabric_api_version=0.68.1
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
java_version=17
|
||||
|
||||
# Fabric Loom
|
||||
# - For Minecraft versions <26.1: enable remap
|
||||
# - For Minecraft versions >=26.1: disable remap
|
||||
fabric_loom_remap=true
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
yarn_mappings=1.19+build.4
|
||||
fabric_loader_version=0.16.10
|
||||
min_fabric_loader_version=
|
||||
fabric_api_version=0.55.1
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
java_version=17
|
||||
|
||||
# Fabric Loom
|
||||
# - For Minecraft versions <26.1: enable remap
|
||||
# - For Minecraft versions >=26.1: disable remap
|
||||
fabric_loom_remap=true
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
yarn_mappings=1.20.3+build.1
|
||||
fabric_loader_version=0.16.10
|
||||
min_fabric_loader_version=
|
||||
fabric_api_version=0.91.1
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
java_version=17
|
||||
|
||||
# Fabric Loom
|
||||
# - For Minecraft versions <26.1: enable remap
|
||||
# - For Minecraft versions >=26.1: disable remap
|
||||
fabric_loom_remap=true
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
yarn_mappings=1.20+build.1
|
||||
fabric_loader_version=0.16.10
|
||||
min_fabric_loader_version=
|
||||
fabric_api_version=0.83.0
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
java_version=21
|
||||
|
||||
# Fabric Loom
|
||||
# - For Minecraft versions <26.1: enable remap
|
||||
# - For Minecraft versions >=26.1: disable remap
|
||||
fabric_loom_remap=true
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
yarn_mappings=1.21+build.9
|
||||
fabric_loader_version=0.16.10
|
||||
min_fabric_loader_version=
|
||||
fabric_api_version=0.100.1
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
java_version=25
|
||||
|
||||
# Fabric Loom
|
||||
# - For Minecraft versions <26.1: enable remap
|
||||
# - For Minecraft versions >=26.1: disable remap
|
||||
fabric_loom_remap=false
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
fabric_loader_version=0.19.1
|
||||
min_fabric_loader_version=
|
||||
fabric_api_version=0.144.0
|
||||
# Fabric API mod ID conventions:
|
||||
# - For Minecraft versions <1.19.2: use "fabric"
|
||||
# - For Minecraft versions >=1.19.2: use "fabric-api"
|
||||
# Ref: https://wiki.fabricmc.net/tutorial:setup
|
||||
fabric_api_mod_id=fabric-api
|
||||
|
||||
# Mod Compatibility
|
||||
! Dynmap 3.8
|
||||
mod_dynmap_version=4UHHD4t6
|
||||
! Styled Chat 2.12.0-pre.1+26.1
|
||||
mod_styled_chat_version=2.12.0-pre.1+26.1
|
||||
mod_styled_chat_placeholder_api_version=3.0.0-beta.2+26.1
|
||||
+2
-2
@@ -24,7 +24,7 @@ def loadProperties() {
|
||||
|
||||
// Prefer the version defined by the command line argument -Pmc=x.x.x
|
||||
def inputVersion = hasProperty("mc") ?
|
||||
validateMinecraftVersionFormat(mc as String, "Invalid Minecraft version provided via -Pmc=${minecraft_version}") :
|
||||
validateMinecraftVersionFormat(mc as String, "Invalid Minecraft version provided via -Pmc=${mc}") :
|
||||
validateMinecraftVersionFormat(minecraft_version, "Invalid Minecraft version in gradle.properties: minecraft_version=${minecraft_version}")
|
||||
gradle.ext.minecraft_version = inputVersion
|
||||
|
||||
@@ -60,7 +60,7 @@ static String findLatestCompatibleVersion(List<String> sortedVersions, String ve
|
||||
sortedVersions.findAll {
|
||||
def versionList = it.tokenize(".")*.toInteger()
|
||||
compareMinecraftVersion(versionList, targetVersionList) <= 0 &&
|
||||
(targetVersionList[0] == versionList[0] && targetVersionList[1] == versionList[1])
|
||||
(targetVersionList[0] == versionList[0] && (targetVersionList[0] >= 26 || targetVersionList[1] == versionList[1]))
|
||||
}.max { a, b -> compareMinecraftVersion(a, b) }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package cn.revaria.chatplus.mixin;
|
||||
|
||||
#if MC_VER <= MC_1_19
|
||||
import net.minecraft.server.filter.FilteredMessage;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.network.FilteredText;
|
||||
#endif
|
||||
|
||||
import cn.revaria.chatplus.plugin.annotation.DisableIfModsLoaded;
|
||||
import net.minecraft.network.message.MessageType;
|
||||
import net.minecraft.network.message.SignedMessage;
|
||||
import net.minecraft.server.PlayerManager;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.PlayerChatMessage;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@@ -18,26 +18,31 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import static cn.revaria.chatplus.util.TextStyleFormatter.applyStyle;
|
||||
|
||||
@DisableIfModsLoaded("styledchat")
|
||||
@Mixin(ServerPlayNetworkHandler.class)
|
||||
@Mixin(ServerGamePacketListenerImpl.class)
|
||||
public abstract class ChatMixin {
|
||||
@Redirect(method = "handleDecoratedMessage", at = @At(value = "INVOKE", target =
|
||||
@Redirect(method = "broadcastChatMessage", at = @At(value = "INVOKE", target =
|
||||
#if MC_VER <= MC_1_19
|
||||
"Lnet/minecraft/server/PlayerManager;broadcast(Lnet/minecraft/server/filter/FilteredMessage;Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/util/registry/RegistryKey;)V"
|
||||
"Lnet/minecraft/server/players/PlayerList;broadcastChatMessage(Lnet/minecraft/server/network/FilteredText;Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/resources/ResourceKey;)V"
|
||||
#else
|
||||
"Lnet/minecraft/server/PlayerManager;broadcast(Lnet/minecraft/network/message/SignedMessage;Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/network/message/MessageType$Parameters;)V"
|
||||
"Lnet/minecraft/server/players/PlayerList;broadcastChatMessage(Lnet/minecraft/network/chat/PlayerChatMessage;Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/network/chat/ChatType$Bound;)V"
|
||||
#endif
|
||||
))
|
||||
#if MC_VER <= MC_1_19
|
||||
private void replaceText(PlayerManager instance, FilteredMessage<SignedMessage> message, ServerPlayerEntity sender, RegistryKey<MessageType> typeKey) {
|
||||
var newMessage = new FilteredMessage<>(
|
||||
message.raw().withUnsigned(applyStyle(message.raw().getContent(), sender)),
|
||||
message.filtered() != null ? message.filtered().withUnsigned(applyStyle(message.filtered().getContent(), sender)) : null
|
||||
private void replaceText(PlayerList instance, FilteredText<PlayerChatMessage> message, ServerPlayer sender, ResourceKey<ChatType> typeKey) {
|
||||
var newMessage = new FilteredText<>(
|
||||
message.raw().withUnsignedContent(applyStyle(message.raw().serverContent(), sender)),
|
||||
message.filtered() != null ? message.filtered().withUnsignedContent(applyStyle(message.filtered().serverContent(), sender)) : null
|
||||
);
|
||||
instance.broadcast(newMessage, sender, typeKey);
|
||||
instance.broadcastChatMessage(newMessage, sender, typeKey);
|
||||
}
|
||||
#else
|
||||
private void replaceText(PlayerManager instance, SignedMessage message, ServerPlayerEntity sender, MessageType.Parameters params) {
|
||||
instance.broadcast(message.withUnsignedContent(applyStyle(message.getContent(), sender)), sender, params);
|
||||
private void replaceText(PlayerList instance, PlayerChatMessage message, ServerPlayer sender, ChatType.Bound params) {
|
||||
instance.broadcastChatMessage(
|
||||
message.withUnsignedContent(
|
||||
applyStyle(message.#if MC_VER <= MC_1_19_1 serverContent() #else decoratedContent() #endif, sender)
|
||||
),
|
||||
sender, params
|
||||
);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package cn.revaria.chatplus.mixin.compat;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -29,13 +29,20 @@ import static cn.revaria.chatplus.util.TextStyleFormatter.applyStyle;
|
||||
"org.dynmap.fabric_1_21.DynmapPlugin$ChatHandler",
|
||||
"org.dynmap.fabric_1_21_1.DynmapPlugin$ChatHandler",
|
||||
"org.dynmap.fabric_1_21_3.DynmapPlugin$ChatHandler",
|
||||
"org.dynmap.fabric_1_21_5.DynmapPlugin$ChatHandler"
|
||||
"org.dynmap.fabric_1_21_5.DynmapPlugin$ChatHandler",
|
||||
"org.dynmap.fabric_1_21_7.DynmapPlugin$ChatHandler",
|
||||
"org.dynmap.fabric_1_21_9_10.DynmapPlugin$ChatHandler",
|
||||
"org.dynmap.fabric_1_21_11.DynmapPlugin$ChatHandler",
|
||||
}
|
||||
#elif MC_VER <= MC_26_1
|
||||
// TODO: Since Dynmap has not yet been updated to be compatible with Minecraft 26.1,
|
||||
// the compatibility Mixins for Dynmap are currently not enabled for this version.
|
||||
{}
|
||||
#endif
|
||||
)
|
||||
public abstract class DynmapMixin {
|
||||
@Inject(method = "handleChat", at = @At("HEAD"), remap = false)
|
||||
private void modifyMessage(ServerPlayerEntity player, String message, CallbackInfo ci, @Local(argsOnly = true) LocalRef<String> messageRef) {
|
||||
messageRef.set(applyStyle(Text.of(message), player).getString());
|
||||
private void modifyMessage(ServerPlayer player, String message, CallbackInfo ci, @Local(argsOnly = true) LocalRef<String> messageRef) {
|
||||
messageRef.set(applyStyle(Component.nullToEmpty(message), player).getString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package cn.revaria.chatplus.mixin.compat;
|
||||
|
||||
#if MC_VER <= MC_1_21
|
||||
import eu.pb4.placeholders.api.PlaceholderContext;
|
||||
#else
|
||||
import eu.pb4.placeholders.api.ServerPlaceholderContext;
|
||||
#endif
|
||||
|
||||
import eu.pb4.styledchat.StyledChatUtils;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -14,8 +19,19 @@ import static cn.revaria.chatplus.util.TextStyleFormatter.applyStyle;
|
||||
@Pseudo
|
||||
@Mixin(StyledChatUtils.class)
|
||||
public abstract class StyledChatMixin {
|
||||
@Inject(method = "formatFor(Leu/pb4/placeholders/api/PlaceholderContext;Ljava/lang/String;)Lnet/minecraft/text/Text;", at = @At("RETURN"), cancellable = true)
|
||||
private static void modifyText(PlaceholderContext context, String input, CallbackInfoReturnable<Text> cir) {
|
||||
cir.setReturnValue(applyStyle(cir.getReturnValue(), context.player()));
|
||||
@Inject(method =
|
||||
#if MC_VER <= MC_1_21
|
||||
"formatFor(Leu/pb4/placeholders/api/PlaceholderContext;Ljava/lang/String;)Lnet/minecraft/network/chat/Component;"
|
||||
#else
|
||||
"formatFor(Leu/pb4/placeholders/api/ServerPlaceholderContext;Ljava/lang/String;)Lnet/minecraft/network/chat/Component;"
|
||||
#endif,
|
||||
at = @At("RETURN"),
|
||||
cancellable = true
|
||||
)
|
||||
private static void modifyText(
|
||||
#if MC_VER <= MC_1_21 PlaceholderContext #else ServerPlaceholderContext #endif context,
|
||||
String input, CallbackInfoReturnable<Component> cir
|
||||
) {
|
||||
cir.setReturnValue(applyStyle(cir.getReturnValue(), context.#if MC_VER <= MC_1_21 player() #else serverPlayer() #endif));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package cn.revaria.chatplus.util;
|
||||
|
||||
#if MC_VER <= MC_1_20
|
||||
import net.minecraft.text.LiteralTextContent;
|
||||
import net.minecraft.network.chat.contents.LiteralContents;
|
||||
#else
|
||||
import net.minecraft.text.PlainTextContent.Literal;
|
||||
import net.minecraft.network.chat.contents.PlainTextContents;
|
||||
#endif
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
@@ -32,13 +32,13 @@ public class TextStyleFormatter {
|
||||
* @param sourcePlayer Player used for item stack references
|
||||
* @return Processed text with styling and item hover elements
|
||||
*/
|
||||
public static MutableText applyStyle(Text sourceText, ServerPlayerEntity sourcePlayer) {
|
||||
MutableText sourceMutableText = sourceText.copy();
|
||||
public static MutableComponent applyStyle(Component sourceText, ServerPlayer sourcePlayer) {
|
||||
MutableComponent sourceMutableText = sourceText.copy();
|
||||
|
||||
MutableText finalText = Text.empty().setStyle(sourceMutableText.getStyle());
|
||||
MutableComponent finalText = Component.empty().setStyle(sourceMutableText.getStyle());
|
||||
|
||||
if (sourceText.getContent() instanceof #if MC_VER <= MC_1_20 LiteralTextContent #else Literal #endif plainTextContent) {
|
||||
String changedMessage = plainTextContent.string()
|
||||
if (sourceText.getContents() instanceof #if MC_VER <= MC_1_20 LiteralContents #else PlainTextContents #endif plainTextContent) {
|
||||
String changedMessage = plainTextContent.text()
|
||||
.replace('&', '§')
|
||||
.replace("§§", "&");
|
||||
String regex = "\\[item(?:=([1-9]))?\\]";
|
||||
@@ -56,22 +56,22 @@ public class TextStyleFormatter {
|
||||
}
|
||||
|
||||
for (String message : messages) {
|
||||
finalText.append(Text.literal(message));
|
||||
finalText.append(Component.literal(message));
|
||||
if (!itemDeque.isEmpty()) {
|
||||
ItemStack itemStack;
|
||||
if (itemDeque.getFirst() == MAIN_HAND) {
|
||||
itemStack = sourcePlayer.getMainHandStack();
|
||||
itemStack = sourcePlayer.getMainHandItem();
|
||||
} else {
|
||||
itemStack = sourcePlayer.getInventory().getStack(itemDeque.getFirst() - 1);
|
||||
itemStack = sourcePlayer.getInventory().getItem(itemDeque.getFirst() - 1);
|
||||
}
|
||||
finalText.append(itemStack.toHoverableText());
|
||||
finalText.append(itemStack.getDisplayName());
|
||||
itemDeque.removeFirst();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Text> sourceTexts = sourceMutableText.getSiblings();
|
||||
for (Text text : sourceTexts) {
|
||||
List<Component> sourceTexts = sourceMutableText.getSiblings();
|
||||
for (Component text : sourceTexts) {
|
||||
finalText.append(applyStyle(text, sourcePlayer));
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": "${fabric_loader_version_range}",
|
||||
"minecraft": "~${minecraft_version}",
|
||||
"minecraft": "${minecraft_version_range}",
|
||||
"java": ">=${java_version}",
|
||||
"${fabric_api_mod_id}": ">=${fabric_api_version}"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user