diff --git a/build.gradle b/build.gradle index 1854f13..8157464 100644 --- a/build.gradle +++ b/build.gradle @@ -78,7 +78,7 @@ dependencies { exclude group: "com.google.guava", module: "guava" } include "com.viaversion:viarewind-core:2.0.4-SNAPSHOT" - include "net.raphimc:ViaLegacy:2.2.11" + include "net.raphimc:ViaLegacy:2.2.12" include "net.raphimc:ViaAprilFools:2.0.6" include("net.raphimc:ViaBedrock:0.0.1-SNAPSHOT") { exclude group: "io.netty", module: "netty-codec-http" @@ -109,9 +109,6 @@ dependencies { exclude group: "com.google.code.gson", module: "gson" exclude group: "org.slf4j", module: "slf4j-api" } - include("net.lenni0451.mcstructs:all:2.2.3") { - exclude group: "com.google.code.gson", module: "gson" - } include "com.vdurmont:semver4j:3.1.0" include("org.cloudburstmc.netty:netty-transport-raknet:1.0.0.CR1-SNAPSHOT") { exclude group: "io.netty", module: "netty-common" diff --git a/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinChatItemRewriter.java b/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinChatItemRewriter.java index 431c33e..7836596 100644 --- a/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinChatItemRewriter.java +++ b/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinChatItemRewriter.java @@ -18,10 +18,8 @@ package net.raphimc.viaproxy.injection.mixins; import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.minecraft.nbt.BinaryTagIO; -import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ChatItemRewriter; -import net.raphimc.vialegacy.util.ViaStringTagReader1_11_2; +import net.lenni0451.mcstructs.snbt.SNbtSerializer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -36,8 +34,7 @@ public abstract class MixinChatItemRewriter { @Redirect(method = "toClient", at = @At(value = "INVOKE", target = "Ljava/util/regex/Pattern;matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;")) private static Matcher rewriteShowItem(Pattern pattern, CharSequence input) { try { - final CompoundTag tag = ViaStringTagReader1_11_2.getTagFromJson(input.toString()); - input = BinaryTagIO.writeString(tag); + input = SNbtSerializer.V1_12.serialize(SNbtSerializer.V1_8.deserialize(input.toString())); } catch (Throwable e) { Via.getPlatform().getLogger().log(Level.WARNING, "Error converting 1.11.2 nbt to 1.12.2 nbt: '" + input + "'", e); } diff --git a/src/main/java/net/raphimc/viaproxy/protocolhack/ProtocolHack.java b/src/main/java/net/raphimc/viaproxy/protocolhack/ProtocolHack.java index b1ff5ce..6292dc3 100644 --- a/src/main/java/net/raphimc/viaproxy/protocolhack/ProtocolHack.java +++ b/src/main/java/net/raphimc/viaproxy/protocolhack/ProtocolHack.java @@ -18,10 +18,14 @@ package net.raphimc.viaproxy.protocolhack; import net.raphimc.viaprotocolhack.ViaProtocolHack; -import net.raphimc.viaprotocolhack.impl.platform.*; +import net.raphimc.viaprotocolhack.impl.platform.ViaAprilFoolsPlatformImpl; +import net.raphimc.viaprotocolhack.impl.platform.ViaBackwardsPlatformImpl; +import net.raphimc.viaprotocolhack.impl.platform.ViaBedrockPlatformImpl; +import net.raphimc.viaprotocolhack.impl.platform.ViaRewindPlatformImpl; import net.raphimc.viaproxy.plugins.PluginManager; import net.raphimc.viaproxy.plugins.events.ProtocolHackInitEvent; import net.raphimc.viaproxy.protocolhack.impl.ViaProxyVPHLoader; +import net.raphimc.viaproxy.protocolhack.impl.ViaProxyViaLegacyPlatformImpl; import net.raphimc.viaproxy.protocolhack.impl.ViaProxyViaVersionPlatformImpl; import java.io.File; @@ -33,7 +37,7 @@ public class ProtocolHack { public static void init() { patchConfigs(); - final Supplier[] platformSuppliers = PluginManager.EVENT_MANAGER.call(new ProtocolHackInitEvent(ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new, ViaLegacyPlatformImpl::new, ViaAprilFoolsPlatformImpl::new, ViaBedrockPlatformImpl::new)).getPlatformSuppliers().toArray(new Supplier[0]); + final Supplier[] platformSuppliers = PluginManager.EVENT_MANAGER.call(new ProtocolHackInitEvent(ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new, ViaProxyViaLegacyPlatformImpl::new, ViaAprilFoolsPlatformImpl::new, ViaBedrockPlatformImpl::new)).getPlatformSuppliers().toArray(new Supplier[0]); ViaProtocolHack.init(new ViaProxyViaVersionPlatformImpl(), new ViaProxyVPHLoader(), null, null, platformSuppliers); } diff --git a/src/main/java/net/raphimc/viaproxy/protocolhack/impl/ViaProxyViaLegacyPlatformImpl.java b/src/main/java/net/raphimc/viaproxy/protocolhack/impl/ViaProxyViaLegacyPlatformImpl.java new file mode 100644 index 0000000..4726ad9 --- /dev/null +++ b/src/main/java/net/raphimc/viaproxy/protocolhack/impl/ViaProxyViaLegacyPlatformImpl.java @@ -0,0 +1,30 @@ +/* + * This file is part of ViaProxy - https://github.com/RaphiMC/ViaProxy + * Copyright (C) 2023 RK_01/RaphiMC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package net.raphimc.viaproxy.protocolhack.impl; + +import net.raphimc.viaprotocolhack.impl.platform.ViaLegacyPlatformImpl; +import net.raphimc.viaproxy.ViaProxy; + +public class ViaProxyViaLegacyPlatformImpl extends ViaLegacyPlatformImpl { + + @Override + public String getCpeAppName() { + return "ViaProxy " + ViaProxy.VERSION; + } + +}