Add bonus notifications with configs
This commit is contained in:
@@ -8,6 +8,7 @@ import net.runelite.client.config.ConfigSection;
|
||||
@ConfigGroup(EasyGiantsFoundryConfig.GROUP)
|
||||
public interface EasyGiantsFoundryConfig extends Config {
|
||||
String GROUP = "easygiantsfoundry";
|
||||
String SOUND_ID = "soundID";
|
||||
|
||||
@ConfigSection(
|
||||
name = "Notifications",
|
||||
@@ -38,6 +39,39 @@ public interface EasyGiantsFoundryConfig extends Config {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "bonusNotification",
|
||||
name = "Notify bonus",
|
||||
description = "Notifies when bonus appears",
|
||||
position = 2,
|
||||
section = notificationList
|
||||
)
|
||||
default boolean bonusNotification() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "bonusSound",
|
||||
name = "Bonus sound",
|
||||
description = "Plays a sound when bonus appears",
|
||||
position = 3,
|
||||
section = notificationList
|
||||
)
|
||||
default boolean bonusSoundNotify() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = SOUND_ID,
|
||||
name = "Bonus sound ID",
|
||||
description = "Sound Effect ID to play when bonus appears",
|
||||
position = 4,
|
||||
section = notificationList
|
||||
)
|
||||
default int soundId() {
|
||||
return 4212;
|
||||
}
|
||||
|
||||
|
||||
@ConfigSection(
|
||||
name = "Highlights",
|
||||
|
||||
@@ -2,12 +2,22 @@ package com.toofifty.easygiantsfoundry;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
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.api.events.GameObjectDespawned;
|
||||
import net.runelite.api.events.GameObjectSpawned;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.ItemContainerChanged;
|
||||
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.client.Notifier;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.events.ConfigChanged;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
@@ -43,6 +53,8 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
||||
|
||||
private int lastBoost;
|
||||
|
||||
private boolean bonusNotified = false;
|
||||
|
||||
@Inject
|
||||
private EasyGiantsFoundryState state;
|
||||
|
||||
@@ -67,6 +79,12 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
||||
@Inject
|
||||
private Notifier notifier;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private ClientThread clientThread;
|
||||
|
||||
@Override
|
||||
protected void startUp()
|
||||
{
|
||||
@@ -220,6 +238,52 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
protected void onConfigChanged(ConfigChanged configChanged)
|
||||
{
|
||||
if (!EasyGiantsFoundryConfig.GROUP.equals(configChanged.getGroup()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (EasyGiantsFoundryConfig.SOUND_ID.equals(configChanged.getKey()))
|
||||
{
|
||||
clientThread.invoke(() -> client.playSoundEffect(config.soundId()));
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameTick(GameTick event)
|
||||
{
|
||||
checkBonus();
|
||||
}
|
||||
|
||||
private void checkBonus()
|
||||
{
|
||||
if (!state.isEnabled() || state.getCurrentStage() == null
|
||||
|| state.getCurrentStage().getHeat() != state.getCurrentHeat()
|
||||
|| !BonusWidget.isActive(client))
|
||||
{
|
||||
bonusNotified = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (bonusNotified)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (config.bonusNotification())
|
||||
{
|
||||
notifier.notify("Bonus - Click tool");
|
||||
}
|
||||
if (config.bonusSoundNotify())
|
||||
{
|
||||
client.playSoundEffect(config.soundId());
|
||||
}
|
||||
|
||||
bonusNotified = true;
|
||||
}
|
||||
|
||||
@Provides
|
||||
EasyGiantsFoundryConfig provideConfig(ConfigManager configManager)
|
||||
|
||||
Reference in New Issue
Block a user