Merge pull request #5 from Vanillj/master
Added notifications and config
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package com.toofifty.easygiantsfoundry;
|
||||
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup(EasyGiantsFoundryConfig.GROUP)
|
||||
public interface EasyGiantsFoundryConfig extends Config {
|
||||
String GROUP = "easygiantsfoundry";
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "giantsFoundryStageNotification",
|
||||
name = "Enable stage notifications",
|
||||
description = "Configures whether to notify you when you are about to finish a stage.",
|
||||
position = 0
|
||||
)
|
||||
default boolean showGiantsFoundryStageNotifications()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "giantsFoundryHeatNotification",
|
||||
name = "Enable heat notifications",
|
||||
description = "Configures whether to notify you when you are about to run out of heat.",
|
||||
position = 1
|
||||
)
|
||||
default boolean showGiantsFoundryHeatNotifications()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,20 @@
|
||||
package com.toofifty.easygiantsfoundry;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.GameObject;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.InventoryID;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.api.events.*;
|
||||
import net.runelite.client.Notifier;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.events.ConfigChanged;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
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 javax.inject.Inject;
|
||||
|
||||
@@ -33,6 +39,10 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
||||
|
||||
private static final int PREFORM = 27010;
|
||||
|
||||
private Stage oldStage;
|
||||
|
||||
private int lastBoost;
|
||||
|
||||
@Inject
|
||||
private EasyGiantsFoundryState state;
|
||||
|
||||
@@ -51,6 +61,12 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
||||
@Inject
|
||||
private MouldHelper mouldHelper;
|
||||
|
||||
@Inject
|
||||
private EasyGiantsFoundryConfig config;
|
||||
|
||||
@Inject
|
||||
private Notifier notifier;
|
||||
|
||||
@Override
|
||||
protected void startUp()
|
||||
{
|
||||
@@ -105,6 +121,33 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatChanged(StatChanged statChanged)
|
||||
{
|
||||
final int currBoost = statChanged.getBoostedLevel();
|
||||
// if the difference between current and last boost is != 0 then a stat boost (or drop) change occurred
|
||||
if (!statChanged.getSkill().equals(Skill.SMITHING) ||
|
||||
currBoost - lastBoost != 0 ||
|
||||
!state.isEnabled() ||
|
||||
state.getCurrentStage() == null)
|
||||
{
|
||||
lastBoost = currBoost;
|
||||
return;
|
||||
}
|
||||
|
||||
if (config.showGiantsFoundryStageNotifications() &&
|
||||
helper.getActionsLeftInStage() == 1 &&
|
||||
(oldStage == null || oldStage != state.getCurrentStage()))
|
||||
{
|
||||
notifier.notify("About to finish the current stage!");
|
||||
oldStage = state.getCurrentStage();
|
||||
}
|
||||
else if (config.showGiantsFoundryHeatNotifications() && helper.getActionsForHeatLevel() == 1)
|
||||
{
|
||||
notifier.notify("About to run out of heat!");
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameObjectDespawned(GameObjectDespawned event)
|
||||
{
|
||||
@@ -161,6 +204,7 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
||||
&& event.getItemContainer().count(PREFORM) == 0)
|
||||
{
|
||||
state.reset();
|
||||
oldStage = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,4 +219,11 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
||||
mouldHelper.selectBest(event.getScriptId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Provides
|
||||
EasyGiantsFoundryConfig provideConfig(ConfigManager configManager)
|
||||
{
|
||||
return configManager.getConfig(EasyGiantsFoundryConfig.class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user