Merge branch 'master' into master
This commit is contained in:
@@ -1,20 +1,27 @@
|
||||
package com.toofifty.easygiantsfoundry;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import static com.toofifty.easygiantsfoundry.EasyGiantsFoundryClientIDs.VARBIT_HEAT;
|
||||
import com.toofifty.easygiantsfoundry.enums.Stage;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameObject;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.InventoryID;
|
||||
import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemContainer;
|
||||
import net.runelite.api.Skill;
|
||||
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.MenuOptionClicked;
|
||||
import net.runelite.api.events.NpcDespawned;
|
||||
import net.runelite.api.events.NpcSpawned;
|
||||
import net.runelite.api.events.ScriptPostFired;
|
||||
@@ -29,6 +36,8 @@ import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Slf4j
|
||||
@PluginDescriptor(
|
||||
name = "Easy Giant's Foundry",
|
||||
@@ -52,6 +61,9 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
||||
|
||||
private static final int REPUTATION_VARBIT = 3436;
|
||||
|
||||
// 5 total items, includes Smiths gloves (i);
|
||||
private static final Set<Integer> SMITHS_OUTFIT_IDS = Set.of(27023, 27025, 27027, 27029, 27031);
|
||||
|
||||
private Stage oldStage;
|
||||
|
||||
private int lastBoost;
|
||||
@@ -143,6 +155,7 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onGameStateChanged(GameStateChanged event)
|
||||
{
|
||||
@@ -172,14 +185,14 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
||||
}
|
||||
|
||||
if (config.showGiantsFoundryStageNotifications() &&
|
||||
helper.getActionsLeftInStage() == config.StageNotificationsThreshold() &&
|
||||
state.getActionsLeftInStage() == config.StageNotificationsThreshold() &&
|
||||
(oldStage == null || oldStage != state.getCurrentStage()))
|
||||
{
|
||||
notifier.notify("About to finish the current stage!");
|
||||
oldStage = state.getCurrentStage();
|
||||
}
|
||||
else if (config.showGiantsFoundryHeatNotifications() &&
|
||||
helper.getActionsForHeatLevel() == config.HeatNotificationsThreshold())
|
||||
state.getActionsForHeatLevel() == config.HeatNotificationsThreshold())
|
||||
{
|
||||
notifier.notify("About to run out of heat!");
|
||||
}
|
||||
@@ -237,11 +250,59 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
||||
@Subscribe
|
||||
public void onItemContainerChanged(ItemContainerChanged event)
|
||||
{
|
||||
if (event.getContainerId() == InventoryID.EQUIPMENT.getId()
|
||||
&& event.getItemContainer().count(PREFORM) == 0)
|
||||
if (event.getContainerId() == InventoryID.EQUIPMENT.getId())
|
||||
{
|
||||
state.reset();
|
||||
oldStage = null;
|
||||
if (event.getItemContainer().count(PREFORM) == 0)
|
||||
{
|
||||
state.reset();
|
||||
oldStage = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
updateSmithsOutfitPieces();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onMenuOptionClicked(MenuOptionClicked event)
|
||||
{
|
||||
if (!state.isEnabled()) return;
|
||||
|
||||
if (event.getMenuTarget().contains("Crucible "))
|
||||
{
|
||||
if (event.getMenuOption().equals("Pour"))
|
||||
{
|
||||
// add persistent game message of the alloy value so user can reference later.
|
||||
client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "The quality of the alloy poured is " + (int) state.getCrucibleQuality(), null);
|
||||
}
|
||||
}
|
||||
|
||||
// Could not find a varbit to capture, so capture the menu-option directly.
|
||||
// start the HeatActionStateMachine when varbit begins to update in onVarbitChanged()
|
||||
if (event.getMenuOption().startsWith("Heat-preform"))
|
||||
{
|
||||
state.heatingCoolingState.stop();
|
||||
state.heatingCoolingState.setup(7, 0, "heats");
|
||||
}
|
||||
else if (event.getMenuOption().startsWith("Dunk-preform"))
|
||||
{
|
||||
state.heatingCoolingState.stop();
|
||||
state.heatingCoolingState.setup(27, 2, "dunks");
|
||||
}
|
||||
else if (event.getMenuOption().startsWith("Cool-preform"))
|
||||
{
|
||||
state.heatingCoolingState.stop();
|
||||
state.heatingCoolingState.setup(-7, 0, "cools");
|
||||
}
|
||||
else if (event.getMenuOption().startsWith("Quench-preform"))
|
||||
{
|
||||
state.heatingCoolingState.stop();
|
||||
state.heatingCoolingState.setup(-27, -2, "quenches");
|
||||
}
|
||||
else // canceled heating/cooling, stop the heating state-machine
|
||||
{
|
||||
state.heatingCoolingState.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,6 +318,9 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
// previous heat varbit value, used to filter out passive heat decay.
|
||||
private int previousHeat = 0;
|
||||
|
||||
@Subscribe
|
||||
public void onVarbitChanged(VarbitChanged event)
|
||||
{
|
||||
@@ -264,6 +328,24 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
||||
{
|
||||
reputation = client.getVarpValue(REPUTATION_VARBIT);
|
||||
}
|
||||
|
||||
// start the heating state-machine when the varbit updates
|
||||
// if heat varbit updated and the user clicked, start the state-machine
|
||||
if (event.getVarbitId() == VARBIT_HEAT && state.heatingCoolingState.getActionName() != null)
|
||||
{
|
||||
// ignore passive heat decay, one heat per two ticks
|
||||
if (event.getValue() - previousHeat != -1)
|
||||
{
|
||||
// if the state-machine is idle, start it
|
||||
if (state.heatingCoolingState.isIdle())
|
||||
{
|
||||
state.heatingCoolingState.start(state, config, state.getHeatAmount());
|
||||
}
|
||||
|
||||
state.heatingCoolingState.onTick();
|
||||
}
|
||||
previousHeat = event.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -315,6 +397,29 @@ public class EasyGiantsFoundryPlugin extends Plugin
|
||||
bonusNotified = true;
|
||||
}
|
||||
|
||||
private void updateSmithsOutfitPieces()
|
||||
{
|
||||
int pieces = 0;
|
||||
|
||||
ItemContainer equipment = client.getItemContainer(InventoryID.EQUIPMENT);
|
||||
if (equipment != null)
|
||||
{
|
||||
for (Item item : equipment.getItems())
|
||||
{
|
||||
if (item != null && isSmithsOutfitPiece(item.getId()))
|
||||
{
|
||||
pieces++;
|
||||
}
|
||||
}
|
||||
}
|
||||
state.setSmithsOutfitPieces(pieces);
|
||||
}
|
||||
|
||||
private boolean isSmithsOutfitPiece(int itemId)
|
||||
{
|
||||
return SMITHS_OUTFIT_IDS.contains(itemId);
|
||||
}
|
||||
|
||||
@Provides
|
||||
EasyGiantsFoundryConfig provideConfig(ConfigManager configManager)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user