woodcutting: account for plane change with despawn events

the server only sends a despawn event when the actual object does
despawn or when you change to that objects level and the server
sends it to sync you with that planes objects.  By setting the current
player plane on gametick and checking that against the despawned objects
plane, and only processing events where they match we can gurantee
that the actual object has just despawned instead of the server sending
the event just to resync the player with the current status of the
location they just entered
This commit is contained in:
Alexsuperfly
2019-12-16 14:55:31 -05:00
parent 510aa63d57
commit cb131029ec

View File

@@ -103,6 +103,7 @@ public class WoodcuttingPlugin extends Plugin
@Getter(AccessLevel.PACKAGE)
private final List<TreeRespawn> respawns = new ArrayList<>();
private boolean recentlyLoggedIn;
private int currentPlane;
@Provides
WoodcuttingConfig getConfig(ConfigManager configManager)
@@ -144,6 +145,7 @@ public class WoodcuttingPlugin extends Plugin
public void onGameTick(GameTick gameTick)
{
recentlyLoggedIn = false;
currentPlane = client.getPlane();
respawns.removeIf(TreeRespawn::isExpired);
@@ -204,7 +206,7 @@ public class WoodcuttingPlugin extends Plugin
Tree tree = Tree.findTree(object.getId());
if (tree != null)
{
if (tree.getRespawnTime() != null && !recentlyLoggedIn)
if (tree.getRespawnTime() != null && !recentlyLoggedIn && currentPlane == object.getPlane())
{
Point max = object.getSceneMaxLocation();
Point min = object.getSceneMinLocation();