Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Remove requirement for MovementTransmitterProvider (#3355)
Dieser Commit ist enthalten in:
Ursprung
408392e796
Commit
a817746edc
@ -25,6 +25,9 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.MovementTrac
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.util.PipelineUtil;
|
||||||
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -79,17 +82,15 @@ public class BukkitViaMovementTransmitter extends MovementTransmitterProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getFlyingPacket() {
|
public Object getFlyingPacket() {
|
||||||
if (idlePacket == null)
|
if (idlePacket == null) throw new NullPointerException("Could not locate flying packet");
|
||||||
throw new NullPointerException("Could not locate flying packet");
|
|
||||||
return idlePacket;
|
return idlePacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getGroundPacket() {
|
public Object getGroundPacket() {
|
||||||
if (idlePacket == null)
|
if (idlePacket == null) throw new NullPointerException("Could not locate flying packet");
|
||||||
throw new NullPointerException("Could not locate flying packet");
|
|
||||||
return idlePacket2;
|
return idlePacket2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +113,15 @@ public class BukkitViaMovementTransmitter extends MovementTransmitterProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,12 +28,10 @@ import com.viaversion.viaversion.bungee.listeners.UpdateListener;
|
|||||||
import com.viaversion.viaversion.bungee.providers.BungeeBossBarProvider;
|
import com.viaversion.viaversion.bungee.providers.BungeeBossBarProvider;
|
||||||
import com.viaversion.viaversion.bungee.providers.BungeeEntityIdProvider;
|
import com.viaversion.viaversion.bungee.providers.BungeeEntityIdProvider;
|
||||||
import com.viaversion.viaversion.bungee.providers.BungeeMainHandProvider;
|
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.bungee.providers.BungeeVersionProvider;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.BossBarProvider;
|
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.EntityIdProvider;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MainHandProvider;
|
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.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -71,7 +69,6 @@ public class BungeeViaLoader implements ViaPlatformLoader {
|
|||||||
Via.getManager().getProviders().use(EntityIdProvider.class, new BungeeEntityIdProvider());
|
Via.getManager().getProviders().use(EntityIdProvider.class, new BungeeEntityIdProvider());
|
||||||
|
|
||||||
if (Via.getAPI().getServerVersion().lowestSupportedVersion() < ProtocolVersion.v1_9.getVersion()) {
|
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(BossBarProvider.class, new BungeeBossBarProvider());
|
||||||
Via.getManager().getProviders().use(MainHandProvider.class, new BungeeMainHandProvider());
|
Via.getManager().getProviders().use(MainHandProvider.class, new BungeeMainHandProvider());
|
||||||
}
|
}
|
||||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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.PlayerPackets;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.SpawnPackets;
|
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.packets.WorldPackets;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.BossBarProvider;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.*;
|
||||||
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.storage.ClientChunks;
|
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.CommandBlockStorage;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
|
||||||
@ -137,7 +131,7 @@ public class Protocol1_9To1_8 extends AbstractProtocol<ClientboundPackets1_8, Cl
|
|||||||
providers.register(BossBarProvider.class, new BossBarProvider());
|
providers.register(BossBarProvider.class, new BossBarProvider());
|
||||||
providers.register(MainHandProvider.class, new MainHandProvider());
|
providers.register(MainHandProvider.class, new MainHandProvider());
|
||||||
providers.register(CompressionProvider.class, new CompressionProvider());
|
providers.register(CompressionProvider.class, new CompressionProvider());
|
||||||
providers.require(MovementTransmitterProvider.class);
|
providers.register(MovementTransmitterProvider.class, new MovementTransmitterProvider());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,27 +17,34 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_9to1_8.providers;
|
package com.viaversion.viaversion.protocols.protocol1_9to1_8.providers;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.platform.providers.Provider;
|
import com.viaversion.viaversion.api.platform.providers.Provider;
|
||||||
|
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.storage.MovementTracker;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.MovementTracker;
|
||||||
import com.viaversion.viaversion.util.PipelineUtil;
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
|
||||||
|
|
||||||
public abstract class MovementTransmitterProvider implements Provider {
|
import java.util.logging.Level;
|
||||||
public abstract Object getFlyingPacket();
|
|
||||||
|
|
||||||
public abstract Object getGroundPacket();
|
public class MovementTransmitterProvider implements Provider {
|
||||||
|
|
||||||
public void sendPlayer(UserConnection userConnection) {
|
public void sendPlayer(UserConnection userConnection) {
|
||||||
// Old method using packets.
|
if (userConnection.getProtocolInfo().getState() != State.PLAY || userConnection.getEntityTracker(Protocol1_9To1_8.class).clientEntityId() == -1) {
|
||||||
ChannelHandlerContext context = PipelineUtil.getContextBefore("decoder", userConnection.getChannel().pipeline());
|
return;
|
||||||
if (context != null) {
|
}
|
||||||
if (userConnection.get(MovementTracker.class).isGround()) {
|
|
||||||
context.fireChannelRead(getGroundPacket());
|
final MovementTracker movementTracker = userConnection.get(MovementTracker.class);
|
||||||
} else {
|
movementTracker.incrementIdlePacket();
|
||||||
context.fireChannelRead(getFlyingPacket());
|
|
||||||
}
|
try {
|
||||||
userConnection.get(MovementTracker.class).incrementIdlePacket();
|
final PacketWrapper playerMovement = PacketWrapper.create(ServerboundPackets1_8.PLAYER_MOVEMENT, userConnection);
|
||||||
|
playerMovement.write(Type.BOOLEAN, movementTracker.isGround()); // on ground
|
||||||
|
playerMovement.scheduleSendToServer(Protocol1_9To1_8.class);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Via.getPlatform().getLogger().log(Level.WARNING, "Failed to send player movement packet", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,8 @@ import com.viaversion.viaversion.api.platform.ViaPlatformLoader;
|
|||||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.BossBarProvider;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.BossBarProvider;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
|
||||||
import com.viaversion.viaversion.velocity.listeners.UpdateListener;
|
import com.viaversion.viaversion.velocity.listeners.UpdateListener;
|
||||||
import com.viaversion.viaversion.velocity.providers.VelocityBossBarProvider;
|
import com.viaversion.viaversion.velocity.providers.VelocityBossBarProvider;
|
||||||
import com.viaversion.viaversion.velocity.providers.VelocityMovementTransmitter;
|
|
||||||
import com.viaversion.viaversion.velocity.providers.VelocityVersionProvider;
|
import com.viaversion.viaversion.velocity.providers.VelocityVersionProvider;
|
||||||
|
|
||||||
public class VelocityViaLoader implements ViaPlatformLoader {
|
public class VelocityViaLoader implements ViaPlatformLoader {
|
||||||
@ -38,7 +36,6 @@ public class VelocityViaLoader implements ViaPlatformLoader {
|
|||||||
.getPlugin("viaversion").flatMap(PluginContainer::getInstance).get();
|
.getPlugin("viaversion").flatMap(PluginContainer::getInstance).get();
|
||||||
|
|
||||||
if (Via.getAPI().getServerVersion().lowestSupportedVersion() < ProtocolVersion.v1_9.getVersion()) {
|
if (Via.getAPI().getServerVersion().lowestSupportedVersion() < ProtocolVersion.v1_9.getVersion()) {
|
||||||
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new VelocityMovementTransmitter());
|
|
||||||
Via.getManager().getProviders().use(BossBarProvider.class, new VelocityBossBarProvider());
|
Via.getManager().getProviders().use(BossBarProvider.class, new VelocityBossBarProvider());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren