Author SHA1 Message Date
CPTProgrammer 7ccb661fbd Update README.md 2025-01-26 21:21:28 +08:00
CPTProgrammer f76b670fdc Update README.md 2025-01-25 22:17:30 +08:00
CPTProgrammer 1cd925f192 Update workflow configuration
Upgrade Java version from 17 to 21 in workflow configuration
2025-01-25 20:32:06 +08:00
CPTProgrammer 6a84f79d69 Update mod compatibility fix
Update compatibility fix for mod "Discord Integration" and "Dynmap" to ensure proper functionality.
2025-01-25 20:28:01 +08:00
BloemenpotandCPTProgrammer a94415e427 Update to 1.20.4 (#7)
* Updated Gradle Version

* Updated Loom Version

* Updated GradleProperties to 1.21.4

* Updated needed classes to 1.21.4

* Update mod version

---------

Co-authored-by: CPTProgrammer <46586216+CPTProgrammer@users.noreply.github.com>
2025-01-25 18:35:20 +08:00
7 changed files with 53 additions and 37 deletions
+2 -2
View File
@@ -12,7 +12,7 @@ jobs:
matrix:
# Use these Java versions
java: [
17, # Current Java LTS & minimum supported by Minecraft
21, # Current Java LTS & minimum supported by Minecraft
]
# and run on both Linux and Windows
os: [ubuntu-22.04, windows-2022]
@@ -33,7 +33,7 @@ jobs:
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v3
with:
name: Artifacts
+11 -3
View File
@@ -1,11 +1,14 @@
# ChatPlus
![Static Badge](https://img.shields.io/badge/Minecraft_version-1.20.1_%7C_1.20.4_%7C_1.21.4-red?style=flat)
<a href="https://modrinth.com/mod/chatplus">
<img src="https://img.shields.io/badge/Modrinth-Chat_Plus-%234e910e?style=flat" />
</a>
A Simple mod add bukkit style with an "&" and "[item]" display for Fabric Server.
It's a **server-side** mod and doesn't need to be installed on the client.
Currently supported Minecraft versions: 1.20.1, 1.20.4
## Screenshot
## Screenshots
![image](https://github.com/CPTProgrammer/ChatPlus/assets/46586216/dcd2ca4b-79e9-4692-a8de-02fddfe4a392)
**^^^ Display the item in main hand**
@@ -14,3 +17,8 @@ Currently supported Minecraft versions: 1.20.1, 1.20.4
![image](https://github.com/CPTProgrammer/ChatPlus/assets/46586216/dc3f0451-cbea-4610-8575-ea5da4e97f0f)
**^^^ Display items in slots**
## Contributors
<a href="https://github.com/CPTProgrammer/ChatPlus/graphs/contributors">
<img src="https://contrib.rocks/image?repo=CPTProgrammer/ChatPlus" />
</a>
+1 -1
View File
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'maven-publish'
}
+5 -5
View File
@@ -4,14 +4,14 @@ org.gradle.parallel=true
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.6
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.8
loader_version=0.16.9
# Mod Properties
mod_version=0.20.3
mod_version=0.21.0
maven_group=cn.revaria.chatplus
archives_base_name=chat-plus
# Dependencies
fabric_version=0.95.1+1.20.4
fabric_version=0.115.0+1.21.4
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
@@ -1,7 +1,6 @@
package cn.revaria.chatplus.mixin;
import net.minecraft.MinecraftVersion;
import net.minecraft.SharedConstants;
import net.minecraft.item.ItemStack;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.message.*;
@@ -14,6 +13,7 @@ import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.StringHelper;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -44,7 +44,9 @@ public abstract class MixinChat extends ServerCommonNetworkHandler {
@Shadow
public ServerPlayerEntity player;
@Shadow protected abstract Optional<LastSeenMessageList> validateMessage(LastSeenMessageList.Acknowledgment acknowledgment);
// @Shadow protected abstract Optional<LastSeenMessageList> validateMessage(LastSeenMessageList.Acknowledgment acknowledgment);
@Shadow protected abstract Optional<LastSeenMessageList> validateAcknowledgment(LastSeenMessageList.Acknowledgment acknowledgment);
@Shadow protected abstract SignedMessage getSignedMessage(ChatMessageC2SPacket packet, LastSeenMessageList lastSeenMessages) throws MessageChain.MessageChainException;
@@ -61,7 +63,7 @@ public abstract class MixinChat extends ServerCommonNetworkHandler {
if (hasIllegalCharacter(packet.chatMessage())) {
disconnect(Text.translatable("multiplayer.disconnect.illegal_characters"));
} else {
Optional<LastSeenMessageList> optional = this.validateMessage(packet.acknowledgment());
Optional<LastSeenMessageList> optional = this.validateAcknowledgment(packet.acknowledgment());
if (optional.isPresent()) {
if (!packet.chatMessage().startsWith("/")){
@@ -98,35 +100,41 @@ public abstract class MixinChat extends ServerCommonNetworkHandler {
try {
SignedMessage signedMessage = getSignedMessage(packet, (LastSeenMessageList) optional.get());
server.getPlayerManager().broadcast(signedMessage.withUnsignedContent(
changedText
changedText
), player, MessageType.params(MessageType.CHAT, player));
// Compatible with mod "Discord Integration"
try {
Class<?> DiscordIntegrationMod = Class.forName("de.erdbeerbaerlp.dcintegration.fabric.DiscordIntegrationMod");
Class<?> DiscordIntegrationMod = Class.forName("de.erdbeerbaerlp.dcintegration.architectury.DiscordIntegrationMod");
Method handleChatMessage = DiscordIntegrationMod.getMethod("handleChatMessage", SignedMessage.class, ServerPlayerEntity.class);
handleChatMessage.invoke(null, signedMessage.withUnsignedContent(changedText), player);
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException |
IllegalAccessException ignored) { }
// Compatible with mod "Dynmap"
try {
/*
Warning: Using reflection can make the code harder to maintain, debug, and understand.
Statement: DynmapMod.plugin.chathandler.handleChat()
*/
Class<?> DynmapMod = Class.forName("org.dynmap.fabric_" + MinecraftVersion.CURRENT.getName().replaceAll("\\.", "_") + ".DynmapMod");
Field pluginField = DynmapMod.getField("plugin");
Object plugin = pluginField.get(null);
Class<?> pluginClass = plugin.getClass();
Field chatHandlerField = pluginClass.getDeclaredField("chathandler");
chatHandlerField.setAccessible(true);
Object chatHandler = chatHandlerField.get(plugin);
Class<?> chatHandlerClass = chatHandler.getClass();
Method handleChat = chatHandlerClass.getMethod("handleChat", ServerPlayerEntity.class, String.class);
handleChat.invoke(chatHandler, player, signedMessage.withUnsignedContent(changedText).getContent().getString());
} catch (ClassNotFoundException | NoSuchMethodException | NoSuchFieldException | NullPointerException |
IllegalAccessException | InvocationTargetException ignored) { }
String[] minecraftVersion = MinecraftVersion.CURRENT.getName().split("\\.");
int minecraftPatchVersion = minecraftVersion.length == 3 ? Integer.parseInt(minecraftVersion[2]) : 0;
for (int i = minecraftPatchVersion; i >= 0; i--){
String version = minecraftVersion[0] + "." + minecraftVersion[1] + (i == 0 ? "" : ("." + i));
try {
/*
Warning: Using reflection can make the code harder to maintain, debug, and understand.
Statement: DynmapMod.plugin.chathandler.handleChat()
*/
Class<?> DynmapMod = Class.forName("org.dynmap.fabric_" + version.replaceAll("\\.", "_") + ".DynmapMod");
Field pluginField = DynmapMod.getField("plugin");
Object plugin = pluginField.get(null);
Class<?> pluginClass = plugin.getClass();
Field chatHandlerField = pluginClass.getDeclaredField("chathandler");
chatHandlerField.setAccessible(true);
Object chatHandler = chatHandlerField.get(plugin);
Class<?> chatHandlerClass = chatHandler.getClass();
Method handleChat = chatHandlerClass.getMethod("handleChat", ServerPlayerEntity.class, String.class);
handleChat.invoke(chatHandler, player, signedMessage.withUnsignedContent(changedText).getContent().getString());
break;
} catch (ClassNotFoundException | NoSuchMethodException | NoSuchFieldException | NullPointerException |
IllegalAccessException | InvocationTargetException ignored) { }
}
} catch (MessageChain.MessageChainException e) {
handleMessageChainException(e);
@@ -158,7 +166,7 @@ public abstract class MixinChat extends ServerCommonNetworkHandler {
private static boolean hasIllegalCharacter(String message) {
for(int i = 0; i < message.length(); ++i) {
if (!SharedConstants.isValidChar(message.charAt(i))) {
if (!StringHelper.isValidChar(message.charAt(i))) {
return true;
}
}
+2 -2
View File
@@ -28,8 +28,8 @@
}
],
"depends": {
"fabricloader": ">=0.14.21",
"minecraft": "~1.20.4",
"fabricloader": ">=0.16.9",
"minecraft": "~1.21.4",
"java": ">=17",
"fabric-api": "*"
},