mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2024-11-21 11:35:16 +01:00
Updated Via API usage
This commit is contained in:
parent
9bc6fb90c9
commit
d6386bf679
@ -1,8 +1,5 @@
|
|||||||
package com.viaversion.fabric.common.util;
|
package com.viaversion.fabric.common.util;
|
||||||
|
|
||||||
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
|
||||||
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
|
||||||
|
|
||||||
public class RemappingUtil {
|
public class RemappingUtil {
|
||||||
public static int swordId(String id) {
|
public static int swordId(String id) {
|
||||||
// https://github.com/ViaVersion/ViaVersion/blob/8de26a0ad33f5b739f5394ed80f69d14197fddc7/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/Protocol1_9To1_8.java#L86
|
// https://github.com/ViaVersion/ViaVersion/blob/8de26a0ad33f5b739f5394ed80f69d14197fddc7/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/Protocol1_9To1_8.java#L86
|
||||||
@ -21,12 +18,4 @@ public class RemappingUtil {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final LegacyComponentSerializer LEGACY_SERIALIZER = LegacyComponentSerializer.builder()
|
|
||||||
.character('§')
|
|
||||||
.extractUrls()
|
|
||||||
.build();
|
|
||||||
|
|
||||||
public static String legacyToJson(String legacy) {
|
|
||||||
return GsonComponentSerializer.gson().serialize(LEGACY_SERIALIZER.deserialize(legacy));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.viaversion.fabric.mc114.commands;
|
package com.viaversion.fabric.mc114.commands;
|
||||||
|
|
||||||
import com.viaversion.fabric.common.util.RemappingUtil;
|
|
||||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||||
|
import com.viaversion.viaversion.util.ComponentUtil;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
@ -28,7 +28,7 @@ public class NMSCommandSender implements ViaCommandSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Text fromLegacy(String legacy) {
|
public static Text fromLegacy(String legacy) {
|
||||||
return Text.Serializer.fromJson(RemappingUtil.legacyToJson(legacy));
|
return Text.Serializer.fromJson(ComponentUtil.legacyToJsonString(legacy));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.viaversion.fabric.mc115.commands;
|
package com.viaversion.fabric.mc115.commands;
|
||||||
|
|
||||||
import com.viaversion.fabric.common.util.RemappingUtil;
|
|
||||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||||
|
import com.viaversion.viaversion.util.ComponentUtil;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
@ -28,7 +28,7 @@ public class NMSCommandSender implements ViaCommandSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Text fromLegacy(String legacy) {
|
public static Text fromLegacy(String legacy) {
|
||||||
return Text.Serializer.fromJson(RemappingUtil.legacyToJson(legacy));
|
return Text.Serializer.fromJson(ComponentUtil.legacyToJsonString(legacy));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.viaversion.fabric.mc116.commands;
|
package com.viaversion.fabric.mc116.commands;
|
||||||
|
|
||||||
import com.viaversion.fabric.common.util.RemappingUtil;
|
|
||||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||||
|
import com.viaversion.viaversion.util.ComponentUtil;
|
||||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||||
import net.minecraft.command.CommandSource;
|
import net.minecraft.command.CommandSource;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
@ -25,7 +25,7 @@ public class NMSCommandSender implements ViaCommandSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Text fromLegacy(String legacy) {
|
public static Text fromLegacy(String legacy) {
|
||||||
return Text.Serializer.fromJson(RemappingUtil.legacyToJson(legacy));
|
return Text.Serializer.fromJson(ComponentUtil.legacyToJsonString(legacy));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.viaversion.fabric.mc117.commands;
|
package com.viaversion.fabric.mc117.commands;
|
||||||
|
|
||||||
import com.viaversion.fabric.common.util.RemappingUtil;
|
import com.viaversion.viaversion.util.ComponentUtil;
|
||||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||||
import net.minecraft.command.CommandSource;
|
import net.minecraft.command.CommandSource;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
@ -26,7 +26,7 @@ public class NMSCommandSender implements ViaCommandSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static MutableText fromLegacy(String legacy) {
|
public static MutableText fromLegacy(String legacy) {
|
||||||
return Text.Serializer.fromJson(RemappingUtil.legacyToJson(legacy));
|
return Text.Serializer.fromJson(ComponentUtil.legacyToJsonString(legacy));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.viaversion.fabric.mc118.commands;
|
package com.viaversion.fabric.mc118.commands;
|
||||||
|
|
||||||
import com.viaversion.fabric.common.util.RemappingUtil;
|
import com.viaversion.viaversion.util.ComponentUtil;
|
||||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||||
import net.minecraft.command.CommandSource;
|
import net.minecraft.command.CommandSource;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
@ -25,7 +25,7 @@ public class NMSCommandSender implements ViaCommandSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Text fromLegacy(String legacy) {
|
public static Text fromLegacy(String legacy) {
|
||||||
return Text.Serializer.fromJson(RemappingUtil.legacyToJson(legacy));
|
return Text.Serializer.fromJson(ComponentUtil.legacyToJsonString(legacy));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.viaversion.fabric.mc119.commands;
|
package com.viaversion.fabric.mc119.commands;
|
||||||
|
|
||||||
import com.viaversion.fabric.common.util.RemappingUtil;
|
import com.viaversion.viaversion.util.ComponentUtil;
|
||||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||||
import net.minecraft.command.CommandSource;
|
import net.minecraft.command.CommandSource;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
@ -26,7 +26,7 @@ public class NMSCommandSender implements ViaCommandSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static MutableText fromLegacy(String legacy) {
|
public static MutableText fromLegacy(String legacy) {
|
||||||
return Text.Serializer.fromJson(RemappingUtil.legacyToJson(legacy));
|
return Text.Serializer.fromJson(ComponentUtil.legacyToJsonString(legacy));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.viaversion.fabric.mc120.commands;
|
package com.viaversion.fabric.mc120.commands;
|
||||||
|
|
||||||
import com.viaversion.fabric.common.util.RemappingUtil;
|
import com.viaversion.viaversion.util.ComponentUtil;
|
||||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||||
import net.minecraft.command.CommandSource;
|
import net.minecraft.command.CommandSource;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
@ -26,7 +26,7 @@ public class NMSCommandSender implements ViaCommandSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static MutableText fromLegacy(String legacy) {
|
public static MutableText fromLegacy(String legacy) {
|
||||||
return Text.Serialization.fromJson(RemappingUtil.legacyToJson(legacy));
|
return Text.Serialization.fromJson(ComponentUtil.legacyToJsonString(legacy));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.viaversion.fabric.mc18.commands;
|
package com.viaversion.fabric.mc18.commands;
|
||||||
|
|
||||||
import com.viaversion.fabric.common.util.RemappingUtil;
|
|
||||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||||
|
import com.viaversion.viaversion.util.ComponentUtil;
|
||||||
import net.minecraft.command.CommandSource;
|
import net.minecraft.command.CommandSource;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
@ -24,7 +24,7 @@ public class NMSCommandSender implements ViaCommandSender {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(String s) {
|
public void sendMessage(String s) {
|
||||||
source.sendMessage(Text.Serializer.deserialize(RemappingUtil.legacyToJson(s)));
|
source.sendMessage(Text.Serializer.deserialize(ComponentUtil.legacyToJsonString(s)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,11 +4,11 @@ import com.viaversion.fabric.common.commands.UserCommandSender;
|
|||||||
import com.viaversion.fabric.common.platform.NativeVersionProvider;
|
import com.viaversion.fabric.common.platform.NativeVersionProvider;
|
||||||
import com.viaversion.fabric.common.provider.AbstractFabricPlatform;
|
import com.viaversion.fabric.common.provider.AbstractFabricPlatform;
|
||||||
import com.viaversion.fabric.common.util.FutureTaskId;
|
import com.viaversion.fabric.common.util.FutureTaskId;
|
||||||
import com.viaversion.fabric.common.util.RemappingUtil;
|
|
||||||
import com.viaversion.fabric.mc18.ViaFabric;
|
import com.viaversion.fabric.mc18.ViaFabric;
|
||||||
import com.viaversion.fabric.mc18.commands.NMSCommandSender;
|
import com.viaversion.fabric.mc18.commands.NMSCommandSender;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||||
|
import com.viaversion.viaversion.util.ComponentUtil;
|
||||||
import io.netty.channel.EventLoop;
|
import io.netty.channel.EventLoop;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
@ -106,7 +106,7 @@ public class FabricPlatform extends AbstractFabricPlatform {
|
|||||||
runServerSync(() -> {
|
runServerSync(() -> {
|
||||||
ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid);
|
ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid);
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
player.sendMessage(Text.Serializer.deserialize(RemappingUtil.legacyToJson(s)));
|
player.sendMessage(Text.Serializer.deserialize(ComponentUtil.legacyToJsonString(s)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user