party: only send location update when the location changes

This commit is contained in:
Adam
2021-05-16 15:19:49 -04:00
parent 8450795bab
commit d97148346d

View File

@@ -153,6 +153,7 @@ public class PartyPlugin extends Plugin
private int lastHp, lastPray; private int lastHp, lastPray;
private String lastCharacterName = ""; private String lastCharacterName = "";
private WorldPoint lastLocation;
private boolean sendAlert; private boolean sendAlert;
@Override @Override
@@ -204,6 +205,7 @@ public class PartyPlugin extends Plugin
wsClient.unregisterMessage(LocationUpdate.class); wsClient.unregisterMessage(LocationUpdate.class);
wsClient.unregisterMessage(CharacterNameUpdate.class); wsClient.unregisterMessage(CharacterNameUpdate.class);
sendAlert = false; sendAlert = false;
lastLocation = null;
} }
@Provides @Provides
@@ -348,7 +350,15 @@ public class PartyPlugin extends Plugin
return; return;
} }
final LocationUpdate locationUpdate = new LocationUpdate(client.getLocalPlayer().getWorldLocation()); WorldPoint location = client.getLocalPlayer().getWorldLocation();
if (location.equals(lastLocation))
{
return;
}
lastLocation = location;
final LocationUpdate locationUpdate = new LocationUpdate(location);
locationUpdate.setMemberId(localMember.getMemberId()); locationUpdate.setMemberId(localMember.getMemberId());
wsClient.send(locationUpdate); wsClient.send(locationUpdate);
} }
@@ -463,6 +473,7 @@ public class PartyPlugin extends Plugin
public void onUserSync(final UserSync event) public void onUserSync(final UserSync event)
{ {
checkStateChanged(true); checkStateChanged(true);
lastLocation = null;
} }
private void checkStateChanged(boolean forceSend) private void checkStateChanged(boolean forceSend)