Check player position on state change
The map region change is triggered when a game starts loading new regions, but that doesn't necessarily mean the player is in the correct region. Additionally the currently loaded regions reveal very little information about where a player is actually located. Instead of relying on this event, the plugin now listens to game state changes, which are triggered for player region changes. When that happens, the plugin checks player region against the actual kingdom regions (2 in total).
This commit is contained in:
@@ -24,8 +24,8 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.kingdomofmiscellania;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.google.common.primitives.Ints;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
@@ -34,7 +34,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.events.MapRegionChanged;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.VarbitChanged;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
@@ -47,7 +47,7 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
@Slf4j
|
||||
public class KingdomPlugin extends Plugin
|
||||
{
|
||||
private static final int[] KINGDOM_REGION = {9787, 9788, 9789, 10043, 10044, 10045, 10299, 10300, 10301};
|
||||
private static final ImmutableSet<Integer> KINGDOM_REGION = ImmutableSet.of(10044, 10300);
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
@@ -85,9 +85,12 @@ public class KingdomPlugin extends Plugin
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onRegionChanged(MapRegionChanged event)
|
||||
public void onGameStateChanged(GameStateChanged event)
|
||||
{
|
||||
processInfobox();
|
||||
if (event.getGameState() == GameState.LOGGED_IN)
|
||||
{
|
||||
processInfobox();
|
||||
}
|
||||
}
|
||||
|
||||
private void processInfobox()
|
||||
@@ -125,7 +128,7 @@ public class KingdomPlugin extends Plugin
|
||||
|
||||
private boolean isInKingdom()
|
||||
{
|
||||
return Ints.indexOf(client.getMapRegions(), KINGDOM_REGION) >= 0;
|
||||
return KINGDOM_REGION.contains(client.getLocalPlayer().getWorldLocation().getRegionID());
|
||||
}
|
||||
|
||||
private boolean hasCompletedQuest()
|
||||
|
||||
Reference in New Issue
Block a user