mirror of
https://github.com/CPTProgrammer/ChatPlus.git
synced 2026-09-22 00:23:36 +08:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ccb661fbd | ||
|
|
f76b670fdc | ||
|
|
1cd925f192 | ||
|
|
6a84f79d69 | ||
|
|
a94415e427 |
@@ -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
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
# ChatPlus
|
||||

|
||||
<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
|
||||

|
||||
**^^^ Display the item in main hand**
|
||||
|
||||
@@ -14,3 +17,8 @@ Currently supported Minecraft versions: 1.20.1, 1.20.4
|
||||
|
||||

|
||||
**^^^ 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
@@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.5-SNAPSHOT'
|
||||
id 'fabric-loom' version '1.9-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -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
@@ -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("/")){
|
||||
|
||||
@@ -103,19 +105,23 @@ public abstract class MixinChat extends ServerCommonNetworkHandler {
|
||||
|
||||
// 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"
|
||||
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_" + MinecraftVersion.CURRENT.getName().replaceAll("\\.", "_") + ".DynmapMod");
|
||||
Class<?> DynmapMod = Class.forName("org.dynmap.fabric_" + version.replaceAll("\\.", "_") + ".DynmapMod");
|
||||
Field pluginField = DynmapMod.getField("plugin");
|
||||
Object plugin = pluginField.get(null);
|
||||
Class<?> pluginClass = plugin.getClass();
|
||||
@@ -125,8 +131,10 @@ public abstract class MixinChat extends ServerCommonNetworkHandler {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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": "*"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user