Daily Task Indicators: delay the varbit check to allow them to initialize

This commit is contained in:
user35557
2018-05-23 16:23:02 +03:00
committed by Adam
parent a56c32f8ae
commit da55841b16

View File

@@ -32,10 +32,10 @@ import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.Varbits;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick;
import net.runelite.client.chat.ChatColor;
import net.runelite.client.chat.ChatColorType;
import net.runelite.client.chat.ChatMessageBuilder;
@@ -61,7 +61,7 @@ public class DailyTasksPlugin extends Plugin
@Inject
private ChatMessageManager chatMessageManager;
private boolean hasSentHerbMsg, hasSentStavesMsg, hasSentEssenceMsg;
private boolean hasSentHerbMsg, hasSentStavesMsg, hasSentEssenceMsg, check;
@Provides
DailyTasksConfig provideConfig(ConfigManager configManager)
@@ -105,23 +105,42 @@ public class DailyTasksPlugin extends Plugin
@Subscribe
public void onGameStateChanged(GameStateChanged event)
{
if (event.getGameState().equals(GameState.LOGGED_IN))
switch (event.getGameState())
{
if (config.showHerbBoxes() && !hasSentHerbMsg && checkCanCollectHerbBox())
{
sendChatMessage("You have herb boxes waiting to be collected at NMZ.");
hasSentHerbMsg = true;
}
if (config.showStaves() && !hasSentStavesMsg && checkCanCollectStaves())
{
sendChatMessage("You have staves waiting to be collected from Zaff.");
hasSentStavesMsg = true;
}
if (config.showEssence() && !hasSentEssenceMsg && checkCanCollectEssence())
{
sendChatMessage("You have pure essence waiting to be collected from Wizard Cromperty.");
hasSentEssenceMsg = true;
}
case HOPPING:
case LOGGED_IN:
//load the varbits on first available tick
check = true;
break;
}
}
@Subscribe
public void onGameTick(GameTick event)
{
if (!check)
{
return;
}
check = false;
if (config.showHerbBoxes() && !hasSentHerbMsg && checkCanCollectHerbBox())
{
sendChatMessage("You have herb boxes waiting to be collected at NMZ.");
hasSentHerbMsg = true;
}
if (config.showStaves() && !hasSentStavesMsg && checkCanCollectStaves())
{
sendChatMessage("You have staves waiting to be collected from Zaff.");
hasSentStavesMsg = true;
}
if (config.showEssence() && !hasSentEssenceMsg && checkCanCollectEssence())
{
sendChatMessage("You have pure essence waiting to be collected from Wizard Cromperty.");
hasSentEssenceMsg = true;
}
}