Fix Player.Spigot#sendMessage

This commit is contained in:
IzzelAliz 2022-09-03 21:14:07 +08:00
parent 6bb2d703ee
commit 7023a576e6
No known key found for this signature in database
GPG Key ID: EE50E123A11D8338
5 changed files with 25 additions and 19 deletions

View File

@ -1,18 +0,0 @@
package io.izzel.arclight.common.mixin.bukkit;
import com.mojang.brigadier.context.CommandContext;
import org.bukkit.craftbukkit.v.command.BukkitCommandWrapper;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(BukkitCommandWrapper.class)
public class BukkitCommandWrapperMixin {
@Redirect(method = "run", remap = false, at = @At(value = "INVOKE", target = "Lcom/mojang/brigadier/context/CommandContext;getInput()Ljava/lang/String;"))
public String arclight$removeSlash(CommandContext<?> context) {
String input = context.getInput();
if (input.startsWith("/")) return input.substring(1);
return input;
}
}

View File

@ -0,0 +1,23 @@
package io.izzel.arclight.common.mixin.core.network.protocol.game;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.chat.ComponentSerializer;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.ClientboundSystemChatPacket;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(ClientboundSystemChatPacket.class)
public class ClientboundSystemChatPacketMixin {
public void arclight$constructor(Component content, boolean overlay) {
throw new RuntimeException();
}
public void arclight$constructor(String content, boolean overlay) {
arclight$constructor(Component.Serializer.fromJson(content), overlay);
}
public void arclight$constructor(BaseComponent[] content, boolean overlay) {
arclight$constructor(ComponentSerializer.toString(content), overlay);
}
}

View File

@ -126,6 +126,7 @@ public class ArclightMixinPlugin implements IMixinConfigPlugin {
.add("net.minecraft.network.chat.TextColor")
.add("net.minecraft.commands.Commands")
.add("net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess")
.add("net.minecraft.network.protocol.game.ClientboundSystemChatPacket")
.build();
@Override

View File

@ -11,7 +11,6 @@
},
"compatibilityLevel": "JAVA_11",
"mixins": [
"BukkitCommandWrapperMixin",
"ColouredConsoleSenderMixin",
"CraftAbstractVillagerMixin",
"CraftBlockMixin",

View File

@ -39,6 +39,7 @@
"network.chat.TextColorMixin",
"network.protocol.PacketThreadUtilMixin",
"network.protocol.game.CCloseWindowPacketMixin",
"network.protocol.game.ClientboundSystemChatPacketMixin",
"network.protocol.game.CPlayerTryUseItemOnBlockPacketMixin",
"network.protocol.game.CPlayerTryUseItemPacketMixin",
"network.protocol.game.SWorldBorderPacketMixin",