Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-09-08 22:02:50 +02:00
Thanks @jollyolbrits for debugging, fix the issue with ground not being sent properly for movement.
Fixes anti-cheat issues. Placement issues. Probably 100 billion other issues. Fix me being an idiot and changing numbers.
Dieser Commit ist enthalten in:
Ursprung
a3db32758c
Commit
3498d093b0
@ -3,6 +3,7 @@ package us.myles.ViaVersion.protocols.protocol1_9to1_8;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.MovementTracker;
|
||||
|
||||
public class PlayerMovementMapper extends PacketRemapper {
|
||||
@ -11,7 +12,12 @@ public class PlayerMovementMapper extends PacketRemapper {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.user().get(MovementTracker.class).incrementIdlePacket();
|
||||
MovementTracker tracker = wrapper.user().get(MovementTracker.class);
|
||||
tracker.incrementIdlePacket();
|
||||
// If packet has the ground data
|
||||
if (wrapper.is(Type.BOOLEAN, 0)) {
|
||||
tracker.setGround(wrapper.get(Type.BOOLEAN, 0));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -4,24 +4,31 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.MovementTracker;
|
||||
import us.myles.ViaVersion.util.PipelineUtil;
|
||||
import us.myles.ViaVersion.util.ReflectionUtil;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ViaIdleThread extends BukkitRunnable {
|
||||
private final Map<UUID, UserConnection> portedPlayers;
|
||||
private final Object idlePacket;
|
||||
private final Object idlePacket2;
|
||||
|
||||
public ViaIdleThread(Map<UUID, UserConnection> portedPlayers) {
|
||||
this.portedPlayers = portedPlayers;
|
||||
try {
|
||||
Class<?> idlePacketClass = ReflectionUtil.nms("PacketPlayInFlying");
|
||||
idlePacket = idlePacketClass.newInstance();
|
||||
} catch (InstantiationException | IllegalArgumentException | IllegalAccessException | ClassNotFoundException e) {
|
||||
idlePacket2 = idlePacketClass.newInstance();
|
||||
|
||||
Field flying = idlePacketClass.getDeclaredField("f");
|
||||
flying.setAccessible(true);
|
||||
|
||||
flying.set(idlePacket2, true);
|
||||
} catch (NoSuchFieldException | InstantiationException | IllegalArgumentException | IllegalAccessException | ClassNotFoundException e) {
|
||||
throw new RuntimeException("Couldn't find/make player idle packet, help!", e);
|
||||
}
|
||||
}
|
||||
@ -35,8 +42,11 @@ public class ViaIdleThread extends BukkitRunnable {
|
||||
ChannelHandlerContext context = PipelineUtil.getContextBefore("decoder", info.getChannel().pipeline());
|
||||
if (info.getChannel().isOpen()) {
|
||||
if (context != null) {
|
||||
context.fireChannelRead(idlePacket);
|
||||
|
||||
if (info.get(MovementTracker.class).isGround()) {
|
||||
context.fireChannelRead(idlePacket2);
|
||||
} else {
|
||||
context.fireChannelRead(idlePacket);
|
||||
}
|
||||
info.get(MovementTracker.class).incrementIdlePacket();
|
||||
}
|
||||
}
|
||||
|
@ -232,12 +232,8 @@ public class WorldPackets {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int status = wrapper.get(Type.UNSIGNED_BYTE, 0);
|
||||
if (status == 5)
|
||||
if (status == 4)
|
||||
wrapper.cancel();
|
||||
if(status > 5){
|
||||
wrapper.set(Type.UNSIGNED_BYTE, 0, (short) (status - 1));
|
||||
}
|
||||
System.out.println("SENDING ID: " + wrapper.get(Type.UNSIGNED_BYTE, 0));
|
||||
}
|
||||
});
|
||||
// Blocking
|
||||
@ -245,7 +241,7 @@ public class WorldPackets {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int status = wrapper.get(Type.UNSIGNED_BYTE, 0);
|
||||
if (status == 5) {
|
||||
if (status == 4) {
|
||||
EntityTracker entityTracker = wrapper.user().get(EntityTracker.class);
|
||||
if (entityTracker.isBlocking()) {
|
||||
entityTracker.setBlocking(false);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import us.myles.ViaVersion.api.data.StoredObject;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
|
||||
@ -9,6 +10,9 @@ public class MovementTracker extends StoredObject {
|
||||
private static final long IDLE_PACKET_LIMIT = 20; // Max 20 ticks behind
|
||||
@Getter
|
||||
private long nextIdlePacket = 0L;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean ground = true;
|
||||
|
||||
public MovementTracker(UserConnection user) {
|
||||
super(user);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren