Merge pull request #5982 from deathbeam/skill-lookup-varbit
Move local player hiscore type check to client thread
This commit is contained in:
@@ -183,6 +183,7 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener
|
|||||||
|
|
||||||
String message = setMessage.getValue();
|
String message = setMessage.getValue();
|
||||||
MessageNode messageNode = setMessage.getMessageNode();
|
MessageNode messageNode = setMessage.getMessageNode();
|
||||||
|
HiscoreEndpoint localEndpoint = getHiscoreEndpointType();
|
||||||
|
|
||||||
// clear RuneLite formatted message as the message node is
|
// clear RuneLite formatted message as the message node is
|
||||||
// being reused
|
// being reused
|
||||||
@@ -191,7 +192,7 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener
|
|||||||
if (config.lvl() && message.toLowerCase().equals(TOTAL_LEVEL_COMMAND_STRING))
|
if (config.lvl() && message.toLowerCase().equals(TOTAL_LEVEL_COMMAND_STRING))
|
||||||
{
|
{
|
||||||
log.debug("Running total level lookup");
|
log.debug("Running total level lookup");
|
||||||
executor.submit(() -> playerSkillLookup(setMessage, "total"));
|
executor.submit(() -> playerSkillLookup(setMessage, localEndpoint, "total"));
|
||||||
}
|
}
|
||||||
else if (config.lvl() && message.toLowerCase().equals(CMB_COMMAND_STRING))
|
else if (config.lvl() && message.toLowerCase().equals(CMB_COMMAND_STRING))
|
||||||
{
|
{
|
||||||
@@ -210,19 +211,19 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener
|
|||||||
String search = message.substring(LEVEL_COMMAND_STRING.length() + 1);
|
String search = message.substring(LEVEL_COMMAND_STRING.length() + 1);
|
||||||
|
|
||||||
log.debug("Running level lookup for {}", search);
|
log.debug("Running level lookup for {}", search);
|
||||||
executor.submit(() -> playerSkillLookup(setMessage, search));
|
executor.submit(() -> playerSkillLookup(setMessage, localEndpoint, search));
|
||||||
}
|
}
|
||||||
else if (config.clue() && message.toLowerCase().equals(CLUES_COMMAND_STRING))
|
else if (config.clue() && message.toLowerCase().equals(CLUES_COMMAND_STRING))
|
||||||
{
|
{
|
||||||
log.debug("Running lookup for overall clues");
|
log.debug("Running lookup for overall clues");
|
||||||
executor.submit(() -> playerClueLookup(setMessage, "total"));
|
executor.submit(() -> playerClueLookup(setMessage, localEndpoint, "total"));
|
||||||
}
|
}
|
||||||
else if (config.clue() && message.toLowerCase().startsWith(CLUES_COMMAND_STRING + " "))
|
else if (config.clue() && message.toLowerCase().startsWith(CLUES_COMMAND_STRING + " "))
|
||||||
{
|
{
|
||||||
String search = message.substring(CLUES_COMMAND_STRING.length() + 1);
|
String search = message.substring(CLUES_COMMAND_STRING.length() + 1);
|
||||||
|
|
||||||
log.debug("Running clue lookup for {}", search);
|
log.debug("Running clue lookup for {}", search);
|
||||||
executor.submit(() -> playerClueLookup(setMessage, search));
|
executor.submit(() -> playerClueLookup(setMessage, localEndpoint, search));
|
||||||
}
|
}
|
||||||
else if (config.killcount() && message.toLowerCase().startsWith(KILLCOUNT_COMMAND_STRING + " "))
|
else if (config.killcount() && message.toLowerCase().startsWith(KILLCOUNT_COMMAND_STRING + " "))
|
||||||
{
|
{
|
||||||
@@ -499,9 +500,10 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener
|
|||||||
* response.
|
* response.
|
||||||
*
|
*
|
||||||
* @param setMessage The chat message containing the command.
|
* @param setMessage The chat message containing the command.
|
||||||
|
* @param local HiscoreEndpoint for local player, needs to be sent in advance to avoid threading bugs
|
||||||
* @param search The item given with the command.
|
* @param search The item given with the command.
|
||||||
*/
|
*/
|
||||||
private void playerSkillLookup(SetMessage setMessage, String search)
|
private void playerSkillLookup(SetMessage setMessage, HiscoreEndpoint local, String search)
|
||||||
{
|
{
|
||||||
search = SkillAbbreviations.getFullName(search);
|
search = SkillAbbreviations.getFullName(search);
|
||||||
final HiscoreSkill skill;
|
final HiscoreSkill skill;
|
||||||
@@ -514,7 +516,7 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final HiscoreLookup lookup = getCorrectLookupFor(setMessage);
|
final HiscoreLookup lookup = getCorrectLookupFor(setMessage, local);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -638,9 +640,9 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener
|
|||||||
* for the requested clue-level (no arg if requesting total)
|
* for the requested clue-level (no arg if requesting total)
|
||||||
* easy, medium, hard, elite, master
|
* easy, medium, hard, elite, master
|
||||||
*/
|
*/
|
||||||
private void playerClueLookup(SetMessage setMessage, String search)
|
private void playerClueLookup(SetMessage setMessage, HiscoreEndpoint local, String search)
|
||||||
{
|
{
|
||||||
final HiscoreLookup lookup = getCorrectLookupFor(setMessage);
|
final HiscoreLookup lookup = getCorrectLookupFor(setMessage, local);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -717,9 +719,10 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener
|
|||||||
* Gets correct lookup data for message
|
* Gets correct lookup data for message
|
||||||
*
|
*
|
||||||
* @param setMessage chat message
|
* @param setMessage chat message
|
||||||
|
* @param local HiscoreEndpoint for local player, needs to be sent in advance to avoid threading bugs
|
||||||
* @return hiscore lookup data
|
* @return hiscore lookup data
|
||||||
*/
|
*/
|
||||||
private HiscoreLookup getCorrectLookupFor(final SetMessage setMessage)
|
private HiscoreLookup getCorrectLookupFor(final SetMessage setMessage, final HiscoreEndpoint local)
|
||||||
{
|
{
|
||||||
final String player;
|
final String player;
|
||||||
final HiscoreEndpoint ironmanStatus;
|
final HiscoreEndpoint ironmanStatus;
|
||||||
@@ -727,7 +730,7 @@ public class ChatCommandsPlugin extends Plugin implements ChatboxInputListener
|
|||||||
if (setMessage.getType().equals(ChatMessageType.PRIVATE_MESSAGE_SENT))
|
if (setMessage.getType().equals(ChatMessageType.PRIVATE_MESSAGE_SENT))
|
||||||
{
|
{
|
||||||
player = client.getLocalPlayer().getName();
|
player = client.getLocalPlayer().getName();
|
||||||
ironmanStatus = getHiscoreEndpointType();
|
ironmanStatus = local;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user