From 343793c4a7c7f4f4fa757c46d7d43c1f3a8a90d6 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 21 Jun 2022 12:11:34 -0400 Subject: [PATCH 1/3] npcutil: make rtconfig nullable --- .../java/net/runelite/client/game/NpcUtil.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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(); From 6dcd2afd8bc2358991c4725e7a5052b85edbf07f Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 21 Jun 2022 12:05:56 -0400 Subject: [PATCH 2/3] api: add server varps --- .../main/java/net/runelite/api/Client.java | 46 ++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) 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 95785bea98..b79a416657 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -766,13 +766,22 @@ 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 */ @VisibleForDevtools 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. */ @@ -787,6 +796,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. * @@ -798,13 +818,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. * @@ -830,6 +860,18 @@ public interface Client extends OAuthApi, GameEngine @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 * From 8972a6de25345082ce5748e4a31528ba8079381b Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 21 Jun 2022 12:06:27 -0400 Subject: [PATCH 3/3] xp drops: test server varbit for prayer active check This fixes an issue where the xp drop recoloring would incorrectly recolor the xpdrop if the prayer was flicked on client side in between when the server tick happens and when the xp drop is created --- .../runelite/client/plugins/experiencedrop/XpDropPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 309c308db5..746019990f 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 @@ -181,7 +181,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(); }