added stage notification and config
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
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 showGiantsFoundryNotifications()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,14 +1,19 @@
|
|||||||
package com.toofifty.easygiantsfoundry;
|
package com.toofifty.easygiantsfoundry;
|
||||||
|
|
||||||
|
import com.google.inject.Provides;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.GameObject;
|
import net.runelite.api.GameObject;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
import net.runelite.api.InventoryID;
|
import net.runelite.api.InventoryID;
|
||||||
import net.runelite.api.events.*;
|
import net.runelite.api.events.*;
|
||||||
|
import net.runelite.client.Notifier;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
|
import net.runelite.client.events.ConfigChanged;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
import net.runelite.client.ui.overlay.OverlayManager;
|
||||||
|
import net.runelite.client.config.ConfigManager;
|
||||||
|
import com.toofifty.easygiantsfoundry.enums.Stage;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@@ -33,6 +38,10 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
|||||||
|
|
||||||
private static final int PREFORM = 27010;
|
private static final int PREFORM = 27010;
|
||||||
|
|
||||||
|
private Stage oldStage;
|
||||||
|
|
||||||
|
private boolean enableStageNotifications;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private EasyGiantsFoundryState state;
|
private EasyGiantsFoundryState state;
|
||||||
|
|
||||||
@@ -51,11 +60,18 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private MouldHelper mouldHelper;
|
private MouldHelper mouldHelper;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private EasyGiantsFoundryConfig config;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Notifier notifier;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startUp()
|
protected void startUp()
|
||||||
{
|
{
|
||||||
overlayManager.add(overlay2d);
|
overlayManager.add(overlay2d);
|
||||||
overlayManager.add(overlay3d);
|
overlayManager.add(overlay3d);
|
||||||
|
enableStageNotifications = config.showGiantsFoundryNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -105,6 +121,20 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onStatChanged(StatChanged statChanged)
|
||||||
|
{
|
||||||
|
if (state.isEnabled() &&
|
||||||
|
enableStageNotifications &&
|
||||||
|
state.getCurrentStage() != null &&
|
||||||
|
helper.getActionsLeftInStage() == 1 &&
|
||||||
|
(oldStage == null || oldStage != state.getCurrentStage()))
|
||||||
|
{
|
||||||
|
notifier.notify("About to finish the current stage!");
|
||||||
|
oldStage = state.getCurrentStage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameObjectDespawned(GameObjectDespawned event)
|
public void onGameObjectDespawned(GameObjectDespawned event)
|
||||||
{
|
{
|
||||||
@@ -161,6 +191,7 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
|||||||
&& event.getItemContainer().count(PREFORM) == 0)
|
&& event.getItemContainer().count(PREFORM) == 0)
|
||||||
{
|
{
|
||||||
state.reset();
|
state.reset();
|
||||||
|
oldStage = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,4 +206,24 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
|||||||
mouldHelper.selectBest(event.getScriptId());
|
mouldHelper.selectBest(event.getScriptId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onConfigChanged(ConfigChanged event)
|
||||||
|
{
|
||||||
|
if (!event.getGroup().equals(EasyGiantsFoundryConfig.GROUP))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.showGiantsFoundryNotifications() != enableStageNotifications)
|
||||||
|
{
|
||||||
|
enableStageNotifications = config.showGiantsFoundryNotifications();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
EasyGiantsFoundryConfig provideConfig(ConfigManager configManager)
|
||||||
|
{
|
||||||
|
return configManager.getConfig(EasyGiantsFoundryConfig.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user