use of com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.MovementTracker in project DirtMultiversion by DirtPowered.
the class ViaPlugin method tick.
@Override
public void tick() {
for (UserData userData : api.getAllConnections()) {
ProtocolStorage s = userData.getProtocolStorage();
if (!s.hasObject(PlayerMovementTracker.class))
return;
PlayerMovementTracker movementTracker = s.get(PlayerMovementTracker.class);
if ((System.currentTimeMillis() - movementTracker.getLastLocationUpdate()) >= 50) {
if (userData.getUniqueId() == null)
return;
UserConnection userConnection = connectionManager.getConnectedClient(userData.getUniqueId());
if (userConnection == null)
return;
ProtocolInfo protocolInfo = userConnection.getProtocolInfo();
if (protocolInfo == null)
return;
if (protocolInfo.getPipeline().contains(Protocol1_9To1_8.class) && protocolInfo.getState() == State.PLAY) {
PacketWrapper wrapper = new PacketWrapperImpl(0x03, null, userConnection);
wrapper.write(Type.BOOLEAN, true);
try {
wrapper.sendToServer(Protocol1_9To1_8.class, true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
use of com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.MovementTracker in project ViaVersion by ViaVersion.
the class PlayerMovementMapper method handle.
@Override
public void handle(PacketWrapper wrapper) throws Exception {
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));
}
}
use of com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.MovementTracker in project ViaVersion by ViaVersion.
the class ViaIdleThread method run.
@Override
public void run() {
for (UserConnection info : Via.getManager().getConnectionManager().getConnections()) {
ProtocolInfo protocolInfo = info.getProtocolInfo();
if (protocolInfo == null || !protocolInfo.getPipeline().contains(Protocol1_9To1_8.class))
continue;
MovementTracker movementTracker = info.get(MovementTracker.class);
if (movementTracker == null)
continue;
long nextIdleUpdate = movementTracker.getNextIdlePacket();
if (nextIdleUpdate <= System.currentTimeMillis() && info.getChannel().isOpen()) {
Via.getManager().getProviders().get(MovementTransmitterProvider.class).sendPlayer(info);
}
}
}
use of com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.MovementTracker in project ViaVersion by ViaVersion.
the class VelocityMovementTransmitter method sendPlayer.
public void sendPlayer(UserConnection userConnection) {
if (userConnection.getProtocolInfo().getState() == State.PLAY) {
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();
}
}
use of com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.MovementTracker in project ViaVersion by ViaVersion.
the class BungeeMovementTransmitter method sendPlayer.
public void sendPlayer(UserConnection userConnection) {
if (userConnection.getProtocolInfo().getState() == State.PLAY) {
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();
}
}
Aggregations