woodcutting: added gpearned for woodcutting

This commit is contained in:
benjaminlgur
2019-11-02 01:57:06 -04:00
parent ddae743f48
commit 866659e653
3 changed files with 80 additions and 0 deletions

View File

@@ -74,4 +74,15 @@ public interface WoodcuttingConfig extends Config
{
return true;
}
@ConfigItem(
position = 5,
keyName = "showGPEarned",
name = "Show GP earned",
description = "Configures whether to show amount of gp earned by chopping trees"
)
default boolean showGPEarned()
{
return false;
}
}

View File

@@ -42,6 +42,7 @@ import net.runelite.client.ui.overlay.components.TitleComponent;
import net.runelite.client.ui.overlay.components.table.TableAlignment;
import net.runelite.client.ui.overlay.components.table.TableComponent;
@Singleton
class WoodcuttingOverlay extends Overlay
{
@@ -50,6 +51,7 @@ class WoodcuttingOverlay extends Overlay
private final XpTrackerService xpTrackerService;
private final PanelComponent panelComponent = new PanelComponent();
@Inject
private WoodcuttingOverlay(final Client client, final WoodcuttingPlugin plugin, final XpTrackerService xpTrackerService)
{
@@ -101,6 +103,11 @@ class WoodcuttingOverlay extends Overlay
{
tableComponent.addRow("Logs cut:", Integer.toString(actions));
if (plugin.isShowGPEarned())
{
tableComponent.addRow("GP earned", Integer.toString((plugin.getGpEarned())));
}
if (actions > 2)
{
tableComponent.addRow("Logs/hr:", Integer.toString(xpTrackerService.getActionsHr(Skill.WOODCUTTING)));
@@ -112,4 +119,5 @@ class WoodcuttingOverlay extends Overlay
return panelComponent.render(graphics);
}
}

View File

@@ -37,6 +37,8 @@ import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.GameObject;
import net.runelite.api.GameState;
import net.runelite.api.Item;
import net.runelite.api.ItemID;
import net.runelite.api.Player;
import net.runelite.api.events.AnimationChanged;
import net.runelite.api.events.ChatMessage;
@@ -49,6 +51,7 @@ import net.runelite.api.events.GameTick;
import net.runelite.client.Notifier;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDependency;
import net.runelite.client.plugins.PluginDescriptor;
@@ -82,6 +85,9 @@ public class WoodcuttingPlugin extends Plugin
@Inject
private WoodcuttingConfig config;
@Inject
private ItemManager itemManager;
@Inject
private EventBus eventBus;
@@ -100,6 +106,12 @@ public class WoodcuttingPlugin extends Plugin
private boolean showWoodcuttingStats;
@Getter(AccessLevel.PACKAGE)
private boolean showRedwoodTrees;
@Getter(AccessLevel.PACKAGE)
private boolean showGPEarned;
private int treeTypeID;
@Getter(AccessLevel.PACKAGE)
private int gpEarned;
@Provides
WoodcuttingConfig getConfig(ConfigManager configManager)
@@ -167,9 +179,13 @@ public class WoodcuttingPlugin extends Plugin
if (session == null)
{
session = new WoodcuttingSession();
gpEarned = 0;
}
session.setLastLogCut();
typeOfLogCut(event);
gpEarned = gpEarned + itemManager.getItemPrice(treeTypeID);
}
if (event.getMessage().contains("A bird's nest falls out of the tree") && this.showNestNotification)
@@ -179,6 +195,50 @@ public class WoodcuttingPlugin extends Plugin
}
}
private void typeOfLogCut(ChatMessage event)
{
if (event.getMessage().contains("mushrooms."))
{
return; //TO DO Add valuation for scullicep mushroom cutting.
}
else if (event.getMessage().contains("oak"))
{
treeTypeID = ItemID.OAK_LOGS;
}
else if (event.getMessage().contains("willow"))
{
treeTypeID = ItemID.WILLOW_LOGS;
}
else if (event.getMessage().contains("yew"))
{
treeTypeID = ItemID.YEW_LOGS;
}
else if (event.getMessage().contains("redwood"))
{
treeTypeID = ItemID.REDWOOD_LOGS;
}
else if (event.getMessage().contains("magic"))
{
treeTypeID = ItemID.MAGIC_LOGS;
}
else if (event.getMessage().contains("teak"))
{
treeTypeID = ItemID.TEAK_LOGS;
}
else if (event.getMessage().contains("mahogany"))
{
treeTypeID = ItemID.MAHOGANY_LOGS;
}
else if (event.getMessage().contains("maple"))
{
treeTypeID = ItemID.MAPLE_LOGS;
}
else
{
treeTypeID = ItemID.LOGS;
}
}
private void onGameObjectSpawned(final GameObjectSpawned event)
{
GameObject gameObject = event.getGameObject();
@@ -241,5 +301,6 @@ public class WoodcuttingPlugin extends Plugin
this.showNestNotification = config.showNestNotification();
this.showWoodcuttingStats = config.showWoodcuttingStats();
this.showRedwoodTrees = config.showRedwoodTrees();
this.showGPEarned = config.showGPEarned();
}
}