mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2025-01-07 19:07:37 +01:00
fix legacy text in NMSCommandSender
This commit is contained in:
parent
4bf7c9c303
commit
e1cf266c2b
@ -31,7 +31,8 @@ import net.minecraft.server.command.CommandSource;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
import us.myles.ViaVersion.api.command.ViaCommandSender;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import us.myles.viaversion.libs.bungeecordchat.api.chat.TextComponent;
|
||||
import us.myles.viaversion.libs.bungeecordchat.chat.ComponentSerializer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -51,12 +52,16 @@ public class NMSCommandSender implements ViaCommandSender {
|
||||
@Override
|
||||
public void sendMessage(String s) {
|
||||
if (source instanceof ServerCommandSource) {
|
||||
((ServerCommandSource) source).sendFeedback(Text.Serializer.fromJson(ChatRewriter.legacyTextToJson(s)), false);
|
||||
((ServerCommandSource) source).sendFeedback(Text.Serializer.fromJson(legacyToJson(s)), false);
|
||||
} else if (source instanceof CottonClientCommandSource) {
|
||||
((CottonClientCommandSource) source).sendFeedback(Text.Serializer.fromJson(ChatRewriter.legacyTextToJson(s)), false);
|
||||
((CottonClientCommandSource) source).sendFeedback(Text.Serializer.fromJson(legacyToJson(s)), false);
|
||||
}
|
||||
}
|
||||
|
||||
private String legacyToJson(String legacy) {
|
||||
return ComponentSerializer.toString(TextComponent.fromLegacyText(legacy));
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
if (source instanceof ServerCommandSource) {
|
||||
|
Loading…
Reference in New Issue
Block a user