Merge remote-tracking branch 'runelite/master'

This commit is contained in:
Owain van Brakel
2022-06-21 23:20:01 +02:00
3 changed files with 65 additions and 9 deletions

View File

@@ -35,6 +35,7 @@ import java.util.Set;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import net.runelite.api.annotations.Varbit; import net.runelite.api.annotations.Varbit;
import net.runelite.api.annotations.VisibleForDevtools;
import net.runelite.api.annotations.VisibleForExternalPlugins; import net.runelite.api.annotations.VisibleForExternalPlugins;
import net.runelite.api.clan.ClanChannel; import net.runelite.api.clan.ClanChannel;
import net.runelite.api.clan.ClanID; import net.runelite.api.clan.ClanID;
@@ -849,12 +850,21 @@ public interface Client extends OAuthApi, GameEngine
int[][] getXteaKeys(); int[][] getXteaKeys();
/** /**
* Gets an array of all client variables. * Gets an array of all client varplayers.
* *
* @return local player variables * @return local player variables
*/ */
int[] getVarps(); 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. * Gets an array of all client variables.
*/ */
@@ -868,6 +878,17 @@ public interface Client extends OAuthApi, GameEngine
*/ */
int getVar(VarPlayer varPlayer); 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. * Gets a value corresponding to the passed varbit.
* *
@@ -879,13 +900,23 @@ public interface Client extends OAuthApi, GameEngine
int getVar(@Varbit int varbit); 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 * @param varbit the varbit id
* @return the value * @return the value
*/ */
int getVarbitValue(@Varbit int varbit); 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. * Gets an int value corresponding to the passed variable.
* *
@@ -902,6 +933,27 @@ public interface Client extends OAuthApi, GameEngine
*/ */
String getVar(VarClientStr varClientStr); 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 * 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[] varps, int varpId);
int getVarpValue(int i);
/** /**
* Sets the value of a given variable. * Sets the value of a given variable.
* *

View File

@@ -26,19 +26,22 @@
package net.runelite.client.game; package net.runelite.client.game;
import java.util.Set; import java.util.Set;
import javax.annotation.Nullable;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.NPC; import net.runelite.api.NPC;
import net.runelite.api.NPCComposition; import net.runelite.api.NPCComposition;
import net.runelite.api.NpcID; import net.runelite.api.NpcID;
import net.runelite.client.RuntimeConfig; import net.runelite.client.RuntimeConfig;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
@Singleton
public class NpcUtil public class NpcUtil
{ {
private final RuntimeConfig runtimeConfig; private final RuntimeConfig runtimeConfig;
@Inject @Inject
private NpcUtil(RuntimeConfig runtimeConfig) private NpcUtil(@Nullable RuntimeConfig runtimeConfig)
{ {
this.runtimeConfig = runtimeConfig; this.runtimeConfig = runtimeConfig;
} }
@@ -92,11 +95,14 @@ public class NpcUtil
case NpcID.KALPHITE_QUEEN_963: // KQ's first form sometimes regenerates 1hp after reaching 0hp, thus not dying case NpcID.KALPHITE_QUEEN_963: // KQ's first form sometimes regenerates 1hp after reaching 0hp, thus not dying
return false; return false;
default: default:
if (runtimeConfig != null)
{
Set<Integer> ignoredNpcs = runtimeConfig.getIgnoreDeadNpcs(); Set<Integer> ignoredNpcs = runtimeConfig.getIgnoreDeadNpcs();
if (ignoredNpcs != null && ignoredNpcs.contains(id)) if (ignoredNpcs != null && ignoredNpcs.contains(id))
{ {
return false; return false;
} }
}
final NPCComposition npcComposition = npc.getTransformedComposition(); final NPCComposition npcComposition = npc.getTransformedComposition();
boolean hasAttack = npcComposition != null && ArrayUtils.contains(npcComposition.getActions(), "Attack"); boolean hasAttack = npcComposition != null && ArrayUtils.contains(npcComposition.getActions(), "Attack");

View File

@@ -223,7 +223,7 @@ public class XpDropPlugin extends Plugin
{ {
for (XpPrayer prayer : XpPrayer.values()) for (XpPrayer prayer : XpPrayer.values())
{ {
if (client.isPrayerActive(prayer.getPrayer())) if (client.getServerVarbitValue(prayer.getPrayer().getVarbit()) == 1)
{ {
return prayer.getType(); return prayer.getType();
} }