From 02b259fa22a6d2ee32f4bf2d1c8984aeb36e5728 Mon Sep 17 00:00:00 2001 From: Zoinkwiz Date: Wed, 20 Aug 2025 13:02:50 +0100 Subject: [PATCH] Feat reorderable herb run (#2259) * fix: Allow reordering of sidebar for hidden sections * feat: Added default true RuneliteRequirement constructor * fix: Remove unused orderedSteps from ConditionalStep * feat: Propogate id for steps to substeps and panel steps * feat: Allow multiple steps with the same id in a ReorderableConditionalStep * feat: Improved herb run helper - Allows for reorganising of sidebar steps - Add Harmony teleport - Modernised code - Added barb training check for dibber requirement * Added herb run to testable list --- .../helpers/mischelpers/farmruns/HerbRun.java | 292 ++++++++++++------ .../com/questhelper/panel/PanelDetails.java | 10 + .../questhelper/panel/QuestOverviewPanel.java | 4 +- .../runelite/RuneliteRequirement.java | 5 + .../questhelper/steps/ConditionalStep.java | 6 - .../java/com/questhelper/steps/QuestStep.java | 4 + .../steps/ReorderableConditionalStep.java | 1 - .../questhelpers/QuestHelperTest.java | 3 +- 8 files changed, 214 insertions(+), 111 deletions(-) diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/HerbRun.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/HerbRun.java index 900b7e94c..2352c9d70 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/HerbRun.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/HerbRun.java @@ -26,12 +26,12 @@ package com.questhelper.helpers.mischelpers.farmruns; import com.questhelper.QuestHelperConfig; import com.questhelper.collections.ItemCollections; +import com.questhelper.config.ConfigKeys; import com.questhelper.panel.PanelDetails; import com.questhelper.questhelpers.ComplexStateQuestHelper; import com.questhelper.questinfo.HelperConfig; import com.questhelper.questinfo.QuestHelperQuest; import com.questhelper.requirements.ManualRequirement; -import com.questhelper.requirements.Requirement; import com.questhelper.requirements.conditional.Conditions; import com.questhelper.requirements.item.ItemRequirement; import com.questhelper.requirements.item.ItemRequirements; @@ -40,13 +40,9 @@ import com.questhelper.requirements.quest.QuestRequirement; import com.questhelper.requirements.runelite.RuneliteRequirement; import com.questhelper.requirements.util.LogicType; import com.questhelper.requirements.var.VarbitRequirement; -import com.questhelper.steps.ConditionalStep; -import com.questhelper.steps.DetailedQuestStep; -import com.questhelper.steps.ObjectStep; -import com.questhelper.steps.QuestStep; +import com.questhelper.steps.*; import net.runelite.api.QuestState; import net.runelite.api.Skill; -import net.runelite.api.Varbits; import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.GameTick; import net.runelite.api.gameval.ItemID; @@ -60,30 +56,110 @@ import net.runelite.client.util.Text; import javax.inject.Inject; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; +import static com.questhelper.requirements.util.LogicHelper.nor; + public class HerbRun extends ComplexStateQuestHelper { - // TODO: Updating setId and setName in ItemRequirement @Inject private FarmingWorld farmingWorld; private FarmingHandler farmingHandler; - DetailedQuestStep waitForHerbs, ardougnePatch, catherbyPatch, faladorPatch, farmingGuildPatch, harmonyPatch, morytaniaPatch, trollStrongholdPatch, weissPatch, hosidiusPatch, varlamorePatch; + // Required items + ItemRequirement spade; + ItemRequirement dibber; + ItemRequirement rake; + ItemRequirement seed; - DetailedQuestStep ardougnePlant, catherbyPlant, faladorPlant, farmingGuildPlant, harmonyPlant, morytaniaPlant, trollStrongholdPlant, weissPlant, hosidiusPlant, varlamorePlant; - ItemRequirement spade, dibber, rake, seed, compost; - ItemRequirement ectophial, magicSec, explorerRing2, ardyCloak2, xericsTalisman, catherbyTeleport, trollheimTeleport, icyBasalt, stonyBasalt, farmingGuildTeleport, hosidiusHouseTeleport, hunterWhistle; - ItemRequirement gracefulHood, gracefulTop, gracefulLegs, gracefulGloves, gracefulBoots, gracefulCape, gracefulOutfit; - ItemRequirement farmingHat, farmingTop, farmingLegs, farmingBoots, farmersOutfit; + // Recommended items + ItemRequirement compost; + ItemRequirement ectophial; + ItemRequirement magicSec; + ItemRequirement explorerRing2; + ItemRequirement ardyCloak2; + ItemRequirement xericsTalisman; + ItemRequirement catherbyTeleport; + ItemRequirement trollheimTeleport; + ItemRequirement icyBasalt; + ItemRequirement stonyBasalt; + ItemRequirement farmingGuildTeleport; + ItemRequirement hosidiusHouseTeleport; + ItemRequirement hunterWhistle; + ItemRequirement harmonyTeleport; + ItemRequirement gracefulHood; + ItemRequirement gracefulTop; + ItemRequirement gracefulLegs; + ItemRequirement gracefulGloves; + ItemRequirement gracefulBoots; + ItemRequirement gracefulCape; + ItemRequirement gracefulOutfit; + ItemRequirement farmingHat; + ItemRequirement farmingTop; + ItemRequirement farmingLegs; + ItemRequirement farmingBoots; + ItemRequirement farmersOutfit; - Requirement accessToHarmony, accessToWeiss, accessToTrollStronghold, accessToFarmingGuildPatch, accessToVarlamore; + // Miscellaneous requirements + QuestRequirement accessToHarmony; + QuestRequirement accessToWeiss; + QuestRequirement accessToTrollStronghold; + SkillRequirement accessToFarmingGuildPatch; + QuestRequirement accessToVarlamore; + RuneliteRequirement unlockedBarbarianPlanting; - ManualRequirement ardougneEmpty, catherbyEmpty, faladorEmpty, farmingGuildEmpty, harmonyEmpty, morytaniaEmpty, trollStrongholdEmpty, weissEmpty, hosidiusEmpty, varlamoreEmpty; - ManualRequirement ardougneReady, catherbyReady, faladorReady, farmingGuildReady, harmonyReady, morytaniaReady, trollStrongholdReady, weissReady, hosidiusReady, varlamoreReady; + ManualRequirement ardougneEmpty; + ManualRequirement catherbyEmpty; + ManualRequirement faladorEmpty; + ManualRequirement farmingGuildEmpty; + ManualRequirement harmonyEmpty; + ManualRequirement morytaniaEmpty; + ManualRequirement trollStrongholdEmpty; + ManualRequirement weissEmpty; + ManualRequirement hosidiusEmpty; + ManualRequirement varlamoreEmpty; + ManualRequirement ardougneReady; + ManualRequirement catherbyReady; + ManualRequirement faladorReady; + ManualRequirement farmingGuildReady; + ManualRequirement harmonyReady; + ManualRequirement morytaniaReady; + ManualRequirement trollStrongholdReady; + ManualRequirement weissReady; + ManualRequirement hosidiusReady; + ManualRequirement varlamoreReady; - private enum Seed { + // Steps + ReorderableConditionalStep steps; + DetailedQuestStep waitForHerbs; + ObjectStep ardougnePatch; + ObjectStep catherbyPatch; + ObjectStep faladorPatch; + ObjectStep farmingGuildPatch; + ObjectStep harmonyPatch; + ObjectStep morytaniaPatch; + ObjectStep trollStrongholdPatch; + ObjectStep weissPatch; + ObjectStep hosidiusPatch; + ObjectStep varlamorePatch; + ObjectStep ardougnePlant; + ObjectStep catherbyPlant; + ObjectStep faladorPlant; + ObjectStep farmingGuildPlant; + ObjectStep harmonyPlant; + ObjectStep morytaniaPlant; + ObjectStep trollStrongholdPlant; + ObjectStep weissPlant; + ObjectStep hosidiusPlant; + ObjectStep varlamorePlant; + + // Sidebar panels + List allSteps; + + private enum Seed + { GUAM(ItemID.GUAM_SEED), MARRENTILL(ItemID.MARRENTILL_SEED), TARROMIN(ItemID.TARROMIN_SEED), HARRALANDER(ItemID.HARRALANDER_SEED), RANARR(ItemID.RANARR_SEED), TOADFLAX(ItemID.TOADFLAX_SEED), IRIT(ItemID.IRIT_SEED), AVANTOE(ItemID.AVANTOE_SEED), KWUARM(ItemID.KWUARM_SEED), SNAPDRAGON(ItemID.SNAPDRAGON_SEED), HUASCA(ItemID.HUASCA_SEED), CADANTINE(ItemID.CADANTINE_SEED), LATANDYME(ItemID.LANTADYME_SEED), @@ -97,58 +173,18 @@ public class HerbRun extends ComplexStateQuestHelper } } - private enum GracefulOrFarming { + private enum GracefulOrFarming + { NONE(), GRACEFUL(), - FARMING(); + FARMING() } private final String HERB_SEEDS = "herbSeeds"; private final String GRACEFUL_OR_FARMING = "gracefulOrFarming"; @Override - public QuestStep loadStep() - { - farmingHandler = new FarmingHandler(client, configManager); - initializeRequirements(); - setupConditions(); - setupSteps(); - - ConditionalStep steps = new ConditionalStep(this, waitForHerbs, spade, dibber, rake, seed, magicSec, farmersOutfit, gracefulOutfit); - steps.addStep(faladorReady, faladorPatch); - steps.addStep(faladorEmpty, faladorPlant); - - steps.addStep(ardougneReady, ardougnePatch); - steps.addStep(ardougneEmpty, ardougnePlant); - - steps.addStep(catherbyReady, catherbyPatch); - steps.addStep(catherbyEmpty, catherbyPlant); - - steps.addStep(morytaniaReady, morytaniaPatch); - steps.addStep(morytaniaEmpty, morytaniaPlant); - - steps.addStep(hosidiusReady, hosidiusPatch); - steps.addStep(hosidiusEmpty, hosidiusPlant); - - steps.addStep(new Conditions(accessToTrollStronghold, trollStrongholdReady), trollStrongholdPatch); - steps.addStep(new Conditions(accessToTrollStronghold, trollStrongholdEmpty), trollStrongholdPlant); - - steps.addStep(new Conditions(accessToWeiss, weissReady), weissPatch); - steps.addStep(new Conditions(accessToWeiss, weissEmpty), weissPlant); - - steps.addStep(new Conditions(accessToFarmingGuildPatch, farmingGuildReady), farmingGuildPatch); - steps.addStep(new Conditions(accessToFarmingGuildPatch, farmingGuildEmpty), farmingGuildPlant); - - steps.addStep(new Conditions(accessToHarmony, harmonyReady), harmonyPatch); - steps.addStep(new Conditions(accessToHarmony, harmonyEmpty), harmonyPlant); - - steps.addStep(new Conditions(accessToVarlamore, varlamoreReady), varlamorePatch); - steps.addStep(new Conditions(accessToVarlamore, varlamoreEmpty), varlamorePlant); - - return steps; - } - - public void setupConditions() + protected void setupRequirements() { ardougneReady = new ManualRequirement(); catherbyReady = new ManualRequirement(); @@ -171,11 +207,7 @@ public class HerbRun extends ComplexStateQuestHelper weissEmpty = new ManualRequirement(); hosidiusEmpty = new ManualRequirement(); varlamoreEmpty = new ManualRequirement(); - } - @Override - protected void setupRequirements() - { accessToFarmingGuildPatch = new SkillRequirement(Skill.FARMING, 65); accessToHarmony = new QuestRequirement(QuestHelperQuest.MORYTANIA_ELITE, QuestState.FINISHED); @@ -183,13 +215,15 @@ public class HerbRun extends ComplexStateQuestHelper accessToTrollStronghold = new QuestRequirement(QuestHelperQuest.MY_ARMS_BIG_ADVENTURE, QuestState.FINISHED); accessToVarlamore = new QuestRequirement(QuestHelperQuest.CHILDREN_OF_THE_SUN, QuestState.FINISHED); + unlockedBarbarianPlanting = new RuneliteRequirement(configManager, ConfigKeys.BARBARIAN_TRAINING_FINISHED_SEED_PLANTING.getKey()); + spade = new ItemRequirement("Spade", ItemID.SPADE); - dibber = new ItemRequirement("Seed dibber", ItemID.DIBBER); + dibber = new ItemRequirement("Seed dibber", ItemID.DIBBER).hideConditioned(unlockedBarbarianPlanting); rake = new ItemRequirement("Rake", ItemID.RAKE).hideConditioned(new VarbitRequirement(VarbitID.FARMING_BLOCKWEEDS, 2)); seed = new ItemRequirement("Seeds of your choice", ItemID.GUAM_SEED); - String seedName = configManager.getRSProfileConfiguration(QuestHelperConfig.QUEST_BACKGROUND_GROUP, HERB_SEEDS); + var seedName = configManager.getRSProfileConfiguration(QuestHelperConfig.QUEST_BACKGROUND_GROUP, HERB_SEEDS); if (seedName != null) { @@ -219,17 +253,17 @@ public class HerbRun extends ComplexStateQuestHelper hosidiusHouseTeleport = new ItemRequirement("Teleport to Hosidius House", ItemID.NZONE_TELETAB_KOUREND); hosidiusHouseTeleport.addAlternates(ItemID.XERIC_TALISMAN); - ItemRequirement catherbyRunes = new ItemRequirements("Catherby teleport runes", new ItemRequirement("Law rune", - ItemID.LAWRUNE), new ItemRequirement("Air rune", ItemID.AIRRUNE, 5)); - ItemRequirement catherbyTablet = new ItemRequirement("Catherby tablet", ItemID.LUNAR_TABLET_CATHERBY_TELEPORT); + var catherbyRunes = new ItemRequirements("Catherby teleport runes", new ItemRequirement("Law rune", + ItemID.LAWRUNE), new ItemRequirement("Air rune", ItemID.AIRRUNE, 5)); + var catherbyTablet = new ItemRequirement("Catherby tablet", ItemID.LUNAR_TABLET_CATHERBY_TELEPORT); catherbyTeleport = new ItemRequirements(LogicType.OR, "Catherby teleport", catherbyRunes, catherbyTablet); - ItemRequirement trollheimRunes = new ItemRequirements("Trollheim teleport runes", new ItemRequirement("Law rune", - ItemID.LAWRUNE, 2), new ItemRequirement("Fire rune", ItemID.FIRERUNE, 2)); - ItemRequirement trollheimTablet = new ItemRequirement("Trollheim tablet", ItemID.NZONE_TELETAB_TROLLHEIM); + var trollheimRunes = new ItemRequirements("Trollheim teleport runes", new ItemRequirement("Law rune", + ItemID.LAWRUNE, 2), new ItemRequirement("Fire rune", ItemID.FIRERUNE, 2)); + var trollheimTablet = new ItemRequirement("Trollheim tablet", ItemID.NZONE_TELETAB_TROLLHEIM); trollheimTeleport = new ItemRequirements(LogicType.OR, "Trollheim teleport", trollheimRunes, trollheimTablet) - .hideConditioned(new QuestRequirement(QuestHelperQuest.MAKING_FRIENDS_WITH_MY_ARM, QuestState.FINISHED)); + .hideConditioned(new QuestRequirement(QuestHelperQuest.MAKING_FRIENDS_WITH_MY_ARM, QuestState.FINISHED)); icyBasalt = new ItemRequirement("Icy basalt", ItemID.WEISS_TELEPORT_BASALT).showConditioned(new QuestRequirement(QuestHelperQuest.MAKING_FRIENDS_WITH_MY_ARM, QuestState.FINISHED)); stonyBasalt = new ItemRequirement("Stony basalt", ItemID.STRONGHOLD_TELEPORT_BASALT).showConditioned(new QuestRequirement(QuestHelperQuest.MAKING_FRIENDS_WITH_MY_ARM, QuestState.FINISHED)); @@ -239,55 +273,57 @@ public class HerbRun extends ComplexStateQuestHelper farmingGuildTeleport.addAlternates(ItemCollections.SKILLS_NECKLACES); farmingGuildTeleport.addAlternates(ItemCollections.FAIRY_STAFF); + harmonyTeleport = new ItemRequirement("Harmony Teleport", ItemID.TELETAB_HARMONY); + hunterWhistle = new ItemRequirement("Quetzal whistle", ItemID.HG_QUETZALWHISTLE_PERFECTED).showConditioned(accessToVarlamore); hunterWhistle.addAlternates(ItemID.HG_QUETZALWHISTLE_BASIC); hunterWhistle.addAlternates(ItemID.HG_QUETZALWHISTLE_ENHANCED); gracefulHood = new ItemRequirement( - "Graceful hood", ItemCollections.GRACEFUL_HOOD, 1 ,true).isNotConsumed(); + "Graceful hood", ItemCollections.GRACEFUL_HOOD, 1, true).isNotConsumed(); gracefulTop = new ItemRequirement( - "Graceful top", ItemCollections.GRACEFUL_TOP, 1, true).isNotConsumed(); + "Graceful top", ItemCollections.GRACEFUL_TOP, 1, true).isNotConsumed(); gracefulLegs = new ItemRequirement( - "Graceful legs", ItemCollections.GRACEFUL_LEGS, 1, true).isNotConsumed(); + "Graceful legs", ItemCollections.GRACEFUL_LEGS, 1, true).isNotConsumed(); gracefulCape = new ItemRequirement( - "Graceful cape", ItemCollections.GRACEFUL_CAPE, 1, true).isNotConsumed(); + "Graceful cape", ItemCollections.GRACEFUL_CAPE, 1, true).isNotConsumed(); gracefulGloves = new ItemRequirement( - "Graceful gloves", ItemCollections.GRACEFUL_GLOVES, 1, true).isNotConsumed(); + "Graceful gloves", ItemCollections.GRACEFUL_GLOVES, 1, true).isNotConsumed(); gracefulBoots = new ItemRequirement( - "Graceful boots", ItemCollections.GRACEFUL_BOOTS, 1, true).isNotConsumed(); + "Graceful boots", ItemCollections.GRACEFUL_BOOTS, 1, true).isNotConsumed(); gracefulBoots.addAlternates(ItemID.IKOV_BOOTSOFLIGHTNESS); gracefulOutfit = new ItemRequirements( - "Graceful outfit (equipped)", - gracefulHood, gracefulTop, gracefulLegs, gracefulGloves, gracefulBoots, gracefulCape + "Graceful outfit (equipped)", + gracefulHood, gracefulTop, gracefulLegs, gracefulGloves, gracefulBoots, gracefulCape ).isNotConsumed().showConditioned(new RuneliteRequirement(configManager, GRACEFUL_OR_FARMING, GracefulOrFarming.GRACEFUL.name())); farmingHat = new ItemRequirement( - "Farmer's strawhat", ItemID.TITHE_REWARD_HAT_MALE, 1 ,true).isNotConsumed(); + "Farmer's strawhat", ItemID.TITHE_REWARD_HAT_MALE, 1, true).isNotConsumed(); farmingHat.addAlternates(ItemID.TITHE_REWARD_HAT_FEMALE, ItemID.TITHE_REWARD_HAT_MALE_DUMMY, ItemID.TITHE_REWARD_HAT_FEMALE_DUMMY); farmingTop = new ItemRequirement( - "Farmer's top", ItemID.TITHE_REWARD_TORSO_MALE, 1, true).isNotConsumed(); + "Farmer's top", ItemID.TITHE_REWARD_TORSO_MALE, 1, true).isNotConsumed(); farmingTop.addAlternates(ItemID.TITHE_REWARD_TORSO_FEMALE); farmingLegs = new ItemRequirement( - "Farmer's boro trousers", ItemID.TITHE_REWARD_LEGS_MALE, 1, true).isNotConsumed(); + "Farmer's boro trousers", ItemID.TITHE_REWARD_LEGS_MALE, 1, true).isNotConsumed(); farmingLegs.addAlternates(ItemID.TITHE_REWARD_LEGS_FEMALE); farmingBoots = new ItemRequirement( - "Graceful cape", ItemID.TITHE_REWARD_FEET_MALE, 1, true).isNotConsumed(); + "Graceful cape", ItemID.TITHE_REWARD_FEET_MALE, 1, true).isNotConsumed(); farmingBoots.addAlternates(ItemID.TITHE_REWARD_FEET_FEMALE); farmersOutfit = new ItemRequirements( - "Farmer's outfit (equipped)", - farmingHat, farmingTop, farmingLegs, farmingBoots + "Farmer's outfit (equipped)", + farmingHat, farmingTop, farmingLegs, farmingBoots ).isNotConsumed().showConditioned(new RuneliteRequirement(configManager, GRACEFUL_OR_FARMING, GracefulOrFarming.FARMING.name())); } @@ -308,7 +344,7 @@ public class HerbRun extends ComplexStateQuestHelper morytaniaPatch = new ObjectStep(this, ObjectID.FARMING_HERB_PATCH_4, new WorldPoint(3605, 3529, 0), "Harvest your herbs from the Morytania patch.", ectophial); trollStrongholdPatch = new ObjectStep(this, ObjectID.MYARM_HERBPATCH, new WorldPoint(2826, 3694, 0), "Harvest your herbs from the Troll Stronghold patch.", - trollheimTeleport, stonyBasalt); + trollheimTeleport, stonyBasalt); trollStrongholdPatch.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToTrollStronghold)); weissPatch = new ObjectStep(this, ObjectID.MY2ARM_HERBPATCH, new WorldPoint(2848, 3934, 0), "Harvest your herbs from the Weiss patch.", icyBasalt); weissPatch.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToWeiss)); @@ -347,7 +383,7 @@ public class HerbRun extends ComplexStateQuestHelper morytaniaPatch.addSubSteps(morytaniaPlant); trollStrongholdPlant = new ObjectStep(this, ObjectID.MYARM_HERBPATCH, new WorldPoint(2826, 3694, 0), "Plant your seeds into the Troll Stronghold patch.", - trollheimTeleport, stonyBasalt); + trollheimTeleport, stonyBasalt); trollStrongholdPlant.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToTrollStronghold)); trollStrongholdPlant.addIcon(ItemID.RANARR_SEED); trollStrongholdPatch.addSubSteps(trollStrongholdPlant); @@ -363,6 +399,48 @@ public class HerbRun extends ComplexStateQuestHelper varlamorePatch.addSubSteps(varlamorePlant); } + @Override + public QuestStep loadStep() + { + farmingHandler = new FarmingHandler(client, configManager); + initializeRequirements(); + setupSteps(); + prepopulateSidebarPanels(); + + steps = new ReorderableConditionalStep(this, waitForHerbs, spade, dibber, rake, seed, magicSec, farmersOutfit, gracefulOutfit); + steps.addStep(faladorReady, faladorPatch); + steps.addStep(faladorEmpty, faladorPlant); + + steps.addStep(ardougneReady, ardougnePatch); + steps.addStep(ardougneEmpty, ardougnePlant); + + steps.addStep(catherbyReady, catherbyPatch); + steps.addStep(catherbyEmpty, catherbyPlant); + + steps.addStep(morytaniaReady, morytaniaPatch); + steps.addStep(morytaniaEmpty, morytaniaPlant); + + steps.addStep(hosidiusReady, hosidiusPatch); + steps.addStep(hosidiusEmpty, hosidiusPlant); + + steps.addStep(new Conditions(accessToTrollStronghold, trollStrongholdReady), trollStrongholdPatch); + steps.addStep(new Conditions(accessToTrollStronghold, trollStrongholdEmpty), trollStrongholdPlant); + + steps.addStep(new Conditions(accessToWeiss, weissReady), weissPatch); + steps.addStep(new Conditions(accessToWeiss, weissEmpty), weissPlant); + + steps.addStep(new Conditions(accessToFarmingGuildPatch, farmingGuildReady), farmingGuildPatch); + steps.addStep(new Conditions(accessToFarmingGuildPatch, farmingGuildEmpty), farmingGuildPlant); + + steps.addStep(new Conditions(accessToHarmony, harmonyReady), harmonyPatch); + steps.addStep(new Conditions(accessToHarmony, harmonyEmpty), harmonyPlant); + + steps.addStep(new Conditions(accessToVarlamore, varlamoreReady), varlamorePatch); + steps.addStep(new Conditions(accessToVarlamore, varlamoreEmpty), varlamorePlant); + + return steps; + } + @Subscribe public void onConfigChanged(ConfigChanged event) { @@ -379,8 +457,7 @@ public class HerbRun extends ComplexStateQuestHelper seed.setId(selectedSeed.seedID); seed.setName(Text.titleCase(selectedSeed) + " seed"); questHelperPlugin.refreshBank(); - } - catch (IllegalArgumentException err) + } catch (IllegalArgumentException err) { questHelperPlugin.getConfigManager().setConfiguration(QuestHelperConfig.QUEST_BACKGROUND_GROUP, HERB_SEEDS, Seed.GUAM); } @@ -423,7 +500,7 @@ public class HerbRun extends ComplexStateQuestHelper case "Farming Guild": farmingGuildReady.setShouldPass(isHarvestable); farmingGuildEmpty.setShouldPass(isPlantable); - if(!accessToFarmingGuildPatch.check(client)) + if (!accessToFarmingGuildPatch.check(client)) { seedsNeeded--; } @@ -447,7 +524,7 @@ public class HerbRun extends ComplexStateQuestHelper case "Troll Stronghold": trollStrongholdReady.setShouldPass(isHarvestable); trollStrongholdEmpty.setShouldPass(isPlantable); - if(!accessToTrollStronghold.check(client)) + if (!accessToTrollStronghold.check(client)) { seedsNeeded--; } @@ -455,7 +532,7 @@ public class HerbRun extends ComplexStateQuestHelper case "Weiss": weissReady.setShouldPass(isHarvestable); weissEmpty.setShouldPass(isPlantable); - if(!accessToWeiss.check(client)) + if (!accessToWeiss.check(client)) { seedsNeeded--; } @@ -463,7 +540,7 @@ public class HerbRun extends ComplexStateQuestHelper case "Civitas illa Fortis": varlamoreReady.setShouldPass(isHarvestable); varlamoreEmpty.setShouldPass(isPlantable); - if(!accessToVarlamore.check(client)) + if (!accessToVarlamore.check(client)) { seedsNeeded--; } @@ -483,7 +560,8 @@ public class HerbRun extends ComplexStateQuestHelper @Override public List getItemRecommended() { - return Arrays.asList(compost, ectophial, magicSec, explorerRing2, ardyCloak2, xericsTalisman, hosidiusHouseTeleport, catherbyTeleport, trollheimTeleport, icyBasalt, stonyBasalt, farmingGuildTeleport, hunterWhistle, gracefulOutfit, farmersOutfit); + return Arrays.asList(compost, ectophial, magicSec, explorerRing2, ardyCloak2, xericsTalisman, hosidiusHouseTeleport, catherbyTeleport, + trollheimTeleport, icyBasalt, stonyBasalt, farmingGuildTeleport, hunterWhistle, harmonyTeleport, gracefulOutfit, farmersOutfit); } @Override @@ -494,14 +572,24 @@ public class HerbRun extends ComplexStateQuestHelper return Arrays.asList(seedsConfig, outfitConfig); } + private void prepopulateSidebarPanels() + { + allSteps = new ArrayList<>(); + allSteps.add(new PanelDetails("Farming Guild", Collections.singletonList(farmingGuildPatch)).withId(0)); + allSteps.add(new PanelDetails("Falador", Collections.singletonList(faladorPatch)).withId(1)); + allSteps.add(new PanelDetails("Ardougne", Collections.singletonList(ardougnePatch)).withId(2)); + allSteps.add(new PanelDetails("Catherby", Collections.singletonList(catherbyPatch)).withId(3)); + allSteps.add(new PanelDetails("Morytania", Collections.singletonList(morytaniaPatch)).withId(4)); + allSteps.add(new PanelDetails("Hosidius", Collections.singletonList(hosidiusPatch)).withId(5)); + allSteps.add(new PanelDetails("Varlamore", Collections.singletonList(varlamorePatch)).withId(6)); + allSteps.add(new PanelDetails("Troll Stronghold", Collections.singletonList(trollStrongholdPatch)).withId(7)); + allSteps.add(new PanelDetails("Weiss", Collections.singletonList(weissPatch)).withId(8)); + allSteps.add(new PanelDetails("Harmony Island", Collections.singletonList(harmonyPatch)).withId(9).withHideCondition(nor(accessToHarmony))); + } + @Override public List getPanels() { - List allSteps = new ArrayList<>(); - allSteps.add(new PanelDetails("Farm run", Arrays.asList(faladorPatch, ardougnePatch, catherbyPatch, morytaniaPatch, hosidiusPatch, - trollStrongholdPatch, weissPatch, farmingGuildPatch, harmonyPatch, varlamorePatch), Arrays.asList(spade, dibber, rake, seed, magicSec), - Arrays.asList(compost, ectophial, explorerRing2, ardyCloak2, xericsTalisman, catherbyTeleport, trollheimTeleport, icyBasalt, stonyBasalt, farmingGuildTeleport, hunterWhistle, gracefulOutfit, farmersOutfit))); - return allSteps; } } diff --git a/src/main/java/com/questhelper/panel/PanelDetails.java b/src/main/java/com/questhelper/panel/PanelDetails.java index 2d008d6e1..acae4cfa7 100644 --- a/src/main/java/com/questhelper/panel/PanelDetails.java +++ b/src/main/java/com/questhelper/panel/PanelDetails.java @@ -95,6 +95,10 @@ public class PanelDetails public PanelDetails withId(int id) { this.id = id; + for (QuestStep step : steps) + { + step.withId(id); + } return this; } @@ -103,6 +107,12 @@ public class PanelDetails setHideCondition(new Conditions(LogicType.NOR, req)); } + public PanelDetails withHideCondition(Requirement requirement) + { + setHideCondition(requirement); + return this; + } + /* Set the states of the quest the steps in the sidebar should be active */ public void setVars(Integer... vars) { diff --git a/src/main/java/com/questhelper/panel/QuestOverviewPanel.java b/src/main/java/com/questhelper/panel/QuestOverviewPanel.java index b05c2f657..874174fa6 100644 --- a/src/main/java/com/questhelper/panel/QuestOverviewPanel.java +++ b/src/main/java/com/questhelper/panel/QuestOverviewPanel.java @@ -713,7 +713,9 @@ public class QuestOverviewPanel extends JPanel if (other == draggingPanel) continue; Rectangle r = other.getBounds(); - int midY = other.getLocationOnScreen().y + r.height / 2; + int otherYPos = 0; + if (other.isVisible()) otherYPos = other.getLocationOnScreen().y; + int midY = otherYPos + r.height / 2; int fromIndex = questStepPanelList.indexOf(draggingPanel); int toIndex = questStepPanelList.indexOf(other); diff --git a/src/main/java/com/questhelper/requirements/runelite/RuneliteRequirement.java b/src/main/java/com/questhelper/requirements/runelite/RuneliteRequirement.java index 5dfefa6b5..ed6a2968f 100644 --- a/src/main/java/com/questhelper/requirements/runelite/RuneliteRequirement.java +++ b/src/main/java/com/questhelper/requirements/runelite/RuneliteRequirement.java @@ -58,6 +58,11 @@ public class RuneliteRequirement extends AbstractRequirement this(configManager, id, "false", expectedValue, text, requirements); } + public RuneliteRequirement(ConfigManager configManager, String id) + { + this(configManager, id, "true", new HashMap<>()); + } + public RuneliteRequirement(ConfigManager configManager, String id, String expectedValue) { this(configManager, id, expectedValue, new HashMap<>()); diff --git a/src/main/java/com/questhelper/steps/ConditionalStep.java b/src/main/java/com/questhelper/steps/ConditionalStep.java index f4be17baa..a7374f691 100644 --- a/src/main/java/com/questhelper/steps/ConditionalStep.java +++ b/src/main/java/com/questhelper/steps/ConditionalStep.java @@ -71,7 +71,6 @@ public class ConditionalStep extends QuestStep implements OwnerStep protected boolean checkAllChildStepsOnListenerCall = false; protected LinkedHashMap steps; - protected final HashMap orderedSteps; protected final List chatConditions = new ArrayList<>(); protected final List npcConditions = new ArrayList<>(); protected final List dialogConditions = new ArrayList<>(); @@ -102,11 +101,6 @@ public class ConditionalStep extends QuestStep implements OwnerStep this.requirements.addAll(Arrays.asList(requirements)); this.steps = new LinkedHashMap<>(); this.steps.put(null, step); - this.orderedSteps = new LinkedHashMap<>(); - if (id != null) - { - this.orderedSteps.put(id, step); - } this.id = id; } diff --git a/src/main/java/com/questhelper/steps/QuestStep.java b/src/main/java/com/questhelper/steps/QuestStep.java index f55f4405b..8f0499750 100644 --- a/src/main/java/com/questhelper/steps/QuestStep.java +++ b/src/main/java/com/questhelper/steps/QuestStep.java @@ -219,6 +219,10 @@ public abstract class QuestStep implements Module public QuestStep withId(Integer id) { this.id = id; + for (QuestStep substep : substeps) + { + substep.withId(id); + } return this; } diff --git a/src/main/java/com/questhelper/steps/ReorderableConditionalStep.java b/src/main/java/com/questhelper/steps/ReorderableConditionalStep.java index 2bae6d795..611f99af3 100644 --- a/src/main/java/com/questhelper/steps/ReorderableConditionalStep.java +++ b/src/main/java/com/questhelper/steps/ReorderableConditionalStep.java @@ -28,7 +28,6 @@ public class ReorderableConditionalStep extends ConditionalStep if (step.getId().equals(sidebarId)) { newSteps.put(req, step); - break; } } } diff --git a/src/test/java/com/questhelper/questhelpers/QuestHelperTest.java b/src/test/java/com/questhelper/questhelpers/QuestHelperTest.java index fc95b2e37..fe497a999 100644 --- a/src/test/java/com/questhelper/questhelpers/QuestHelperTest.java +++ b/src/test/java/com/questhelper/questhelpers/QuestHelperTest.java @@ -292,7 +292,8 @@ public class QuestHelperTest extends MockedTest QuestHelperQuest.CLIENT_OF_KOUREND, QuestHelperQuest.CHILDREN_OF_THE_SUN, QuestHelperQuest.MISTHALIN_MYSTERY, - QuestHelperQuest.PRINCE_ALI_RESCUE + QuestHelperQuest.PRINCE_ALI_RESCUE, + QuestHelperQuest.HERB_RUN ); // If you add a quest to this list, then this unit test will *only* test this quest