diff --git a/runelite-api/src/main/java/net/runelite/api/Client.java b/runelite-api/src/main/java/net/runelite/api/Client.java index 14936153d7..1fcff8e9e7 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -35,6 +35,7 @@ import java.util.Set; import javax.annotation.Nonnull; import javax.annotation.Nullable; import net.runelite.api.annotations.Varbit; +import net.runelite.api.annotations.VisibleForDevtools; import net.runelite.api.annotations.VisibleForExternalPlugins; import net.runelite.api.clan.ClanChannel; import net.runelite.api.clan.ClanID; @@ -849,12 +850,21 @@ public interface Client extends OAuthApi, GameEngine int[][] getXteaKeys(); /** - * Gets an array of all client variables. + * Gets an array of all client varplayers. * * @return local player variables */ int[] getVarps(); + /** + * Get an array of all server varplayers. These vars are only + * modified by the server, and so represent the server's idea of + * the varp values. + * @return the server varps + */ + @VisibleForDevtools + int[] getServerVarps(); + /** * Gets an array of all client variables. */ @@ -868,6 +878,17 @@ public interface Client extends OAuthApi, GameEngine */ int getVar(VarPlayer varPlayer); + /** + * Gets the value corresponding to the passed player variable. + * This returns the server's idea of the value, not the client's. This is + * specifically the last value set by the server regardless of changes to + * the var by the client. + * + * @param varPlayer the player variable + * @return the value + */ + int getServerVar(VarPlayer varPlayer); + /** * Gets a value corresponding to the passed varbit. * @@ -879,13 +900,23 @@ public interface Client extends OAuthApi, GameEngine int getVar(@Varbit int varbit); /** - * Gets a value corresponding to the passed varbit. + * Gets the value of the given varbit. * * @param varbit the varbit id * @return the value */ int getVarbitValue(@Varbit int varbit); + /** + * Gets the value of the given varbit. + * This returns the server's idea of the value, not the client's. This is + * specifically the last value set by the server regardless of changes to + * the var by the client. + * @param varbit the varbit id + * @return the value + */ + int getServerVarbitValue(@Varbit int varbit); + /** * Gets an int value corresponding to the passed variable. * @@ -902,6 +933,27 @@ public interface Client extends OAuthApi, GameEngine */ String getVar(VarClientStr varClientStr); + /** + * Gets the value of a given VarPlayer. + * + * @param varpId the VarPlayer id + * @return the value + */ + @VisibleForExternalPlugins + int getVarpValue(int varpId); + + /** + * Gets the value of a given VarPlayer. + * This returns the server's idea of the value, not the client's. This is + * specifically the last value set by the server regardless of changes to + * the var by the client. + * + * @param varpId the VarPlayer id + * @return the value + */ + @VisibleForExternalPlugins + int getServerVarpValue(int varpId); + /** * Gets the value of a given VarClientInt * @@ -967,8 +1019,6 @@ public interface Client extends OAuthApi, GameEngine */ int getVarpValue(int[] varps, int varpId); - int getVarpValue(int i); - /** * Sets the value of a given variable. * diff --git a/runelite-client/src/main/java/net/runelite/client/game/NpcUtil.java b/runelite-client/src/main/java/net/runelite/client/game/NpcUtil.java index ee4f580512..a147c114e4 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/NpcUtil.java +++ b/runelite-client/src/main/java/net/runelite/client/game/NpcUtil.java @@ -26,19 +26,22 @@ package net.runelite.client.game; import java.util.Set; +import javax.annotation.Nullable; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.NPC; import net.runelite.api.NPCComposition; import net.runelite.api.NpcID; import net.runelite.client.RuntimeConfig; import org.apache.commons.lang3.ArrayUtils; +@Singleton public class NpcUtil { private final RuntimeConfig runtimeConfig; @Inject - private NpcUtil(RuntimeConfig runtimeConfig) + private NpcUtil(@Nullable RuntimeConfig runtimeConfig) { this.runtimeConfig = runtimeConfig; } @@ -92,10 +95,13 @@ public class NpcUtil case NpcID.KALPHITE_QUEEN_963: // KQ's first form sometimes regenerates 1hp after reaching 0hp, thus not dying return false; default: - Set ignoredNpcs = runtimeConfig.getIgnoreDeadNpcs(); - if (ignoredNpcs != null && ignoredNpcs.contains(id)) + if (runtimeConfig != null) { - return false; + Set ignoredNpcs = runtimeConfig.getIgnoreDeadNpcs(); + if (ignoredNpcs != null && ignoredNpcs.contains(id)) + { + return false; + } } final NPCComposition npcComposition = npc.getTransformedComposition(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java index 94290b1c32..9f83be669c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java @@ -223,7 +223,7 @@ public class XpDropPlugin extends Plugin { for (XpPrayer prayer : XpPrayer.values()) { - if (client.isPrayerActive(prayer.getPrayer())) + if (client.getServerVarbitValue(prayer.getPrayer().getVarbit()) == 1) { return prayer.getType(); }