From 3f9f5ee8d13f98db814c18de667ba386bbfc9dd0 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Sat, 4 May 2024 22:00:28 +0800 Subject: [PATCH] Bump ViaVersion and clean up imports --- build.gradle.kts | 2 +- .../moulberry/axiom/packet/HelloPacketListener.java | 2 +- .../moulberry/axiom/viaversion/ViaVersionHelper.java | 12 +++--------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a6944e8..c726874 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -34,7 +34,7 @@ dependencies { implementation("com.github.luben:zstd-jni:1.5.5-4") // ViaVersion support - compileOnly("com.viaversion:viaversion-api:4.9.4-SNAPSHOT") + compileOnly("com.viaversion:viaversion-api:4.10.1-SNAPSHOT") // WorldGuard support compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT") diff --git a/src/main/java/com/moulberry/axiom/packet/HelloPacketListener.java b/src/main/java/com/moulberry/axiom/packet/HelloPacketListener.java index 06bfc86..29d9679 100644 --- a/src/main/java/com/moulberry/axiom/packet/HelloPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/HelloPacketListener.java @@ -56,7 +56,7 @@ public class HelloPacketListener implements PluginMessageListener { FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message)); int apiVersion = friendlyByteBuf.readVarInt(); int dataVersion = friendlyByteBuf.readVarInt(); - ViaVersionHelper.skipTagUnknown(friendlyByteBuf, player); + // note - skipping NBT here. friendlyByteBuf.readNBT(); int serverDataVersion = SharedConstants.getCurrentVersion().getDataVersion().getVersion(); if (dataVersion != serverDataVersion) { diff --git a/src/main/java/com/moulberry/axiom/viaversion/ViaVersionHelper.java b/src/main/java/com/moulberry/axiom/viaversion/ViaVersionHelper.java index 53d03be..d3cafab 100644 --- a/src/main/java/com/moulberry/axiom/viaversion/ViaVersionHelper.java +++ b/src/main/java/com/moulberry/axiom/viaversion/ViaVersionHelper.java @@ -1,8 +1,8 @@ package com.moulberry.axiom.viaversion; +import com.moulberry.axiom.AxiomPaper; import com.moulberry.axiom.buffer.BlockBuffer; import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.data.BiMappings; import com.viaversion.viaversion.api.data.MappingData; import com.viaversion.viaversion.api.data.Mappings; import com.viaversion.viaversion.api.protocol.ProtocolPathEntry; @@ -11,18 +11,12 @@ import com.viaversion.viaversion.api.type.Type; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; import net.minecraft.SharedConstants; import net.minecraft.core.IdMapper; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import org.jetbrains.annotations.Nullable; import java.util.List; @@ -104,7 +98,7 @@ public class ViaVersionHelper { private static final int UNNAMED_COMPOUND_TAG_CHANGE_VERSION = ProtocolVersion.v1_20_2.getVersion(); public static void skipTagUnknown(FriendlyByteBuf friendlyByteBuf, Player player) { - if (Bukkit.getPluginManager().isPluginEnabled("ViaVersion")) { + if (AxiomPaper.PLUGIN.isMismatchedDataVersion(player.getUniqueId())) { int playerVersion = Via.getAPI().getPlayerVersion(player.getUniqueId()); try { ViaVersionHelper.skipTagViaVersion(friendlyByteBuf, playerVersion); @@ -117,7 +111,7 @@ public class ViaVersionHelper { } public static CompoundTag readTagUnknown(FriendlyByteBuf friendlyByteBuf, Player player) { - if (Bukkit.getPluginManager().isPluginEnabled("ViaVersion")) { + if (AxiomPaper.PLUGIN.isMismatchedDataVersion(player.getUniqueId())) { int playerVersion = Via.getAPI().getPlayerVersion(player.getUniqueId()); try { return ViaVersionHelper.readTagViaVersion(friendlyByteBuf, playerVersion);