Add bonus notifications with configs
This commit is contained in:
@@ -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