Skip to content

Commit

Permalink
attach command debugging and auto-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Mar 3, 2021
1 parent cb2c6bd commit 21a1c16
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Expand Up @@ -47,12 +47,16 @@ public void startTask() {
checkTask.cancel();
}
BukkitRunnable runnable = new BukkitRunnable() {
int ticks = 0;
@Override
public void run() {
if (!attached.isValid() || !to.isValid()) {
cancelAndRemove();
return;
}
if (ticks++ >= 20 * 10) { // Run a forcetele every 10 seconds to guarantee sync
visiblePositions.clear();
}
if (syncServer) {
Location goal = to.getLocation();
if (positionalOffset != null) {
Expand Down
Expand Up @@ -427,6 +427,9 @@ else if (isRotate) {
POS_Z_PACKTELENT.setDouble(newTeleportPacket, goalPosition.getZ());
YAW_PACKTELENT.setByte(newTeleportPacket, yaw);
PITCH_PACKTELENT.setByte(newTeleportPacket, pitch);
if (NMSHandler.debugPackets) {
Debug.log("Attach Move-Tele Packet: " + newTeleportPacket.getClass().getCanonicalName() + " for " + att.attached.getUUID() + " sent to " + player.getName());
}
oldManager.sendPacket(newTeleportPacket);
}
else {
Expand All @@ -437,10 +440,16 @@ else if (isRotate) {
YAW_PACKENT.setByte(pNew, yaw);
PITCH_PACKENT.setByte(pNew, pitch);
}
if (NMSHandler.debugPackets) {
Debug.log("Attach Move Packet: " + pNew.getClass().getCanonicalName() + " for " + att.attached.getUUID() + " sent to " + player.getName());
}
oldManager.sendPacket(pNew);
}
}
else {
if (NMSHandler.debugPackets) {
Debug.log("Attach Replica-Move Packet: " + pNew.getClass().getCanonicalName() + " for " + att.attached.getUUID() + " sent to " + player.getName());
}
oldManager.sendPacket(pNew);
}
}
Expand All @@ -461,6 +470,9 @@ public void tryProcessVelocityPacketForAttach(Packet<?> packet, Entity e) throws
if (attMap.attached.isValid() && att != null) {
Packet pNew = (Packet) duplo(packet);
ENTITY_ID_PACKVELENT.setInt(pNew, att.attached.getBukkitEntity().getEntityId());
if (NMSHandler.debugPackets) {
Debug.log("Attach Velocity Packet: " + pNew.getClass().getCanonicalName() + " for " + att.attached.getUUID() + " sent to " + player.getName());
}
oldManager.sendPacket(pNew);
}
}
Expand Down Expand Up @@ -502,6 +514,9 @@ public void tryProcessTeleportPacketForAttach(Packet<?> packet, Entity e, Vector
PITCH_PACKTELENT.setByte(pNew, pitch);
}
att.visiblePositions.put(player.getUniqueID(), resultPos.clone());
if (NMSHandler.debugPackets) {
Debug.log("Attach Teleport Packet: " + pNew.getClass().getCanonicalName() + " for " + att.attached.getUUID() + " sent to " + player.getName());
}
oldManager.sendPacket(pNew);
}
}
Expand Down

0 comments on commit 21a1c16

Please sign in to comment.