Added Foundry Points

This commit is contained in:
Robin Davidsson
2022-07-12 00:43:33 +02:00
parent fbd80428b0
commit 4067c1a9e3
4 changed files with 88 additions and 2 deletions

View File

@@ -10,7 +10,7 @@ repositories {
mavenCentral()
}
def runeLiteVersion = '1.8.24.3'
def runeLiteVersion = '1.8.26'
dependencies {
compileOnly group: 'net.runelite', name:'client', version: runeLiteVersion

View File

@@ -9,6 +9,7 @@ import net.runelite.client.config.ConfigSection;
public interface EasyGiantsFoundryConfig extends Config {
String GROUP = "easygiantsfoundry";
String SOUND_ID = "soundID";
String POINTS_KEY = "easygiantsfoundrypoints";
@ConfigSection(
name = "Notifications",
@@ -219,4 +220,16 @@ public interface EasyGiantsFoundryConfig extends Config {
default boolean drawHeatLeft() {
return true;
}
@ConfigItem(
keyName = "shopPoints",
name = "Shop points",
description = "Toggle for shop points",
position = 5,
section = infoPanelList
)
default boolean drawShopPoints()
{
return false;
}
}

View File

@@ -1,6 +1,7 @@
package com.toofifty.easygiantsfoundry;
import com.google.inject.Provides;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client;
import net.runelite.api.GameObject;
@@ -16,6 +17,7 @@ import net.runelite.api.events.NpcDespawned;
import net.runelite.api.events.NpcSpawned;
import net.runelite.api.events.ScriptPostFired;
import net.runelite.api.events.StatChanged;
import net.runelite.api.widgets.Widget;
import net.runelite.client.Notifier;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.eventbus.Subscribe;
@@ -25,8 +27,11 @@ import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.config.ConfigManager;
import com.toofifty.easygiantsfoundry.enums.Stage;
import net.runelite.client.util.Text;
import javax.inject.Inject;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Slf4j
@PluginDescriptor(
@@ -49,6 +54,21 @@ public class EasyGiantsFoundryPlugin extends Plugin
private static final int PREFORM = 27010;
private static final int SHOP_WIDGET = 753;
private static final int CHAT_WIDGET = 229;
private static final int SHOP_POINTS_TEXT = 13;
private static final int CHAT_POINTS_TEXT = 1;
private static final Pattern pattern = Pattern.compile("quality: (?<points>\\d+) Best");
@Getter
private int shopPoints;
private boolean increasePoints = false;
private Stage oldStage;
private int lastBoost;
@@ -85,6 +105,9 @@ public class EasyGiantsFoundryPlugin extends Plugin
@Inject
private ClientThread clientThread;
@Inject
private ConfigManager configManager;
@Override
protected void startUp()
{
@@ -137,6 +160,15 @@ public class EasyGiantsFoundryPlugin extends Plugin
{
state.setEnabled(false);
}
if (event.getGameState().equals(GameState.LOGGED_IN))
{
Integer points = configManager.getRSProfileConfiguration(config.GROUP, config.POINTS_KEY, int.class);
if (points != null)
{
shopPoints = points;
}
}
}
@Subscribe
@@ -257,6 +289,37 @@ public class EasyGiantsFoundryPlugin extends Plugin
public void onGameTick(GameTick event)
{
checkBonus();
Widget chat = client.getWidget(CHAT_WIDGET, CHAT_POINTS_TEXT);
Widget shop = client.getWidget(SHOP_WIDGET, SHOP_POINTS_TEXT);
if (shop != null && shop.getText() != null && Integer.parseInt(shop.getText()) != shopPoints)
{
shopPoints = Integer.parseInt(shop.getText());
storePoints();
return;
}
if (chat == null)
{
increasePoints = true;
return;
}
String chatText = Text.sanitizeMultilineText(chat.getText());
final Matcher matcher = pattern.matcher(chatText);
if (increasePoints && matcher.find())
{
shopPoints += Integer.parseInt(matcher.group("points"));
storePoints();
increasePoints = false;
}
}
private void storePoints()
{
configManager.setRSProfileConfiguration(config.GROUP, config.POINTS_KEY, shopPoints);
}
private void checkBonus()

View File

@@ -17,13 +17,15 @@ import java.awt.Graphics2D;
@Singleton
public class FoundryOverlay2D extends OverlayPanel
{
private final EasyGiantsFoundryPlugin plugin;
private final EasyGiantsFoundryState state;
private final EasyGiantsFoundryHelper helper;
private final EasyGiantsFoundryConfig config;
@Inject
private FoundryOverlay2D(EasyGiantsFoundryState state, EasyGiantsFoundryHelper helper, EasyGiantsFoundryConfig config)
private FoundryOverlay2D(EasyGiantsFoundryPlugin plugin, EasyGiantsFoundryState state, EasyGiantsFoundryHelper helper, EasyGiantsFoundryConfig config)
{
this.plugin = plugin;
this.state = state;
this.helper = helper;
this.config = config;
@@ -89,6 +91,14 @@ public class FoundryOverlay2D extends OverlayPanel
);
}
int points = plugin.getShopPoints();
if (config.drawShopPoints())
{
panelComponent.getChildren().add(
LineComponent.builder().left("Points").right(points + "").build()
);
}
return super.render(graphics);
}
}