mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2024-11-25 12:15:14 +01:00
adventure
This commit is contained in:
parent
d7276da2ea
commit
cdad3dbe3a
@ -25,6 +25,7 @@
|
||||
|
||||
package com.github.creeper123123321.viafabric.commands;
|
||||
|
||||
import com.github.creeper123123321.viafabric.platform.VRPlatform;
|
||||
import io.github.cottonmc.clientcommands.CottonClientCommandSource;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.command.CommandSource;
|
||||
@ -32,8 +33,6 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
import us.myles.ViaVersion.api.command.ViaCommandSender;
|
||||
import us.myles.viaversion.libs.bungeecordchat.api.chat.TextComponent;
|
||||
import us.myles.viaversion.libs.bungeecordchat.chat.ComponentSerializer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -53,16 +52,12 @@ public class NMSCommandSender implements ViaCommandSender {
|
||||
@Override
|
||||
public void sendMessage(String s) {
|
||||
if (source instanceof ServerCommandSource) {
|
||||
((ServerCommandSource) source).sendFeedback(Text.Serializer.fromJson(legacyToJson(s)), false);
|
||||
((ServerCommandSource) source).sendFeedback(Text.Serializer.fromJson(VRPlatform.legacyToJson(s)), false);
|
||||
} else if (source instanceof CottonClientCommandSource) {
|
||||
((CottonClientCommandSource) source).sendFeedback(Text.Serializer.fromJson(legacyToJson(s)), false);
|
||||
((CottonClientCommandSource) source).sendFeedback(Text.Serializer.fromJson(VRPlatform.legacyToJson(s)), false);
|
||||
}
|
||||
}
|
||||
|
||||
private String legacyToJson(String legacy) {
|
||||
return ComponentSerializer.toString(TextComponent.fromLegacyText(legacy));
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
if (source instanceof ServerCommandSource) {
|
||||
|
@ -54,10 +54,9 @@ import us.myles.ViaVersion.api.platform.ViaConnectionManager;
|
||||
import us.myles.ViaVersion.api.platform.ViaPlatform;
|
||||
import us.myles.ViaVersion.dump.PluginInfo;
|
||||
import us.myles.ViaVersion.util.GsonUtil;
|
||||
import us.myles.viaversion.libs.bungeecordchat.api.chat.TextComponent;
|
||||
import us.myles.viaversion.libs.bungeecordchat.chat.ComponentSerializer;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
|
||||
import us.myles.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import us.myles.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
@ -307,7 +306,7 @@ public class VRPlatform implements ViaPlatform<UUID> {
|
||||
return connectionManager;
|
||||
}
|
||||
|
||||
private String legacyToJson(String legacy) {
|
||||
return ComponentSerializer.toString(TextComponent.fromLegacyText(legacy));
|
||||
public static String legacyToJson(String legacy) {
|
||||
return GsonComponentSerializer.gson().serialize(LegacyComponentSerializer.legacySection().deserialize(legacy));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user