chatcommands: don't throw every tick if the player has opened a scroll
This interface is used in many other places
This commit is contained in:
@@ -152,7 +152,7 @@ public class WidgetID
|
|||||||
public static final int LMS_GROUP_ID = 333;
|
public static final int LMS_GROUP_ID = 333;
|
||||||
public static final int LMS_INGAME_GROUP_ID = 328;
|
public static final int LMS_INGAME_GROUP_ID = 328;
|
||||||
public static final int ADVENTURE_LOG_ID = 187;
|
public static final int ADVENTURE_LOG_ID = 187;
|
||||||
public static final int COUNTERS_LOG_GROUP_ID = 625;
|
public static final int GENERIC_SCROLL_GROUP_ID = 625;
|
||||||
public static final int GAUNTLET_TIMER_GROUP_ID = 637;
|
public static final int GAUNTLET_TIMER_GROUP_ID = 637;
|
||||||
public static final int BANK_PIN_GROUP_ID = 213;
|
public static final int BANK_PIN_GROUP_ID = 213;
|
||||||
|
|
||||||
@@ -915,9 +915,8 @@ public class WidgetID
|
|||||||
static final int CONTAINER = 0;
|
static final int CONTAINER = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class CountersLog
|
static class GenericScroll
|
||||||
{
|
{
|
||||||
static final int OWNER = 4;
|
|
||||||
static final int TEXT = 6;
|
static final int TEXT = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -488,7 +488,7 @@ public enum WidgetInfo
|
|||||||
|
|
||||||
ADVENTURE_LOG(WidgetID.ADVENTURE_LOG_ID, WidgetID.AdventureLog.CONTAINER),
|
ADVENTURE_LOG(WidgetID.ADVENTURE_LOG_ID, WidgetID.AdventureLog.CONTAINER),
|
||||||
|
|
||||||
COUNTERS_LOG_TEXT(WidgetID.COUNTERS_LOG_GROUP_ID, WidgetID.CountersLog.TEXT),
|
GENERIC_SCROLL_TEXT(WidgetID.GENERIC_SCROLL_GROUP_ID, WidgetID.GenericScroll.TEXT),
|
||||||
|
|
||||||
WORLD_SWITCHER_LIST(WidgetID.WORLD_SWITCHER_GROUP_ID, WidgetID.WorldSwitcher.WORLD_LIST),
|
WORLD_SWITCHER_LIST(WidgetID.WORLD_SWITCHER_GROUP_ID, WidgetID.WorldSwitcher.WORLD_LIST),
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ import net.runelite.api.events.WidgetLoaded;
|
|||||||
import net.runelite.api.vars.AccountType;
|
import net.runelite.api.vars.AccountType;
|
||||||
import net.runelite.api.widgets.Widget;
|
import net.runelite.api.widgets.Widget;
|
||||||
import static net.runelite.api.widgets.WidgetID.ADVENTURE_LOG_ID;
|
import static net.runelite.api.widgets.WidgetID.ADVENTURE_LOG_ID;
|
||||||
import static net.runelite.api.widgets.WidgetID.COUNTERS_LOG_GROUP_ID;
|
import static net.runelite.api.widgets.WidgetID.GENERIC_SCROLL_GROUP_ID;
|
||||||
import static net.runelite.api.widgets.WidgetID.KILL_LOGS_GROUP_ID;
|
import static net.runelite.api.widgets.WidgetID.KILL_LOGS_GROUP_ID;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.client.chat.ChatColorType;
|
import net.runelite.client.chat.ChatColorType;
|
||||||
@@ -132,7 +132,7 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
|
|
||||||
private boolean bossLogLoaded;
|
private boolean bossLogLoaded;
|
||||||
private boolean advLogLoaded;
|
private boolean advLogLoaded;
|
||||||
private boolean countersLogLoaded;
|
private boolean scrollInterfaceLoaded;
|
||||||
private String pohOwner;
|
private String pohOwner;
|
||||||
private HiscoreEndpoint hiscoreEndpoint; // hiscore endpoint for current player
|
private HiscoreEndpoint hiscoreEndpoint; // hiscore endpoint for current player
|
||||||
private String lastBossKill;
|
private String lastBossKill;
|
||||||
@@ -497,36 +497,39 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (countersLogLoaded && pohOwner.equals(client.getLocalPlayer().getName()))
|
if (scrollInterfaceLoaded)
|
||||||
{
|
{
|
||||||
countersLogLoaded = false;
|
scrollInterfaceLoaded = false;
|
||||||
|
|
||||||
String counterText = Text.sanitizeMultilineText(client.getWidget(WidgetInfo.COUNTERS_LOG_TEXT).getText());
|
if (client.getLocalPlayer().getName().equals(pohOwner))
|
||||||
Matcher mCounterText = ADVENTURE_LOG_PB_PATTERN.matcher(counterText);
|
|
||||||
while (mCounterText.find())
|
|
||||||
{
|
{
|
||||||
String bossName = longBossName(mCounterText.group(1));
|
String counterText = Text.sanitizeMultilineText(client.getWidget(WidgetInfo.GENERIC_SCROLL_TEXT).getText());
|
||||||
if (bossName.equalsIgnoreCase("chambers of xeric") ||
|
Matcher mCounterText = ADVENTURE_LOG_PB_PATTERN.matcher(counterText);
|
||||||
bossName.equalsIgnoreCase("chambers of xeric challenge mode"))
|
while (mCounterText.find())
|
||||||
{
|
{
|
||||||
Matcher mCoxRuns = ADVENTURE_LOG_COX_PB_PATTERN.matcher(mCounterText.group());
|
String bossName = longBossName(mCounterText.group(1));
|
||||||
int bestPbTime = Integer.MAX_VALUE;
|
if (bossName.equalsIgnoreCase("chambers of xeric") ||
|
||||||
while (mCoxRuns.find())
|
bossName.equalsIgnoreCase("chambers of xeric challenge mode"))
|
||||||
{
|
{
|
||||||
bestPbTime = Math.min(timeStringToSeconds(mCoxRuns.group(1)), bestPbTime);
|
Matcher mCoxRuns = ADVENTURE_LOG_COX_PB_PATTERN.matcher(mCounterText.group());
|
||||||
|
int bestPbTime = Integer.MAX_VALUE;
|
||||||
|
while (mCoxRuns.find())
|
||||||
|
{
|
||||||
|
bestPbTime = Math.min(timeStringToSeconds(mCoxRuns.group(1)), bestPbTime);
|
||||||
|
}
|
||||||
|
// So we don't reset people's already saved PB's if they had one before the update
|
||||||
|
int currentPb = getPb(bossName);
|
||||||
|
if (currentPb == 0 || currentPb > bestPbTime)
|
||||||
|
{
|
||||||
|
setPb(bossName, bestPbTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// So we don't reset people's already saved PB's if they had one before the update
|
else
|
||||||
int currentPb = getPb(bossName);
|
|
||||||
if (currentPb == 0 || currentPb > bestPbTime)
|
|
||||||
{
|
{
|
||||||
setPb(bossName, bestPbTime);
|
String pbTime = mCounterText.group(2);
|
||||||
|
setPb(bossName, timeStringToSeconds(pbTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
String pbTime = mCounterText.group(2);
|
|
||||||
setPb(bossName, timeStringToSeconds(pbTime));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -542,8 +545,8 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
case KILL_LOGS_GROUP_ID:
|
case KILL_LOGS_GROUP_ID:
|
||||||
bossLogLoaded = true;
|
bossLogLoaded = true;
|
||||||
break;
|
break;
|
||||||
case COUNTERS_LOG_GROUP_ID:
|
case GENERIC_SCROLL_GROUP_ID:
|
||||||
countersLogLoaded = true;
|
scrollInterfaceLoaded = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ import net.runelite.api.events.GameTick;
|
|||||||
import net.runelite.api.events.WidgetLoaded;
|
import net.runelite.api.events.WidgetLoaded;
|
||||||
import net.runelite.api.widgets.Widget;
|
import net.runelite.api.widgets.Widget;
|
||||||
import static net.runelite.api.widgets.WidgetID.ADVENTURE_LOG_ID;
|
import static net.runelite.api.widgets.WidgetID.ADVENTURE_LOG_ID;
|
||||||
import static net.runelite.api.widgets.WidgetID.COUNTERS_LOG_GROUP_ID;
|
import static net.runelite.api.widgets.WidgetID.GENERIC_SCROLL_GROUP_ID;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.client.chat.ChatCommandManager;
|
import net.runelite.client.chat.ChatCommandManager;
|
||||||
import net.runelite.client.chat.ChatMessageManager;
|
import net.runelite.client.chat.ChatMessageManager;
|
||||||
@@ -465,10 +465,10 @@ public class ChatCommandsPluginTest
|
|||||||
|
|
||||||
Widget countersPage = mock(Widget.class);
|
Widget countersPage = mock(Widget.class);
|
||||||
when(countersPage.getText()).thenReturn(COUNTER_TEXT);
|
when(countersPage.getText()).thenReturn(COUNTER_TEXT);
|
||||||
when(client.getWidget(WidgetInfo.COUNTERS_LOG_TEXT)).thenReturn(countersPage);
|
when(client.getWidget(WidgetInfo.GENERIC_SCROLL_TEXT)).thenReturn(countersPage);
|
||||||
|
|
||||||
WidgetLoaded countersLogEvent = new WidgetLoaded();
|
WidgetLoaded countersLogEvent = new WidgetLoaded();
|
||||||
countersLogEvent.setGroupId(COUNTERS_LOG_GROUP_ID);
|
countersLogEvent.setGroupId(GENERIC_SCROLL_GROUP_ID);
|
||||||
chatCommandsPlugin.onWidgetLoaded(countersLogEvent);
|
chatCommandsPlugin.onWidgetLoaded(countersLogEvent);
|
||||||
chatCommandsPlugin.onGameTick(new GameTick());
|
chatCommandsPlugin.onGameTick(new GameTick());
|
||||||
|
|
||||||
@@ -521,10 +521,10 @@ public class ChatCommandsPluginTest
|
|||||||
|
|
||||||
Widget countersPage = mock(Widget.class);
|
Widget countersPage = mock(Widget.class);
|
||||||
when(countersPage.getText()).thenReturn(COUNTER_TEXT);
|
when(countersPage.getText()).thenReturn(COUNTER_TEXT);
|
||||||
when(client.getWidget(WidgetInfo.COUNTERS_LOG_TEXT)).thenReturn(countersPage);
|
when(client.getWidget(WidgetInfo.GENERIC_SCROLL_TEXT)).thenReturn(countersPage);
|
||||||
|
|
||||||
WidgetLoaded countersLogEvent = new WidgetLoaded();
|
WidgetLoaded countersLogEvent = new WidgetLoaded();
|
||||||
countersLogEvent.setGroupId(COUNTERS_LOG_GROUP_ID);
|
countersLogEvent.setGroupId(GENERIC_SCROLL_GROUP_ID);
|
||||||
chatCommandsPlugin.onWidgetLoaded(countersLogEvent);
|
chatCommandsPlugin.onWidgetLoaded(countersLogEvent);
|
||||||
chatCommandsPlugin.onGameTick(new GameTick());
|
chatCommandsPlugin.onGameTick(new GameTick());
|
||||||
|
|
||||||
@@ -555,7 +555,7 @@ public class ChatCommandsPluginTest
|
|||||||
chatCommandsPlugin.onGameTick(new GameTick());
|
chatCommandsPlugin.onGameTick(new GameTick());
|
||||||
|
|
||||||
WidgetLoaded countersLogEvent = new WidgetLoaded();
|
WidgetLoaded countersLogEvent = new WidgetLoaded();
|
||||||
countersLogEvent.setGroupId(COUNTERS_LOG_GROUP_ID);
|
countersLogEvent.setGroupId(GENERIC_SCROLL_GROUP_ID);
|
||||||
chatCommandsPlugin.onWidgetLoaded(countersLogEvent);
|
chatCommandsPlugin.onWidgetLoaded(countersLogEvent);
|
||||||
chatCommandsPlugin.onGameTick(new GameTick());
|
chatCommandsPlugin.onGameTick(new GameTick());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user