diff --git a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/providers/BukkitViaMovementTransmitter.java b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/providers/BukkitViaMovementTransmitter.java index bd6128dcb..8dc3ed7e1 100644 --- a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/providers/BukkitViaMovementTransmitter.java +++ b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/providers/BukkitViaMovementTransmitter.java @@ -25,6 +25,9 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.MovementTrac import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; + +import com.viaversion.viaversion.util.PipelineUtil; +import io.netty.channel.ChannelHandlerContext; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -79,17 +82,15 @@ public class BukkitViaMovementTransmitter extends MovementTransmitterProvider { } } - @Override public Object getFlyingPacket() { - if (idlePacket == null) - throw new NullPointerException("Could not locate flying packet"); + if (idlePacket == null) throw new NullPointerException("Could not locate flying packet"); + return idlePacket; } - @Override public Object getGroundPacket() { - if (idlePacket == null) - throw new NullPointerException("Could not locate flying packet"); + if (idlePacket == null) throw new NullPointerException("Could not locate flying packet"); + return idlePacket2; } @@ -112,7 +113,15 @@ public class BukkitViaMovementTransmitter extends MovementTransmitterProvider { } } } else { - super.sendPlayer(info); + ChannelHandlerContext context = PipelineUtil.getContextBefore("decoder", info.getChannel().pipeline()); + if (context != null) { + if (info.get(MovementTracker.class).isGround()) { + context.fireChannelRead(getGroundPacket()); + } else { + context.fireChannelRead(getFlyingPacket()); + } + info.get(MovementTracker.class).incrementIdlePacket(); + } } } } diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaLoader.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaLoader.java index 307122255..932ca548f 100644 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaLoader.java +++ b/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaLoader.java @@ -28,12 +28,10 @@ import com.viaversion.viaversion.bungee.listeners.UpdateListener; import com.viaversion.viaversion.bungee.providers.BungeeBossBarProvider; import com.viaversion.viaversion.bungee.providers.BungeeEntityIdProvider; import com.viaversion.viaversion.bungee.providers.BungeeMainHandProvider; -import com.viaversion.viaversion.bungee.providers.BungeeMovementTransmitter; import com.viaversion.viaversion.bungee.providers.BungeeVersionProvider; import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.BossBarProvider; import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.EntityIdProvider; import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MainHandProvider; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -71,7 +69,6 @@ public class BungeeViaLoader implements ViaPlatformLoader { Via.getManager().getProviders().use(EntityIdProvider.class, new BungeeEntityIdProvider()); if (Via.getAPI().getServerVersion().lowestSupportedVersion() < ProtocolVersion.v1_9.getVersion()) { - Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter()); Via.getManager().getProviders().use(BossBarProvider.class, new BungeeBossBarProvider()); Via.getManager().getProviders().use(MainHandProvider.class, new BungeeMainHandProvider()); } diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeMovementTransmitter.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeMovementTransmitter.java deleted file mode 100644 index e4f4511e4..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeMovementTransmitter.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2023 ViaVersion 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 com.viaversion.viaversion.bungee.providers; - -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; -import com.viaversion.viaversion.api.protocol.packet.State; -import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.MovementTracker; - -public class BungeeMovementTransmitter extends MovementTransmitterProvider { - @Override - public Object getFlyingPacket() { - return null; - } - - @Override - public Object getGroundPacket() { - return null; - } - - public void sendPlayer(UserConnection userConnection) { - if (userConnection.getProtocolInfo().getState() == State.PLAY && userConnection.getEntityTracker(Protocol1_9To1_8.class).clientEntityId() != -1) { - PacketWrapper wrapper = PacketWrapper.create(ServerboundPackets1_8.PLAYER_MOVEMENT, null, userConnection); - MovementTracker tracker = userConnection.get(MovementTracker.class); - wrapper.write(Type.BOOLEAN, tracker.isGround()); - try { - wrapper.scheduleSendToServer(Protocol1_9To1_8.class); - } catch (Exception e) { - e.printStackTrace(); - } - tracker.incrementIdlePacket(); - } - } -} diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/Protocol1_9To1_8.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/Protocol1_9To1_8.java index d0cad81fa..ad65c29ee 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/Protocol1_9To1_8.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/Protocol1_9To1_8.java @@ -37,13 +37,7 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.InventoryPac import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.PlayerPackets; import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.SpawnPackets; import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.WorldPackets; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.BossBarProvider; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.CommandBlockProvider; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.CompressionProvider; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.EntityIdProvider; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemProvider; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MainHandProvider; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider; +import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.*; import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.ClientChunks; import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.CommandBlockStorage; import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9; @@ -137,7 +131,7 @@ public class Protocol1_9To1_8 extends AbstractProtocol. - */ -package com.viaversion.viaversion.velocity.providers; - -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; -import com.viaversion.viaversion.api.protocol.packet.State; -import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.MovementTracker; - -public class VelocityMovementTransmitter extends MovementTransmitterProvider { - @Override - public Object getFlyingPacket() { - return null; - } - - @Override - public Object getGroundPacket() { - return null; - } - - public void sendPlayer(UserConnection userConnection) { - if (userConnection.getProtocolInfo().getState() == State.PLAY && userConnection.getEntityTracker(Protocol1_9To1_8.class).clientEntityId() != -1) { - PacketWrapper wrapper = PacketWrapper.create(ServerboundPackets1_8.PLAYER_MOVEMENT, null, userConnection); - MovementTracker tracker = userConnection.get(MovementTracker.class); - wrapper.write(Type.BOOLEAN, tracker.isGround()); - try { - wrapper.scheduleSendToServer(Protocol1_9To1_8.class); - } catch (Exception e) { - e.printStackTrace(); - } - tracker.incrementIdlePacket(); - } - } -}