From e81f86f3a183eecd1f01471e3aa392db1f0bd2fa Mon Sep 17 00:00:00 2001 From: Kerpackie Date: Mon, 4 Sep 2023 14:08:07 +0100 Subject: [PATCH 01/20] Start Tree Run and Add createSeedRequirement Starts the tree run with some conditions Adds a FarmingUtils class which handles configuration options for the farm helpers. Add createSeedRequirement which providing an easy way to set up seed/sapling requirements without repeating code. --- .../{herbrun => farmruns}/FarmingHandler.java | 2 +- .../{herbrun => farmruns}/FarmingPatch.java | 2 +- .../{herbrun => farmruns}/FarmingRegion.java | 2 +- .../mischelpers/farmruns/FarmingUtils.java | 117 ++++++ .../{herbrun => farmruns}/FarmingWorld.java | 4 +- .../{herbrun => farmruns}/HerbRun.java | 2 +- .../PatchImplementation.java | 2 +- .../PatchPrediction.java | 2 +- .../{herbrun => farmruns}/PatchState.java | 2 +- .../helpers/mischelpers/farmruns/TreeRun.java | 343 ++++++++++++++++++ .../questinfo/QuestHelperQuest.java | 4 +- 11 files changed, 471 insertions(+), 11 deletions(-) rename src/main/java/com/questhelper/helpers/mischelpers/{herbrun => farmruns}/FarmingHandler.java (98%) rename src/main/java/com/questhelper/helpers/mischelpers/{herbrun => farmruns}/FarmingPatch.java (97%) rename src/main/java/com/questhelper/helpers/mischelpers/{herbrun => farmruns}/FarmingRegion.java (97%) create mode 100644 src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java rename src/main/java/com/questhelper/helpers/mischelpers/{herbrun => farmruns}/FarmingWorld.java (99%) rename src/main/java/com/questhelper/helpers/mischelpers/{herbrun => farmruns}/HerbRun.java (99%) rename src/main/java/com/questhelper/helpers/mischelpers/{herbrun => farmruns}/PatchImplementation.java (99%) rename src/main/java/com/questhelper/helpers/mischelpers/{herbrun => farmruns}/PatchPrediction.java (96%) rename src/main/java/com/questhelper/helpers/mischelpers/{herbrun => farmruns}/PatchState.java (97%) create mode 100644 src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java diff --git a/src/main/java/com/questhelper/helpers/mischelpers/herbrun/FarmingHandler.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingHandler.java similarity index 98% rename from src/main/java/com/questhelper/helpers/mischelpers/herbrun/FarmingHandler.java rename to src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingHandler.java index 3458f365bc..27a04031b8 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/herbrun/FarmingHandler.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingHandler.java @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package com.questhelper.helpers.mischelpers.herbrun; +package com.questhelper.helpers.mischelpers.farmruns; import java.time.Instant; import javax.annotation.Nullable; diff --git a/src/main/java/com/questhelper/helpers/mischelpers/herbrun/FarmingPatch.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingPatch.java similarity index 97% rename from src/main/java/com/questhelper/helpers/mischelpers/herbrun/FarmingPatch.java rename to src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingPatch.java index 4721463625..b557d786d5 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/herbrun/FarmingPatch.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingPatch.java @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package com.questhelper.helpers.mischelpers.herbrun; +package com.questhelper.helpers.mischelpers.farmruns; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/com/questhelper/helpers/mischelpers/herbrun/FarmingRegion.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingRegion.java similarity index 97% rename from src/main/java/com/questhelper/helpers/mischelpers/herbrun/FarmingRegion.java rename to src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingRegion.java index 6b74060c24..cc2549312c 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/herbrun/FarmingRegion.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingRegion.java @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package com.questhelper.helpers.mischelpers.herbrun; +package com.questhelper.helpers.mischelpers.farmruns; import lombok.Getter; import net.runelite.api.coords.WorldPoint; diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java new file mode 100644 index 0000000000..9c2160231d --- /dev/null +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java @@ -0,0 +1,117 @@ +package com.questhelper.helpers.mischelpers.farmruns; + +import com.questhelper.requirements.item.ItemRequirement; +import net.runelite.api.ItemID; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.util.Text; + +public class FarmingUtils +{ + + /** + * Creates an ItemRequirement representing a seed requirement for farming-related tasks. + * + * This method allows for customization based on configuration settings or uses default values if necessary. + * + * @param configManager The RuneLite ConfigManager instance used to access configuration settings. + * @param configGroupName The name of the configuration group where seed settings are stored. + * @param seedConfigName The name of the specific seed configuration setting. + * @param defaultValue The default seed enum value. + * @param defaultItemId The default item ID associated with the seed. + * @return An ItemRequirement object representing the seed requirement. + */ + + public static ItemRequirement createSeedRequirement(ConfigManager configManager, String configGroupName, + String seedConfigName, Enum defaultValue, int defaultItemId) + { + + ItemRequirement seedRequirement = new ItemRequirement(Text.titleCase(defaultValue), defaultItemId); + + String seedName = configManager.getRSProfileConfiguration(configGroupName, seedConfigName); + + if (seedName != null) + { + try + { + Enum seedEnum = Enum.valueOf(defaultValue.getDeclaringClass(), seedName); + seedRequirement.setId(getItemIdFromEnum(seedEnum)); + if (seedEnum instanceof HardwoodTreeSapling || + seedEnum instanceof FruitTreeSapling || + seedEnum instanceof TreeSapling) + { + seedRequirement.setName(Text.titleCase(seedEnum) + " sapling"); + } + else + { + seedRequirement.setName(Text.titleCase(seedEnum) + " seed"); + } + + } + catch (IllegalArgumentException e) + { + configManager.setRSProfileConfiguration(configGroupName, seedConfigName, defaultValue.name()); + } + } + else + { + configManager.setConfiguration(configGroupName, seedConfigName, defaultValue.name()); + } + + return seedRequirement; + } + + private static int getItemIdFromEnum(Enum enumValue) + { + if (enumValue instanceof TreeSapling) + { + return ((TreeSapling) enumValue).treeSaplingID; + } + else if (enumValue instanceof FruitTreeSapling) + { + return ((FruitTreeSapling) enumValue).fruitTreeSaplingId; + } + else if (enumValue instanceof HardwoodTreeSapling) + { + return ((HardwoodTreeSapling) enumValue).hardwoodTreeSaplingId; + } + else + { + throw new IllegalArgumentException("Unsupported enum type"); + } + } + + public enum TreeSapling { + OAK(ItemID.OAK_SAPLING), WILLOW(ItemID.WILLOW_SAPLING), MAPLE(ItemID.MAPLE_SAPLING), YEW(ItemID.YEW_SAPLING), + MAGIC(ItemID.MAGIC_SAPLING); + + final int treeSaplingID; + + TreeSapling(int treeSaplingID) { + this.treeSaplingID = treeSaplingID; + } + } + + public enum FruitTreeSapling { + APPLE(ItemID.APPLE_SAPLING), BANANA(ItemID.BANANA_SAPLING), ORANGE(ItemID.ORANGE_SAPLING), + CURRY(ItemID.CURRY_SAPLING), PINEAPPLE(ItemID.PINEAPPLE_SAPLING), PAPAYA(ItemID.PAPAYA_SAPLING), + PALM(ItemID.PALM_SAPLING), DRAGONFRUIT(ItemID.DRAGONFRUIT_SAPLING); + + final int fruitTreeSaplingId; + + FruitTreeSapling(int fruitTreeSaplingId) { + this.fruitTreeSaplingId = fruitTreeSaplingId; + } + } + + public enum HardwoodTreeSapling { + TEAK(ItemID.TEAK_SAPLING), + MAHOGANY(ItemID.MAHOGANY_SAPLING); + + final int hardwoodTreeSaplingId; + + HardwoodTreeSapling(int hardwoodTreeSaplingId) { + this.hardwoodTreeSaplingId = hardwoodTreeSaplingId; + } + } +} + diff --git a/src/main/java/com/questhelper/helpers/mischelpers/herbrun/FarmingWorld.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingWorld.java similarity index 99% rename from src/main/java/com/questhelper/helpers/mischelpers/herbrun/FarmingWorld.java rename to src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingWorld.java index 33d7ccb546..d96afdf06e 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/herbrun/FarmingWorld.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingWorld.java @@ -23,13 +23,12 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package com.questhelper.helpers.mischelpers.herbrun; +package com.questhelper.helpers.mischelpers.farmruns; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; import com.google.inject.Singleton; -import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; @@ -37,7 +36,6 @@ import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; -import java.util.stream.Collectors; import lombok.Getter; import net.runelite.api.NpcID; import net.runelite.api.Varbits; diff --git a/src/main/java/com/questhelper/helpers/mischelpers/herbrun/HerbRun.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/HerbRun.java similarity index 99% rename from src/main/java/com/questhelper/helpers/mischelpers/herbrun/HerbRun.java rename to src/main/java/com/questhelper/helpers/mischelpers/farmruns/HerbRun.java index 39b432d2f1..f5e8fe1f8a 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/herbrun/HerbRun.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/HerbRun.java @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package com.questhelper.helpers.mischelpers.herbrun; +package com.questhelper.helpers.mischelpers.farmruns; import com.questhelper.questinfo.HelperConfig; import com.questhelper.collections.ItemCollections; diff --git a/src/main/java/com/questhelper/helpers/mischelpers/herbrun/PatchImplementation.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchImplementation.java similarity index 99% rename from src/main/java/com/questhelper/helpers/mischelpers/herbrun/PatchImplementation.java rename to src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchImplementation.java index 40db4a7aa0..bafc27d60f 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/herbrun/PatchImplementation.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchImplementation.java @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package com.questhelper.helpers.mischelpers.herbrun; +package com.questhelper.helpers.mischelpers.farmruns; import javax.annotation.Nullable; import lombok.Getter; diff --git a/src/main/java/com/questhelper/helpers/mischelpers/herbrun/PatchPrediction.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchPrediction.java similarity index 96% rename from src/main/java/com/questhelper/helpers/mischelpers/herbrun/PatchPrediction.java rename to src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchPrediction.java index e0fc91b8f2..f9ad856f47 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/herbrun/PatchPrediction.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchPrediction.java @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package com.questhelper.helpers.mischelpers.herbrun; +package com.questhelper.helpers.mischelpers.farmruns; import lombok.Value; diff --git a/src/main/java/com/questhelper/helpers/mischelpers/herbrun/PatchState.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchState.java similarity index 97% rename from src/main/java/com/questhelper/helpers/mischelpers/herbrun/PatchState.java rename to src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchState.java index c88c534f09..2f6f9702ff 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/herbrun/PatchState.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchState.java @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package com.questhelper.helpers.mischelpers.herbrun; +package com.questhelper.helpers.mischelpers.farmruns; import lombok.Value; import net.runelite.client.plugins.timetracking.farming.CropState; diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java new file mode 100644 index 0000000000..4616246abc --- /dev/null +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java @@ -0,0 +1,343 @@ +package com.questhelper.helpers.mischelpers.farmruns; + +import com.google.inject.Inject; +import com.questhelper.QuestDescriptor; +import com.questhelper.QuestHelperConfig; +import com.questhelper.QuestHelperQuest; +import com.questhelper.questhelpers.ComplexStateQuestHelper; +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.player.Favour; +import com.questhelper.requirements.player.FavourRequirement; +import com.questhelper.requirements.player.SkillRequirement; +import com.questhelper.requirements.quest.QuestRequirement; +import com.questhelper.requirements.var.VarbitRequirement; +import com.questhelper.steps.ConditionalStep; +import com.questhelper.steps.DetailedQuestStep; +import com.questhelper.steps.QuestStep; +import net.runelite.api.Item; +import net.runelite.api.ItemID; +import net.runelite.api.Quest; +import net.runelite.api.QuestState; +import net.runelite.api.Skill; +import net.runelite.api.Varbits; +import net.runelite.client.util.Text; +import sun.reflect.generics.tree.Tree; + +@QuestDescriptor( + quest = QuestHelperQuest.TREE_RUN +) + +public class TreeRun extends ComplexStateQuestHelper +{ + @Inject + private FarmingWorld farmingWorld; + private FarmingHandler farmingHandler; + + DetailedQuestStep waitForTree; + + // Trees + DetailedQuestStep farmingGuildTreePatch, lumbridgeTreePatch, faladorTreePatch, taverleyTreePatch, varrockTreePatch, + gnomeStrongholdTreePatch; + DetailedQuestStep farmingGuildTreePatchPlant, lumbridgeTreePatchPlant, faladorTreePatchPlant, taverlyTreePatchPlant, + varrockTreePatchPlant, gnomeStrongholdTreePatchPlant; + + // Fruit Trees + DetailedQuestStep farmingGuildFruitTreePatch, gnomeStrongholdFruitTreePatch, gnomeVillageFruitTreePatch, + brimhavenFruitTreePatch, lletyaFruitTreePatch, catherbyFruitTreePatch; + DetailedQuestStep farmingGuildFruitTreePatchPlant, gnomeStrongholdFruitTreePatchPlant, gnomeVillageFruitTreePatchPlant, + brimhavenFruitTreePatchPlant, lletyaFruitTreePatchPlant, catherbyFruitTreePatchPlant; + + // Hardwood Trees + DetailedQuestStep eastHardwoodTreePatch, westHardwoodTreePatch, middleHardwoodTreePatch; + DetailedQuestStep eastHardwoodTreePatchPlant, westHardwoodTreePatchPlant, middleHardwoodTreePatchPlant; + + // Farming Items + ItemRequirement coins, spade, rake, treeSapling, fruitTreeSapling, hardwoodSapling, compost; + + // Teleport Items + // TODO: Add these... + + // Graceful Set + ItemRequirement gracefulHood, gracefulTop, gracefulLegs, gracefulGloves, gracefulBoots, gracefulCape, gracefulOutfit; + + // Farming Set + ItemRequirement farmingHat, farmingTop, farmingLegs, farmingBoots, farmersOutfit; + + // Access Requirements + Requirement accessToFarmingGuildTreePatch, accessToFarmingGuildFruitTreePatch, accessToLletya, accessToFossilIsland; + + // Tree Requirements + ManualRequirement lumbridgeTreePatchEmpty, faladorTreePatchEmpty, taverlyTreePatchEmpty, + varrockTreePatchEmpty, gnomeStrongholdTreePatchEmpty, farmingGuildTreePatchEmpty; + ManualRequirement lumbridgeTreePatchReady, faladorTreePatchReady, taverlyTreePatchReady, + varrockTreePatchReady, gnomeStrongholdTreePatchReady, farmingGuildTreePatchReady; + + // Fruit Tree Requirements + ManualRequirement gnomeStrongholdFruitTreePatchEmpty, gnomeVillageFruitTreePatchEmpty, + brimhavenFruitTreePatchEmpty, lletyaFruitTreePatchEmpty, catherbyFruitTreePatchEmpty, farmingGuildFruitTreePatchEmpty; + ManualRequirement gnomeStrongholdFruitTreePatchReady, gnomeVillageFruitTreePatchReady, + brimhavenFruitTreePatchReady, lletyaFruitTreePatchReady, catherbyFruitTreePatchReady, farmingGuildFruitTreePatchReady; + + // Hardwood Tree Requirements + ManualRequirement eastHardwoodTreePatchEmpty, westHardwoodTreePatchEmpty, middleHardwoodTreePatchEmpty; + ManualRequirement eastHardwoodTreePatchReady, westHardwoodTreePatchReady, middleHardwoodTreePatchReady; + + private enum TreeSapling + { + OAK(ItemID.OAK_SAPLING), WILLOW(ItemID.WILLOW_SAPLING), MAPLE(ItemID.MAPLE_SAPLING), YEW(ItemID.YEW_SAPLING), + MAGIC(ItemID.MAGIC_SAPLING); + + final int treeSaplingID; + + TreeSapling(int treeSaplingID) + { + this.treeSaplingID = treeSaplingID; + } + } + + private enum FruitTreeSapling + { + APPLE(ItemID.APPLE_SAPLING), BANANA(ItemID.BANANA_SAPLING), ORANGE(ItemID.ORANGE_SAPLING), + CURRY(ItemID.CURRY_SAPLING), PINEAPPLE(ItemID.PINEAPPLE_SAPLING), PAPAYA(ItemID.PAPAYA_SAPLING), + PALM(ItemID.PALM_SAPLING), DRAGONFRUIT(ItemID.DRAGONFRUIT_SAPLING); + + final int fruitTreeSaplingId; + + FruitTreeSapling(int fruitTreeSaplingId) + { + this.fruitTreeSaplingId = fruitTreeSaplingId; + } + } + + private enum HardwoodTreeSapling + { + TEAK(ItemID.TEAK_SAPLING), + MAHOGANY(ItemID.MAHOGANY_SAPLING); + + final int hardwoodTreeSaplingId; + + HardwoodTreeSapling(int hardwoodTreeSaplingId) + { + this.hardwoodTreeSaplingId = hardwoodTreeSaplingId; + } + } + + private enum GracefulOrFarming { + NONE(), + GRACEFUL(), + FARMING(); + } + + private final String TREE_SAPLING = "treeSaplings"; + private final String FRUIT_TREE_SAPLING = "fruitTreeSaplings"; + private final String HARDWOOD_TREE_SAPLING = "hardwoodTreeSaplings"; + private final String GRACEFUL_OR_FARMING = "gracefulOrFarming"; + + @Override + public QuestStep loadStep() + { + farmingHandler = new FarmingHandler(client, configManager); + setupRequirements(); + setupConditions(); + setupSteps(); + + ConditionalStep steps = new ConditionalStep(this, waitForTree, spade, coins, rake, treeSapling, + fruitTreeSapling, hardwoodSapling, farmersOutfit, gracefulOutfit); + + return steps; + } + + private void setupConditions() + { + // Tree Patch Ready Requirements + lumbridgeTreePatchReady = new ManualRequirement(); + faladorTreePatchReady = new ManualRequirement(); + taverlyTreePatchReady = new ManualRequirement(); + varrockTreePatchReady = new ManualRequirement(); + gnomeStrongholdTreePatchReady = new ManualRequirement(); + farmingGuildTreePatchReady = new ManualRequirement(); + + // Tree Patch Empty Requirements + lumbridgeTreePatchEmpty = new ManualRequirement(); + faladorTreePatchEmpty = new ManualRequirement(); + taverlyTreePatchEmpty = new ManualRequirement(); + varrockTreePatchEmpty = new ManualRequirement(); + gnomeStrongholdTreePatchEmpty = new ManualRequirement(); + farmingGuildTreePatchEmpty = new ManualRequirement(); + + // Fruit Patch Ready Requirements + gnomeStrongholdFruitTreePatchReady = new ManualRequirement(); + gnomeVillageFruitTreePatchReady = new ManualRequirement(); + brimhavenFruitTreePatchReady = new ManualRequirement(); + lletyaFruitTreePatchReady = new ManualRequirement(); + catherbyFruitTreePatchReady = new ManualRequirement(); + farmingGuildFruitTreePatchReady = new ManualRequirement(); + + // Fruit Patch Empty Requirements + gnomeStrongholdFruitTreePatchEmpty = new ManualRequirement(); + gnomeVillageFruitTreePatchEmpty = new ManualRequirement(); + brimhavenFruitTreePatchEmpty = new ManualRequirement(); + lletyaFruitTreePatchEmpty = new ManualRequirement(); + catherbyFruitTreePatchEmpty = new ManualRequirement(); + farmingGuildFruitTreePatchEmpty = new ManualRequirement(); + + // Hardwood Tree Ready Requirements + eastHardwoodTreePatchReady = new ManualRequirement(); + westHardwoodTreePatchReady = new ManualRequirement(); + middleHardwoodTreePatchReady = new ManualRequirement(); + + // Hardwood Tree Empty Requirements + eastHardwoodTreePatchEmpty = new ManualRequirement(); + westHardwoodTreePatchEmpty = new ManualRequirement(); + middleHardwoodTreePatchEmpty = new ManualRequirement(); + + // Access Requirements + // ME1 partial completion required only, however much easier to access when finished. + accessToLletya = new QuestRequirement(QuestHelperQuest.MOURNINGS_END_PART_I, QuestState.FINISHED); + accessToFossilIsland = new QuestRequirement(QuestHelperQuest.BONE_VOYAGE, QuestState.FINISHED); + accessToFarmingGuildTreePatch = new Conditions( + new FavourRequirement(Favour.HOSIDIUS, 60), + new SkillRequirement(Skill.FARMING, 65) + ); + accessToFarmingGuildFruitTreePatch = new Conditions( + new FavourRequirement(Favour.HOSIDIUS, 60), + new SkillRequirement(Skill.FARMING, 85) + ); + } + + @Override + public void setupRequirements() + { + // Farming Item Requirements + spade = new ItemRequirement("Spade", ItemID.SPADE); + rake = new ItemRequirement("Rake", ItemID.RAKE) + .hideConditioned(new VarbitRequirement(Varbits.AUTOWEED, 2)); + coins = new ItemRequirement("Coins to quickly remove trees.", ItemID.COINS_995, -1); + + // TODO: Make a util function that can ingest the ItemRequirement and other required objects to make below 3 single function calls instead of the current repetition, should work for all farming helpers. + // Saplings + // Tree + /*treeSapling = new ItemRequirement("Tree saplings of your choice", ItemID.OAK_SAPLING); + + String treeSaplingName = configManager.getRSProfileConfiguration( + QuestHelperConfig.QUEST_BACKGROUND_GROUP, TREE_SAPLING + ); + + if (treeSaplingName != null) + { + try + { + treeSapling.setId(TreeSapling.valueOf(treeSaplingName).treeSaplingID); + } + catch (IllegalArgumentException e) + { + questHelperPlugin.getConfigManager().setRSProfileConfiguration( + QuestHelperConfig.QUEST_BACKGROUND_GROUP, TREE_SAPLING, TreeSapling.OAK + ); + } + + treeSapling.setName(Text.titleCase(TreeSapling.valueOf(treeSaplingName)) + " sapling"); + } + else + { + questHelperPlugin.getConfigManager().setConfiguration( + QuestHelperConfig.QUEST_BACKGROUND_GROUP, TREE_SAPLING, TreeSapling.OAK + ); + } + + // Fruit Tree + fruitTreeSapling = new ItemRequirement("Fruit tree saplings of your choice", ItemID.APPLE_SAPLING); + + String fruitTreeSaplingName = configManager.getRSProfileConfiguration( + QuestHelperConfig.QUEST_BACKGROUND_GROUP, FRUIT_TREE_SAPLING + ); + + if (fruitTreeSaplingName != null) + { + try + { + fruitTreeSapling.setId(FruitTreeSapling.valueOf(fruitTreeSaplingName).fruitTreeSaplingId); + } + catch (IllegalArgumentException e) + { + questHelperPlugin.getConfigManager().setRSProfileConfiguration( + QuestHelperConfig.QUEST_BACKGROUND_GROUP, FRUIT_TREE_SAPLING, FruitTreeSapling.APPLE + ); + } + + fruitTreeSapling.setName(Text.titleCase(FruitTreeSapling.valueOf(fruitTreeSaplingName)) + "sapling"); + } + else + { + questHelperPlugin.getConfigManager().setConfiguration( + QuestHelperConfig.QUEST_BACKGROUND_GROUP, FRUIT_TREE_SAPLING, FruitTreeSapling.APPLE + ); + } + + // Hardwood Tree + hardwoodSapling = new ItemRequirement("Hardwood tree saplings of your choice", ItemID.TEAK_SAPLING); + + String hardwoodTreeSaplingName = configManager.getRSProfileConfiguration( + QuestHelperConfig.QUEST_BACKGROUND_GROUP, HARDWOOD_TREE_SAPLING + ); + + if (hardwoodTreeSaplingName != null) + { + try + { + hardwoodSapling.setId(HardwoodTreeSapling.valueOf(hardwoodTreeSaplingName).hardwoodTreeSaplingId); + } + catch (IllegalArgumentException e) + { + questHelperPlugin.getConfigManager().setRSProfileConfiguration( + QuestHelperConfig.QUEST_BACKGROUND_GROUP, HARDWOOD_TREE_SAPLING, HardwoodTreeSapling.TEAK + ); + } + + hardwoodSapling.setName(Text.titleCase(HardwoodTreeSapling.valueOf(hardwoodTreeSaplingName)) + " sapling"); + } + else + { + questHelperPlugin.getConfigManager().setConfiguration( + QuestHelperConfig.QUEST_BACKGROUND_GROUP, HARDWOOD_TREE_SAPLING, HardwoodTreeSapling.TEAK + ); + }*/ + + // Replace the existing code for treeSapling, fruitTreeSapling, and hardwoodSapling setup with the following: + + treeSapling = FarmingUtils.createSeedRequirement( + configManager, + QuestHelperConfig.QUEST_BACKGROUND_GROUP, + TREE_SAPLING, + TreeSapling.OAK, + ItemID.OAK_SAPLING + ); + + fruitTreeSapling = FarmingUtils.createSeedRequirement( + configManager, + QuestHelperConfig.QUEST_BACKGROUND_GROUP, + FRUIT_TREE_SAPLING, + FruitTreeSapling.APPLE, + ItemID.APPLE_SAPLING + ); + + hardwoodSapling = FarmingUtils.createSeedRequirement ( + configManager, + QuestHelperConfig.QUEST_BACKGROUND_GROUP, + HARDWOOD_TREE_SAPLING, + HardwoodTreeSapling.TEAK, + ItemID.TEAK_SAPLING + ); + + + } + + private void setupSteps() + { + } + + +} diff --git a/src/main/java/com/questhelper/questinfo/QuestHelperQuest.java b/src/main/java/com/questhelper/questinfo/QuestHelperQuest.java index d3e15e1e11..6ca0f5f7d7 100644 --- a/src/main/java/com/questhelper/questinfo/QuestHelperQuest.java +++ b/src/main/java/com/questhelper/questinfo/QuestHelperQuest.java @@ -77,8 +77,9 @@ import com.questhelper.helpers.miniquests.hisfaithfulservants.BarrowsHelper; import com.questhelper.helpers.miniquests.hisfaithfulservants.HisFaithfulServants; import com.questhelper.helpers.mischelpers.allneededitems.AllNeededItems; -import com.questhelper.helpers.mischelpers.herbrun.HerbRun; import com.questhelper.helpers.mischelpers.strongholdofsecurity.StrongholdOfSecurity; +import com.questhelper.helpers.mischelpers.farmruns.HerbRun; +import com.questhelper.helpers.mischelpers.farmruns.TreeRun; import com.questhelper.helpers.quests.akingdomdivided.AKingdomDivided; import com.questhelper.helpers.miniquests.alfredgrimhandsbarcrawl.AlfredGrimhandsBarcrawl; import com.questhelper.helpers.quests.anightatthetheatre.ANightAtTheTheatre; @@ -635,6 +636,7 @@ public enum QuestHelperQuest DAG_ROUTE(new DagRouteHelper(), "Dagannoth Kings Route", QuestVarbits.QUEST_THE_FREMENNIK_ISLES, -1, QuestDetails.Type.GENERIC, QuestDetails.Difficulty.GENERIC), HERB_RUN(new HerbRun(), "Herb run", QuestVarbits.CUTSCENE, -1, QuestDetails.Type.GENERIC, QuestDetails.Difficulty.GENERIC), + TREE_RUN(new TreeRun(), "Tree run", QuestVarbits.CUTSCENE, -1, QuestDetails.Type.GENERIC, QuestDetails.Difficulty.GENERIC), BARROWS_HELPER(new BarrowsHelper(), "Barrows helper", QuestVarbits.CUTSCENE, -1, QuestDetails.Type.GENERIC, QuestDetails.Difficulty.GENERIC), STRONGHOLD_OF_SECURITY(new StrongholdOfSecurity(), "Stronghold of Security", QuestVarbits.STRONGHOLD_OF_SECURITY, 1, QuestDetails.Type.GENERIC, QuestDetails.Difficulty.GENERIC), From ba28c026d5ab2440f09a2b651b50638697067fde Mon Sep 17 00:00:00 2001 From: Kerpackie Date: Mon, 4 Sep 2023 16:55:55 +0100 Subject: [PATCH 02/20] Add Configuration Options Adds configuration options Starts the patch steps --- .../mischelpers/farmruns/FarmingUtils.java | 4 +- .../helpers/mischelpers/farmruns/TreeRun.java | 186 +++++++++++++++++- 2 files changed, 183 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java index 9c2160231d..5abb73a243 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java @@ -36,8 +36,8 @@ public static ItemRequirement createSeedRequirement(ConfigManager configManager, Enum seedEnum = Enum.valueOf(defaultValue.getDeclaringClass(), seedName); seedRequirement.setId(getItemIdFromEnum(seedEnum)); if (seedEnum instanceof HardwoodTreeSapling || - seedEnum instanceof FruitTreeSapling || - seedEnum instanceof TreeSapling) + seedEnum instanceof FruitTreeSapling || + seedEnum instanceof TreeSapling) { seedRequirement.setName(Text.titleCase(seedEnum) + " sapling"); } diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java index 4616246abc..8692fd708e 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java @@ -1,6 +1,8 @@ package com.questhelper.helpers.mischelpers.farmruns; import com.google.inject.Inject; +import com.questhelper.HelperConfig; +import com.questhelper.ItemCollections; import com.questhelper.QuestDescriptor; import com.questhelper.QuestHelperConfig; import com.questhelper.QuestHelperQuest; @@ -9,22 +11,33 @@ import com.questhelper.requirements.Requirement; import com.questhelper.requirements.conditional.Conditions; import com.questhelper.requirements.item.ItemRequirement; +import com.questhelper.requirements.item.ItemRequirements; import com.questhelper.requirements.player.Favour; import com.questhelper.requirements.player.FavourRequirement; import com.questhelper.requirements.player.SkillRequirement; 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 net.runelite.api.Item; import net.runelite.api.ItemID; +import net.runelite.api.NullObjectID; import net.runelite.api.Quest; import net.runelite.api.QuestState; import net.runelite.api.Skill; import net.runelite.api.Varbits; +import net.runelite.api.World; +import net.runelite.api.coords.WorldPoint; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.events.ConfigChanged; import net.runelite.client.util.Text; import sun.reflect.generics.tree.Tree; +import java.util.Arrays; +import java.util.List; @QuestDescriptor( quest = QuestHelperQuest.TREE_RUN @@ -41,7 +54,7 @@ public class TreeRun extends ComplexStateQuestHelper // Trees DetailedQuestStep farmingGuildTreePatch, lumbridgeTreePatch, faladorTreePatch, taverleyTreePatch, varrockTreePatch, gnomeStrongholdTreePatch; - DetailedQuestStep farmingGuildTreePatchPlant, lumbridgeTreePatchPlant, faladorTreePatchPlant, taverlyTreePatchPlant, + DetailedQuestStep farmingGuildTreePatchPlant, lumbridgeTreePatchPlant, faladorTreePatchPlant, taverleyTreePatchPlant, varrockTreePatchPlant, gnomeStrongholdTreePatchPlant; // Fruit Trees @@ -59,6 +72,7 @@ public class TreeRun extends ComplexStateQuestHelper // Teleport Items // TODO: Add these... + ItemRequirement farmingGuildTeleport; // Graceful Set ItemRequirement gracefulHood, gracefulTop, gracefulLegs, gracefulGloves, gracefulBoots, gracefulCape, gracefulOutfit; @@ -70,9 +84,9 @@ public class TreeRun extends ComplexStateQuestHelper Requirement accessToFarmingGuildTreePatch, accessToFarmingGuildFruitTreePatch, accessToLletya, accessToFossilIsland; // Tree Requirements - ManualRequirement lumbridgeTreePatchEmpty, faladorTreePatchEmpty, taverlyTreePatchEmpty, + ManualRequirement lumbridgeTreePatchEmpty, faladorTreePatchEmpty, taverleyTreePatchEmpty, varrockTreePatchEmpty, gnomeStrongholdTreePatchEmpty, farmingGuildTreePatchEmpty; - ManualRequirement lumbridgeTreePatchReady, faladorTreePatchReady, taverlyTreePatchReady, + ManualRequirement lumbridgeTreePatchReady, faladorTreePatchReady, taverleyTreePatchReady, varrockTreePatchReady, gnomeStrongholdTreePatchReady, farmingGuildTreePatchReady; // Fruit Tree Requirements @@ -155,7 +169,7 @@ private void setupConditions() // Tree Patch Ready Requirements lumbridgeTreePatchReady = new ManualRequirement(); faladorTreePatchReady = new ManualRequirement(); - taverlyTreePatchReady = new ManualRequirement(); + taverleyTreePatchReady = new ManualRequirement(); varrockTreePatchReady = new ManualRequirement(); gnomeStrongholdTreePatchReady = new ManualRequirement(); farmingGuildTreePatchReady = new ManualRequirement(); @@ -163,7 +177,7 @@ private void setupConditions() // Tree Patch Empty Requirements lumbridgeTreePatchEmpty = new ManualRequirement(); faladorTreePatchEmpty = new ManualRequirement(); - taverlyTreePatchEmpty = new ManualRequirement(); + taverleyTreePatchEmpty = new ManualRequirement(); varrockTreePatchEmpty = new ManualRequirement(); gnomeStrongholdTreePatchEmpty = new ManualRequirement(); farmingGuildTreePatchEmpty = new ManualRequirement(); @@ -206,6 +220,7 @@ private void setupConditions() new FavourRequirement(Favour.HOSIDIUS, 60), new SkillRequirement(Skill.FARMING, 85) ); + } @Override @@ -332,12 +347,173 @@ public void setupRequirements() ItemID.TEAK_SAPLING ); + compost = new ItemRequirement("Compost", ItemCollections.COMPOST); + + // Teleport Items + farmingGuildTeleport = new ItemRequirement("Farming Guild Teleport", ItemCollections.SKILLS_NECKLACES); + + // Graceful and Farming Outfit + // TODO: Extract to FarmingUtils + + gracefulHood = new ItemRequirement( + "Graceful hood", ItemCollections.GRACEFUL_HOOD, 1 ,true).isNotConsumed(); + + gracefulTop = new ItemRequirement( + "Graceful top", ItemCollections.GRACEFUL_TOP, 1, true).isNotConsumed(); + + gracefulLegs = new ItemRequirement( + "Graceful legs", ItemCollections.GRACEFUL_LEGS, 1, true).isNotConsumed(); + + gracefulCape = new ItemRequirement( + "Graceful cape", ItemCollections.GRACEFUL_CAPE, 1, true).isNotConsumed(); + + gracefulGloves = new ItemRequirement( + "Graceful gloves", ItemCollections.GRACEFUL_GLOVES, 1, true).isNotConsumed(); + + gracefulBoots = new ItemRequirement( + "Graceful boots", ItemCollections.GRACEFUL_BOOTS, 1, true).isNotConsumed(); + gracefulBoots.addAlternates(ItemID.BOOTS_OF_LIGHTNESS); + + gracefulOutfit = new ItemRequirements( + "Graceful outfit (equipped)", + gracefulHood, gracefulTop, gracefulLegs, gracefulGloves, gracefulBoots, gracefulCape + ).isNotConsumed().showConditioned(new RuneliteRequirement(configManager, GRACEFUL_OR_FARMING, TreeRun.GracefulOrFarming.GRACEFUL.name())); + + farmingHat = new ItemRequirement( + "Farmer's strawhat", ItemID.FARMERS_STRAWHAT, 1 ,true).isNotConsumed(); + farmingHat.addAlternates(ItemID.FARMERS_STRAWHAT_13647, ItemID.FARMERS_STRAWHAT_21253, ItemID.FARMERS_STRAWHAT_21254); + + farmingTop = new ItemRequirement( + "Farmer's top", ItemID.FARMERS_JACKET, 1, true).isNotConsumed(); + farmingTop.addAlternates(ItemID.FARMERS_SHIRT); + + + farmingLegs = new ItemRequirement( + "Farmer's boro trousers", ItemID.FARMERS_BORO_TROUSERS, 1, true).isNotConsumed(); + farmingLegs.addAlternates(ItemID.FARMERS_BORO_TROUSERS_13641); + + farmingBoots = new ItemRequirement( + "Graceful cape", ItemID.FARMERS_BOOTS, 1, true).isNotConsumed(); + farmingBoots.addAlternates(ItemID.FARMERS_BOOTS_13645); + + + farmersOutfit = new ItemRequirements( + "Farmer's outfit (equipped)", + farmingHat, farmingTop, farmingLegs, farmingBoots + ).isNotConsumed().showConditioned(new RuneliteRequirement(configManager, GRACEFUL_OR_FARMING, TreeRun.GracefulOrFarming.FARMING.name())); } private void setupSteps() { + waitForTree = new DetailedQuestStep(this, "Wait for your trees to grow! This may take a while..!"); + + // Tree Steps + lumbridgeTreePatch = new ObjectStep(this, NullObjectID.NULL_8391, new WorldPoint(3192, 3230, 0), + "Check the health of the tree planted in Lumbridge."); + faladorTreePatch = new ObjectStep(this, NullObjectID.NULL_8389, new WorldPoint(3003, 3372, 0), + "Check the health of the tree planted in Falador."); + taverleyTreePatch = new ObjectStep(this, NullObjectID.NULL_8388, new WorldPoint(2935, 3437, 0), + "Check the health of the tree planted in Taverley."); + varrockTreePatch = new ObjectStep(this, NullObjectID.NULL_8390, new WorldPoint(3228, 3458, 0), + "Check the health of the tree planted in Varrock."); + gnomeStrongholdTreePatch = new ObjectStep(this, NullObjectID.NULL_19147, new WorldPoint(2435, 3414, 0), + "Check the health of the tree planted in the Tree Gnome Stronghold."); + + farmingGuildTreePatch = new ObjectStep(this, NullObjectID.NULL_33732, new WorldPoint(1231, 3735, 0), + "Check the health of the tree planted in the Farming Guild."); + farmingGuildTreePatch.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildTreePatch)); + + + + // Fruit Tree Steps + gnomeStrongholdFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_7962, new WorldPoint(2475, 3445, 0), + "Check the health of the fruit tree planted in the Tree Gnome Stronghold."); + gnomeVillageFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_7963, new WorldPoint(2489, 3179, 0), + "Check the health of the fruit tree planted outside the Tree Gnome Village. Follow Elkoy to get out quickly."); + brimhavenFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_7964, new WorldPoint(2764, 3212, 0), + "Check the health of the fruit tree planted in Brimhaven."); + catherbyFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_7965, new WorldPoint(2680, 3433, 0), + "Check the health of the fruit tree planted in Catherby"); + + lletyaFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_26579, new WorldPoint(2346, 3161, 0), + "Check the health of the fruit tree planted in Lletya."); + lletyaFruitTreePatch.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToLletya)); + + farmingGuildFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_34007, new WorldPoint(1242, 3759, 0), + "Check the health of the fruit tree planted in the Farming Guild."); + farmingGuildFruitTreePatch.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildFruitTreePatch)); + + + } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals(QuestHelperConfig.QUEST_BACKGROUND_GROUP)) + { + return; + } + + if (event.getKey().equals(TREE_SAPLING)) + { + try + { + TreeSapling selectedTreeSapling = TreeSapling.valueOf(event.getNewValue()); + treeSapling.setId(selectedTreeSapling.treeSaplingID); + treeSapling.setName(Text.titleCase(selectedTreeSapling) + " sapling"); + questHelperPlugin.refreshBank(); + } + catch (IllegalArgumentException e) + { + questHelperPlugin.getConfigManager().setConfiguration(QuestHelperConfig.QUEST_BACKGROUND_GROUP, TREE_SAPLING, TreeSapling.OAK); + } + } + + if (event.getKey().equals(FRUIT_TREE_SAPLING)) + { + try + { + FruitTreeSapling selectedFruitTreeSapling = FruitTreeSapling.valueOf(event.getNewValue()); + fruitTreeSapling.setId(selectedFruitTreeSapling.fruitTreeSaplingId); + fruitTreeSapling.setName(Text.titleCase(selectedFruitTreeSapling) + " sapling"); + questHelperPlugin.refreshBank(); + } + catch (IllegalArgumentException e) + { + questHelperPlugin.getConfigManager().setConfiguration(QuestHelperConfig.QUEST_BACKGROUND_GROUP, FRUIT_TREE_SAPLING, FruitTreeSapling.APPLE); + } + } + + if (event.getKey().equals(HARDWOOD_TREE_SAPLING)) + { + try + { + HardwoodTreeSapling selectedHardwoodTreeSapling = HardwoodTreeSapling.valueOf(event.getNewValue()); + hardwoodSapling.setId(selectedHardwoodTreeSapling.hardwoodTreeSaplingId); + hardwoodSapling.setName(Text.titleCase(selectedHardwoodTreeSapling) + " sapling"); + questHelperPlugin.refreshBank(); + } + catch (IllegalArgumentException e) + { + questHelperPlugin.getConfigManager().setConfiguration(QuestHelperConfig.QUEST_BACKGROUND_GROUP, HARDWOOD_TREE_SAPLING, HardwoodTreeSapling.TEAK); + } + } + + if (event.getKey().equals(GRACEFUL_OR_FARMING)) + { + questHelperPlugin.refreshBank(); + } } + @Override + public List getConfigs() + { + HelperConfig treesConfig = new HelperConfig("Trees", TREE_SAPLING, TreeRun.TreeSapling.values()); + HelperConfig fruitTreesConfig = new HelperConfig("Fruit Trees", FRUIT_TREE_SAPLING, TreeRun.FruitTreeSapling.values()); + HelperConfig hardwoodTreesConfig = new HelperConfig("Hardwood Trees", HARDWOOD_TREE_SAPLING, TreeRun.HardwoodTreeSapling.values()); + HelperConfig outfitConfig = new HelperConfig("Outfit", GRACEFUL_OR_FARMING, TreeRun.GracefulOrFarming.values()); + return Arrays.asList(treesConfig, fruitTreesConfig, hardwoodTreesConfig, outfitConfig); + } } From 918b897aa49894dbc22b67ef10407caef3d2eb42 Mon Sep 17 00:00:00 2001 From: Kerpackie Date: Mon, 4 Sep 2023 17:13:11 +0100 Subject: [PATCH 03/20] Add FarmConfigChangeHandler Adds a FarmConfigChangeHandler which (better?) handles the onChange events for the Farming Helpers. --- .../farmruns/FarmingConfigChangeHandler.java | 31 ++++++++++++ .../mischelpers/farmruns/FarmingUtils.java | 4 +- .../helpers/mischelpers/farmruns/TreeRun.java | 49 ++++++++++++++++++- 3 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java new file mode 100644 index 0000000000..b3f68819b2 --- /dev/null +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java @@ -0,0 +1,31 @@ +package com.questhelper.helpers.mischelpers.farmruns; + +import net.runelite.client.config.ConfigManager; +import java.util.function.Consumer; + +public class FarmingConfigChangeHandler +{ + public static void handleConfigChange(ConfigManager configManager, String configGroupName, + Enum defaultValue, Consumer> updateFunction) + { + String newValue = configManager.getRSProfileConfiguration(configGroupName, defaultValue.name()); + + if (newValue != null) + { + try + { + Enum enumValue = Enum.valueOf(defaultValue.getDeclaringClass(), newValue); + updateFunction.accept(enumValue); + } + catch (IllegalArgumentException e) + { + configManager.setRSProfileConfiguration(configGroupName, defaultValue.name(), defaultValue); + } + } + else + { + configManager.setConfiguration(configGroupName, defaultValue.name(), defaultValue); + } + } + +} diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java index 5abb73a243..1eae6d74bc 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java @@ -34,7 +34,7 @@ public static ItemRequirement createSeedRequirement(ConfigManager configManager, try { Enum seedEnum = Enum.valueOf(defaultValue.getDeclaringClass(), seedName); - seedRequirement.setId(getItemIdFromEnum(seedEnum)); + seedRequirement.setId(getSeedItemIdFromEnum(seedEnum)); if (seedEnum instanceof HardwoodTreeSapling || seedEnum instanceof FruitTreeSapling || seedEnum instanceof TreeSapling) @@ -60,7 +60,7 @@ public static ItemRequirement createSeedRequirement(ConfigManager configManager, return seedRequirement; } - private static int getItemIdFromEnum(Enum enumValue) + public static int getSeedItemIdFromEnum(Enum enumValue) { if (enumValue instanceof TreeSapling) { diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java index 8692fd708e..fef1acc5c7 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java @@ -448,6 +448,53 @@ private void setupSteps() } @Subscribe + public void onConfigChanged(ConfigChanged event) { + if (!event.getGroup().equals(QuestHelperConfig.QUEST_BACKGROUND_GROUP)) { + return; + } + + if (event.getKey().equals(TREE_SAPLING)) { + FarmingConfigChangeHandler.handleConfigChange( + questHelperPlugin.getConfigManager(), + QuestHelperConfig.QUEST_BACKGROUND_GROUP, + TreeSapling.OAK, + (selectedTreeSapling) -> { + treeSapling.setId(FarmingUtils.getSeedItemIdFromEnum(selectedTreeSapling)); + treeSapling.setName(Text.titleCase(selectedTreeSapling) + " sapling"); + questHelperPlugin.refreshBank(); + } + ); + } + + if (event.getKey().equals(FRUIT_TREE_SAPLING)) { + FarmingConfigChangeHandler.handleConfigChange( + questHelperPlugin.getConfigManager(), + QuestHelperConfig.QUEST_BACKGROUND_GROUP, + FruitTreeSapling.APPLE, + (selectedFruitTreeSapling) -> { + fruitTreeSapling.setId(FarmingUtils.getSeedItemIdFromEnum(selectedFruitTreeSapling)); + fruitTreeSapling.setName(Text.titleCase(selectedFruitTreeSapling) + " sapling"); + questHelperPlugin.refreshBank(); + } + ); + } + + if (event.getKey().equals(HARDWOOD_TREE_SAPLING)) { + FarmingConfigChangeHandler.handleConfigChange( + questHelperPlugin.getConfigManager(), + QuestHelperConfig.QUEST_BACKGROUND_GROUP, + HardwoodTreeSapling.TEAK, + (selectedHardwoodTreeSapling) -> { + hardwoodSapling.setId(FarmingUtils.getSeedItemIdFromEnum(selectedHardwoodTreeSapling)); + hardwoodSapling.setName(Text.titleCase(selectedHardwoodTreeSapling) + " sapling"); + questHelperPlugin.refreshBank(); + } + ); + } + } + + +/* @Subscribe public void onConfigChanged(ConfigChanged event) { if (!event.getGroup().equals(QuestHelperConfig.QUEST_BACKGROUND_GROUP)) @@ -504,7 +551,7 @@ public void onConfigChanged(ConfigChanged event) { questHelperPlugin.refreshBank(); } - } + }*/ @Override public List getConfigs() From e3817a432f84d542ea07d6cb43358683045bac22 Mon Sep 17 00:00:00 2001 From: Kerpackie Date: Mon, 4 Sep 2023 17:50:00 +0100 Subject: [PATCH 04/20] Refactor and Fix FarmConfigChangeHandler It actually works now, and is now actually shorter than originally. --- .../farmruns/FarmingConfigChangeHandler.java | 27 ++--- .../helpers/mischelpers/farmruns/TreeRun.java | 114 +++--------------- 2 files changed, 30 insertions(+), 111 deletions(-) diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java index b3f68819b2..1a07447f69 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java @@ -1,31 +1,30 @@ package com.questhelper.helpers.mischelpers.farmruns; +import com.questhelper.QuestHelperConfig; +import com.questhelper.QuestHelperPlugin; import net.runelite.client.config.ConfigManager; +import net.runelite.client.events.ConfigChanged; import java.util.function.Consumer; public class FarmingConfigChangeHandler { - public static void handleConfigChange(ConfigManager configManager, String configGroupName, - Enum defaultValue, Consumer> updateFunction) - { - String newValue = configManager.getRSProfileConfiguration(configGroupName, defaultValue.name()); - if (newValue != null) + public static > void handleFarmingEnumConfigChange(ConfigChanged event, String configKey, + Class enumClass, Consumer updateAction, T defaultValue, ConfigManager configManager, QuestHelperPlugin questHelperPlugin) + { + if (event.getKey().equals(configKey)) { - try + try { - Enum enumValue = Enum.valueOf(defaultValue.getDeclaringClass(), newValue); - updateFunction.accept(enumValue); + T selectedEnumValue = Enum.valueOf(enumClass, event.getNewValue()); + updateAction.accept(selectedEnumValue); + questHelperPlugin.refreshBank(); } catch (IllegalArgumentException e) { - configManager.setRSProfileConfiguration(configGroupName, defaultValue.name(), defaultValue); + configManager.setConfiguration(QuestHelperConfig.QUEST_BACKGROUND_GROUP, configKey, defaultValue.name()); } } - else - { - configManager.setConfiguration(configGroupName, defaultValue.name(), defaultValue); - } } - } + diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java index fef1acc5c7..4f0862fcf4 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java @@ -23,19 +23,15 @@ import com.questhelper.steps.DetailedQuestStep; import com.questhelper.steps.ObjectStep; import com.questhelper.steps.QuestStep; -import net.runelite.api.Item; import net.runelite.api.ItemID; import net.runelite.api.NullObjectID; -import net.runelite.api.Quest; import net.runelite.api.QuestState; import net.runelite.api.Skill; import net.runelite.api.Varbits; -import net.runelite.api.World; import net.runelite.api.coords.WorldPoint; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.ConfigChanged; import net.runelite.client.util.Text; -import sun.reflect.generics.tree.Tree; import java.util.Arrays; import java.util.List; @@ -453,105 +449,29 @@ public void onConfigChanged(ConfigChanged event) { return; } - if (event.getKey().equals(TREE_SAPLING)) { - FarmingConfigChangeHandler.handleConfigChange( - questHelperPlugin.getConfigManager(), - QuestHelperConfig.QUEST_BACKGROUND_GROUP, - TreeSapling.OAK, - (selectedTreeSapling) -> { - treeSapling.setId(FarmingUtils.getSeedItemIdFromEnum(selectedTreeSapling)); - treeSapling.setName(Text.titleCase(selectedTreeSapling) + " sapling"); - questHelperPlugin.refreshBank(); - } - ); - } - - if (event.getKey().equals(FRUIT_TREE_SAPLING)) { - FarmingConfigChangeHandler.handleConfigChange( - questHelperPlugin.getConfigManager(), - QuestHelperConfig.QUEST_BACKGROUND_GROUP, - FruitTreeSapling.APPLE, - (selectedFruitTreeSapling) -> { - fruitTreeSapling.setId(FarmingUtils.getSeedItemIdFromEnum(selectedFruitTreeSapling)); - fruitTreeSapling.setName(Text.titleCase(selectedFruitTreeSapling) + " sapling"); - questHelperPlugin.refreshBank(); - } - ); - } + FarmingConfigChangeHandler.handleEnumConfigChange(event, TREE_SAPLING, TreeSapling.class, this::updateTreeSapling, TreeSapling.OAK, configManager, questHelperPlugin); + FarmingConfigChangeHandler.handleEnumConfigChange(event, FRUIT_TREE_SAPLING, FruitTreeSapling.class, this::updateFruitTreeSapling, FruitTreeSapling.APPLE, configManager, questHelperPlugin); + FarmingConfigChangeHandler.handleEnumConfigChange(event, HARDWOOD_TREE_SAPLING, HardwoodTreeSapling.class, this::updateHardwoodTreeSapling, HardwoodTreeSapling.TEAK, configManager, questHelperPlugin); - if (event.getKey().equals(HARDWOOD_TREE_SAPLING)) { - FarmingConfigChangeHandler.handleConfigChange( - questHelperPlugin.getConfigManager(), - QuestHelperConfig.QUEST_BACKGROUND_GROUP, - HardwoodTreeSapling.TEAK, - (selectedHardwoodTreeSapling) -> { - hardwoodSapling.setId(FarmingUtils.getSeedItemIdFromEnum(selectedHardwoodTreeSapling)); - hardwoodSapling.setName(Text.titleCase(selectedHardwoodTreeSapling) + " sapling"); - questHelperPlugin.refreshBank(); - } - ); + if (event.getKey().equals(GRACEFUL_OR_FARMING)) { + questHelperPlugin.refreshBank(); } } + private void updateTreeSapling(TreeSapling selectedTreeSapling) { + treeSapling.setId(selectedTreeSapling.treeSaplingID); + treeSapling.setName(Text.titleCase(selectedTreeSapling) + " sapling"); + } -/* @Subscribe - public void onConfigChanged(ConfigChanged event) - { - if (!event.getGroup().equals(QuestHelperConfig.QUEST_BACKGROUND_GROUP)) - { - return; - } - - if (event.getKey().equals(TREE_SAPLING)) - { - try - { - TreeSapling selectedTreeSapling = TreeSapling.valueOf(event.getNewValue()); - treeSapling.setId(selectedTreeSapling.treeSaplingID); - treeSapling.setName(Text.titleCase(selectedTreeSapling) + " sapling"); - questHelperPlugin.refreshBank(); - } - catch (IllegalArgumentException e) - { - questHelperPlugin.getConfigManager().setConfiguration(QuestHelperConfig.QUEST_BACKGROUND_GROUP, TREE_SAPLING, TreeSapling.OAK); - } - } - - if (event.getKey().equals(FRUIT_TREE_SAPLING)) - { - try - { - FruitTreeSapling selectedFruitTreeSapling = FruitTreeSapling.valueOf(event.getNewValue()); - fruitTreeSapling.setId(selectedFruitTreeSapling.fruitTreeSaplingId); - fruitTreeSapling.setName(Text.titleCase(selectedFruitTreeSapling) + " sapling"); - questHelperPlugin.refreshBank(); - } - catch (IllegalArgumentException e) - { - questHelperPlugin.getConfigManager().setConfiguration(QuestHelperConfig.QUEST_BACKGROUND_GROUP, FRUIT_TREE_SAPLING, FruitTreeSapling.APPLE); - } - } - - if (event.getKey().equals(HARDWOOD_TREE_SAPLING)) - { - try - { - HardwoodTreeSapling selectedHardwoodTreeSapling = HardwoodTreeSapling.valueOf(event.getNewValue()); - hardwoodSapling.setId(selectedHardwoodTreeSapling.hardwoodTreeSaplingId); - hardwoodSapling.setName(Text.titleCase(selectedHardwoodTreeSapling) + " sapling"); - questHelperPlugin.refreshBank(); - } - catch (IllegalArgumentException e) - { - questHelperPlugin.getConfigManager().setConfiguration(QuestHelperConfig.QUEST_BACKGROUND_GROUP, HARDWOOD_TREE_SAPLING, HardwoodTreeSapling.TEAK); - } - } + private void updateFruitTreeSapling(FruitTreeSapling selectedFruitTreeSapling) { + fruitTreeSapling.setId(selectedFruitTreeSapling.fruitTreeSaplingId); + fruitTreeSapling.setName(Text.titleCase(selectedFruitTreeSapling) + " sapling"); + } - if (event.getKey().equals(GRACEFUL_OR_FARMING)) - { - questHelperPlugin.refreshBank(); - } - }*/ + private void updateHardwoodTreeSapling(HardwoodTreeSapling selectedHardwoodTreeSapling) { + hardwoodSapling.setId(selectedHardwoodTreeSapling.hardwoodTreeSaplingId); + hardwoodSapling.setName(Text.titleCase(selectedHardwoodTreeSapling) + " sapling"); + } @Override public List getConfigs() From c5ba3be48ca84cb44d8eff6528f4dbe00368374f Mon Sep 17 00:00:00 2001 From: Kerpackie Date: Mon, 4 Sep 2023 17:52:06 +0100 Subject: [PATCH 05/20] Update TreeRun.java --- .../mischelpers/farmruns/FarmingConfigChangeHandler.java | 2 +- .../questhelper/helpers/mischelpers/farmruns/TreeRun.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java index 1a07447f69..3f06cee83a 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java @@ -14,7 +14,7 @@ public static > void handleFarmingEnumConfigChange(ConfigChang { if (event.getKey().equals(configKey)) { - try + try { T selectedEnumValue = Enum.valueOf(enumClass, event.getNewValue()); updateAction.accept(selectedEnumValue); diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java index 4f0862fcf4..a530fb7c38 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java @@ -449,9 +449,9 @@ public void onConfigChanged(ConfigChanged event) { return; } - FarmingConfigChangeHandler.handleEnumConfigChange(event, TREE_SAPLING, TreeSapling.class, this::updateTreeSapling, TreeSapling.OAK, configManager, questHelperPlugin); - FarmingConfigChangeHandler.handleEnumConfigChange(event, FRUIT_TREE_SAPLING, FruitTreeSapling.class, this::updateFruitTreeSapling, FruitTreeSapling.APPLE, configManager, questHelperPlugin); - FarmingConfigChangeHandler.handleEnumConfigChange(event, HARDWOOD_TREE_SAPLING, HardwoodTreeSapling.class, this::updateHardwoodTreeSapling, HardwoodTreeSapling.TEAK, configManager, questHelperPlugin); + FarmingConfigChangeHandler.handleFarmingEnumConfigChange(event, TREE_SAPLING, TreeSapling.class, this::updateTreeSapling, TreeSapling.OAK, configManager, questHelperPlugin); + FarmingConfigChangeHandler.handleFarmingEnumConfigChange(event, FRUIT_TREE_SAPLING, FruitTreeSapling.class, this::updateFruitTreeSapling, FruitTreeSapling.APPLE, configManager, questHelperPlugin); + FarmingConfigChangeHandler.handleFarmingEnumConfigChange(event, HARDWOOD_TREE_SAPLING, HardwoodTreeSapling.class, this::updateHardwoodTreeSapling, HardwoodTreeSapling.TEAK, configManager, questHelperPlugin); if (event.getKey().equals(GRACEFUL_OR_FARMING)) { questHelperPlugin.refreshBank(); From a7fd6846bcc1207ffb59c65f020522b9d9307244 Mon Sep 17 00:00:00 2001 From: Kerpackie Date: Tue, 5 Sep 2023 22:55:04 +0100 Subject: [PATCH 06/20] Add Tree and Fruit Tree steps --- .../mischelpers/farmruns/FarmingUtils.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java index 1eae6d74bc..65641987ff 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java @@ -80,38 +80,51 @@ else if (enumValue instanceof HardwoodTreeSapling) } } - public enum TreeSapling { + public enum TreeSapling + { OAK(ItemID.OAK_SAPLING), WILLOW(ItemID.WILLOW_SAPLING), MAPLE(ItemID.MAPLE_SAPLING), YEW(ItemID.YEW_SAPLING), MAGIC(ItemID.MAGIC_SAPLING); final int treeSaplingID; - TreeSapling(int treeSaplingID) { + TreeSapling(int treeSaplingID) + { this.treeSaplingID = treeSaplingID; } } - public enum FruitTreeSapling { + public enum FruitTreeSapling + { APPLE(ItemID.APPLE_SAPLING), BANANA(ItemID.BANANA_SAPLING), ORANGE(ItemID.ORANGE_SAPLING), CURRY(ItemID.CURRY_SAPLING), PINEAPPLE(ItemID.PINEAPPLE_SAPLING), PAPAYA(ItemID.PAPAYA_SAPLING), PALM(ItemID.PALM_SAPLING), DRAGONFRUIT(ItemID.DRAGONFRUIT_SAPLING); final int fruitTreeSaplingId; - FruitTreeSapling(int fruitTreeSaplingId) { + FruitTreeSapling(int fruitTreeSaplingId) + { this.fruitTreeSaplingId = fruitTreeSaplingId; } } - public enum HardwoodTreeSapling { + public enum HardwoodTreeSapling + { TEAK(ItemID.TEAK_SAPLING), MAHOGANY(ItemID.MAHOGANY_SAPLING); final int hardwoodTreeSaplingId; - HardwoodTreeSapling(int hardwoodTreeSaplingId) { + HardwoodTreeSapling(int hardwoodTreeSaplingId) + { this.hardwoodTreeSaplingId = hardwoodTreeSaplingId; } } + + public enum GracefulOrFarming + { + NONE(), + GRACEFUL(), + FARMING(); + } } From ce69e9eade94aacb25e650dc44e8e0255d0c76f9 Mon Sep 17 00:00:00 2001 From: Kerpackie Date: Tue, 5 Sep 2023 22:55:28 +0100 Subject: [PATCH 07/20] Add Tree and Fruit Tree Steps --- .../helpers/mischelpers/farmruns/TreeRun.java | 257 +++++++++++++----- 1 file changed, 184 insertions(+), 73 deletions(-) diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java index a530fb7c38..f9cb00c6dd 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java @@ -6,6 +6,10 @@ import com.questhelper.QuestDescriptor; import com.questhelper.QuestHelperConfig; import com.questhelper.QuestHelperQuest; +import com.questhelper.helpers.mischelpers.farmruns.FarmingUtils.FruitTreeSapling; +import com.questhelper.helpers.mischelpers.farmruns.FarmingUtils.GracefulOrFarming; +import com.questhelper.helpers.mischelpers.farmruns.FarmingUtils.HardwoodTreeSapling; +import com.questhelper.helpers.mischelpers.farmruns.FarmingUtils.TreeSapling; import com.questhelper.questhelpers.ComplexStateQuestHelper; import com.questhelper.requirements.ManualRequirement; import com.questhelper.requirements.Requirement; @@ -29,8 +33,11 @@ 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.client.eventbus.Subscribe; import net.runelite.client.events.ConfigChanged; +import net.runelite.client.plugins.timetracking.Tab; +import net.runelite.client.plugins.timetracking.farming.CropState; import net.runelite.client.util.Text; import java.util.Arrays; import java.util.List; @@ -39,6 +46,14 @@ quest = QuestHelperQuest.TREE_RUN ) +/* +* +* TODO LIST: +* Add option for protection of items, have as config option. +* Add steps to highlight farmer for clearing. +* Config for chop or clear? +* +* */ public class TreeRun extends ComplexStateQuestHelper { @Inject @@ -64,7 +79,7 @@ public class TreeRun extends ComplexStateQuestHelper DetailedQuestStep eastHardwoodTreePatchPlant, westHardwoodTreePatchPlant, middleHardwoodTreePatchPlant; // Farming Items - ItemRequirement coins, spade, rake, treeSapling, fruitTreeSapling, hardwoodSapling, compost; + ItemRequirement coins, spade, rake, treeSapling, fruitTreeSapling, hardwoodSapling, compost, axe, protectionItem; // Teleport Items // TODO: Add these... @@ -95,52 +110,6 @@ public class TreeRun extends ComplexStateQuestHelper ManualRequirement eastHardwoodTreePatchEmpty, westHardwoodTreePatchEmpty, middleHardwoodTreePatchEmpty; ManualRequirement eastHardwoodTreePatchReady, westHardwoodTreePatchReady, middleHardwoodTreePatchReady; - private enum TreeSapling - { - OAK(ItemID.OAK_SAPLING), WILLOW(ItemID.WILLOW_SAPLING), MAPLE(ItemID.MAPLE_SAPLING), YEW(ItemID.YEW_SAPLING), - MAGIC(ItemID.MAGIC_SAPLING); - - final int treeSaplingID; - - TreeSapling(int treeSaplingID) - { - this.treeSaplingID = treeSaplingID; - } - } - - private enum FruitTreeSapling - { - APPLE(ItemID.APPLE_SAPLING), BANANA(ItemID.BANANA_SAPLING), ORANGE(ItemID.ORANGE_SAPLING), - CURRY(ItemID.CURRY_SAPLING), PINEAPPLE(ItemID.PINEAPPLE_SAPLING), PAPAYA(ItemID.PAPAYA_SAPLING), - PALM(ItemID.PALM_SAPLING), DRAGONFRUIT(ItemID.DRAGONFRUIT_SAPLING); - - final int fruitTreeSaplingId; - - FruitTreeSapling(int fruitTreeSaplingId) - { - this.fruitTreeSaplingId = fruitTreeSaplingId; - } - } - - private enum HardwoodTreeSapling - { - TEAK(ItemID.TEAK_SAPLING), - MAHOGANY(ItemID.MAHOGANY_SAPLING); - - final int hardwoodTreeSaplingId; - - HardwoodTreeSapling(int hardwoodTreeSaplingId) - { - this.hardwoodTreeSaplingId = hardwoodTreeSaplingId; - } - } - - private enum GracefulOrFarming { - NONE(), - GRACEFUL(), - FARMING(); - } - private final String TREE_SAPLING = "treeSaplings"; private final String FRUIT_TREE_SAPLING = "fruitTreeSaplings"; private final String HARDWOOD_TREE_SAPLING = "hardwoodTreeSaplings"; @@ -373,7 +342,7 @@ public void setupRequirements() gracefulOutfit = new ItemRequirements( "Graceful outfit (equipped)", gracefulHood, gracefulTop, gracefulLegs, gracefulGloves, gracefulBoots, gracefulCape - ).isNotConsumed().showConditioned(new RuneliteRequirement(configManager, GRACEFUL_OR_FARMING, TreeRun.GracefulOrFarming.GRACEFUL.name())); + ).isNotConsumed().showConditioned(new RuneliteRequirement(configManager, GRACEFUL_OR_FARMING, GracefulOrFarming.GRACEFUL.name())); farmingHat = new ItemRequirement( "Farmer's strawhat", ItemID.FARMERS_STRAWHAT, 1 ,true).isNotConsumed(); @@ -395,8 +364,8 @@ public void setupRequirements() farmersOutfit = new ItemRequirements( "Farmer's outfit (equipped)", - farmingHat, farmingTop, farmingLegs, farmingBoots - ).isNotConsumed().showConditioned(new RuneliteRequirement(configManager, GRACEFUL_OR_FARMING, TreeRun.GracefulOrFarming.FARMING.name())); + farmingHat, farmingTop, farmingLegs, farmingBoots).isNotConsumed() + .showConditioned(new RuneliteRequirement(configManager, GRACEFUL_OR_FARMING, GracefulOrFarming.FARMING.name())); } @@ -404,7 +373,7 @@ private void setupSteps() { waitForTree = new DetailedQuestStep(this, "Wait for your trees to grow! This may take a while..!"); - // Tree Steps + // Tree Patch Steps lumbridgeTreePatch = new ObjectStep(this, NullObjectID.NULL_8391, new WorldPoint(3192, 3230, 0), "Check the health of the tree planted in Lumbridge."); faladorTreePatch = new ObjectStep(this, NullObjectID.NULL_8389, new WorldPoint(3003, 3372, 0), @@ -420,7 +389,37 @@ private void setupSteps() "Check the health of the tree planted in the Farming Guild."); farmingGuildTreePatch.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildTreePatch)); - + // Tree Plant Steps + lumbridgeTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8391, new WorldPoint(3192, 3230, 0), + "Plant your sapling in the Lumbridge patch."); + lumbridgeTreePatchPlant.addIcon(treeSapling.getId()); + lumbridgeTreePatch.addSubSteps(lumbridgeTreePatchPlant); + + faladorTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8389, new WorldPoint(3003, 3372, 0), + "Plant your sapling in the Falador patch."); + faladorTreePatchPlant.addIcon(treeSapling.getId()); + faladorTreePatch.addSubSteps(faladorTreePatchPlant); + + taverleyTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8388, new WorldPoint(2935, 3437, 0), + "Plant your sapling in the Taverley patch."); + taverleyTreePatchPlant.addIcon(treeSapling.getId()); + taverleyTreePatch.addSubSteps(taverleyTreePatchPlant); + + varrockTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8390, new WorldPoint(3228, 3458, 0), + "Plant your sapling in the Varrock patch."); + varrockTreePatchPlant.addIcon(treeSapling.getId()); + varrockTreePatch.addSubSteps(varrockTreePatchPlant); + + gnomeStrongholdTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_19147, new WorldPoint(2435, 3414, 0), + "Plant your sapling in the Gnome Stronghold patch."); + gnomeStrongholdTreePatchPlant.addIcon(treeSapling.getId()); + gnomeStrongholdTreePatch.addSubSteps(gnomeStrongholdTreePatchPlant); + + farmingGuildTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_33732, new WorldPoint(1231, 3735, 0), + "Plant your sapling in the Farming Guild tree patch."); + farmingGuildTreePatchPlant.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildTreePatch)); + farmingGuildTreePatchPlant.addIcon(treeSapling.getId()); + farmingGuildTreePatch.addSubSteps(farmingGuildTreePatchPlant); // Fruit Tree Steps gnomeStrongholdFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_7962, new WorldPoint(2475, 3445, 0), @@ -440,47 +439,159 @@ private void setupSteps() "Check the health of the fruit tree planted in the Farming Guild."); farmingGuildFruitTreePatch.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildFruitTreePatch)); - + // Fruit Tree Plant Steps + gnomeStrongholdFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7962, new WorldPoint(2475, 3445, 0), + "Plant your sapling in the Tree Gnome Stronghold patch."); + gnomeStrongholdFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); + gnomeStrongholdTreePatch.addSubSteps(gnomeStrongholdTreePatchPlant); + + gnomeVillageFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7963, new WorldPoint(2489, 3179, 0), + "Plant your sapling in the Tree Gnome Village patch. Follow Elkoy to get out quickly."); + gnomeVillageFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); + gnomeVillageFruitTreePatch.addSubSteps(gnomeVillageFruitTreePatchPlant); + + brimhavenFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7964, new WorldPoint(2764, 3212, 0), + "Plant your sapling in the Brimhaven patch."); + brimhavenFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); + brimhavenFruitTreePatch.addSubSteps(brimhavenFruitTreePatchPlant); + + catherbyFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7965, new WorldPoint(2680, 3433, 0), + "Plant your sapling in the Catherby patch."); + catherbyFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); + catherbyFruitTreePatch.addSubSteps(catherbyFruitTreePatchPlant); + + lletyaFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_26579, new WorldPoint(2346, 3161, 0), + "Plant your sapling in the Lletya patch."); + lletyaFruitTreePatchPlant.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToLletya)); + lletyaFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); + lletyaFruitTreePatch.addSubSteps(lletyaFruitTreePatchPlant); + + farmingGuildFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_34007, new WorldPoint(1242, 3759, 0), + "Plant your sapling in the Farming Guild patch."); + farmingGuildFruitTreePatchPlant.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildFruitTreePatch)); + farmingGuildFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); + farmingGuildFruitTreePatch.addSubSteps(farmingGuildFruitTreePatchPlant); } @Subscribe - public void onConfigChanged(ConfigChanged event) { - if (!event.getGroup().equals(QuestHelperConfig.QUEST_BACKGROUND_GROUP)) { + public void onGameTick(GameTick event) + { + for (FarmingPatch treePatch : farmingWorld.getTabs().get(Tab.TREE)) + { + CropState treeState = farmingHandler.predictPatch(treePatch); + boolean isTreePatchHarvestable = treeState == CropState.HARVESTABLE; + boolean isTreePatchPlantable = treeState == CropState.EMPTY || treeState == CropState.DEAD; + + switch (treePatch.getRegion().getName()) + { + case "Lumbridge": + lumbridgeTreePatchReady.setShouldPass(isTreePatchHarvestable); + lumbridgeTreePatchEmpty.setShouldPass(isTreePatchPlantable); + break; + case "Varrock": + varrockTreePatchReady.setShouldPass(isTreePatchHarvestable); + varrockTreePatchEmpty.setShouldPass(isTreePatchPlantable); + break; + case "Falador": + faladorTreePatchReady.setShouldPass(isTreePatchHarvestable); + faladorTreePatchEmpty.setShouldPass(isTreePatchPlantable); + break; + case "Gnome Stronghold": + gnomeStrongholdTreePatchReady.setShouldPass(isTreePatchHarvestable); + gnomeStrongholdTreePatchEmpty.setShouldPass(isTreePatchPlantable); + break; + case "Taverley": + taverleyTreePatchReady.setShouldPass(isTreePatchHarvestable); + taverleyTreePatchEmpty.setShouldPass(isTreePatchPlantable); + break; + case "Farming Guild": + farmingGuildTreePatchReady.setShouldPass(isTreePatchHarvestable); + farmingGuildTreePatchEmpty.setShouldPass(isTreePatchPlantable); + break; + } + } + + for (FarmingPatch fruitTreePatch : farmingWorld.getTabs().get(Tab.FRUIT_TREE)) + { + CropState fruitTreeState = farmingHandler.predictPatch(fruitTreePatch); + boolean isFruitTreePatchHarvestable = fruitTreeState == CropState.HARVESTABLE; + boolean isFruitTreePatchPlantable = fruitTreeState == CropState.EMPTY || fruitTreeState == CropState.DEAD; + + switch (fruitTreePatch.getRegion().getName()) + { + case "Catherby": + catherbyFruitTreePatchReady.setShouldPass(isFruitTreePatchHarvestable); + catherbyFruitTreePatchEmpty.setShouldPass(isFruitTreePatchPlantable); + break; + case "Brimhaven": + brimhavenFruitTreePatchReady.setShouldPass(isFruitTreePatchHarvestable); + brimhavenFruitTreePatchEmpty.setShouldPass(isFruitTreePatchPlantable); + break; + case "Tree Gnome Village": + gnomeVillageFruitTreePatchReady.setShouldPass(isFruitTreePatchHarvestable); + gnomeVillageFruitTreePatchEmpty.setShouldPass(isFruitTreePatchPlantable); + break; + case "Gnome Stronghold": + gnomeStrongholdFruitTreePatchReady.setShouldPass(isFruitTreePatchHarvestable); + gnomeStrongholdFruitTreePatchEmpty.setShouldPass(isFruitTreePatchPlantable); + break; + case "Lletya": + lletyaFruitTreePatchReady.setShouldPass(isFruitTreePatchHarvestable); + lletyaFruitTreePatchEmpty.setShouldPass(isFruitTreePatchPlantable); + break; + case "Farming Guild": + farmingGuildFruitTreePatchReady.setShouldPass(isFruitTreePatchHarvestable); + farmingGuildFruitTreePatchEmpty.setShouldPass(isFruitTreePatchPlantable); + break; + } + } + } + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals(QuestHelperConfig.QUEST_BACKGROUND_GROUP)) + { return; } - FarmingConfigChangeHandler.handleFarmingEnumConfigChange(event, TREE_SAPLING, TreeSapling.class, this::updateTreeSapling, TreeSapling.OAK, configManager, questHelperPlugin); - FarmingConfigChangeHandler.handleFarmingEnumConfigChange(event, FRUIT_TREE_SAPLING, FruitTreeSapling.class, this::updateFruitTreeSapling, FruitTreeSapling.APPLE, configManager, questHelperPlugin); - FarmingConfigChangeHandler.handleFarmingEnumConfigChange(event, HARDWOOD_TREE_SAPLING, HardwoodTreeSapling.class, this::updateHardwoodTreeSapling, HardwoodTreeSapling.TEAK, configManager, questHelperPlugin); + FarmingConfigChangeHandler.handleFarmingEnumConfigChange(event, TREE_SAPLING, TreeSapling.class, + this::updateTreeSapling, TreeSapling.OAK, configManager, questHelperPlugin); + FarmingConfigChangeHandler.handleFarmingEnumConfigChange(event, FRUIT_TREE_SAPLING, FruitTreeSapling.class, + this::updateFruitTreeSapling, FruitTreeSapling.APPLE, configManager, questHelperPlugin); + FarmingConfigChangeHandler.handleFarmingEnumConfigChange(event, HARDWOOD_TREE_SAPLING, HardwoodTreeSapling.class, + this::updateHardwoodTreeSapling, HardwoodTreeSapling.TEAK, configManager, questHelperPlugin); - if (event.getKey().equals(GRACEFUL_OR_FARMING)) { + if (event.getKey().equals(GRACEFUL_OR_FARMING)) + { questHelperPlugin.refreshBank(); } } - private void updateTreeSapling(TreeSapling selectedTreeSapling) { + @Override + public List getConfigs() + { + HelperConfig treesConfig = new HelperConfig("Trees", TREE_SAPLING, TreeSapling.values()); + HelperConfig fruitTreesConfig = new HelperConfig("Fruit Trees", FRUIT_TREE_SAPLING, FruitTreeSapling.values()); + HelperConfig hardwoodTreesConfig = new HelperConfig("Hardwood Trees", HARDWOOD_TREE_SAPLING, HardwoodTreeSapling.values()); + HelperConfig outfitConfig = new HelperConfig("Outfit", GRACEFUL_OR_FARMING, GracefulOrFarming.values()); + return Arrays.asList(treesConfig, fruitTreesConfig, hardwoodTreesConfig, outfitConfig); + } + + private void updateTreeSapling(TreeSapling selectedTreeSapling) + { treeSapling.setId(selectedTreeSapling.treeSaplingID); treeSapling.setName(Text.titleCase(selectedTreeSapling) + " sapling"); } - private void updateFruitTreeSapling(FruitTreeSapling selectedFruitTreeSapling) { + private void updateFruitTreeSapling(FruitTreeSapling selectedFruitTreeSapling) + { fruitTreeSapling.setId(selectedFruitTreeSapling.fruitTreeSaplingId); fruitTreeSapling.setName(Text.titleCase(selectedFruitTreeSapling) + " sapling"); } - private void updateHardwoodTreeSapling(HardwoodTreeSapling selectedHardwoodTreeSapling) { + private void updateHardwoodTreeSapling(HardwoodTreeSapling selectedHardwoodTreeSapling) + { hardwoodSapling.setId(selectedHardwoodTreeSapling.hardwoodTreeSaplingId); hardwoodSapling.setName(Text.titleCase(selectedHardwoodTreeSapling) + " sapling"); } - - @Override - public List getConfigs() - { - HelperConfig treesConfig = new HelperConfig("Trees", TREE_SAPLING, TreeRun.TreeSapling.values()); - HelperConfig fruitTreesConfig = new HelperConfig("Fruit Trees", FRUIT_TREE_SAPLING, TreeRun.FruitTreeSapling.values()); - HelperConfig hardwoodTreesConfig = new HelperConfig("Hardwood Trees", HARDWOOD_TREE_SAPLING, TreeRun.HardwoodTreeSapling.values()); - HelperConfig outfitConfig = new HelperConfig("Outfit", GRACEFUL_OR_FARMING, TreeRun.GracefulOrFarming.values()); - return Arrays.asList(treesConfig, fruitTreesConfig, hardwoodTreesConfig, outfitConfig); - } - } From 28f31488d479edbb16f4ca70b238427b3fd3047e Mon Sep 17 00:00:00 2001 From: Kerpackie Date: Wed, 6 Sep 2023 11:21:41 +0100 Subject: [PATCH 08/20] Add Hardwood Steps Adds Hardwood Steps to TreeHelper --- .../helpers/mischelpers/farmruns/TreeRun.java | 121 ++++-------------- 1 file changed, 26 insertions(+), 95 deletions(-) diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java index f9cb00c6dd..e3fc655b2f 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java @@ -32,6 +32,7 @@ import net.runelite.api.QuestState; import net.runelite.api.Skill; import net.runelite.api.Varbits; +import net.runelite.api.World; import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.GameTick; import net.runelite.client.eventbus.Subscribe; @@ -197,97 +198,6 @@ public void setupRequirements() .hideConditioned(new VarbitRequirement(Varbits.AUTOWEED, 2)); coins = new ItemRequirement("Coins to quickly remove trees.", ItemID.COINS_995, -1); - // TODO: Make a util function that can ingest the ItemRequirement and other required objects to make below 3 single function calls instead of the current repetition, should work for all farming helpers. - // Saplings - // Tree - /*treeSapling = new ItemRequirement("Tree saplings of your choice", ItemID.OAK_SAPLING); - - String treeSaplingName = configManager.getRSProfileConfiguration( - QuestHelperConfig.QUEST_BACKGROUND_GROUP, TREE_SAPLING - ); - - if (treeSaplingName != null) - { - try - { - treeSapling.setId(TreeSapling.valueOf(treeSaplingName).treeSaplingID); - } - catch (IllegalArgumentException e) - { - questHelperPlugin.getConfigManager().setRSProfileConfiguration( - QuestHelperConfig.QUEST_BACKGROUND_GROUP, TREE_SAPLING, TreeSapling.OAK - ); - } - - treeSapling.setName(Text.titleCase(TreeSapling.valueOf(treeSaplingName)) + " sapling"); - } - else - { - questHelperPlugin.getConfigManager().setConfiguration( - QuestHelperConfig.QUEST_BACKGROUND_GROUP, TREE_SAPLING, TreeSapling.OAK - ); - } - - // Fruit Tree - fruitTreeSapling = new ItemRequirement("Fruit tree saplings of your choice", ItemID.APPLE_SAPLING); - - String fruitTreeSaplingName = configManager.getRSProfileConfiguration( - QuestHelperConfig.QUEST_BACKGROUND_GROUP, FRUIT_TREE_SAPLING - ); - - if (fruitTreeSaplingName != null) - { - try - { - fruitTreeSapling.setId(FruitTreeSapling.valueOf(fruitTreeSaplingName).fruitTreeSaplingId); - } - catch (IllegalArgumentException e) - { - questHelperPlugin.getConfigManager().setRSProfileConfiguration( - QuestHelperConfig.QUEST_BACKGROUND_GROUP, FRUIT_TREE_SAPLING, FruitTreeSapling.APPLE - ); - } - - fruitTreeSapling.setName(Text.titleCase(FruitTreeSapling.valueOf(fruitTreeSaplingName)) + "sapling"); - } - else - { - questHelperPlugin.getConfigManager().setConfiguration( - QuestHelperConfig.QUEST_BACKGROUND_GROUP, FRUIT_TREE_SAPLING, FruitTreeSapling.APPLE - ); - } - - // Hardwood Tree - hardwoodSapling = new ItemRequirement("Hardwood tree saplings of your choice", ItemID.TEAK_SAPLING); - - String hardwoodTreeSaplingName = configManager.getRSProfileConfiguration( - QuestHelperConfig.QUEST_BACKGROUND_GROUP, HARDWOOD_TREE_SAPLING - ); - - if (hardwoodTreeSaplingName != null) - { - try - { - hardwoodSapling.setId(HardwoodTreeSapling.valueOf(hardwoodTreeSaplingName).hardwoodTreeSaplingId); - } - catch (IllegalArgumentException e) - { - questHelperPlugin.getConfigManager().setRSProfileConfiguration( - QuestHelperConfig.QUEST_BACKGROUND_GROUP, HARDWOOD_TREE_SAPLING, HardwoodTreeSapling.TEAK - ); - } - - hardwoodSapling.setName(Text.titleCase(HardwoodTreeSapling.valueOf(hardwoodTreeSaplingName)) + " sapling"); - } - else - { - questHelperPlugin.getConfigManager().setConfiguration( - QuestHelperConfig.QUEST_BACKGROUND_GROUP, HARDWOOD_TREE_SAPLING, HardwoodTreeSapling.TEAK - ); - }*/ - - // Replace the existing code for treeSapling, fruitTreeSapling, and hardwoodSapling setup with the following: - treeSapling = FarmingUtils.createSeedRequirement( configManager, QuestHelperConfig.QUEST_BACKGROUND_GROUP, @@ -318,8 +228,6 @@ public void setupRequirements() farmingGuildTeleport = new ItemRequirement("Farming Guild Teleport", ItemCollections.SKILLS_NECKLACES); // Graceful and Farming Outfit - // TODO: Extract to FarmingUtils - gracefulHood = new ItemRequirement( "Graceful hood", ItemCollections.GRACEFUL_HOOD, 1 ,true).isNotConsumed(); @@ -344,6 +252,7 @@ public void setupRequirements() gracefulHood, gracefulTop, gracefulLegs, gracefulGloves, gracefulBoots, gracefulCape ).isNotConsumed().showConditioned(new RuneliteRequirement(configManager, GRACEFUL_OR_FARMING, GracefulOrFarming.GRACEFUL.name())); + farmingHat = new ItemRequirement( "Farmer's strawhat", ItemID.FARMERS_STRAWHAT, 1 ,true).isNotConsumed(); farmingHat.addAlternates(ItemID.FARMERS_STRAWHAT_13647, ItemID.FARMERS_STRAWHAT_21253, ItemID.FARMERS_STRAWHAT_21254); @@ -352,7 +261,6 @@ public void setupRequirements() "Farmer's top", ItemID.FARMERS_JACKET, 1, true).isNotConsumed(); farmingTop.addAlternates(ItemID.FARMERS_SHIRT); - farmingLegs = new ItemRequirement( "Farmer's boro trousers", ItemID.FARMERS_BORO_TROUSERS, 1, true).isNotConsumed(); farmingLegs.addAlternates(ItemID.FARMERS_BORO_TROUSERS_13641); @@ -361,7 +269,6 @@ public void setupRequirements() "Graceful cape", ItemID.FARMERS_BOOTS, 1, true).isNotConsumed(); farmingBoots.addAlternates(ItemID.FARMERS_BOOTS_13645); - farmersOutfit = new ItemRequirements( "Farmer's outfit (equipped)", farmingHat, farmingTop, farmingLegs, farmingBoots).isNotConsumed() @@ -471,6 +378,30 @@ private void setupSteps() farmingGuildFruitTreePatchPlant.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildFruitTreePatch)); farmingGuildFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); farmingGuildFruitTreePatch.addSubSteps(farmingGuildFruitTreePatchPlant); + + // Hardwood Tree Steps + westHardwoodTreePatch = new ObjectStep(this, NullObjectID.NULL_30481, new WorldPoint(3701, 3836, 0), + "Check the health of the western hardwood tree on Fossil Island."); + middleHardwoodTreePatch = new ObjectStep(this, NullObjectID.NULL_30480, new WorldPoint(3707, 3832, 0), + "Check the health of the centre hardwood tree on Fossil Island."); + eastHardwoodTreePatch = new ObjectStep(this, NullObjectID.NULL_30482, new WorldPoint(3714, 3834, 0), + "Check the health of the eastern hardwood tree on Fossil Island."); + + // Hardwood Tree Plant Steps + westHardwoodTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_30481, new WorldPoint(3701, 3836, 0), + "Plant your sapling on the western hardwood tree on Fossil Island."); + westHardwoodTreePatchPlant.addIcon(hardwoodSapling.getId()); + westHardwoodTreePatch.addSubSteps(westHardwoodTreePatchPlant); + + middleHardwoodTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_30480, new WorldPoint(3707, 3832, 0), + "Plant your sapling on the centre hardwood tree on Fossil Island."); + middleHardwoodTreePatchPlant.addIcon(hardwoodSapling.getId()); + middleHardwoodTreePatch.addSubSteps(middleHardwoodTreePatchPlant); + + eastHardwoodTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_30482, new WorldPoint(3714, 3834, 0), + "Plant your sapling on the eastern hardwood tree on Fossil Island."); + eastHardwoodTreePatchPlant.addIcon(hardwoodSapling.getId()); + eastHardwoodTreePatch.addSubSteps(eastHardwoodTreePatchPlant); } @Subscribe From cbc994042ec56d575b7f30f7ae4beb24dfcf1edc Mon Sep 17 00:00:00 2001 From: Kerpackie Date: Wed, 6 Sep 2023 15:25:37 +0100 Subject: [PATCH 09/20] Add base requirements Adds base requirements and steps --- .../helpers/mischelpers/farmruns/TreeRun.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java index e3fc655b2f..a8453b0345 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java @@ -10,6 +10,7 @@ import com.questhelper.helpers.mischelpers.farmruns.FarmingUtils.GracefulOrFarming; import com.questhelper.helpers.mischelpers.farmruns.FarmingUtils.HardwoodTreeSapling; import com.questhelper.helpers.mischelpers.farmruns.FarmingUtils.TreeSapling; +import com.questhelper.panel.PanelDetails; import com.questhelper.questhelpers.ComplexStateQuestHelper; import com.questhelper.requirements.ManualRequirement; import com.questhelper.requirements.Requirement; @@ -40,6 +41,7 @@ import net.runelite.client.plugins.timetracking.Tab; import net.runelite.client.plugins.timetracking.farming.CropState; import net.runelite.client.util.Text; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -508,6 +510,32 @@ public List getConfigs() return Arrays.asList(treesConfig, fruitTreesConfig, hardwoodTreesConfig, outfitConfig); } + @Override + public List getItemRequirements() + { + return Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling); + } + + @Override + public List getItemRecommended() + { + return Arrays.asList(gracefulOutfit, farmersOutfit); + } + + @Override + public List getPanels() + { + List allSteps = new ArrayList<>(); + allSteps.add(new PanelDetails("Farm run", Arrays.asList(farmingGuildTreePatch, farmingGuildFruitTreePatch, + lumbridgeTreePatch, faladorTreePatch, taverleyTreePatch, varrockTreePatch, gnomeStrongholdFruitTreePatch, + gnomeStrongholdTreePatch, gnomeVillageFruitTreePatch, brimhavenFruitTreePatch, catherbyFruitTreePatch, + lletyaFruitTreePatch, eastHardwoodTreePatch, middleHardwoodTreePatch, westHardwoodTreePatch), + Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), + Arrays.asList(gracefulOutfit, farmersOutfit))); + + return allSteps; + } + private void updateTreeSapling(TreeSapling selectedTreeSapling) { treeSapling.setId(selectedTreeSapling.treeSaplingID); From 3a141299b1979f9e4fe547f46030ff080a82c961 Mon Sep 17 00:00:00 2001 From: Kerpackie Date: Wed, 6 Sep 2023 17:59:53 +0100 Subject: [PATCH 10/20] Add Steps and Fix Coords Adds steps so that they function correctly. Fixes all coords so that highlight will function correctly. --- .../helpers/mischelpers/farmruns/TreeRun.java | 114 +++++++++++++----- 1 file changed, 82 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java index a8453b0345..e48e216b41 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java @@ -44,6 +44,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.concurrent.locks.Condition; @QuestDescriptor( quest = QuestHelperQuest.TREE_RUN @@ -55,7 +56,7 @@ * Add option for protection of items, have as config option. * Add steps to highlight farmer for clearing. * Config for chop or clear? -* +* PRIORITY: Add checked or notchecked checks, varbits used for patch checked status? * */ public class TreeRun extends ComplexStateQuestHelper { @@ -126,9 +127,58 @@ public QuestStep loadStep() setupConditions(); setupSteps(); - ConditionalStep steps = new ConditionalStep(this, waitForTree, spade, coins, rake, treeSapling, + ConditionalStep steps = new ConditionalStep(this, waitForTree, spade, coins, rake, compost, treeSapling, fruitTreeSapling, hardwoodSapling, farmersOutfit, gracefulOutfit); + // Farming Guild Tree -> Farming Guild Fruit Tree -> Lumbridge -> Falador -> Taverley + // Varrock -> Gnome Stronghold Fruit -> Gnome Stronghold Tree -> Gnome Village -> Brimhaven + // -> catherby -> lletya -> east hardwood -> middle hardwood -> west hardwood. + + steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreePatchReady), farmingGuildTreePatch); + steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreePatchEmpty), farmingGuildTreePatchPlant); + + steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitTreePatchReady), farmingGuildFruitTreePatch); + steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitTreePatchEmpty), farmingGuildFruitTreePatchPlant); + + steps.addStep(lumbridgeTreePatchReady, lumbridgeTreePatch); + steps.addStep(lumbridgeTreePatchEmpty, lumbridgeTreePatchPlant); + + steps.addStep(faladorTreePatchReady, faladorTreePatch); + steps.addStep(faladorTreePatchEmpty, faladorTreePatchPlant); + + steps.addStep(taverleyTreePatchReady, taverleyTreePatch); + steps.addStep(taverleyTreePatchEmpty, taverleyTreePatchPlant); + + steps.addStep(varrockTreePatchReady, varrockTreePatch); + steps.addStep(varrockTreePatchEmpty, varrockTreePatchPlant); + + steps.addStep(gnomeStrongholdFruitTreePatchReady, gnomeStrongholdFruitTreePatch); + steps.addStep(gnomeStrongholdFruitTreePatchEmpty, gnomeStrongholdFruitTreePatchPlant); + + steps.addStep(gnomeStrongholdTreePatchReady, gnomeStrongholdTreePatch); + steps.addStep(gnomeStrongholdTreePatchEmpty, gnomeStrongholdFruitTreePatchPlant); + + steps.addStep(gnomeVillageFruitTreePatchReady, gnomeVillageFruitTreePatch); + steps.addStep(gnomeVillageFruitTreePatchEmpty, gnomeVillageFruitTreePatchPlant); + + steps.addStep(brimhavenFruitTreePatchReady, brimhavenFruitTreePatch); + steps.addStep(brimhavenFruitTreePatchEmpty, brimhavenFruitTreePatchPlant); + + steps.addStep(catherbyFruitTreePatchReady, catherbyFruitTreePatch); + steps.addStep(catherbyFruitTreePatchEmpty, catherbyFruitTreePatchPlant); + + steps.addStep(new Conditions(accessToLletya, lletyaFruitTreePatchReady), lletyaFruitTreePatch); + steps.addStep(new Conditions(accessToLletya, lletyaFruitTreePatchEmpty), lletyaFruitTreePatchPlant); + + steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodTreePatchReady), eastHardwoodTreePatch); + steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodTreePatchEmpty), eastHardwoodTreePatchPlant); + + steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodTreePatchReady), middleHardwoodTreePatch); + steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodTreePatchEmpty), middleHardwoodTreePatchPlant); + + steps.addStep(new Conditions(accessToFossilIsland, westHardwoodTreePatchReady), westHardwoodTreePatch); + steps.addStep(new Conditions(accessToFossilIsland, westHardwoodTreePatchEmpty), westHardwoodTreePatchPlant); + return steps; } @@ -283,124 +333,124 @@ private void setupSteps() waitForTree = new DetailedQuestStep(this, "Wait for your trees to grow! This may take a while..!"); // Tree Patch Steps - lumbridgeTreePatch = new ObjectStep(this, NullObjectID.NULL_8391, new WorldPoint(3192, 3230, 0), + lumbridgeTreePatch = new ObjectStep(this, NullObjectID.NULL_8391, new WorldPoint(3193, 3231, 0), "Check the health of the tree planted in Lumbridge."); - faladorTreePatch = new ObjectStep(this, NullObjectID.NULL_8389, new WorldPoint(3003, 3372, 0), + faladorTreePatch = new ObjectStep(this, NullObjectID.NULL_8389, new WorldPoint(3004, 3373, 0), "Check the health of the tree planted in Falador."); - taverleyTreePatch = new ObjectStep(this, NullObjectID.NULL_8388, new WorldPoint(2935, 3437, 0), + taverleyTreePatch = new ObjectStep(this, NullObjectID.NULL_8388, new WorldPoint(2936, 3438, 0), "Check the health of the tree planted in Taverley."); - varrockTreePatch = new ObjectStep(this, NullObjectID.NULL_8390, new WorldPoint(3228, 3458, 0), + varrockTreePatch = new ObjectStep(this, NullObjectID.NULL_8390, new WorldPoint(3229, 3459, 0), "Check the health of the tree planted in Varrock."); - gnomeStrongholdTreePatch = new ObjectStep(this, NullObjectID.NULL_19147, new WorldPoint(2435, 3414, 0), + gnomeStrongholdTreePatch = new ObjectStep(this, NullObjectID.NULL_19147, new WorldPoint(2436, 3415, 0), "Check the health of the tree planted in the Tree Gnome Stronghold."); - farmingGuildTreePatch = new ObjectStep(this, NullObjectID.NULL_33732, new WorldPoint(1231, 3735, 0), + farmingGuildTreePatch = new ObjectStep(this, NullObjectID.NULL_33732, new WorldPoint(1232, 3736, 0), "Check the health of the tree planted in the Farming Guild."); farmingGuildTreePatch.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildTreePatch)); // Tree Plant Steps - lumbridgeTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8391, new WorldPoint(3192, 3230, 0), + lumbridgeTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8391, new WorldPoint(3193, 3231, 0), "Plant your sapling in the Lumbridge patch."); lumbridgeTreePatchPlant.addIcon(treeSapling.getId()); lumbridgeTreePatch.addSubSteps(lumbridgeTreePatchPlant); - faladorTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8389, new WorldPoint(3003, 3372, 0), + faladorTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8389, new WorldPoint(3004, 3373, 0), "Plant your sapling in the Falador patch."); faladorTreePatchPlant.addIcon(treeSapling.getId()); faladorTreePatch.addSubSteps(faladorTreePatchPlant); - taverleyTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8388, new WorldPoint(2935, 3437, 0), + taverleyTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8388, new WorldPoint(2936, 3438, 0), "Plant your sapling in the Taverley patch."); taverleyTreePatchPlant.addIcon(treeSapling.getId()); taverleyTreePatch.addSubSteps(taverleyTreePatchPlant); - varrockTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8390, new WorldPoint(3228, 3458, 0), + varrockTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8390, new WorldPoint(3229, 3459, 0), "Plant your sapling in the Varrock patch."); varrockTreePatchPlant.addIcon(treeSapling.getId()); varrockTreePatch.addSubSteps(varrockTreePatchPlant); - gnomeStrongholdTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_19147, new WorldPoint(2435, 3414, 0), + gnomeStrongholdTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_19147, new WorldPoint(2436, 3415, 0), "Plant your sapling in the Gnome Stronghold patch."); gnomeStrongholdTreePatchPlant.addIcon(treeSapling.getId()); gnomeStrongholdTreePatch.addSubSteps(gnomeStrongholdTreePatchPlant); - farmingGuildTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_33732, new WorldPoint(1231, 3735, 0), + farmingGuildTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_33732, new WorldPoint(1232, 3736, 0), "Plant your sapling in the Farming Guild tree patch."); farmingGuildTreePatchPlant.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildTreePatch)); farmingGuildTreePatchPlant.addIcon(treeSapling.getId()); farmingGuildTreePatch.addSubSteps(farmingGuildTreePatchPlant); // Fruit Tree Steps - gnomeStrongholdFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_7962, new WorldPoint(2475, 3445, 0), + gnomeStrongholdFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_7962, new WorldPoint(2476, 3446, 0), "Check the health of the fruit tree planted in the Tree Gnome Stronghold."); - gnomeVillageFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_7963, new WorldPoint(2489, 3179, 0), + gnomeVillageFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_7963, new WorldPoint(2490, 3180, 0), "Check the health of the fruit tree planted outside the Tree Gnome Village. Follow Elkoy to get out quickly."); - brimhavenFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_7964, new WorldPoint(2764, 3212, 0), + brimhavenFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_7964, new WorldPoint(2765, 3213, 0), "Check the health of the fruit tree planted in Brimhaven."); - catherbyFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_7965, new WorldPoint(2680, 3433, 0), + catherbyFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_7965, new WorldPoint(2681, 3434, 0), "Check the health of the fruit tree planted in Catherby"); - lletyaFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_26579, new WorldPoint(2346, 3161, 0), + lletyaFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_26579, new WorldPoint(2347, 3162, 0), "Check the health of the fruit tree planted in Lletya."); lletyaFruitTreePatch.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToLletya)); - farmingGuildFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_34007, new WorldPoint(1242, 3759, 0), + farmingGuildFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_34007, new WorldPoint(1243, 3760, 0), "Check the health of the fruit tree planted in the Farming Guild."); farmingGuildFruitTreePatch.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildFruitTreePatch)); // Fruit Tree Plant Steps - gnomeStrongholdFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7962, new WorldPoint(2475, 3445, 0), + gnomeStrongholdFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7962, new WorldPoint(2476, 3446, 0), "Plant your sapling in the Tree Gnome Stronghold patch."); gnomeStrongholdFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); gnomeStrongholdTreePatch.addSubSteps(gnomeStrongholdTreePatchPlant); - gnomeVillageFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7963, new WorldPoint(2489, 3179, 0), + gnomeVillageFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7963, new WorldPoint(2490, 3180, 0), "Plant your sapling in the Tree Gnome Village patch. Follow Elkoy to get out quickly."); gnomeVillageFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); gnomeVillageFruitTreePatch.addSubSteps(gnomeVillageFruitTreePatchPlant); - brimhavenFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7964, new WorldPoint(2764, 3212, 0), + brimhavenFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7964, new WorldPoint(2765, 3213, 0), "Plant your sapling in the Brimhaven patch."); brimhavenFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); brimhavenFruitTreePatch.addSubSteps(brimhavenFruitTreePatchPlant); - catherbyFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7965, new WorldPoint(2680, 3433, 0), + catherbyFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7965, new WorldPoint(2681, 3434, 0), "Plant your sapling in the Catherby patch."); catherbyFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); catherbyFruitTreePatch.addSubSteps(catherbyFruitTreePatchPlant); - lletyaFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_26579, new WorldPoint(2346, 3161, 0), + lletyaFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_26579, new WorldPoint(2347, 3162, 0), "Plant your sapling in the Lletya patch."); lletyaFruitTreePatchPlant.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToLletya)); lletyaFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); lletyaFruitTreePatch.addSubSteps(lletyaFruitTreePatchPlant); - farmingGuildFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_34007, new WorldPoint(1242, 3759, 0), + farmingGuildFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_34007, new WorldPoint(1243, 3760, 0), "Plant your sapling in the Farming Guild patch."); farmingGuildFruitTreePatchPlant.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildFruitTreePatch)); farmingGuildFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); farmingGuildFruitTreePatch.addSubSteps(farmingGuildFruitTreePatchPlant); // Hardwood Tree Steps - westHardwoodTreePatch = new ObjectStep(this, NullObjectID.NULL_30481, new WorldPoint(3701, 3836, 0), + westHardwoodTreePatch = new ObjectStep(this, NullObjectID.NULL_30481, new WorldPoint(3702, 3837, 0), "Check the health of the western hardwood tree on Fossil Island."); - middleHardwoodTreePatch = new ObjectStep(this, NullObjectID.NULL_30480, new WorldPoint(3707, 3832, 0), + middleHardwoodTreePatch = new ObjectStep(this, NullObjectID.NULL_30480, new WorldPoint(3708, 3833, 0), "Check the health of the centre hardwood tree on Fossil Island."); - eastHardwoodTreePatch = new ObjectStep(this, NullObjectID.NULL_30482, new WorldPoint(3714, 3834, 0), + eastHardwoodTreePatch = new ObjectStep(this, NullObjectID.NULL_30482, new WorldPoint(3715, 3835, 0), "Check the health of the eastern hardwood tree on Fossil Island."); // Hardwood Tree Plant Steps - westHardwoodTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_30481, new WorldPoint(3701, 3836, 0), + westHardwoodTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_30481, new WorldPoint(3702, 3837, 0), "Plant your sapling on the western hardwood tree on Fossil Island."); westHardwoodTreePatchPlant.addIcon(hardwoodSapling.getId()); westHardwoodTreePatch.addSubSteps(westHardwoodTreePatchPlant); - middleHardwoodTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_30480, new WorldPoint(3707, 3832, 0), + middleHardwoodTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_30480, new WorldPoint(3708, 3833, 0), "Plant your sapling on the centre hardwood tree on Fossil Island."); middleHardwoodTreePatchPlant.addIcon(hardwoodSapling.getId()); middleHardwoodTreePatch.addSubSteps(middleHardwoodTreePatchPlant); - eastHardwoodTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_30482, new WorldPoint(3714, 3834, 0), + eastHardwoodTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_30482, new WorldPoint(3715, 3835, 0), "Plant your sapling on the eastern hardwood tree on Fossil Island."); eastHardwoodTreePatchPlant.addIcon(hardwoodSapling.getId()); eastHardwoodTreePatch.addSubSteps(eastHardwoodTreePatchPlant); From 7ba9f08a06064bc223fd67f4e15025986c8ee1bd Mon Sep 17 00:00:00 2001 From: Kerpackie Date: Thu, 7 Sep 2023 18:43:04 +0100 Subject: [PATCH 11/20] Experimenting more robust checking for TreeState Check using Varbit the current state of the trees nearby, allowing for better differentiation of trees in a Checked/Unchecked and stump state to accommodate clearing. --- .../mischelpers/farmruns/FarmingUtils.java | 16 ++ .../helpers/mischelpers/farmruns/TreeRun.java | 192 ++++++++++++++++-- 2 files changed, 190 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java index 65641987ff..8d4a6d090b 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java @@ -1,7 +1,9 @@ package com.questhelper.helpers.mischelpers.farmruns; import com.questhelper.requirements.item.ItemRequirement; +import net.runelite.api.Client; import net.runelite.api.ItemID; +import net.runelite.api.Varbits; import net.runelite.client.config.ConfigManager; import net.runelite.client.util.Text; @@ -80,6 +82,20 @@ else if (enumValue instanceof HardwoodTreeSapling) } } + public static boolean getPatchState(Client client, int[] patchStates, int varbit) + { + for (int stateVarb : patchStates) + { + if (client.getVarbitValue(varbit) == stateVarb) + { + System.out.println("Found patch state: " + client.getVarbitValue(varbit) + " " + stateVarb); + return true; + } + } + + return false; + } + public enum TreeSapling { OAK(ItemID.OAK_SAPLING), WILLOW(ItemID.WILLOW_SAPLING), MAPLE(ItemID.MAPLE_SAPLING), YEW(ItemID.YEW_SAPLING), diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java index e48e216b41..e5ea0e2de1 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java @@ -26,14 +26,16 @@ import com.questhelper.requirements.var.VarbitRequirement; import com.questhelper.steps.ConditionalStep; import com.questhelper.steps.DetailedQuestStep; +import com.questhelper.steps.NpcStep; import com.questhelper.steps.ObjectStep; import com.questhelper.steps.QuestStep; +import com.sun.source.doctree.ValueTree; import net.runelite.api.ItemID; +import net.runelite.api.NpcID; import net.runelite.api.NullObjectID; import net.runelite.api.QuestState; import net.runelite.api.Skill; import net.runelite.api.Varbits; -import net.runelite.api.World; import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.GameTick; import net.runelite.client.eventbus.Subscribe; @@ -44,7 +46,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.concurrent.locks.Condition; @QuestDescriptor( quest = QuestHelperQuest.TREE_RUN @@ -72,16 +73,24 @@ public class TreeRun extends ComplexStateQuestHelper DetailedQuestStep farmingGuildTreePatchPlant, lumbridgeTreePatchPlant, faladorTreePatchPlant, taverleyTreePatchPlant, varrockTreePatchPlant, gnomeStrongholdTreePatchPlant; + DetailedQuestStep lumbridgeTreePatchClear, faladorTreePatchClear, taverleyTreePatchClear, varrockTreePatchClear, + gnomeStrongholdTreePatchClear, farmingGuildTreePatchClear; + // Fruit Trees DetailedQuestStep farmingGuildFruitTreePatch, gnomeStrongholdFruitTreePatch, gnomeVillageFruitTreePatch, brimhavenFruitTreePatch, lletyaFruitTreePatch, catherbyFruitTreePatch; DetailedQuestStep farmingGuildFruitTreePatchPlant, gnomeStrongholdFruitTreePatchPlant, gnomeVillageFruitTreePatchPlant, brimhavenFruitTreePatchPlant, lletyaFruitTreePatchPlant, catherbyFruitTreePatchPlant; + DetailedQuestStep farmingGuildFruitTreePatchClear, gnomeStrongholdFruitTreePatchClear, gnomeVillageFruitTreePatchClear, + brimhavenFruitTreePatchClear, lletyaFruitTreePatchClear, catherbyFruitTreePatchClear; + // Hardwood Trees DetailedQuestStep eastHardwoodTreePatch, westHardwoodTreePatch, middleHardwoodTreePatch; DetailedQuestStep eastHardwoodTreePatchPlant, westHardwoodTreePatchPlant, middleHardwoodTreePatchPlant; + DetailedQuestStep eastHardwoodTreePatchClear, westHardwoodTreePatchClear, middleHardwoodTreePatchClear; + // Farming Items ItemRequirement coins, spade, rake, treeSapling, fruitTreeSapling, hardwoodSapling, compost, axe, protectionItem; @@ -103,6 +112,12 @@ public class TreeRun extends ComplexStateQuestHelper varrockTreePatchEmpty, gnomeStrongholdTreePatchEmpty, farmingGuildTreePatchEmpty; ManualRequirement lumbridgeTreePatchReady, faladorTreePatchReady, taverleyTreePatchReady, varrockTreePatchReady, gnomeStrongholdTreePatchReady, farmingGuildTreePatchReady; + ManualRequirement faladorTreePatchNotChecked, faladorTreePatchChecked, faladorTreePatchIsStump, + lumbridgeTreePatchNotChecked, lumbridgeTreePatchChecked, lumbridgeTreePatchIsStump, + farmingGuildTreePatchNotChecked, farmingGuildTreePatchChecked, farmingGuildTreePatchIsStump, + taverleyTreePatchNotChecked, taverleyTreePatchChecked, taverleyTreePatchIsStump, + varrockTreePatchNotChecked, varrockTreePatchChecked, varrockTreePatchIsStump, + gnomeStrongholdTreePatchNotChecked, gnomeStrongholdTreePatchChecked, gnomeStrongholdTreePatchIsStump; // Fruit Tree Requirements ManualRequirement gnomeStrongholdFruitTreePatchEmpty, gnomeVillageFruitTreePatchEmpty, @@ -110,15 +125,31 @@ public class TreeRun extends ComplexStateQuestHelper ManualRequirement gnomeStrongholdFruitTreePatchReady, gnomeVillageFruitTreePatchReady, brimhavenFruitTreePatchReady, lletyaFruitTreePatchReady, catherbyFruitTreePatchReady, farmingGuildFruitTreePatchReady; + ManualRequirement gnomeStrongholdFruitTreePatchNotChecked, gnomeStrongholdFruitTreePatchChecked, gnomeStrongholdFruitTreePatchIsStump, + gnomeVillageFruitTreePatchNotChecked, gnomeVillageFruitTreePatchChecked, gnomeVillageFruitTreePatchIsStump, + brimhavenFruitTreePatchNotChecked, brimhavenFruitTreePatchChecked, brimhavenFruitTreePatchIsStump, + lletyaFruitTreePatchNotChecked, lletyaFruitTreePatchChecked, lletyaFruitTreePatchIsStump, + catherbyFruitTreePatchNotChecked, catherbyFruitTreePatchChecked, catherbyFruitTreePatchIsStump, + farmingGuildFruitTreePatchNotChecked, farmingGuildFruitTreePatchChecked, farmingGuildFruitTreePatchIsStump; + // Hardwood Tree Requirements ManualRequirement eastHardwoodTreePatchEmpty, westHardwoodTreePatchEmpty, middleHardwoodTreePatchEmpty; ManualRequirement eastHardwoodTreePatchReady, westHardwoodTreePatchReady, middleHardwoodTreePatchReady; + ManualRequirement eastHardwoodTreePatchNotChecked, eastHardwoodTreePatchChecked, eastHardwoodTreePatchIsStump, + westHardwoodTreePatchNotChecked, westHardwoodTreePatchChecked, westHardwoodTreePatchIsStump, + middleHardwoodTreePatchNotChecked, middleHardwoodTreePatchChecked, middleHardwoodTreePatchIsStump; + private final String TREE_SAPLING = "treeSaplings"; private final String FRUIT_TREE_SAPLING = "fruitTreeSaplings"; private final String HARDWOOD_TREE_SAPLING = "hardwoodTreeSaplings"; private final String GRACEFUL_OR_FARMING = "gracefulOrFarming"; + private final int[] TREE_UNCHECKED = { 12, 21, 32, 45, 60 }; + // 192 - 197 for Willow tree final state? Are all trees like this? + private final int[] TREE_CHECKED = {13, 22, 33, 46, 61, 192, 193, 194, 195, 196, 197}; + private final int[] TREE_STUMP = {14, 23, 34, 47, 62}; + @Override public QuestStep loadStep() { @@ -143,7 +174,8 @@ public QuestStep loadStep() steps.addStep(lumbridgeTreePatchReady, lumbridgeTreePatch); steps.addStep(lumbridgeTreePatchEmpty, lumbridgeTreePatchPlant); - steps.addStep(faladorTreePatchReady, faladorTreePatch); + steps.addStep(new Conditions(faladorTreePatchReady, faladorTreePatchNotChecked), faladorTreePatch); + steps.addStep(new Conditions(faladorTreePatchReady, faladorTreePatchChecked), faladorTreePatchClear); steps.addStep(faladorTreePatchEmpty, faladorTreePatchPlant); steps.addStep(taverleyTreePatchReady, taverleyTreePatch); @@ -239,6 +271,69 @@ private void setupConditions() new SkillRequirement(Skill.FARMING, 85) ); + // Tree Not Checked + lumbridgeTreePatchNotChecked = new ManualRequirement(); + lumbridgeTreePatchChecked = new ManualRequirement(); + lumbridgeTreePatchIsStump = new ManualRequirement(); + + faladorTreePatchNotChecked = new ManualRequirement(); + faladorTreePatchChecked = new ManualRequirement(); + faladorTreePatchIsStump = new ManualRequirement(); + + taverleyTreePatchNotChecked = new ManualRequirement(); + taverleyTreePatchChecked = new ManualRequirement(); + taverleyTreePatchIsStump = new ManualRequirement(); + + varrockTreePatchNotChecked = new ManualRequirement(); + varrockTreePatchChecked = new ManualRequirement(); + varrockTreePatchIsStump = new ManualRequirement(); + + gnomeStrongholdTreePatchNotChecked = new ManualRequirement(); + gnomeStrongholdTreePatchChecked = new ManualRequirement(); + gnomeStrongholdTreePatchIsStump = new ManualRequirement(); + + farmingGuildTreePatchNotChecked = new ManualRequirement(); + farmingGuildTreePatchChecked = new ManualRequirement(); + farmingGuildTreePatchIsStump = new ManualRequirement(); + + // Fruit Tree Not Checked + gnomeStrongholdFruitTreePatchNotChecked = new ManualRequirement(); + gnomeStrongholdFruitTreePatchChecked = new ManualRequirement(); + gnomeStrongholdFruitTreePatchIsStump = new ManualRequirement(); + + gnomeVillageFruitTreePatchNotChecked = new ManualRequirement(); + gnomeVillageFruitTreePatchChecked = new ManualRequirement(); + gnomeVillageFruitTreePatchIsStump = new ManualRequirement(); + + brimhavenFruitTreePatchNotChecked = new ManualRequirement(); + brimhavenFruitTreePatchChecked = new ManualRequirement(); + brimhavenFruitTreePatchIsStump = new ManualRequirement(); + + lletyaFruitTreePatchNotChecked = new ManualRequirement(); + lletyaFruitTreePatchChecked = new ManualRequirement(); + lletyaFruitTreePatchIsStump = new ManualRequirement(); + + catherbyFruitTreePatchNotChecked = new ManualRequirement(); + catherbyFruitTreePatchChecked = new ManualRequirement(); + catherbyFruitTreePatchIsStump = new ManualRequirement(); + + farmingGuildFruitTreePatchNotChecked = new ManualRequirement(); + farmingGuildFruitTreePatchChecked = new ManualRequirement(); + farmingGuildFruitTreePatchIsStump = new ManualRequirement(); + + // Hardwood Tree Not Checked + eastHardwoodTreePatchNotChecked = new ManualRequirement(); + eastHardwoodTreePatchChecked = new ManualRequirement(); + eastHardwoodTreePatchIsStump = new ManualRequirement(); + + westHardwoodTreePatchNotChecked = new ManualRequirement(); + westHardwoodTreePatchChecked = new ManualRequirement(); + westHardwoodTreePatchIsStump = new ManualRequirement(); + + middleHardwoodTreePatchNotChecked = new ManualRequirement(); + middleHardwoodTreePatchChecked = new ManualRequirement(); + middleHardwoodTreePatchIsStump = new ManualRequirement(); + } @Override @@ -257,6 +352,7 @@ public void setupRequirements() TreeSapling.OAK, ItemID.OAK_SAPLING ); + treeSapling.setHighlightInInventory(true); fruitTreeSapling = FarmingUtils.createSeedRequirement( configManager, @@ -265,6 +361,7 @@ public void setupRequirements() FruitTreeSapling.APPLE, ItemID.APPLE_SAPLING ); + fruitTreeSapling.setHighlightInInventory(true); hardwoodSapling = FarmingUtils.createSeedRequirement ( configManager, @@ -273,6 +370,7 @@ public void setupRequirements() HardwoodTreeSapling.TEAK, ItemID.TEAK_SAPLING ); + hardwoodSapling.setHighlightInInventory(true); compost = new ItemRequirement("Compost", ItemCollections.COMPOST); @@ -332,6 +430,30 @@ private void setupSteps() { waitForTree = new DetailedQuestStep(this, "Wait for your trees to grow! This may take a while..!"); + // Tree Patch Clear Steps + + lumbridgeTreePatchClear = new NpcStep(this, NpcID.FARMER, new WorldPoint(3226, 3219, 0), + "Speak to the farmer to clear the patch."); + lumbridgeTreePatchClear.addDialogStep("Yes."); + + faladorTreePatchClear = new NpcStep(this, NpcID.FAYETH, "Speak to the farmer to clear the patch."); + faladorTreePatchClear.addDialogStep("Yes."); + + taverleyTreePatchClear = new NpcStep(this, NpcID.ALAIN, "Speak to the farmer to clear the patch."); + taverleyTreePatchClear.addDialogStep("Yes."); + + varrockTreePatchClear = new NpcStep(this, NpcID.TREZNOR_11957, new WorldPoint(3226, 3219, 0), + "Speak to the farmer to clear the patch."); + varrockTreePatchClear.addDialogStep("Yes."); + + gnomeStrongholdTreePatchClear = new NpcStep(this, NpcID.PRISSY_SCILLA, new WorldPoint(3226, 3219, 0), + "Speak to the farmer to clear the patch."); + gnomeStrongholdTreePatchClear.addDialogStep("Yes."); + + farmingGuildTreePatchClear = new NpcStep(this, NpcID.ROSIE, new WorldPoint(3226, 3219, 0), + "Speak to the farmer to clear the patch."); + farmingGuildTreePatchClear.addDialogStep("Yes."); + // Tree Patch Steps lumbridgeTreePatch = new ObjectStep(this, NullObjectID.NULL_8391, new WorldPoint(3193, 3231, 0), "Check the health of the tree planted in Lumbridge."); @@ -350,32 +472,33 @@ private void setupSteps() // Tree Plant Steps lumbridgeTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8391, new WorldPoint(3193, 3231, 0), - "Plant your sapling in the Lumbridge patch."); + "Plant your sapling in the Lumbridge patch.", treeSapling); + treeSapling.highlighted(); lumbridgeTreePatchPlant.addIcon(treeSapling.getId()); lumbridgeTreePatch.addSubSteps(lumbridgeTreePatchPlant); faladorTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8389, new WorldPoint(3004, 3373, 0), - "Plant your sapling in the Falador patch."); + "Plant your sapling in the Falador patch.", treeSapling); faladorTreePatchPlant.addIcon(treeSapling.getId()); faladorTreePatch.addSubSteps(faladorTreePatchPlant); taverleyTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8388, new WorldPoint(2936, 3438, 0), - "Plant your sapling in the Taverley patch."); + "Plant your sapling in the Taverley patch.", treeSapling); taverleyTreePatchPlant.addIcon(treeSapling.getId()); taverleyTreePatch.addSubSteps(taverleyTreePatchPlant); varrockTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8390, new WorldPoint(3229, 3459, 0), - "Plant your sapling in the Varrock patch."); + "Plant your sapling in the Varrock patch.", treeSapling); varrockTreePatchPlant.addIcon(treeSapling.getId()); varrockTreePatch.addSubSteps(varrockTreePatchPlant); gnomeStrongholdTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_19147, new WorldPoint(2436, 3415, 0), - "Plant your sapling in the Gnome Stronghold patch."); + "Plant your sapling in the Gnome Stronghold patch.", treeSapling); gnomeStrongholdTreePatchPlant.addIcon(treeSapling.getId()); gnomeStrongholdTreePatch.addSubSteps(gnomeStrongholdTreePatchPlant); farmingGuildTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_33732, new WorldPoint(1232, 3736, 0), - "Plant your sapling in the Farming Guild tree patch."); + "Plant your sapling in the Farming Guild tree patch.", treeSapling); farmingGuildTreePatchPlant.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildTreePatch)); farmingGuildTreePatchPlant.addIcon(treeSapling.getId()); farmingGuildTreePatch.addSubSteps(farmingGuildTreePatchPlant); @@ -400,33 +523,33 @@ private void setupSteps() // Fruit Tree Plant Steps gnomeStrongholdFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7962, new WorldPoint(2476, 3446, 0), - "Plant your sapling in the Tree Gnome Stronghold patch."); + "Plant your sapling in the Tree Gnome Stronghold patch.", fruitTreeSapling); gnomeStrongholdFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); gnomeStrongholdTreePatch.addSubSteps(gnomeStrongholdTreePatchPlant); gnomeVillageFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7963, new WorldPoint(2490, 3180, 0), - "Plant your sapling in the Tree Gnome Village patch. Follow Elkoy to get out quickly."); + "Plant your sapling in the Tree Gnome Village patch. Follow Elkoy to get out quickly.", fruitTreeSapling); gnomeVillageFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); gnomeVillageFruitTreePatch.addSubSteps(gnomeVillageFruitTreePatchPlant); brimhavenFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7964, new WorldPoint(2765, 3213, 0), - "Plant your sapling in the Brimhaven patch."); + "Plant your sapling in the Brimhaven patch.", fruitTreeSapling); brimhavenFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); brimhavenFruitTreePatch.addSubSteps(brimhavenFruitTreePatchPlant); catherbyFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7965, new WorldPoint(2681, 3434, 0), - "Plant your sapling in the Catherby patch."); + "Plant your sapling in the Catherby patch.", fruitTreeSapling); catherbyFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); catherbyFruitTreePatch.addSubSteps(catherbyFruitTreePatchPlant); lletyaFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_26579, new WorldPoint(2347, 3162, 0), - "Plant your sapling in the Lletya patch."); + "Plant your sapling in the Lletya patch.", fruitTreeSapling); lletyaFruitTreePatchPlant.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToLletya)); lletyaFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); lletyaFruitTreePatch.addSubSteps(lletyaFruitTreePatchPlant); farmingGuildFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_34007, new WorldPoint(1243, 3760, 0), - "Plant your sapling in the Farming Guild patch."); + "Plant your sapling in the Farming Guild patch.", fruitTreeSapling); farmingGuildFruitTreePatchPlant.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildFruitTreePatch)); farmingGuildFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); farmingGuildFruitTreePatch.addSubSteps(farmingGuildFruitTreePatchPlant); @@ -441,24 +564,37 @@ private void setupSteps() // Hardwood Tree Plant Steps westHardwoodTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_30481, new WorldPoint(3702, 3837, 0), - "Plant your sapling on the western hardwood tree on Fossil Island."); + "Plant your sapling on the western hardwood tree on Fossil Island.", hardwoodSapling); westHardwoodTreePatchPlant.addIcon(hardwoodSapling.getId()); westHardwoodTreePatch.addSubSteps(westHardwoodTreePatchPlant); middleHardwoodTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_30480, new WorldPoint(3708, 3833, 0), - "Plant your sapling on the centre hardwood tree on Fossil Island."); + "Plant your sapling on the centre hardwood tree on Fossil Island.", hardwoodSapling); middleHardwoodTreePatchPlant.addIcon(hardwoodSapling.getId()); middleHardwoodTreePatch.addSubSteps(middleHardwoodTreePatchPlant); eastHardwoodTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_30482, new WorldPoint(3715, 3835, 0), - "Plant your sapling on the eastern hardwood tree on Fossil Island."); + "Plant your sapling on the eastern hardwood tree on Fossil Island.", hardwoodSapling); eastHardwoodTreePatchPlant.addIcon(hardwoodSapling.getId()); eastHardwoodTreePatch.addSubSteps(eastHardwoodTreePatchPlant); } + @Subscribe public void onGameTick(GameTick event) { + + // Tree Patch Checks + // Since these all use the same values, it is probably redundant as it will always return the same thing.. + // Should instead use a single Checked/NotChecked/Stump conditional for 4771 and another for 7905? + // Need to see radius that causes varb to update, as sometimes update doesn't trigger.... + checkTreePatch(lumbridgeTreePatchNotChecked, lumbridgeTreePatchChecked, lumbridgeTreePatchIsStump, Varbits.FARMING_4771); + checkTreePatch(faladorTreePatchNotChecked, faladorTreePatchChecked, faladorTreePatchIsStump, Varbits.FARMING_4771); + checkTreePatch(taverleyTreePatchNotChecked, taverleyTreePatchChecked, taverleyTreePatchIsStump, Varbits.FARMING_4771); + checkTreePatch(varrockTreePatchNotChecked, varrockTreePatchChecked, varrockTreePatchIsStump, Varbits.FARMING_4771); + checkTreePatch(gnomeStrongholdTreePatchNotChecked, gnomeStrongholdTreePatchChecked, gnomeStrongholdTreePatchIsStump, Varbits.FARMING_4771); + checkTreePatch(farmingGuildTreePatchNotChecked, farmingGuildTreePatchChecked, farmingGuildTreePatchIsStump, Varbits.FARMING_7905); + for (FarmingPatch treePatch : farmingWorld.getTabs().get(Tab.TREE)) { CropState treeState = farmingHandler.predictPatch(treePatch); @@ -529,6 +665,26 @@ public void onGameTick(GameTick event) } } } + + private void checkTreePatch(ManualRequirement treePatchUnchecked, ManualRequirement treePatchChecked, + ManualRequirement treePatchIsStump, int farmingVarbit) + { + if (FarmingUtils.getPatchState(client, TREE_UNCHECKED, farmingVarbit)) + { + treePatchUnchecked.setShouldPass(true); + } + + if (FarmingUtils.getPatchState(client, TREE_CHECKED, farmingVarbit)) + { + treePatchChecked.setShouldPass(true); + } + + if (FarmingUtils.getPatchState(client, TREE_STUMP, farmingVarbit)) + { + treePatchIsStump.setShouldPass(true); + } + } + @Subscribe public void onConfigChanged(ConfigChanged event) { From 5df3932d30cd039ae9113bdb0ff5a21e03d69e47 Mon Sep 17 00:00:00 2001 From: Zoinkwiz Date: Wed, 5 Jun 2024 11:31:27 +0100 Subject: [PATCH 12/20] Remove unused and broken references in TreeRun --- .../helpers/mischelpers/farmruns/TreeRun.java | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java index e5ea0e2de1..0c36a8bfc9 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java @@ -1,24 +1,21 @@ package com.questhelper.helpers.mischelpers.farmruns; import com.google.inject.Inject; -import com.questhelper.HelperConfig; -import com.questhelper.ItemCollections; -import com.questhelper.QuestDescriptor; import com.questhelper.QuestHelperConfig; -import com.questhelper.QuestHelperQuest; +import com.questhelper.collections.ItemCollections; import com.questhelper.helpers.mischelpers.farmruns.FarmingUtils.FruitTreeSapling; import com.questhelper.helpers.mischelpers.farmruns.FarmingUtils.GracefulOrFarming; import com.questhelper.helpers.mischelpers.farmruns.FarmingUtils.HardwoodTreeSapling; import com.questhelper.helpers.mischelpers.farmruns.FarmingUtils.TreeSapling; 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; -import com.questhelper.requirements.player.Favour; -import com.questhelper.requirements.player.FavourRequirement; import com.questhelper.requirements.player.SkillRequirement; import com.questhelper.requirements.quest.QuestRequirement; import com.questhelper.requirements.runelite.RuneliteRequirement; @@ -29,7 +26,6 @@ import com.questhelper.steps.NpcStep; import com.questhelper.steps.ObjectStep; import com.questhelper.steps.QuestStep; -import com.sun.source.doctree.ValueTree; import net.runelite.api.ItemID; import net.runelite.api.NpcID; import net.runelite.api.NullObjectID; @@ -47,10 +43,6 @@ import java.util.Arrays; import java.util.List; -@QuestDescriptor( - quest = QuestHelperQuest.TREE_RUN -) - /* * * TODO LIST: @@ -263,11 +255,9 @@ private void setupConditions() accessToLletya = new QuestRequirement(QuestHelperQuest.MOURNINGS_END_PART_I, QuestState.FINISHED); accessToFossilIsland = new QuestRequirement(QuestHelperQuest.BONE_VOYAGE, QuestState.FINISHED); accessToFarmingGuildTreePatch = new Conditions( - new FavourRequirement(Favour.HOSIDIUS, 60), new SkillRequirement(Skill.FARMING, 65) ); accessToFarmingGuildFruitTreePatch = new Conditions( - new FavourRequirement(Favour.HOSIDIUS, 60), new SkillRequirement(Skill.FARMING, 85) ); From fb512fff5eaa1d4fcf03f8ac5b5507bbb5d6d136 Mon Sep 17 00:00:00 2001 From: Zoinkwiz Date: Wed, 5 Jun 2024 23:09:02 +0100 Subject: [PATCH 13/20] Add more usable states for crops --- .../mischelpers/farmruns/CropState.java | 42 +++++++++++++++++++ .../mischelpers/farmruns/FarmingHandler.java | 10 ++++- 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/questhelper/helpers/mischelpers/farmruns/CropState.java diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/CropState.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/CropState.java new file mode 100644 index 0000000000..35abbe2132 --- /dev/null +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/CropState.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2018 Abex + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.questhelper.helpers.mischelpers.farmruns; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Getter +public enum CropState +{ + HARVESTABLE(), // Ready for checking + UNCHECKED(), + STUMP(), // Cut down + GROWING(), + DISEASED(), + DEAD(), + EMPTY(), + FILLING(); +} diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingHandler.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingHandler.java index 27a04031b8..1b73bc8c23 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingHandler.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingHandler.java @@ -30,7 +30,6 @@ import net.runelite.api.Varbits; import net.runelite.client.config.ConfigManager; import net.runelite.client.plugins.timetracking.TimeTrackingConfig; -import net.runelite.client.plugins.timetracking.farming.CropState; import net.runelite.client.plugins.timetracking.farming.Produce; public class FarmingHandler @@ -108,7 +107,14 @@ public CropState predictPatch(FarmingPatch patch, String profile) doneEstimate = getTickTime(tickrate, stages - 1 - stage, tickTime, profile); } - if (unixNow >= doneEstimate) return CropState.HARVESTABLE; + if (unixNow >= doneEstimate) + { + if (state.getCropState() == CropState.GROWING) + { + + } + return CropState.HARVESTABLE; + } return CropState.GROWING; } From 90ae3a38143ccbb89ba31a9bdc2141c7715b009e Mon Sep 17 00:00:00 2001 From: Zoinkwiz Date: Wed, 5 Jun 2024 23:23:02 +0100 Subject: [PATCH 14/20] Add basic outline for Tree Run --- .../mischelpers/farmruns/FarmingUtils.java | 1 - .../helpers/mischelpers/farmruns/HerbRun.java | 3 +- .../farmruns/PatchImplementation.java | 89 ++- .../mischelpers/farmruns/PatchPrediction.java | 1 - .../mischelpers/farmruns/PatchState.java | 1 - .../helpers/mischelpers/farmruns/TreeRun.java | 537 ++++++++++++------ 6 files changed, 407 insertions(+), 225 deletions(-) diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java index 8d4a6d090b..7cc6415023 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java @@ -88,7 +88,6 @@ public static boolean getPatchState(Client client, int[] patchStates, int varbit { if (client.getVarbitValue(varbit) == stateVarb) { - System.out.println("Found patch state: " + client.getVarbitValue(varbit) + " " + stateVarb); return true; } } 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 f5e8fe1f8a..c637127a54 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/HerbRun.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/HerbRun.java @@ -58,7 +58,6 @@ import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.ConfigChanged; import net.runelite.client.plugins.timetracking.Tab; -import net.runelite.client.plugins.timetracking.farming.CropState; import net.runelite.client.util.Text; public class HerbRun extends ComplexStateQuestHelper @@ -469,7 +468,7 @@ public void onGameTick(GameTick event) } } seed.setQuantity(seedsNeeded); - compost.quantity(seedsNeeded); + compost.setQuantity(seedsNeeded); } @Override diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchImplementation.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchImplementation.java index bafc27d60f..f7cf0d73ad 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchImplementation.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchImplementation.java @@ -28,7 +28,6 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; import net.runelite.client.plugins.timetracking.Tab; -import net.runelite.client.plugins.timetracking.farming.CropState; import net.runelite.client.plugins.timetracking.farming.Produce; @RequiredArgsConstructor @@ -1216,32 +1215,32 @@ PatchState forVarbitValue(int value) if (value == 250) { // Redberry bush[Check-health,Inspect,Guide] 7702 - return new PatchState(Produce.REDBERRIES, CropState.GROWING, Produce.REDBERRIES.getStages() - 1); + return new PatchState(Produce.REDBERRIES, CropState.UNCHECKED, Produce.REDBERRIES.getStages() - 1); } if (value == 251) { // Cadavaberry bush[Check-health,Inspect,Guide] 7592 - return new PatchState(Produce.CADAVABERRIES, CropState.GROWING, Produce.CADAVABERRIES.getStages() - 1); + return new PatchState(Produce.CADAVABERRIES, CropState.UNCHECKED, Produce.CADAVABERRIES.getStages() - 1); } if (value == 252) { // Dwellberry bush[Check-health,Inspect,Guide] 7617 - return new PatchState(Produce.DWELLBERRIES, CropState.GROWING, Produce.DWELLBERRIES.getStages() - 1); + return new PatchState(Produce.DWELLBERRIES, CropState.UNCHECKED, Produce.DWELLBERRIES.getStages() - 1); } if (value == 253) { // Jangerberry bush[Check-health,Inspect,Guide] 7645 - return new PatchState(Produce.JANGERBERRIES, CropState.GROWING, Produce.JANGERBERRIES.getStages() - 1); + return new PatchState(Produce.JANGERBERRIES, CropState.UNCHECKED, Produce.JANGERBERRIES.getStages() - 1); } if (value == 254) { // Whiteberry bush[Check-health,Inspect,Guide] 7726 - return new PatchState(Produce.WHITEBERRIES, CropState.GROWING, Produce.WHITEBERRIES.getStages() - 1); + return new PatchState(Produce.WHITEBERRIES, CropState.UNCHECKED, Produce.WHITEBERRIES.getStages() - 1); } if (value == 255) { // Poison Ivy bush[Check-health,Inspect,Guide] 7675 - return new PatchState(Produce.POISON_IVY, CropState.GROWING, Produce.POISON_IVY.getStages() - 1); + return new PatchState(Produce.POISON_IVY, CropState.UNCHECKED, Produce.POISON_IVY.getStages() - 1); } return null; } @@ -1284,12 +1283,12 @@ PatchState forVarbitValue(int value) if (value == 33) { // Apple tree stump[Clear,Inspect,Guide] 7961 - return new PatchState(Produce.APPLE, CropState.HARVESTABLE, 0); + return new PatchState(Produce.APPLE, CropState.STUMP, 0); } if (value == 34) { // Apple tree[Check-health,Inspect,Guide] 7948 - return new PatchState(Produce.APPLE, CropState.GROWING, Produce.APPLE.getStages() - 1); + return new PatchState(Produce.APPLE, CropState.UNCHECKED, Produce.APPLE.getStages() - 1); } if (value >= 35 && value <= 40) { @@ -1314,12 +1313,12 @@ PatchState forVarbitValue(int value) if (value == 60) { // Banana tree stump[Clear,Inspect,Guide] 8019 - return new PatchState(Produce.BANANA, CropState.HARVESTABLE, 0); + return new PatchState(Produce.BANANA, CropState.STUMP, 0); } if (value == 61) { // Banana tree[Check-health,Inspect,Guide] 7999 - return new PatchState(Produce.BANANA, CropState.GROWING, Produce.BANANA.getStages() - 1); + return new PatchState(Produce.BANANA, CropState.UNCHECKED, Produce.BANANA.getStages() - 1); } if (value >= 62 && value <= 71) { @@ -1354,12 +1353,12 @@ PatchState forVarbitValue(int value) if (value == 97) { // Orange tree stump[Clear,Inspect,Guide] 8077 - return new PatchState(Produce.ORANGE, CropState.HARVESTABLE, 0); + return new PatchState(Produce.ORANGE, CropState.STUMP, 0); } if (value == 98) { // Orange tree[Check-health,Inspect,Guide] 8064 - return new PatchState(Produce.ORANGE, CropState.GROWING, Produce.ORANGE.getStages() - 1); + return new PatchState(Produce.ORANGE, CropState.UNCHECKED, Produce.ORANGE.getStages() - 1); } if (value >= 99 && value <= 104) { @@ -1384,12 +1383,12 @@ PatchState forVarbitValue(int value) if (value == 124) { // Curry tree stump[Clear,Inspect,Guide] 8046 - return new PatchState(Produce.CURRY, CropState.HARVESTABLE, 0); + return new PatchState(Produce.CURRY, CropState.STUMP, 0); } if (value == 125) { // Curry tree[Check-health,Inspect,Guide] 8033 - return new PatchState(Produce.CURRY, CropState.GROWING, Produce.CURRY.getStages() - 1); + return new PatchState(Produce.CURRY, CropState.UNCHECKED, Produce.CURRY.getStages() - 1); } if (value >= 126 && value <= 135) { @@ -1419,12 +1418,12 @@ PatchState forVarbitValue(int value) if (value == 161) { // Pineapple plant stump[Clear,Inspect,Guide] 7992 - return new PatchState(Produce.PINEAPPLE, CropState.HARVESTABLE, 0); + return new PatchState(Produce.PINEAPPLE, CropState.STUMP, 0); } if (value == 162) { // Pineapple plant[Check-health,Inspect,Guide] 7979 - return new PatchState(Produce.PINEAPPLE, CropState.GROWING, Produce.PINEAPPLE.getStages() - 1); + return new PatchState(Produce.PINEAPPLE, CropState.UNCHECKED, Produce.PINEAPPLE.getStages() - 1); } if (value >= 163 && value <= 168) { @@ -1449,12 +1448,12 @@ PatchState forVarbitValue(int value) if (value == 188) { // Papaya tree stump[Clear,Inspect,Guide] 8131 - return new PatchState(Produce.PAPAYA, CropState.HARVESTABLE, 0); + return new PatchState(Produce.PAPAYA, CropState.STUMP, 0); } if (value == 189) { // Papaya tree[Check-health,Inspect,Guide] 8118 - return new PatchState(Produce.PAPAYA, CropState.GROWING, Produce.PAPAYA.getStages() - 1); + return new PatchState(Produce.PAPAYA, CropState.UNCHECKED, Produce.PAPAYA.getStages() - 1); } if (value >= 190 && value <= 199) { @@ -1484,12 +1483,12 @@ PatchState forVarbitValue(int value) if (value == 225) { // Palm tree stump[Clear,Inspect,Guide] 8104 - return new PatchState(Produce.PALM, CropState.HARVESTABLE, 0); + return new PatchState(Produce.PALM, CropState.STUMP, 0); } if (value == 226) { // Palm tree[Check-health,Inspect,Guide] 8091 - return new PatchState(Produce.PALM, CropState.GROWING, Produce.PALM.getStages() - 1); + return new PatchState(Produce.PALM, CropState.UNCHECKED, Produce.PALM.getStages() - 1); } if (value >= 227 && value <= 232) { @@ -1514,12 +1513,12 @@ PatchState forVarbitValue(int value) if (value == 252) { // Dragonfruit tree stump[Clear,Inspect,Guide] 34034 - return new PatchState(Produce.DRAGONFRUIT, CropState.HARVESTABLE, 0); + return new PatchState(Produce.DRAGONFRUIT, CropState.STUMP, 0); } if (value == 253) { // Dragonfruit tree[Check-health,Inspect,Guide] 34021 - return new PatchState(Produce.DRAGONFRUIT, CropState.GROWING, Produce.DRAGONFRUIT.getStages() - 1); + return new PatchState(Produce.DRAGONFRUIT, CropState.UNCHECKED, Produce.DRAGONFRUIT.getStages() - 1); } if (value >= 254 && value <= 255) { @@ -1855,7 +1854,7 @@ PatchState forVarbitValue(int value) if (value == 12) { // Oak[Check-health,Inspect,Guide] 8466 - return new PatchState(Produce.OAK, CropState.GROWING, Produce.OAK.getStages() - 1); + return new PatchState(Produce.OAK, CropState.UNCHECKED, Produce.OAK.getStages() - 1); } if (value == 13) { @@ -1865,7 +1864,7 @@ PatchState forVarbitValue(int value) if (value == 14) { // Oak tree stump[Clear,Inspect,Guide] 8468 - return new PatchState(Produce.OAK, CropState.HARVESTABLE, 0); + return new PatchState(Produce.OAK, CropState.STUMP, 0); } if (value >= 15 && value <= 20) { @@ -1875,7 +1874,7 @@ PatchState forVarbitValue(int value) if (value == 21) { // Willow Tree[Check-health,Inspect,Guide] 8487 - return new PatchState(Produce.WILLOW, CropState.GROWING, Produce.WILLOW.getStages() - 1); + return new PatchState(Produce.WILLOW, CropState.UNCHECKED, Produce.WILLOW.getStages() - 1); } if (value == 22) { @@ -1885,7 +1884,7 @@ PatchState forVarbitValue(int value) if (value == 23) { // Willow tree stump[Clear,Inspect,Guide] 8489 - return new PatchState(Produce.WILLOW, CropState.HARVESTABLE, 0); + return new PatchState(Produce.WILLOW, CropState.STUMP, 0); } if (value >= 24 && value <= 31) { @@ -1895,7 +1894,7 @@ PatchState forVarbitValue(int value) if (value == 32) { // Maple Tree[Check-health,Inspect,Guide] 8443 - return new PatchState(Produce.MAPLE, CropState.GROWING, Produce.MAPLE.getStages() - 1); + return new PatchState(Produce.MAPLE, CropState.UNCHECKED, Produce.MAPLE.getStages() - 1); } if (value == 33) { @@ -1905,7 +1904,7 @@ PatchState forVarbitValue(int value) if (value == 34) { // Tree stump[Clear,Inspect,Guide] 8445 - return new PatchState(Produce.MAPLE, CropState.HARVESTABLE, 0); + return new PatchState(Produce.MAPLE, CropState.STUMP, 0); } if (value >= 35 && value <= 44) { @@ -1915,7 +1914,7 @@ PatchState forVarbitValue(int value) if (value == 45) { // Yew tree[Check-health,Inspect,Guide] 8512 - return new PatchState(Produce.YEW, CropState.GROWING, Produce.YEW.getStages() - 1); + return new PatchState(Produce.YEW, CropState.UNCHECKED, Produce.YEW.getStages() - 1); } if (value == 46) { @@ -1925,7 +1924,7 @@ PatchState forVarbitValue(int value) if (value == 47) { // Yew tree stump[Clear,Inspect,Guide] 8514 - return new PatchState(Produce.YEW, CropState.HARVESTABLE, 0); + return new PatchState(Produce.YEW, CropState.STUMP, 0); } if (value >= 48 && value <= 59) { @@ -1935,7 +1934,7 @@ PatchState forVarbitValue(int value) if (value == 60) { // Magic Tree[Check-health,Inspect,Guide] 8408 - return new PatchState(Produce.MAGIC, CropState.GROWING, Produce.MAGIC.getStages() - 1); + return new PatchState(Produce.MAGIC, CropState.UNCHECKED, Produce.MAGIC.getStages() - 1); } if (value == 61) { @@ -1945,7 +1944,7 @@ PatchState forVarbitValue(int value) if (value == 62) { // Magic Tree Stump[Clear,Inspect,Guide] 8410 - return new PatchState(Produce.MAGIC, CropState.HARVESTABLE, 0); + return new PatchState(Produce.MAGIC, CropState.STUMP, 0); } if (value >= 63 && value <= 72) { @@ -2138,7 +2137,7 @@ PatchState forVarbitValue(int value) if (value == 15) { // Teak Tree[Check-health,Inspect,Guide] 30444 - return new PatchState(Produce.TEAK, CropState.GROWING, Produce.TEAK.getStages() - 1); + return new PatchState(Produce.TEAK, CropState.UNCHECKED, Produce.TEAK.getStages() - 1); } if (value == 16) { @@ -2148,7 +2147,7 @@ PatchState forVarbitValue(int value) if (value == 17) { // Tree stump[Clear,Inspect,Guide] 30446 - return new PatchState(Produce.TEAK, CropState.HARVESTABLE, 0); + return new PatchState(Produce.TEAK, CropState.STUMP, 0); } if (value >= 18 && value <= 23) { @@ -2168,7 +2167,7 @@ PatchState forVarbitValue(int value) if (value == 38) { // Mahogany tree[Check-health,Inspect,Guide] 30416 - return new PatchState(Produce.MAHOGANY, CropState.GROWING, Produce.MAHOGANY.getStages() - 1); + return new PatchState(Produce.MAHOGANY, CropState.UNCHECKED, Produce.MAHOGANY.getStages() - 1); } if (value == 39) { @@ -2178,7 +2177,7 @@ PatchState forVarbitValue(int value) if (value == 40) { // Mahogany tree stump[Clear,Inspect,Guide] 30418 - return new PatchState(Produce.MAHOGANY, CropState.HARVESTABLE, 0); + return new PatchState(Produce.MAHOGANY, CropState.STUMP, 0); } if (value >= 41 && value <= 47) { @@ -2236,7 +2235,7 @@ PatchState forVarbitValue(int value) if (value == 37) { // Redwood tree[Check-health,Inspect,Guide] 34297 - return new PatchState(Produce.REDWOOD, CropState.GROWING, Produce.REDWOOD.getStages() - 1); + return new PatchState(Produce.REDWOOD, CropState.UNCHECKED, Produce.REDWOOD.getStages() - 1); } if (value >= 41 && value <= 55) { @@ -2284,7 +2283,7 @@ PatchState forVarbitValue(int value) if (value == 44) { // Spirit Tree[Check-health,Inspect,Guide] 8356 - return new PatchState(Produce.SPIRIT_TREE, CropState.GROWING, Produce.SPIRIT_TREE.getStages() - 1); + return new PatchState(Produce.SPIRIT_TREE, CropState.UNCHECKED, Produce.SPIRIT_TREE.getStages() - 1); } if (value >= 45 && value <= 63) { @@ -2379,7 +2378,7 @@ PatchState forVarbitValue(int value) if (value == 31) { // Cactus[Check-health,Inspect,Guide] 7758 - return new PatchState(Produce.CACTUS, CropState.GROWING, Produce.CACTUS.getStages() - 1); + return new PatchState(Produce.CACTUS, CropState.UNCHECKED, Produce.CACTUS.getStages() - 1); } if (value >= 32 && value <= 38) { @@ -2404,7 +2403,7 @@ PatchState forVarbitValue(int value) if (value == 58) { // Potato cactus[Check-health,Inspect,Guide] 33748 - return new PatchState(Produce.POTATO_CACTUS, CropState.GROWING, Produce.POTATO_CACTUS.getStages() - 1); + return new PatchState(Produce.POTATO_CACTUS, CropState.UNCHECKED, Produce.POTATO_CACTUS.getStages() - 1); } if (value >= 59 && value <= 255) { @@ -2485,7 +2484,7 @@ PatchState forVarbitValue(int value) if (value == 34) { // Calquat Tree[Check-health,Inspect,Guide] 7791 - return new PatchState(Produce.CALQUAT, CropState.GROWING, Produce.CALQUAT.getStages() - 1); + return new PatchState(Produce.CALQUAT, CropState.UNCHECKED, Produce.CALQUAT.getStages() - 1); } if (value >= 35 && value <= 255) { @@ -2518,7 +2517,7 @@ PatchState forVarbitValue(int value) if (value == 13) { // Celastrus tree[Check-health,Inspect,Guide] 33704 - return new PatchState(Produce.CELASTRUS, CropState.GROWING, Produce.CELASTRUS.getStages() - 1); + return new PatchState(Produce.CELASTRUS, CropState.UNCHECKED, Produce.CELASTRUS.getStages() - 1); } if (value >= 14 && value <= 16) { @@ -2543,7 +2542,7 @@ PatchState forVarbitValue(int value) if (value == 28) { // Celastrus tree stump[Clear,Inspect,Guide] 33721 - return new PatchState(Produce.CELASTRUS, CropState.HARVESTABLE, 0); + return new PatchState(Produce.CELASTRUS, CropState.STUMP, 0); } if (value >= 29 && value <= 255) { @@ -2596,7 +2595,7 @@ PatchState forVarbitValue(int value) if (value == 14) { // Crystal tree[Check-health,Inspect,Guide] 34917 - return new PatchState(Produce.CRYSTAL_TREE, CropState.GROWING, Produce.CRYSTAL_TREE.getStages() - 1); + return new PatchState(Produce.CRYSTAL_TREE, CropState.UNCHECKED, Produce.CRYSTAL_TREE.getStages() - 1); } if (value == 15) { diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchPrediction.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchPrediction.java index f9ad856f47..383b18d0f3 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchPrediction.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchPrediction.java @@ -26,7 +26,6 @@ import lombok.Value; -import net.runelite.client.plugins.timetracking.farming.CropState; import net.runelite.client.plugins.timetracking.farming.Produce; @Value diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchState.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchState.java index 2f6f9702ff..ff35593291 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchState.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchState.java @@ -25,7 +25,6 @@ package com.questhelper.helpers.mischelpers.farmruns; import lombok.Value; -import net.runelite.client.plugins.timetracking.farming.CropState; import net.runelite.client.plugins.timetracking.farming.Produce; @Value class PatchState diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java index 0c36a8bfc9..4450fee0dc 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java @@ -26,6 +26,8 @@ import com.questhelper.steps.NpcStep; import com.questhelper.steps.ObjectStep; import com.questhelper.steps.QuestStep; +import com.questhelper.steps.widget.LunarSpells; +import com.questhelper.steps.widget.NormalSpells; import net.runelite.api.ItemID; import net.runelite.api.NpcID; import net.runelite.api.NullObjectID; @@ -37,7 +39,6 @@ import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.ConfigChanged; import net.runelite.client.plugins.timetracking.Tab; -import net.runelite.client.plugins.timetracking.farming.CropState; import net.runelite.client.util.Text; import java.util.ArrayList; import java.util.Arrays; @@ -60,35 +61,40 @@ public class TreeRun extends ComplexStateQuestHelper DetailedQuestStep waitForTree; // Trees - DetailedQuestStep farmingGuildTreePatch, lumbridgeTreePatch, faladorTreePatch, taverleyTreePatch, varrockTreePatch, - gnomeStrongholdTreePatch; + DetailedQuestStep farmingGuildTreePatchCheckHealth, lumbridgeTreePatchCheckHealth, faladorTreePatchCheckHealth, taverleyTreePatchCheckHealth, varrockTreePatchCheckHealth, + gnomeStrongholdTreePatchCheckHealth; DetailedQuestStep farmingGuildTreePatchPlant, lumbridgeTreePatchPlant, faladorTreePatchPlant, taverleyTreePatchPlant, varrockTreePatchPlant, gnomeStrongholdTreePatchPlant; DetailedQuestStep lumbridgeTreePatchClear, faladorTreePatchClear, taverleyTreePatchClear, varrockTreePatchClear, gnomeStrongholdTreePatchClear, farmingGuildTreePatchClear; + DetailedQuestStep lumbridgeTreePatchDig, faladorTreePatchDig, taverleyTreePatchDig, varrockTreePatchDig, + gnomeStrongholdTreePatchDig, farmingGuildTreePatchDig; // Fruit Trees - DetailedQuestStep farmingGuildFruitTreePatch, gnomeStrongholdFruitTreePatch, gnomeVillageFruitTreePatch, - brimhavenFruitTreePatch, lletyaFruitTreePatch, catherbyFruitTreePatch; + DetailedQuestStep farmingGuildFruitTreePatchCheckHealth, gnomeStrongholdFruitTreePatchCheckHealth, gnomeVillageFruitTreePatchCheckHealth, + brimhavenFruitTreePatchCheckHealth, lletyaFruitTreePatchCheckHealth, catherbyFruitTreePatchCheckHealth; DetailedQuestStep farmingGuildFruitTreePatchPlant, gnomeStrongholdFruitTreePatchPlant, gnomeVillageFruitTreePatchPlant, brimhavenFruitTreePatchPlant, lletyaFruitTreePatchPlant, catherbyFruitTreePatchPlant; DetailedQuestStep farmingGuildFruitTreePatchClear, gnomeStrongholdFruitTreePatchClear, gnomeVillageFruitTreePatchClear, brimhavenFruitTreePatchClear, lletyaFruitTreePatchClear, catherbyFruitTreePatchClear; + DetailedQuestStep farmingGuildFruitTreePatchDig, gnomeStrongholdFruitTreePatchDig, gnomeVillageFruitTreePatchDig, + brimhavenFruitTreePatchDig, lletyaFruitTreePatchDig, catherbyFruitTreePatchDig; // Hardwood Trees - DetailedQuestStep eastHardwoodTreePatch, westHardwoodTreePatch, middleHardwoodTreePatch; + DetailedQuestStep eastHardwoodTreePatchCheckHealth, westHardwoodTreePatchCheckHealth, middleHardwoodTreePatchCheckHealth; DetailedQuestStep eastHardwoodTreePatchPlant, westHardwoodTreePatchPlant, middleHardwoodTreePatchPlant; + DetailedQuestStep eastHardwoodTreePatchDig, westHardwoodTreePatchDig, middleHardwoodTreePatchDig; DetailedQuestStep eastHardwoodTreePatchClear, westHardwoodTreePatchClear, middleHardwoodTreePatchClear; // Farming Items - ItemRequirement coins, spade, rake, treeSapling, fruitTreeSapling, hardwoodSapling, compost, axe, protectionItem; + ItemRequirement coins, spade, rake, allTreeSaplings, treeSapling, allFruitSaplings, fruitTreeSapling, hardwoodSapling, compost, axe, protectionItem; // Teleport Items // TODO: Add these... - ItemRequirement farmingGuildTeleport; + ItemRequirement farmingGuildTeleport, crystalTeleport, catherbyTeleport, varrockTeleport, lumbridgeTeleport, faladorTeleport, fossilIslandTeleport; // Graceful Set ItemRequirement gracefulHood, gracefulTop, gracefulLegs, gracefulGloves, gracefulBoots, gracefulCape, gracefulOutfit; @@ -102,46 +108,41 @@ public class TreeRun extends ComplexStateQuestHelper // Tree Requirements ManualRequirement lumbridgeTreePatchEmpty, faladorTreePatchEmpty, taverleyTreePatchEmpty, varrockTreePatchEmpty, gnomeStrongholdTreePatchEmpty, farmingGuildTreePatchEmpty; - ManualRequirement lumbridgeTreePatchReady, faladorTreePatchReady, taverleyTreePatchReady, - varrockTreePatchReady, gnomeStrongholdTreePatchReady, farmingGuildTreePatchReady; - ManualRequirement faladorTreePatchNotChecked, faladorTreePatchChecked, faladorTreePatchIsStump, - lumbridgeTreePatchNotChecked, lumbridgeTreePatchChecked, lumbridgeTreePatchIsStump, - farmingGuildTreePatchNotChecked, farmingGuildTreePatchChecked, farmingGuildTreePatchIsStump, - taverleyTreePatchNotChecked, taverleyTreePatchChecked, taverleyTreePatchIsStump, - varrockTreePatchNotChecked, varrockTreePatchChecked, varrockTreePatchIsStump, - gnomeStrongholdTreePatchNotChecked, gnomeStrongholdTreePatchChecked, gnomeStrongholdTreePatchIsStump; + ManualRequirement lumbridgeTreePatchHarvestable, faladorTreePatchHarvestable, taverleyTreePatchHarvestable, + varrockTreePatchHarvestable, gnomeStrongholdTreePatchHarvestable, farmingGuildTreePatchHarvestable; + ManualRequirement faladorTreePatchNotChecked, faladorTreePatchIsStump, + lumbridgeTreePatchNotChecked, lumbridgeTreePatchIsStump, + farmingGuildTreePatchNotChecked, farmingGuildTreePatchIsStump, + taverleyTreePatchNotChecked, taverleyTreePatchIsStump, + varrockTreePatchNotChecked, varrockTreePatchIsStump, + gnomeStrongholdTreePatchNotChecked, gnomeStrongholdTreePatchIsStump; // Fruit Tree Requirements ManualRequirement gnomeStrongholdFruitTreePatchEmpty, gnomeVillageFruitTreePatchEmpty, brimhavenFruitTreePatchEmpty, lletyaFruitTreePatchEmpty, catherbyFruitTreePatchEmpty, farmingGuildFruitTreePatchEmpty; - ManualRequirement gnomeStrongholdFruitTreePatchReady, gnomeVillageFruitTreePatchReady, - brimhavenFruitTreePatchReady, lletyaFruitTreePatchReady, catherbyFruitTreePatchReady, farmingGuildFruitTreePatchReady; - - ManualRequirement gnomeStrongholdFruitTreePatchNotChecked, gnomeStrongholdFruitTreePatchChecked, gnomeStrongholdFruitTreePatchIsStump, - gnomeVillageFruitTreePatchNotChecked, gnomeVillageFruitTreePatchChecked, gnomeVillageFruitTreePatchIsStump, - brimhavenFruitTreePatchNotChecked, brimhavenFruitTreePatchChecked, brimhavenFruitTreePatchIsStump, - lletyaFruitTreePatchNotChecked, lletyaFruitTreePatchChecked, lletyaFruitTreePatchIsStump, - catherbyFruitTreePatchNotChecked, catherbyFruitTreePatchChecked, catherbyFruitTreePatchIsStump, + ManualRequirement gnomeStrongholdFruitTreePatchHarvestable, gnomeVillageFruitTreePatchHarvestable, + brimhavenFruitTreePatchHarvestable, lletyaFruitTreePatchHarvestable, catherbyFruitTreePatchHarvestable, farmingGuildFruitTreePatchHarvestable; + + ManualRequirement gnomeStrongholdFruitTreePatchNotChecked, gnomeStrongholdFruitTreePatchIsStump, + gnomeVillageFruitTreePatchNotChecked, gnomeVillageFruitTreePatchIsStump, + brimhavenFruitTreePatchNotChecked, brimhavenFruitTreePatchIsStump, + lletyaFruitTreePatchNotChecked, lletyaFruitTreePatchIsStump, + catherbyFruitTreePatchNotChecked, catherbyFruitTreePatchIsStump, farmingGuildFruitTreePatchNotChecked, farmingGuildFruitTreePatchChecked, farmingGuildFruitTreePatchIsStump; // Hardwood Tree Requirements ManualRequirement eastHardwoodTreePatchEmpty, westHardwoodTreePatchEmpty, middleHardwoodTreePatchEmpty; ManualRequirement eastHardwoodTreePatchReady, westHardwoodTreePatchReady, middleHardwoodTreePatchReady; - ManualRequirement eastHardwoodTreePatchNotChecked, eastHardwoodTreePatchChecked, eastHardwoodTreePatchIsStump, - westHardwoodTreePatchNotChecked, westHardwoodTreePatchChecked, westHardwoodTreePatchIsStump, - middleHardwoodTreePatchNotChecked, middleHardwoodTreePatchChecked, middleHardwoodTreePatchIsStump; + ManualRequirement eastHardwoodTreePatchNotChecked, eastHardwoodTreePatchHarvestable, eastHardwoodTreePatchIsStump, + westHardwoodTreePatchNotChecked, westHardwoodTreePatchHarvestable, westHardwoodTreePatchIsStump, + middleHardwoodTreePatchNotChecked, middleHardwoodTreePatchHarvestable, middleHardwoodTreePatchIsStump; private final String TREE_SAPLING = "treeSaplings"; private final String FRUIT_TREE_SAPLING = "fruitTreeSaplings"; private final String HARDWOOD_TREE_SAPLING = "hardwoodTreeSaplings"; private final String GRACEFUL_OR_FARMING = "gracefulOrFarming"; - private final int[] TREE_UNCHECKED = { 12, 21, 32, 45, 60 }; - // 192 - 197 for Willow tree final state? Are all trees like this? - private final int[] TREE_CHECKED = {13, 22, 33, 46, 61, 192, 193, 194, 195, 196, 197}; - private final int[] TREE_STUMP = {14, 23, 34, 47, 62}; - @Override public QuestStep loadStep() { @@ -157,51 +158,81 @@ public QuestStep loadStep() // Varrock -> Gnome Stronghold Fruit -> Gnome Stronghold Tree -> Gnome Village -> Brimhaven // -> catherby -> lletya -> east hardwood -> middle hardwood -> west hardwood. - steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreePatchReady), farmingGuildTreePatch); + + steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreePatchNotChecked), farmingGuildTreePatchCheckHealth); + steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreePatchHarvestable), farmingGuildTreePatchClear); + steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreePatchIsStump), farmingGuildTreePatchDig); steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreePatchEmpty), farmingGuildTreePatchPlant); - steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitTreePatchReady), farmingGuildFruitTreePatch); + steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitTreePatchNotChecked), farmingGuildFruitTreePatchCheckHealth); + steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitTreePatchChecked), farmingGuildTreePatchClear); steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitTreePatchEmpty), farmingGuildFruitTreePatchPlant); + steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitTreePatchIsStump), farmingGuildTreePatchDig); - steps.addStep(lumbridgeTreePatchReady, lumbridgeTreePatch); + steps.addStep(lumbridgeTreePatchNotChecked, lumbridgeTreePatchCheckHealth); steps.addStep(lumbridgeTreePatchEmpty, lumbridgeTreePatchPlant); + steps.addStep(lumbridgeTreePatchHarvestable, lumbridgeTreePatchClear); + steps.addStep(lumbridgeTreePatchIsStump, lumbridgeTreePatchDig); - steps.addStep(new Conditions(faladorTreePatchReady, faladorTreePatchNotChecked), faladorTreePatch); - steps.addStep(new Conditions(faladorTreePatchReady, faladorTreePatchChecked), faladorTreePatchClear); + steps.addStep(faladorTreePatchNotChecked, faladorTreePatchCheckHealth); steps.addStep(faladorTreePatchEmpty, faladorTreePatchPlant); + steps.addStep(faladorTreePatchHarvestable, faladorTreePatchClear); + steps.addStep(faladorTreePatchIsStump, faladorTreePatchDig); - steps.addStep(taverleyTreePatchReady, taverleyTreePatch); + steps.addStep(taverleyTreePatchNotChecked, taverleyTreePatchCheckHealth); steps.addStep(taverleyTreePatchEmpty, taverleyTreePatchPlant); + steps.addStep(taverleyTreePatchHarvestable, taverleyTreePatchClear); + steps.addStep(taverleyTreePatchIsStump, taverleyTreePatchDig); - steps.addStep(varrockTreePatchReady, varrockTreePatch); + steps.addStep(varrockTreePatchNotChecked, varrockTreePatchCheckHealth); steps.addStep(varrockTreePatchEmpty, varrockTreePatchPlant); + steps.addStep(varrockTreePatchHarvestable, varrockTreePatchClear); + steps.addStep(varrockTreePatchIsStump, varrockTreePatchDig); - steps.addStep(gnomeStrongholdFruitTreePatchReady, gnomeStrongholdFruitTreePatch); + steps.addStep(gnomeStrongholdFruitTreePatchNotChecked, gnomeStrongholdFruitTreePatchCheckHealth); steps.addStep(gnomeStrongholdFruitTreePatchEmpty, gnomeStrongholdFruitTreePatchPlant); + steps.addStep(gnomeStrongholdFruitTreePatchHarvestable, gnomeStrongholdFruitTreePatchClear); + steps.addStep(gnomeStrongholdFruitTreePatchIsStump, gnomeStrongholdFruitTreePatchDig); - steps.addStep(gnomeStrongholdTreePatchReady, gnomeStrongholdTreePatch); + steps.addStep(gnomeStrongholdTreePatchNotChecked, gnomeStrongholdTreePatchCheckHealth); steps.addStep(gnomeStrongholdTreePatchEmpty, gnomeStrongholdFruitTreePatchPlant); + steps.addStep(gnomeStrongholdTreePatchHarvestable, gnomeStrongholdTreePatchClear); + steps.addStep(gnomeStrongholdTreePatchIsStump, gnomeStrongholdTreePatchDig); - steps.addStep(gnomeVillageFruitTreePatchReady, gnomeVillageFruitTreePatch); + steps.addStep(gnomeVillageFruitTreePatchNotChecked, gnomeVillageFruitTreePatchCheckHealth); steps.addStep(gnomeVillageFruitTreePatchEmpty, gnomeVillageFruitTreePatchPlant); + steps.addStep(gnomeVillageFruitTreePatchHarvestable, gnomeVillageFruitTreePatchClear); + steps.addStep(gnomeVillageFruitTreePatchIsStump, gnomeVillageFruitTreePatchDig); - steps.addStep(brimhavenFruitTreePatchReady, brimhavenFruitTreePatch); + steps.addStep(brimhavenFruitTreePatchNotChecked, brimhavenFruitTreePatchCheckHealth); steps.addStep(brimhavenFruitTreePatchEmpty, brimhavenFruitTreePatchPlant); + steps.addStep(brimhavenFruitTreePatchHarvestable, brimhavenFruitTreePatchClear); + steps.addStep(brimhavenFruitTreePatchIsStump, brimhavenFruitTreePatchDig); - steps.addStep(catherbyFruitTreePatchReady, catherbyFruitTreePatch); + steps.addStep(catherbyFruitTreePatchNotChecked, catherbyFruitTreePatchCheckHealth); steps.addStep(catherbyFruitTreePatchEmpty, catherbyFruitTreePatchPlant); + steps.addStep(catherbyFruitTreePatchHarvestable, catherbyFruitTreePatchClear); + steps.addStep(catherbyFruitTreePatchIsStump, catherbyFruitTreePatchDig); - steps.addStep(new Conditions(accessToLletya, lletyaFruitTreePatchReady), lletyaFruitTreePatch); + steps.addStep(new Conditions(accessToLletya, lletyaFruitTreePatchNotChecked), lletyaFruitTreePatchCheckHealth); steps.addStep(new Conditions(accessToLletya, lletyaFruitTreePatchEmpty), lletyaFruitTreePatchPlant); + steps.addStep(new Conditions(accessToLletya, lletyaFruitTreePatchHarvestable), lletyaFruitTreePatchClear); + steps.addStep(new Conditions(accessToLletya, lletyaFruitTreePatchIsStump), lletyaFruitTreePatchDig); - steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodTreePatchReady), eastHardwoodTreePatch); + steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodTreePatchNotChecked), eastHardwoodTreePatchCheckHealth); steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodTreePatchEmpty), eastHardwoodTreePatchPlant); + steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodTreePatchHarvestable), eastHardwoodTreePatchClear); + steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodTreePatchIsStump), eastHardwoodTreePatchDig); - steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodTreePatchReady), middleHardwoodTreePatch); + steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodTreePatchNotChecked), middleHardwoodTreePatchCheckHealth); steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodTreePatchEmpty), middleHardwoodTreePatchPlant); + steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodTreePatchHarvestable), middleHardwoodTreePatchClear); + steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodTreePatchIsStump), middleHardwoodTreePatchDig); - steps.addStep(new Conditions(accessToFossilIsland, westHardwoodTreePatchReady), westHardwoodTreePatch); + steps.addStep(new Conditions(accessToFossilIsland, westHardwoodTreePatchNotChecked), westHardwoodTreePatchCheckHealth); steps.addStep(new Conditions(accessToFossilIsland, westHardwoodTreePatchEmpty), westHardwoodTreePatchPlant); + steps.addStep(new Conditions(accessToFossilIsland, westHardwoodTreePatchHarvestable), westHardwoodTreePatchClear); + steps.addStep(new Conditions(accessToFossilIsland, westHardwoodTreePatchIsStump), westHardwoodTreePatchDig); return steps; } @@ -209,12 +240,12 @@ public QuestStep loadStep() private void setupConditions() { // Tree Patch Ready Requirements - lumbridgeTreePatchReady = new ManualRequirement(); - faladorTreePatchReady = new ManualRequirement(); - taverleyTreePatchReady = new ManualRequirement(); - varrockTreePatchReady = new ManualRequirement(); - gnomeStrongholdTreePatchReady = new ManualRequirement(); - farmingGuildTreePatchReady = new ManualRequirement(); + lumbridgeTreePatchHarvestable = new ManualRequirement(); + faladorTreePatchHarvestable = new ManualRequirement(); + taverleyTreePatchHarvestable = new ManualRequirement(); + varrockTreePatchHarvestable = new ManualRequirement(); + gnomeStrongholdTreePatchHarvestable = new ManualRequirement(); + farmingGuildTreePatchHarvestable = new ManualRequirement(); // Tree Patch Empty Requirements lumbridgeTreePatchEmpty = new ManualRequirement(); @@ -225,12 +256,12 @@ private void setupConditions() farmingGuildTreePatchEmpty = new ManualRequirement(); // Fruit Patch Ready Requirements - gnomeStrongholdFruitTreePatchReady = new ManualRequirement(); - gnomeVillageFruitTreePatchReady = new ManualRequirement(); - brimhavenFruitTreePatchReady = new ManualRequirement(); - lletyaFruitTreePatchReady = new ManualRequirement(); - catherbyFruitTreePatchReady = new ManualRequirement(); - farmingGuildFruitTreePatchReady = new ManualRequirement(); + gnomeStrongholdFruitTreePatchHarvestable = new ManualRequirement(); + gnomeVillageFruitTreePatchHarvestable = new ManualRequirement(); + brimhavenFruitTreePatchHarvestable = new ManualRequirement(); + lletyaFruitTreePatchHarvestable = new ManualRequirement(); + catherbyFruitTreePatchHarvestable = new ManualRequirement(); + farmingGuildFruitTreePatchHarvestable = new ManualRequirement(); // Fruit Patch Empty Requirements gnomeStrongholdFruitTreePatchEmpty = new ManualRequirement(); @@ -263,67 +294,66 @@ private void setupConditions() // Tree Not Checked lumbridgeTreePatchNotChecked = new ManualRequirement(); - lumbridgeTreePatchChecked = new ManualRequirement(); + lumbridgeTreePatchHarvestable = new ManualRequirement(); lumbridgeTreePatchIsStump = new ManualRequirement(); faladorTreePatchNotChecked = new ManualRequirement(); - faladorTreePatchChecked = new ManualRequirement(); + faladorTreePatchHarvestable = new ManualRequirement(); faladorTreePatchIsStump = new ManualRequirement(); taverleyTreePatchNotChecked = new ManualRequirement(); - taverleyTreePatchChecked = new ManualRequirement(); + taverleyTreePatchHarvestable = new ManualRequirement(); taverleyTreePatchIsStump = new ManualRequirement(); varrockTreePatchNotChecked = new ManualRequirement(); - varrockTreePatchChecked = new ManualRequirement(); + varrockTreePatchHarvestable = new ManualRequirement(); varrockTreePatchIsStump = new ManualRequirement(); gnomeStrongholdTreePatchNotChecked = new ManualRequirement(); - gnomeStrongholdTreePatchChecked = new ManualRequirement(); + gnomeStrongholdTreePatchHarvestable = new ManualRequirement(); gnomeStrongholdTreePatchIsStump = new ManualRequirement(); farmingGuildTreePatchNotChecked = new ManualRequirement(); - farmingGuildTreePatchChecked = new ManualRequirement(); + farmingGuildTreePatchHarvestable = new ManualRequirement(); farmingGuildTreePatchIsStump = new ManualRequirement(); // Fruit Tree Not Checked gnomeStrongholdFruitTreePatchNotChecked = new ManualRequirement(); - gnomeStrongholdFruitTreePatchChecked = new ManualRequirement(); + gnomeStrongholdFruitTreePatchHarvestable = new ManualRequirement(); gnomeStrongholdFruitTreePatchIsStump = new ManualRequirement(); gnomeVillageFruitTreePatchNotChecked = new ManualRequirement(); - gnomeVillageFruitTreePatchChecked = new ManualRequirement(); + gnomeVillageFruitTreePatchHarvestable = new ManualRequirement(); gnomeVillageFruitTreePatchIsStump = new ManualRequirement(); brimhavenFruitTreePatchNotChecked = new ManualRequirement(); - brimhavenFruitTreePatchChecked = new ManualRequirement(); + brimhavenFruitTreePatchHarvestable = new ManualRequirement(); brimhavenFruitTreePatchIsStump = new ManualRequirement(); lletyaFruitTreePatchNotChecked = new ManualRequirement(); - lletyaFruitTreePatchChecked = new ManualRequirement(); + lletyaFruitTreePatchHarvestable = new ManualRequirement(); lletyaFruitTreePatchIsStump = new ManualRequirement(); catherbyFruitTreePatchNotChecked = new ManualRequirement(); - catherbyFruitTreePatchChecked = new ManualRequirement(); + catherbyFruitTreePatchHarvestable = new ManualRequirement(); catherbyFruitTreePatchIsStump = new ManualRequirement(); farmingGuildFruitTreePatchNotChecked = new ManualRequirement(); - farmingGuildFruitTreePatchChecked = new ManualRequirement(); + farmingGuildFruitTreePatchHarvestable = new ManualRequirement(); farmingGuildFruitTreePatchIsStump = new ManualRequirement(); // Hardwood Tree Not Checked eastHardwoodTreePatchNotChecked = new ManualRequirement(); - eastHardwoodTreePatchChecked = new ManualRequirement(); + eastHardwoodTreePatchHarvestable = new ManualRequirement(); eastHardwoodTreePatchIsStump = new ManualRequirement(); westHardwoodTreePatchNotChecked = new ManualRequirement(); - westHardwoodTreePatchChecked = new ManualRequirement(); + westHardwoodTreePatchHarvestable = new ManualRequirement(); westHardwoodTreePatchIsStump = new ManualRequirement(); middleHardwoodTreePatchNotChecked = new ManualRequirement(); - middleHardwoodTreePatchChecked = new ManualRequirement(); + middleHardwoodTreePatchHarvestable = new ManualRequirement(); middleHardwoodTreePatchIsStump = new ManualRequirement(); - } @Override @@ -333,7 +363,8 @@ public void setupRequirements() spade = new ItemRequirement("Spade", ItemID.SPADE); rake = new ItemRequirement("Rake", ItemID.RAKE) .hideConditioned(new VarbitRequirement(Varbits.AUTOWEED, 2)); - coins = new ItemRequirement("Coins to quickly remove trees.", ItemID.COINS_995, -1); + coins = new ItemRequirement("Coins to quickly remove trees.", ItemID.COINS_995); + axe = new ItemRequirement("Any axe you can use", ItemCollections.AXES); treeSapling = FarmingUtils.createSeedRequirement( configManager, @@ -343,6 +374,7 @@ public void setupRequirements() ItemID.OAK_SAPLING ); treeSapling.setHighlightInInventory(true); + allTreeSaplings = treeSapling.copy(); fruitTreeSapling = FarmingUtils.createSeedRequirement( configManager, @@ -352,8 +384,9 @@ public void setupRequirements() ItemID.APPLE_SAPLING ); fruitTreeSapling.setHighlightInInventory(true); + allFruitSaplings = fruitTreeSapling.copy(); - hardwoodSapling = FarmingUtils.createSeedRequirement ( + hardwoodSapling = FarmingUtils.createSeedRequirement( configManager, QuestHelperConfig.QUEST_BACKGROUND_GROUP, HARDWOOD_TREE_SAPLING, @@ -366,6 +399,15 @@ public void setupRequirements() // Teleport Items farmingGuildTeleport = new ItemRequirement("Farming Guild Teleport", ItemCollections.SKILLS_NECKLACES); + crystalTeleport = new ItemRequirement("Crystal teleport", ItemCollections.TELEPORT_CRYSTAL); + catherbyTeleport = new ItemRequirement("Catherby teleport", ItemID.CATHERBY_TELEPORT); + catherbyTeleport.addAlternates(ItemID.CAMELOT_TELEPORT); + varrockTeleport = new ItemRequirement("Varrock teleport", ItemID.VARROCK_TELEPORT); + lumbridgeTeleport = new ItemRequirement("Lumbridge teleport", ItemID.LUMBRIDGE_TELEPORT); + faladorTeleport = new ItemRequirement("Falador teleport", ItemCollections.RING_OF_WEALTHS); + faladorTeleport.addAlternates(ItemID.FALADOR_TELEPORT); + fossilIslandTeleport = new ItemRequirement("Teleport to Fossil Island", ItemCollections.DIGSITE_PENDANTS); + // Graceful and Farming Outfit gracefulHood = new ItemRequirement( @@ -413,7 +455,6 @@ public void setupRequirements() "Farmer's outfit (equipped)", farmingHat, farmingTop, farmingLegs, farmingBoots).isNotConsumed() .showConditioned(new RuneliteRequirement(configManager, GRACEFUL_OR_FARMING, GracefulOrFarming.FARMING.name())); - } private void setupSteps() @@ -422,257 +463,374 @@ private void setupSteps() // Tree Patch Clear Steps - lumbridgeTreePatchClear = new NpcStep(this, NpcID.FARMER, new WorldPoint(3226, 3219, 0), - "Speak to the farmer to clear the patch."); + lumbridgeTreePatchClear = new NpcStep(this, NpcID.FARMER, new WorldPoint(3193, 3231, 0), + "Speak to the farmer to clear the patch.", coins.quantity(200)); lumbridgeTreePatchClear.addDialogStep("Yes."); - faladorTreePatchClear = new NpcStep(this, NpcID.FAYETH, "Speak to the farmer to clear the patch."); + faladorTreePatchClear = new NpcStep(this, NpcID.FAYETH, new WorldPoint(3004, 3373, 0), + "Speak to Fayeth to clear the patch.", coins.quantity(200)); faladorTreePatchClear.addDialogStep("Yes."); - taverleyTreePatchClear = new NpcStep(this, NpcID.ALAIN, "Speak to the farmer to clear the patch."); + taverleyTreePatchClear = new NpcStep(this, NpcID.ALAIN, new WorldPoint(2936, 3438, 0), + "Speak to Alain to clear the patch.", coins.quantity(200)); taverleyTreePatchClear.addDialogStep("Yes."); - varrockTreePatchClear = new NpcStep(this, NpcID.TREZNOR_11957, new WorldPoint(3226, 3219, 0), - "Speak to the farmer to clear the patch."); + varrockTreePatchClear = new NpcStep(this, NpcID.TREZNOR_11957, new WorldPoint(3229, 3459, 0), + "Speak to Treznor to clear the patch.", coins.quantity(200)); varrockTreePatchClear.addDialogStep("Yes."); - gnomeStrongholdTreePatchClear = new NpcStep(this, NpcID.PRISSY_SCILLA, new WorldPoint(3226, 3219, 0), - "Speak to the farmer to clear the patch."); + gnomeStrongholdTreePatchClear = new NpcStep(this, NpcID.PRISSY_SCILLA, new WorldPoint(2436, 3415, 0), + "Speak to Prissy Scilla to clear the patch.", coins.quantity(200)); gnomeStrongholdTreePatchClear.addDialogStep("Yes."); - farmingGuildTreePatchClear = new NpcStep(this, NpcID.ROSIE, new WorldPoint(3226, 3219, 0), - "Speak to the farmer to clear the patch."); + farmingGuildTreePatchClear = new NpcStep(this, NpcID.ROSIE, new WorldPoint(1232, 3736, 0), + "Speak to Rosie to clear the patch.", coins.quantity(200)); farmingGuildTreePatchClear.addDialogStep("Yes."); // Tree Patch Steps - lumbridgeTreePatch = new ObjectStep(this, NullObjectID.NULL_8391, new WorldPoint(3193, 3231, 0), + lumbridgeTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_8391, new WorldPoint(3193, 3231, 0), "Check the health of the tree planted in Lumbridge."); - faladorTreePatch = new ObjectStep(this, NullObjectID.NULL_8389, new WorldPoint(3004, 3373, 0), + lumbridgeTreePatchCheckHealth.addTeleport(lumbridgeTeleport); + lumbridgeTreePatchCheckHealth.addSpellHighlight(NormalSpells.LUMBRIDGE_TELEPORT); + lumbridgeTreePatchCheckHealth.addSpellHighlight(NormalSpells.LUMBRIDGE_HOME_TELEPORT); + faladorTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_8389, new WorldPoint(3004, 3373, 0), "Check the health of the tree planted in Falador."); - taverleyTreePatch = new ObjectStep(this, NullObjectID.NULL_8388, new WorldPoint(2936, 3438, 0), + faladorTreePatchCheckHealth.addTeleport(faladorTeleport); + faladorTreePatchCheckHealth.addSpellHighlight(NormalSpells.FALADOR_TELEPORT); + taverleyTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_8388, new WorldPoint(2936, 3438, 0), "Check the health of the tree planted in Taverley."); - varrockTreePatch = new ObjectStep(this, NullObjectID.NULL_8390, new WorldPoint(3229, 3459, 0), + varrockTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_8390, new WorldPoint(3229, 3459, 0), "Check the health of the tree planted in Varrock."); - gnomeStrongholdTreePatch = new ObjectStep(this, NullObjectID.NULL_19147, new WorldPoint(2436, 3415, 0), + varrockTreePatchCheckHealth.addTeleport(varrockTeleport); + varrockTreePatchCheckHealth.addSpellHighlight(NormalSpells.VARROCK_TELEPORT); + gnomeStrongholdTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_19147, new WorldPoint(2436, 3415, 0), "Check the health of the tree planted in the Tree Gnome Stronghold."); - - farmingGuildTreePatch = new ObjectStep(this, NullObjectID.NULL_33732, new WorldPoint(1232, 3736, 0), + farmingGuildTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_33732, new WorldPoint(1232, 3736, 0), "Check the health of the tree planted in the Farming Guild."); - farmingGuildTreePatch.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildTreePatch)); + farmingGuildTreePatchCheckHealth.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildTreePatch)); + farmingGuildTreePatchCheckHealth.addTeleport(farmingGuildTeleport); // Tree Plant Steps lumbridgeTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8391, new WorldPoint(3193, 3231, 0), "Plant your sapling in the Lumbridge patch.", treeSapling); - treeSapling.highlighted(); lumbridgeTreePatchPlant.addIcon(treeSapling.getId()); - lumbridgeTreePatch.addSubSteps(lumbridgeTreePatchPlant); + lumbridgeTreePatchCheckHealth.addSubSteps(lumbridgeTreePatchPlant); faladorTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8389, new WorldPoint(3004, 3373, 0), "Plant your sapling in the Falador patch.", treeSapling); faladorTreePatchPlant.addIcon(treeSapling.getId()); - faladorTreePatch.addSubSteps(faladorTreePatchPlant); + faladorTreePatchCheckHealth.addSubSteps(faladorTreePatchPlant); taverleyTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8388, new WorldPoint(2936, 3438, 0), "Plant your sapling in the Taverley patch.", treeSapling); taverleyTreePatchPlant.addIcon(treeSapling.getId()); - taverleyTreePatch.addSubSteps(taverleyTreePatchPlant); + taverleyTreePatchCheckHealth.addSubSteps(taverleyTreePatchPlant); varrockTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_8390, new WorldPoint(3229, 3459, 0), "Plant your sapling in the Varrock patch.", treeSapling); varrockTreePatchPlant.addIcon(treeSapling.getId()); - varrockTreePatch.addSubSteps(varrockTreePatchPlant); + varrockTreePatchCheckHealth.addSubSteps(varrockTreePatchPlant); gnomeStrongholdTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_19147, new WorldPoint(2436, 3415, 0), "Plant your sapling in the Gnome Stronghold patch.", treeSapling); gnomeStrongholdTreePatchPlant.addIcon(treeSapling.getId()); - gnomeStrongholdTreePatch.addSubSteps(gnomeStrongholdTreePatchPlant); + gnomeStrongholdTreePatchCheckHealth.addSubSteps(gnomeStrongholdTreePatchPlant); farmingGuildTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_33732, new WorldPoint(1232, 3736, 0), "Plant your sapling in the Farming Guild tree patch.", treeSapling); farmingGuildTreePatchPlant.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildTreePatch)); farmingGuildTreePatchPlant.addIcon(treeSapling.getId()); - farmingGuildTreePatch.addSubSteps(farmingGuildTreePatchPlant); + farmingGuildTreePatchCheckHealth.addSubSteps(farmingGuildTreePatchPlant); + + // Dig + lumbridgeTreePatchDig = new ObjectStep(this, NullObjectID.NULL_8391, new WorldPoint(3193, 3231, 0), + "Dig up the tree stump in Lumbridge.", spade); + faladorTreePatchDig = new ObjectStep(this, NullObjectID.NULL_8389, new WorldPoint(3004, 3373, 0), + "Dig up the tree stump in Falador.", spade); + taverleyTreePatchDig = new ObjectStep(this, NullObjectID.NULL_8388, new WorldPoint(2936, 3438, 0), + "Dig up the tree stump in Taverley.", spade); + varrockTreePatchDig = new ObjectStep(this, NullObjectID.NULL_8390, new WorldPoint(3229, 3459, 0), + "Dig up the tree stump in Varrock.", spade); + gnomeStrongholdTreePatchDig = new ObjectStep(this, NullObjectID.NULL_19147, new WorldPoint(2436, 3415, 0), + "Dig up the tree stump in the Tree Gnome Stronghold.", spade); + farmingGuildTreePatchDig = new ObjectStep(this, NullObjectID.NULL_33732, new WorldPoint(1232, 3736, 0), + "Dig up the tree stump in the Farming Guild tree patch.", spade); + + faladorTreePatchClear.addSubSteps(faladorTreePatchDig); + taverleyTreePatchClear.addSubSteps(taverleyTreePatchDig); + varrockTreePatchClear.addSubSteps(varrockTreePatchDig); + gnomeStrongholdTreePatchClear.addSubSteps(gnomeStrongholdTreePatchDig); + lumbridgeTreePatchClear.addSubSteps(lumbridgeTreePatchDig); + farmingGuildTreePatchClear.addSubSteps(farmingGuildTreePatchDig); // Fruit Tree Steps - gnomeStrongholdFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_7962, new WorldPoint(2476, 3446, 0), + gnomeStrongholdFruitTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_7962, new WorldPoint(2476, 3446, 0), "Check the health of the fruit tree planted in the Tree Gnome Stronghold."); - gnomeVillageFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_7963, new WorldPoint(2490, 3180, 0), + gnomeVillageFruitTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_7963, new WorldPoint(2490, 3180, 0), "Check the health of the fruit tree planted outside the Tree Gnome Village. Follow Elkoy to get out quickly."); - brimhavenFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_7964, new WorldPoint(2765, 3213, 0), + brimhavenFruitTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_7964, new WorldPoint(2765, 3213, 0), "Check the health of the fruit tree planted in Brimhaven."); - catherbyFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_7965, new WorldPoint(2681, 3434, 0), + catherbyFruitTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_7965, new WorldPoint(2681, 3434, 0), "Check the health of the fruit tree planted in Catherby"); + catherbyFruitTreePatchCheckHealth.addTeleport(catherbyTeleport); + catherbyFruitTreePatchCheckHealth.addSpellHighlight(NormalSpells.CAMELOT_TELEPORT); + catherbyFruitTreePatchCheckHealth.addSpellHighlight(LunarSpells.CATHERBY_TELEPORT); - lletyaFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_26579, new WorldPoint(2347, 3162, 0), + lletyaFruitTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_26579, new WorldPoint(2347, 3162, 0), "Check the health of the fruit tree planted in Lletya."); - lletyaFruitTreePatch.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToLletya)); + lletyaFruitTreePatchCheckHealth.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToLletya)); + lletyaFruitTreePatchCheckHealth.addTeleport(crystalTeleport); - farmingGuildFruitTreePatch = new ObjectStep(this, NullObjectID.NULL_34007, new WorldPoint(1243, 3760, 0), + farmingGuildFruitTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_34007, new WorldPoint(1243, 3760, 0), "Check the health of the fruit tree planted in the Farming Guild."); - farmingGuildFruitTreePatch.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildFruitTreePatch)); + farmingGuildFruitTreePatchCheckHealth.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildFruitTreePatch)); + farmingGuildFruitTreePatchCheckHealth.addTeleport(farmingGuildTeleport); // Fruit Tree Plant Steps gnomeStrongholdFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7962, new WorldPoint(2476, 3446, 0), "Plant your sapling in the Tree Gnome Stronghold patch.", fruitTreeSapling); gnomeStrongholdFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); - gnomeStrongholdTreePatch.addSubSteps(gnomeStrongholdTreePatchPlant); + gnomeStrongholdTreePatchCheckHealth.addSubSteps(gnomeStrongholdTreePatchPlant); gnomeVillageFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7963, new WorldPoint(2490, 3180, 0), "Plant your sapling in the Tree Gnome Village patch. Follow Elkoy to get out quickly.", fruitTreeSapling); gnomeVillageFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); - gnomeVillageFruitTreePatch.addSubSteps(gnomeVillageFruitTreePatchPlant); + gnomeVillageFruitTreePatchCheckHealth.addSubSteps(gnomeVillageFruitTreePatchPlant); brimhavenFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7964, new WorldPoint(2765, 3213, 0), "Plant your sapling in the Brimhaven patch.", fruitTreeSapling); brimhavenFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); - brimhavenFruitTreePatch.addSubSteps(brimhavenFruitTreePatchPlant); + brimhavenFruitTreePatchCheckHealth.addSubSteps(brimhavenFruitTreePatchPlant); + // Plant catherbyFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7965, new WorldPoint(2681, 3434, 0), "Plant your sapling in the Catherby patch.", fruitTreeSapling); catherbyFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); - catherbyFruitTreePatch.addSubSteps(catherbyFruitTreePatchPlant); + catherbyFruitTreePatchCheckHealth.addSubSteps(catherbyFruitTreePatchPlant); lletyaFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_26579, new WorldPoint(2347, 3162, 0), "Plant your sapling in the Lletya patch.", fruitTreeSapling); lletyaFruitTreePatchPlant.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToLletya)); lletyaFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); - lletyaFruitTreePatch.addSubSteps(lletyaFruitTreePatchPlant); + lletyaFruitTreePatchCheckHealth.addSubSteps(lletyaFruitTreePatchPlant); farmingGuildFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_34007, new WorldPoint(1243, 3760, 0), "Plant your sapling in the Farming Guild patch.", fruitTreeSapling); farmingGuildFruitTreePatchPlant.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildFruitTreePatch)); farmingGuildFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); - farmingGuildFruitTreePatch.addSubSteps(farmingGuildFruitTreePatchPlant); + farmingGuildFruitTreePatchCheckHealth.addSubSteps(farmingGuildFruitTreePatchPlant); + + // Clear + gnomeStrongholdFruitTreePatchClear = new NpcStep(this, NpcID.BOLONGO, new WorldPoint(2476, 3446, 0), + "Pay Bolongo 200 coins to clear the fruit tree, or pick all the fruit and cut it down.", coins.quantity(200)); + gnomeStrongholdFruitTreePatchClear.addDialogStep("Yes."); + gnomeVillageFruitTreePatchClear = new NpcStep(this, NpcID.GILETH, new WorldPoint(2490, 3180, 0), + "Pay Gileth 200 coins to clear the fruit tree, or pick all the fruit and cut it down.", coins.quantity(200)); + gnomeVillageFruitTreePatchClear.addDialogStep("Yes."); + brimhavenFruitTreePatchClear = new NpcStep(this, NpcID.GARTH, new WorldPoint(2765, 3213, 0), + "Pay Garth 200 coins to clear the fruit tree, or pick all the fruit and cut it down.", coins.quantity(200)); + brimhavenFruitTreePatchClear.addDialogStep("Yes."); + catherbyFruitTreePatchClear = new NpcStep(this, NpcID.ELLENA, new WorldPoint(2681, 3434, 0), + "Pay Ellena 200 coins to clear the fruit tree, or pick all the fruit and cut it down.", coins.quantity(200)); + catherbyFruitTreePatchClear.addDialogStep("Yes."); + lletyaFruitTreePatchClear = new NpcStep(this, NpcID.LILIWEN, new WorldPoint(2347, 3162, 0), + "Pay Liliwen 200 coins to clear the fruit tree, or pick all the fruit and cut it down.", coins.quantity(200)); + lletyaFruitTreePatchClear.addDialogStep("Yes."); + farmingGuildFruitTreePatchClear = new NpcStep(this, NpcID.NIKKIE, new WorldPoint(1243, 3760, 0), + "Pay Nikkie 200 coins to clear the fruit tree, or pick all the fruit and cut it down.", coins.quantity(200)); + farmingGuildFruitTreePatchClear.addDialogStep("Yes."); + + // Dig Fruit Tree Steps + gnomeStrongholdFruitTreePatchDig = new ObjectStep(this, NullObjectID.NULL_7962, new WorldPoint(2476, 3446, 0), + "Dig up the fruit tree's stump in the Tree Gnome Stronghold."); + gnomeVillageFruitTreePatchDig = new ObjectStep(this, NullObjectID.NULL_7963, new WorldPoint(2490, 3180, 0), + "Dig up the fruit tree's stump outside the Tree Gnome Village."); + brimhavenFruitTreePatchDig = new ObjectStep(this, NullObjectID.NULL_7964, new WorldPoint(2765, 3213, 0), + "Dig up the fruit tree's stump in Brimhaven."); + catherbyFruitTreePatchDig = new ObjectStep(this, NullObjectID.NULL_7965, new WorldPoint(2681, 3434, 0), + "Check the health of the fruit tree planted in Catherby"); + lletyaFruitTreePatchDig = new ObjectStep(this, NullObjectID.NULL_26579, new WorldPoint(2347, 3162, 0), + "Dig up the fruit tree's stump in Lletya."); + farmingGuildFruitTreePatchDig = new ObjectStep(this, NullObjectID.NULL_34007, new WorldPoint(1243, 3760, 0), + "Dig up the fruit tree's stump in the Farming Guild."); + + gnomeStrongholdFruitTreePatchClear.addSubSteps(gnomeStrongholdFruitTreePatchDig); + gnomeVillageFruitTreePatchClear.addSubSteps(gnomeVillageFruitTreePatchDig); + brimhavenFruitTreePatchClear.addSubSteps(brimhavenFruitTreePatchDig); + catherbyFruitTreePatchClear.addSubSteps(catherbyFruitTreePatchDig); + lletyaFruitTreePatchClear.addSubSteps(lletyaFruitTreePatchDig); + farmingGuildFruitTreePatchClear.addSubSteps(farmingGuildFruitTreePatchDig); // Hardwood Tree Steps - westHardwoodTreePatch = new ObjectStep(this, NullObjectID.NULL_30481, new WorldPoint(3702, 3837, 0), + westHardwoodTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_30481, new WorldPoint(3702, 3837, 0), "Check the health of the western hardwood tree on Fossil Island."); - middleHardwoodTreePatch = new ObjectStep(this, NullObjectID.NULL_30480, new WorldPoint(3708, 3833, 0), + middleHardwoodTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_30480, new WorldPoint(3708, 3833, 0), "Check the health of the centre hardwood tree on Fossil Island."); - eastHardwoodTreePatch = new ObjectStep(this, NullObjectID.NULL_30482, new WorldPoint(3715, 3835, 0), + eastHardwoodTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_30482, new WorldPoint(3715, 3835, 0), "Check the health of the eastern hardwood tree on Fossil Island."); // Hardwood Tree Plant Steps westHardwoodTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_30481, new WorldPoint(3702, 3837, 0), "Plant your sapling on the western hardwood tree on Fossil Island.", hardwoodSapling); westHardwoodTreePatchPlant.addIcon(hardwoodSapling.getId()); - westHardwoodTreePatch.addSubSteps(westHardwoodTreePatchPlant); + westHardwoodTreePatchCheckHealth.addSubSteps(westHardwoodTreePatchPlant); middleHardwoodTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_30480, new WorldPoint(3708, 3833, 0), "Plant your sapling on the centre hardwood tree on Fossil Island.", hardwoodSapling); middleHardwoodTreePatchPlant.addIcon(hardwoodSapling.getId()); - middleHardwoodTreePatch.addSubSteps(middleHardwoodTreePatchPlant); + middleHardwoodTreePatchCheckHealth.addSubSteps(middleHardwoodTreePatchPlant); eastHardwoodTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_30482, new WorldPoint(3715, 3835, 0), "Plant your sapling on the eastern hardwood tree on Fossil Island.", hardwoodSapling); eastHardwoodTreePatchPlant.addIcon(hardwoodSapling.getId()); - eastHardwoodTreePatch.addSubSteps(eastHardwoodTreePatchPlant); + eastHardwoodTreePatchCheckHealth.addSubSteps(eastHardwoodTreePatchPlant); + + westHardwoodTreePatchClear = new NpcStep(this, NpcID.SQUIRREL_7756, new WorldPoint(3702, 3837, 0), + "Pay the brown squirrel to remove the west tree.", coins.quantity(200)); + middleHardwoodTreePatchClear = new NpcStep(this, NpcID.SQUIRREL_7755, new WorldPoint(3702, 3837, 0), + "Pay the black squirrel to remove the middle tree.", coins.quantity(200)); + eastHardwoodTreePatchClear = new NpcStep(this, NpcID.SQUIRREL_7754, new WorldPoint(3702, 3837, 0), + "Pay the grey squirrel to remove the east tree.", coins.quantity(200)); + + westHardwoodTreePatchDig = new ObjectStep(this, NullObjectID.NULL_30481, new WorldPoint(3702, 3837, 0), + "Dig up the western hardwood tree's stump on Fossil Island."); + middleHardwoodTreePatchDig = new ObjectStep(this, NullObjectID.NULL_30480, new WorldPoint(3708, 3833, 0), + "Dig up the centre hardwood tree's stump on Fossil Island."); + eastHardwoodTreePatchDig = new ObjectStep(this, NullObjectID.NULL_30482, new WorldPoint(3715, 3835, 0), + "Dig up the eastern hardwood tree's stump on Fossil Island."); + westHardwoodTreePatchClear.addSubSteps(westHardwoodTreePatchDig); + middleHardwoodTreePatchClear.addSubSteps(middleHardwoodTreePatchDig); + eastHardwoodTreePatchClear.addSubSteps(eastHardwoodTreePatchDig); } @Subscribe public void onGameTick(GameTick event) { - - // Tree Patch Checks - // Since these all use the same values, it is probably redundant as it will always return the same thing.. - // Should instead use a single Checked/NotChecked/Stump conditional for 4771 and another for 7905? - // Need to see radius that causes varb to update, as sometimes update doesn't trigger.... - checkTreePatch(lumbridgeTreePatchNotChecked, lumbridgeTreePatchChecked, lumbridgeTreePatchIsStump, Varbits.FARMING_4771); - checkTreePatch(faladorTreePatchNotChecked, faladorTreePatchChecked, faladorTreePatchIsStump, Varbits.FARMING_4771); - checkTreePatch(taverleyTreePatchNotChecked, taverleyTreePatchChecked, taverleyTreePatchIsStump, Varbits.FARMING_4771); - checkTreePatch(varrockTreePatchNotChecked, varrockTreePatchChecked, varrockTreePatchIsStump, Varbits.FARMING_4771); - checkTreePatch(gnomeStrongholdTreePatchNotChecked, gnomeStrongholdTreePatchChecked, gnomeStrongholdTreePatchIsStump, Varbits.FARMING_4771); - checkTreePatch(farmingGuildTreePatchNotChecked, farmingGuildTreePatchChecked, farmingGuildTreePatchIsStump, Varbits.FARMING_7905); - + int numberOfTreeSaplings = 0; for (FarmingPatch treePatch : farmingWorld.getTabs().get(Tab.TREE)) { CropState treeState = farmingHandler.predictPatch(treePatch); - boolean isTreePatchHarvestable = treeState == CropState.HARVESTABLE; boolean isTreePatchPlantable = treeState == CropState.EMPTY || treeState == CropState.DEAD; + boolean isTreeUnchecked = treeState == CropState.UNCHECKED; // 'Check health' + boolean isTreePatchHarvestable = treeState == CropState.HARVESTABLE; // 'Chop' + boolean isTreeStump = treeState == CropState.STUMP; // 'Clear' + + if (treeState != CropState.GROWING) + { + numberOfTreeSaplings++; + } + switch (treePatch.getRegion().getName()) { case "Lumbridge": - lumbridgeTreePatchReady.setShouldPass(isTreePatchHarvestable); + lumbridgeTreePatchHarvestable.setShouldPass(isTreePatchHarvestable); lumbridgeTreePatchEmpty.setShouldPass(isTreePatchPlantable); + lumbridgeTreePatchNotChecked.setShouldPass(isTreeUnchecked); + lumbridgeTreePatchIsStump.setShouldPass(isTreeStump); break; case "Varrock": - varrockTreePatchReady.setShouldPass(isTreePatchHarvestable); + varrockTreePatchHarvestable.setShouldPass(isTreePatchHarvestable); varrockTreePatchEmpty.setShouldPass(isTreePatchPlantable); + varrockTreePatchNotChecked.setShouldPass(isTreeUnchecked); + varrockTreePatchIsStump.setShouldPass(isTreeStump); break; case "Falador": - faladorTreePatchReady.setShouldPass(isTreePatchHarvestable); + faladorTreePatchHarvestable.setShouldPass(isTreePatchHarvestable); faladorTreePatchEmpty.setShouldPass(isTreePatchPlantable); + faladorTreePatchNotChecked.setShouldPass(isTreeUnchecked); + faladorTreePatchIsStump.setShouldPass(isTreeStump); break; case "Gnome Stronghold": - gnomeStrongholdTreePatchReady.setShouldPass(isTreePatchHarvestable); + gnomeStrongholdTreePatchHarvestable.setShouldPass(isTreePatchHarvestable); gnomeStrongholdTreePatchEmpty.setShouldPass(isTreePatchPlantable); + gnomeStrongholdTreePatchNotChecked.setShouldPass(isTreeUnchecked); + gnomeStrongholdTreePatchIsStump.setShouldPass(isTreeStump); break; case "Taverley": - taverleyTreePatchReady.setShouldPass(isTreePatchHarvestable); + taverleyTreePatchHarvestable.setShouldPass(isTreePatchHarvestable); taverleyTreePatchEmpty.setShouldPass(isTreePatchPlantable); + taverleyTreePatchNotChecked.setShouldPass(isTreeUnchecked); + taverleyTreePatchIsStump.setShouldPass(isTreeStump); break; case "Farming Guild": - farmingGuildTreePatchReady.setShouldPass(isTreePatchHarvestable); + farmingGuildTreePatchHarvestable.setShouldPass(isTreePatchHarvestable); farmingGuildTreePatchEmpty.setShouldPass(isTreePatchPlantable); + farmingGuildTreePatchNotChecked.setShouldPass(isTreeUnchecked); + farmingGuildTreePatchIsStump.setShouldPass(isTreeStump); + if (!accessToFarmingGuildTreePatch.check(client)) + { + numberOfTreeSaplings--; + } break; } } + allTreeSaplings.quantity(numberOfTreeSaplings); + int numberOfFruitTreeSaplings = 0; for (FarmingPatch fruitTreePatch : farmingWorld.getTabs().get(Tab.FRUIT_TREE)) { CropState fruitTreeState = farmingHandler.predictPatch(fruitTreePatch); - boolean isFruitTreePatchHarvestable = fruitTreeState == CropState.HARVESTABLE; boolean isFruitTreePatchPlantable = fruitTreeState == CropState.EMPTY || fruitTreeState == CropState.DEAD; + boolean isFruitTreeUnchecked = fruitTreeState == CropState.UNCHECKED; // 'Check health' + boolean isFruitTreePatchHarvestable = fruitTreeState == CropState.HARVESTABLE; // 'Chop' + boolean isFruitTreeStump = fruitTreeState == CropState.STUMP; // 'Clear' + + if (fruitTreeState != CropState.GROWING) + { + numberOfFruitTreeSaplings++; + } switch (fruitTreePatch.getRegion().getName()) { case "Catherby": - catherbyFruitTreePatchReady.setShouldPass(isFruitTreePatchHarvestable); + catherbyFruitTreePatchHarvestable.setShouldPass(isFruitTreePatchHarvestable); catherbyFruitTreePatchEmpty.setShouldPass(isFruitTreePatchPlantable); + catherbyFruitTreePatchNotChecked.setShouldPass(isFruitTreeUnchecked); + catherbyFruitTreePatchIsStump.setShouldPass(isFruitTreeStump); break; case "Brimhaven": - brimhavenFruitTreePatchReady.setShouldPass(isFruitTreePatchHarvestable); + brimhavenFruitTreePatchHarvestable.setShouldPass(isFruitTreePatchHarvestable); brimhavenFruitTreePatchEmpty.setShouldPass(isFruitTreePatchPlantable); + brimhavenFruitTreePatchNotChecked.setShouldPass(isFruitTreeUnchecked); + brimhavenFruitTreePatchIsStump.setShouldPass(isFruitTreeStump); break; case "Tree Gnome Village": - gnomeVillageFruitTreePatchReady.setShouldPass(isFruitTreePatchHarvestable); + gnomeVillageFruitTreePatchHarvestable.setShouldPass(isFruitTreePatchHarvestable); gnomeVillageFruitTreePatchEmpty.setShouldPass(isFruitTreePatchPlantable); + gnomeVillageFruitTreePatchNotChecked.setShouldPass(isFruitTreeUnchecked); + gnomeVillageFruitTreePatchIsStump.setShouldPass(isFruitTreeStump); break; case "Gnome Stronghold": - gnomeStrongholdFruitTreePatchReady.setShouldPass(isFruitTreePatchHarvestable); + gnomeStrongholdFruitTreePatchHarvestable.setShouldPass(isFruitTreePatchHarvestable); gnomeStrongholdFruitTreePatchEmpty.setShouldPass(isFruitTreePatchPlantable); + gnomeStrongholdFruitTreePatchNotChecked.setShouldPass(isFruitTreeUnchecked); + gnomeStrongholdFruitTreePatchIsStump.setShouldPass(isFruitTreeStump); break; case "Lletya": - lletyaFruitTreePatchReady.setShouldPass(isFruitTreePatchHarvestable); + lletyaFruitTreePatchHarvestable.setShouldPass(isFruitTreePatchHarvestable); lletyaFruitTreePatchEmpty.setShouldPass(isFruitTreePatchPlantable); + lletyaFruitTreePatchNotChecked.setShouldPass(isFruitTreeUnchecked); + lletyaFruitTreePatchIsStump.setShouldPass(isFruitTreeStump); + if (!accessToLletya.check(client)) + { + numberOfFruitTreeSaplings--; + } break; case "Farming Guild": - farmingGuildFruitTreePatchReady.setShouldPass(isFruitTreePatchHarvestable); + farmingGuildFruitTreePatchHarvestable.setShouldPass(isFruitTreePatchHarvestable); farmingGuildFruitTreePatchEmpty.setShouldPass(isFruitTreePatchPlantable); + farmingGuildFruitTreePatchNotChecked.setShouldPass(isFruitTreeUnchecked); + farmingGuildFruitTreePatchIsStump.setShouldPass(isFruitTreeStump); + if (!accessToFarmingGuildFruitTreePatch.check(client)) + { + numberOfFruitTreeSaplings--; + } break; } } - } - - private void checkTreePatch(ManualRequirement treePatchUnchecked, ManualRequirement treePatchChecked, - ManualRequirement treePatchIsStump, int farmingVarbit) - { - if (FarmingUtils.getPatchState(client, TREE_UNCHECKED, farmingVarbit)) - { - treePatchUnchecked.setShouldPass(true); - } - - if (FarmingUtils.getPatchState(client, TREE_CHECKED, farmingVarbit)) - { - treePatchChecked.setShouldPass(true); - } - - if (FarmingUtils.getPatchState(client, TREE_STUMP, farmingVarbit)) - { - treePatchIsStump.setShouldPass(true); - } + allFruitSaplings.quantity(numberOfFruitTreeSaplings); } @Subscribe @@ -709,25 +867,54 @@ public List getConfigs() @Override public List getItemRequirements() { - return Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling); + return Arrays.asList(spade, rake, coins, allTreeSaplings, allFruitSaplings, hardwoodSapling); } @Override public List getItemRecommended() { - return Arrays.asList(gracefulOutfit, farmersOutfit); + return Arrays.asList(gracefulOutfit, farmersOutfit, farmingGuildTeleport, lumbridgeTeleport, faladorTeleport, varrockTeleport, catherbyTeleport, crystalTeleport, fossilIslandTeleport); } @Override public List getPanels() { List allSteps = new ArrayList<>(); - allSteps.add(new PanelDetails("Farm run", Arrays.asList(farmingGuildTreePatch, farmingGuildFruitTreePatch, - lumbridgeTreePatch, faladorTreePatch, taverleyTreePatch, varrockTreePatch, gnomeStrongholdFruitTreePatch, - gnomeStrongholdTreePatch, gnomeVillageFruitTreePatch, brimhavenFruitTreePatch, catherbyFruitTreePatch, - lletyaFruitTreePatch, eastHardwoodTreePatch, middleHardwoodTreePatch, westHardwoodTreePatch), + allSteps.add(new PanelDetails("Farming Guild", Arrays.asList(farmingGuildTreePatchCheckHealth, farmingGuildTreePatchClear, farmingGuildFruitTreePatchCheckHealth, farmingGuildFruitTreePatchClear), + Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), + Arrays.asList(gracefulOutfit, farmersOutfit, farmingGuildTeleport))); + allSteps.add(new PanelDetails("Lumbridge", Arrays.asList(lumbridgeTreePatchCheckHealth, lumbridgeTreePatchClear), + Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), + Arrays.asList(gracefulOutfit, farmersOutfit, lumbridgeTeleport))); + allSteps.add(new PanelDetails("Falador", Arrays.asList(faladorTreePatchCheckHealth, faladorTreePatchClear), + Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), + Arrays.asList(gracefulOutfit, farmersOutfit, faladorTeleport))); + allSteps.add(new PanelDetails("Taverley", Arrays.asList(taverleyTreePatchCheckHealth, taverleyTreePatchClear), + Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), + Arrays.asList(gracefulOutfit, farmersOutfit))); + allSteps.add(new PanelDetails("Varrock", Arrays.asList(varrockTreePatchCheckHealth, varrockTreePatchClear), + Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), + Arrays.asList(gracefulOutfit, farmersOutfit, varrockTeleport))); + allSteps.add(new PanelDetails("Gnome Stronghold", Arrays.asList(gnomeVillageFruitTreePatchCheckHealth, gnomeVillageFruitTreePatchClear, gnomeStrongholdTreePatchCheckHealth, gnomeStrongholdTreePatchClear), + Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), + Arrays.asList(gracefulOutfit, farmersOutfit))); + allSteps.add(new PanelDetails("Tree Gnome Village", Arrays.asList(gnomeVillageFruitTreePatchCheckHealth, gnomeVillageFruitTreePatchClear), + Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), + Arrays.asList(gracefulOutfit, farmersOutfit))); + allSteps.add(new PanelDetails("Catherby", Arrays.asList(catherbyFruitTreePatchCheckHealth, catherbyFruitTreePatchClear), + Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), + Arrays.asList(gracefulOutfit, farmersOutfit, catherbyTeleport))); + allSteps.add(new PanelDetails("Brimhaven", Arrays.asList(brimhavenFruitTreePatchCheckHealth, brimhavenFruitTreePatchClear), Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), Arrays.asList(gracefulOutfit, farmersOutfit))); + allSteps.add(new PanelDetails("Llyeta", Arrays.asList(lletyaFruitTreePatchCheckHealth, lletyaFruitTreePatchClear), + Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), + Arrays.asList(gracefulOutfit, farmersOutfit))); + allSteps.add(new PanelDetails("Fossil Island", Arrays.asList(eastHardwoodTreePatchCheckHealth, eastHardwoodTreePatchClear, + middleHardwoodTreePatchCheckHealth, middleHardwoodTreePatchClear, + westHardwoodTreePatchCheckHealth, westHardwoodTreePatchClear), + Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), + Arrays.asList(gracefulOutfit, farmersOutfit, fossilIslandTeleport))); return allSteps; } From 9b7a721b476b1b7c09a41b63f8c55be02f597652 Mon Sep 17 00:00:00 2001 From: Zoinkwiz Date: Thu, 6 Jun 2024 16:05:10 +0100 Subject: [PATCH 15/20] Cut down on amount of manual setup in TreeRun --- .../banktab/QuestHelperBankTagService.java | 23 +- .../mischelpers/farmruns/FarmingUtils.java | 191 +++++- .../mischelpers/farmruns/PatchStates.java | 45 ++ .../helpers/mischelpers/farmruns/TreeRun.java | 606 ++++++------------ 4 files changed, 438 insertions(+), 427 deletions(-) create mode 100644 src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchStates.java diff --git a/src/main/java/com/questhelper/bank/banktab/QuestHelperBankTagService.java b/src/main/java/com/questhelper/bank/banktab/QuestHelperBankTagService.java index d6d5fb47d0..de7f07a1bc 100644 --- a/src/main/java/com/questhelper/bank/banktab/QuestHelperBankTagService.java +++ b/src/main/java/com/questhelper/bank/banktab/QuestHelperBankTagService.java @@ -49,6 +49,8 @@ public class QuestHelperBankTagService @Inject private QuestBank questBank; + private final String RECOMMENDED_TAB_NAME = "Recommended items"; + public ArrayList itemsToTag() { ArrayList sortedItems = getPluginBankTagItemsForSections(true); @@ -95,8 +97,8 @@ public ArrayList getPluginBankTagItemsForSections(boolean onlyGetM if (recommendedItems != null && !recommendedItems.isEmpty()) { - BankTabItems pluginItems = new BankTabItems("Recommended items"); - // Here we specify getItems so as to avoid a double 'Recommended' title + BankTabItems pluginItems = new BankTabItems(RECOMMENDED_TAB_NAME); + // Here we specify getItems to avoid a double 'Recommended' title recommendedItems.forEach(item -> getItemsFromRequirement(pluginItems.getItems(), item, item)); newList.add(pluginItems); } @@ -137,7 +139,22 @@ public ArrayList getPluginBankTagItemsForSections(boolean onlyGetM items.forEach(item -> getItemsFromRequirement(pluginItems.getItems(), item, item)); recommendedItemsForSection.forEach(item -> getItemsFromRequirement(pluginItems.getRecommendedItems(), item, item)); // We don't add the recommended items as they're already used - newList.add(pluginItems); + if (items.size() > 0) + { + newList.add(pluginItems); + } + } + + // If none of the sections have anything in it, create a generic require items section + if (newList.size() == 0 || (newList.size() == 1 && newList.get(0).getName().equals(RECOMMENDED_TAB_NAME))) + { + BankTabItems allRequiredItems = new BankTabItems("Required items"); + List allRequired = plugin.getSelectedQuest().getItemRequirements(); + if (allRequired != null && allRequired.size() > 0) + { + allRequired.forEach(item -> getItemsFromRequirement(allRequiredItems.getItems(), item, item)); + } + newList.add(allRequiredItems); } return newList; diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java index 7cc6415023..3575453eee 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java @@ -1,10 +1,13 @@ package com.questhelper.helpers.mischelpers.farmruns; +import com.questhelper.QuestHelperConfig; import com.questhelper.requirements.item.ItemRequirement; +import java.util.ArrayList; +import java.util.List; import net.runelite.api.Client; import net.runelite.api.ItemID; -import net.runelite.api.Varbits; import net.runelite.client.config.ConfigManager; +import net.runelite.client.game.ItemManager; import net.runelite.client.util.Text; public class FarmingUtils @@ -24,7 +27,7 @@ public class FarmingUtils */ public static ItemRequirement createSeedRequirement(ConfigManager configManager, String configGroupName, - String seedConfigName, Enum defaultValue, int defaultItemId) + String seedConfigName, Enum defaultValue, int defaultItemId) { ItemRequirement seedRequirement = new ItemRequirement(Text.titleCase(defaultValue), defaultItemId); @@ -55,7 +58,7 @@ public static ItemRequirement createSeedRequirement(ConfigManager configManager, } } else - { + { configManager.setConfiguration(configGroupName, seedConfigName, defaultValue.name()); } @@ -95,43 +98,186 @@ public static boolean getPatchState(Client client, int[] patchStates, int varbit return false; } - public enum TreeSapling + public static String getEnumFromConfig(ConfigManager configManager, ConfigEnum configEnum) + { + try + { + return configManager.getRSProfileConfiguration(QuestHelperConfig.QUEST_BACKGROUND_GROUP, configEnum.getConfigKey()); + } + catch (Exception err) + { + configManager.setRSProfileConfiguration(QuestHelperConfig.QUEST_BACKGROUND_GROUP, configEnum.getDefault().getConfigKey(), configEnum.getDefault()); + return null; + } + } + + public interface ConfigEnum + { + String getConfigKey(); + + ConfigEnum getDefault(); + } + + public interface PlantableItem extends ConfigEnum + { + int getPlantableItemId(); + + int getProtectionItemId(); + + int getProtectionItemQuantity(); + + default ItemRequirement getPlantableItemRequirement(ItemManager itemManager) + { + return new ItemRequirement(itemManager.getItemComposition(getPlantableItemId()).getName(), getPlantableItemId()); + } + + default ItemRequirement getProtectionItemRequirement(ItemManager itemManager) + { + return new ItemRequirement(itemManager.getItemComposition(getProtectionItemId()).getName(), getProtectionItemId(), getProtectionItemQuantity()); + } + } + + public enum TreeSapling implements PlantableItem { - OAK(ItemID.OAK_SAPLING), WILLOW(ItemID.WILLOW_SAPLING), MAPLE(ItemID.MAPLE_SAPLING), YEW(ItemID.YEW_SAPLING), - MAGIC(ItemID.MAGIC_SAPLING); + OAK(ItemID.OAK_SAPLING, ItemID.TOMATOES5, 1), WILLOW(ItemID.WILLOW_SAPLING, ItemID.APPLES5, 1), + MAPLE(ItemID.MAPLE_SAPLING, ItemID.ORANGES5, 1), YEW(ItemID.YEW_SAPLING, ItemID.CACTUS_SPINE, 10), + MAGIC(ItemID.MAGIC_SAPLING, ItemID.COCONUT, 25); final int treeSaplingID; + final int protectionItemId; + final int protectionItemQuantity; - TreeSapling(int treeSaplingID) + TreeSapling(int treeSaplingID, int protectionItemId, int protectionItemQuantity) { this.treeSaplingID = treeSaplingID; + this.protectionItemId = protectionItemId; + this.protectionItemQuantity = protectionItemQuantity; + } + + @Override + public String getConfigKey() + { + return "treeSaplings"; + } + + @Override + public int getPlantableItemId() + { + return treeSaplingID; + } + + @Override + public int getProtectionItemId() + { + return protectionItemId; + } + + @Override + public int getProtectionItemQuantity() + { + return protectionItemQuantity; + } + + @Override + public ConfigEnum getDefault() + { + return TreeSapling.OAK; } } - public enum FruitTreeSapling + public enum FruitTreeSapling implements PlantableItem { - APPLE(ItemID.APPLE_SAPLING), BANANA(ItemID.BANANA_SAPLING), ORANGE(ItemID.ORANGE_SAPLING), - CURRY(ItemID.CURRY_SAPLING), PINEAPPLE(ItemID.PINEAPPLE_SAPLING), PAPAYA(ItemID.PAPAYA_SAPLING), - PALM(ItemID.PALM_SAPLING), DRAGONFRUIT(ItemID.DRAGONFRUIT_SAPLING); + APPLE(ItemID.APPLE_SAPLING, ItemID.SWEETCORN, 9), BANANA(ItemID.BANANA_SAPLING, ItemID.APPLES5, 4), + ORANGE(ItemID.ORANGE_SAPLING, ItemID.STRAWBERRIES5, 3), CURRY(ItemID.CURRY_SAPLING, ItemID.BANANAS5, 5), + PINEAPPLE(ItemID.PINEAPPLE_SAPLING, ItemID.WATERMELON, 10), PAPAYA(ItemID.PAPAYA_SAPLING, ItemID.PINEAPPLE, 10), + PALM(ItemID.PALM_SAPLING, ItemID.PAPAYA_FRUIT, 15), DRAGONFRUIT(ItemID.DRAGONFRUIT_SAPLING, ItemID.COCONUT, 15); final int fruitTreeSaplingId; + final int protectionItemId; + final int protectionItemQuantity; - FruitTreeSapling(int fruitTreeSaplingId) + FruitTreeSapling(int fruitTreeSaplingId, int protectionItemId, int protectionItemQuantity) { this.fruitTreeSaplingId = fruitTreeSaplingId; + this.protectionItemId = protectionItemId; + this.protectionItemQuantity = protectionItemQuantity; + } + + @Override + public String getConfigKey() + { + return "fruitTreeSaplings"; + } + + @Override + public int getPlantableItemId() + { + return fruitTreeSaplingId; + } + + @Override + public int getProtectionItemId() + { + return protectionItemId; + } + + @Override + public int getProtectionItemQuantity() + { + return protectionItemQuantity; + } + + @Override + public ConfigEnum getDefault() + { + return FruitTreeSapling.APPLE; } } - public enum HardwoodTreeSapling + public enum HardwoodTreeSapling implements PlantableItem { - TEAK(ItemID.TEAK_SAPLING), - MAHOGANY(ItemID.MAHOGANY_SAPLING); + TEAK(ItemID.TEAK_SAPLING, ItemID.LIMPWURT_ROOT, 15), + MAHOGANY(ItemID.MAHOGANY_SAPLING, ItemID.YANILLIAN_HOPS, 25); final int hardwoodTreeSaplingId; + final int protectionItemId; + final int protectionItemQuantity; - HardwoodTreeSapling(int hardwoodTreeSaplingId) + HardwoodTreeSapling(int hardwoodTreeSaplingId, int protectionItemId, int protectionItemQuantity) { this.hardwoodTreeSaplingId = hardwoodTreeSaplingId; + this.protectionItemId = protectionItemId; + this.protectionItemQuantity = protectionItemQuantity; + } + + @Override + public String getConfigKey() + { + return "hardwoodTreeSaplings"; + } + + @Override + public int getPlantableItemId() + { + return hardwoodTreeSaplingId; + } + + @Override + public int getProtectionItemId() + { + return protectionItemId; + } + + @Override + public int getProtectionItemQuantity() + { + return protectionItemQuantity; + } + + @Override + public ConfigEnum getDefault() + { + return HardwoodTreeSapling.TEAK; } } @@ -141,5 +287,18 @@ public enum GracefulOrFarming GRACEFUL(), FARMING(); } + + public enum PayOrCut + { + PAY(), + DIG(); + } + + public enum PayOrCompost + { + PAY(), + COMPOST(), + NEITHER(); + } } diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchStates.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchStates.java new file mode 100644 index 0000000000..5d700ce9e5 --- /dev/null +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchStates.java @@ -0,0 +1,45 @@ +package com.questhelper.helpers.mischelpers.farmruns; + +import com.questhelper.requirements.ManualRequirement; +import com.questhelper.requirements.Requirement; +import lombok.Getter; +import net.runelite.api.Client; + +@Getter +public class PatchStates +{ + private final String regionName; + private final String patchName; + private final ManualRequirement isHarvestable = new ManualRequirement(); + private final ManualRequirement isEmpty = new ManualRequirement(); + private final ManualRequirement isUnchecked = new ManualRequirement(); + private final ManualRequirement isStump = new ManualRequirement(); + private final Requirement requirement; + + public PatchStates(String regionName) + { + this.regionName = regionName; + this.patchName = null; + this.requirement = null; + } + + public PatchStates(String regionName, String patchName) + { + this.regionName = regionName; + this.patchName = patchName; + this.requirement = null; + } + + public PatchStates(String regionName, Requirement requirement) + { + this.regionName = regionName; + this.patchName = null; + this.requirement = requirement; + } + + public boolean canAccess(Client client) + { + if (requirement == null) return true; + return requirement.check(client); + } +} diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java index 4450fee0dc..b0b2df84b3 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java @@ -7,11 +7,12 @@ import com.questhelper.helpers.mischelpers.farmruns.FarmingUtils.GracefulOrFarming; import com.questhelper.helpers.mischelpers.farmruns.FarmingUtils.HardwoodTreeSapling; import com.questhelper.helpers.mischelpers.farmruns.FarmingUtils.TreeSapling; +import com.questhelper.helpers.mischelpers.farmruns.FarmingUtils.PayOrCut; +import com.questhelper.helpers.mischelpers.farmruns.FarmingUtils.PayOrCompost; 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; @@ -28,6 +29,7 @@ import com.questhelper.steps.QuestStep; import com.questhelper.steps.widget.LunarSpells; import com.questhelper.steps.widget.NormalSpells; +import java.util.Set; import net.runelite.api.ItemID; import net.runelite.api.NpcID; import net.runelite.api.NullObjectID; @@ -38,6 +40,7 @@ import net.runelite.api.events.GameTick; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.ConfigChanged; +import net.runelite.client.game.ItemManager; import net.runelite.client.plugins.timetracking.Tab; import net.runelite.client.util.Text; import java.util.ArrayList; @@ -56,6 +59,10 @@ public class TreeRun extends ComplexStateQuestHelper { @Inject private FarmingWorld farmingWorld; + + @Inject + ItemManager itemManager; + private FarmingHandler farmingHandler; DetailedQuestStep waitForTree; @@ -90,7 +97,7 @@ public class TreeRun extends ComplexStateQuestHelper DetailedQuestStep eastHardwoodTreePatchClear, westHardwoodTreePatchClear, middleHardwoodTreePatchClear; // Farming Items - ItemRequirement coins, spade, rake, allTreeSaplings, treeSapling, allFruitSaplings, fruitTreeSapling, hardwoodSapling, compost, axe, protectionItem; + ItemRequirement coins, spade, rake, allTreeSaplings, treeSapling, allFruitSaplings, fruitTreeSapling, allHardwoodSaplings, hardwoodSapling, compost, axe, protectionItemTree, protectionItemFruitTree, protectionItemHardwood; // Teleport Items // TODO: Add these... @@ -105,42 +112,14 @@ public class TreeRun extends ComplexStateQuestHelper // Access Requirements Requirement accessToFarmingGuildTreePatch, accessToFarmingGuildFruitTreePatch, accessToLletya, accessToFossilIsland; - // Tree Requirements - ManualRequirement lumbridgeTreePatchEmpty, faladorTreePatchEmpty, taverleyTreePatchEmpty, - varrockTreePatchEmpty, gnomeStrongholdTreePatchEmpty, farmingGuildTreePatchEmpty; - ManualRequirement lumbridgeTreePatchHarvestable, faladorTreePatchHarvestable, taverleyTreePatchHarvestable, - varrockTreePatchHarvestable, gnomeStrongholdTreePatchHarvestable, farmingGuildTreePatchHarvestable; - ManualRequirement faladorTreePatchNotChecked, faladorTreePatchIsStump, - lumbridgeTreePatchNotChecked, lumbridgeTreePatchIsStump, - farmingGuildTreePatchNotChecked, farmingGuildTreePatchIsStump, - taverleyTreePatchNotChecked, taverleyTreePatchIsStump, - varrockTreePatchNotChecked, varrockTreePatchIsStump, - gnomeStrongholdTreePatchNotChecked, gnomeStrongholdTreePatchIsStump; - - // Fruit Tree Requirements - ManualRequirement gnomeStrongholdFruitTreePatchEmpty, gnomeVillageFruitTreePatchEmpty, - brimhavenFruitTreePatchEmpty, lletyaFruitTreePatchEmpty, catherbyFruitTreePatchEmpty, farmingGuildFruitTreePatchEmpty; - ManualRequirement gnomeStrongholdFruitTreePatchHarvestable, gnomeVillageFruitTreePatchHarvestable, - brimhavenFruitTreePatchHarvestable, lletyaFruitTreePatchHarvestable, catherbyFruitTreePatchHarvestable, farmingGuildFruitTreePatchHarvestable; - - ManualRequirement gnomeStrongholdFruitTreePatchNotChecked, gnomeStrongholdFruitTreePatchIsStump, - gnomeVillageFruitTreePatchNotChecked, gnomeVillageFruitTreePatchIsStump, - brimhavenFruitTreePatchNotChecked, brimhavenFruitTreePatchIsStump, - lletyaFruitTreePatchNotChecked, lletyaFruitTreePatchIsStump, - catherbyFruitTreePatchNotChecked, catherbyFruitTreePatchIsStump, - farmingGuildFruitTreePatchNotChecked, farmingGuildFruitTreePatchChecked, farmingGuildFruitTreePatchIsStump; - - // Hardwood Tree Requirements - ManualRequirement eastHardwoodTreePatchEmpty, westHardwoodTreePatchEmpty, middleHardwoodTreePatchEmpty; - ManualRequirement eastHardwoodTreePatchReady, westHardwoodTreePatchReady, middleHardwoodTreePatchReady; - - ManualRequirement eastHardwoodTreePatchNotChecked, eastHardwoodTreePatchHarvestable, eastHardwoodTreePatchIsStump, - westHardwoodTreePatchNotChecked, westHardwoodTreePatchHarvestable, westHardwoodTreePatchIsStump, - middleHardwoodTreePatchNotChecked, middleHardwoodTreePatchHarvestable, middleHardwoodTreePatchIsStump; + PatchStates faladorStates, lumbridgeStates, farmingGuildTreeStates, taverleyStates, varrockStates, gnomeStrongholdTreeStates; - private final String TREE_SAPLING = "treeSaplings"; - private final String FRUIT_TREE_SAPLING = "fruitTreeSaplings"; - private final String HARDWOOD_TREE_SAPLING = "hardwoodTreeSaplings"; + PatchStates gnomeStrongholdFruitStates, gnomeVillageStates, brimhavenStates, catherbyStates, lletyaStates, farmingGuildFruitStates; + + PatchStates eastHardwoodStates, middleHardwoodStates, westHardwoodStates; + + private final String PAY_OR_CUT = "payOrCutTree"; + private final String PAY_OR_COMPOST = "payOrCompostTree"; private final String GRACEFUL_OR_FARMING = "gracefulOrFarming"; @Override @@ -159,80 +138,80 @@ public QuestStep loadStep() // -> catherby -> lletya -> east hardwood -> middle hardwood -> west hardwood. - steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreePatchNotChecked), farmingGuildTreePatchCheckHealth); - steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreePatchHarvestable), farmingGuildTreePatchClear); - steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreePatchIsStump), farmingGuildTreePatchDig); - steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreePatchEmpty), farmingGuildTreePatchPlant); - - steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitTreePatchNotChecked), farmingGuildFruitTreePatchCheckHealth); - steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitTreePatchChecked), farmingGuildTreePatchClear); - steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitTreePatchEmpty), farmingGuildFruitTreePatchPlant); - steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitTreePatchIsStump), farmingGuildTreePatchDig); - - steps.addStep(lumbridgeTreePatchNotChecked, lumbridgeTreePatchCheckHealth); - steps.addStep(lumbridgeTreePatchEmpty, lumbridgeTreePatchPlant); - steps.addStep(lumbridgeTreePatchHarvestable, lumbridgeTreePatchClear); - steps.addStep(lumbridgeTreePatchIsStump, lumbridgeTreePatchDig); - - steps.addStep(faladorTreePatchNotChecked, faladorTreePatchCheckHealth); - steps.addStep(faladorTreePatchEmpty, faladorTreePatchPlant); - steps.addStep(faladorTreePatchHarvestable, faladorTreePatchClear); - steps.addStep(faladorTreePatchIsStump, faladorTreePatchDig); - - steps.addStep(taverleyTreePatchNotChecked, taverleyTreePatchCheckHealth); - steps.addStep(taverleyTreePatchEmpty, taverleyTreePatchPlant); - steps.addStep(taverleyTreePatchHarvestable, taverleyTreePatchClear); - steps.addStep(taverleyTreePatchIsStump, taverleyTreePatchDig); - - steps.addStep(varrockTreePatchNotChecked, varrockTreePatchCheckHealth); - steps.addStep(varrockTreePatchEmpty, varrockTreePatchPlant); - steps.addStep(varrockTreePatchHarvestable, varrockTreePatchClear); - steps.addStep(varrockTreePatchIsStump, varrockTreePatchDig); - - steps.addStep(gnomeStrongholdFruitTreePatchNotChecked, gnomeStrongholdFruitTreePatchCheckHealth); - steps.addStep(gnomeStrongholdFruitTreePatchEmpty, gnomeStrongholdFruitTreePatchPlant); - steps.addStep(gnomeStrongholdFruitTreePatchHarvestable, gnomeStrongholdFruitTreePatchClear); - steps.addStep(gnomeStrongholdFruitTreePatchIsStump, gnomeStrongholdFruitTreePatchDig); - - steps.addStep(gnomeStrongholdTreePatchNotChecked, gnomeStrongholdTreePatchCheckHealth); - steps.addStep(gnomeStrongholdTreePatchEmpty, gnomeStrongholdFruitTreePatchPlant); - steps.addStep(gnomeStrongholdTreePatchHarvestable, gnomeStrongholdTreePatchClear); - steps.addStep(gnomeStrongholdTreePatchIsStump, gnomeStrongholdTreePatchDig); - - steps.addStep(gnomeVillageFruitTreePatchNotChecked, gnomeVillageFruitTreePatchCheckHealth); - steps.addStep(gnomeVillageFruitTreePatchEmpty, gnomeVillageFruitTreePatchPlant); - steps.addStep(gnomeVillageFruitTreePatchHarvestable, gnomeVillageFruitTreePatchClear); - steps.addStep(gnomeVillageFruitTreePatchIsStump, gnomeVillageFruitTreePatchDig); - - steps.addStep(brimhavenFruitTreePatchNotChecked, brimhavenFruitTreePatchCheckHealth); - steps.addStep(brimhavenFruitTreePatchEmpty, brimhavenFruitTreePatchPlant); - steps.addStep(brimhavenFruitTreePatchHarvestable, brimhavenFruitTreePatchClear); - steps.addStep(brimhavenFruitTreePatchIsStump, brimhavenFruitTreePatchDig); - - steps.addStep(catherbyFruitTreePatchNotChecked, catherbyFruitTreePatchCheckHealth); - steps.addStep(catherbyFruitTreePatchEmpty, catherbyFruitTreePatchPlant); - steps.addStep(catherbyFruitTreePatchHarvestable, catherbyFruitTreePatchClear); - steps.addStep(catherbyFruitTreePatchIsStump, catherbyFruitTreePatchDig); - - steps.addStep(new Conditions(accessToLletya, lletyaFruitTreePatchNotChecked), lletyaFruitTreePatchCheckHealth); - steps.addStep(new Conditions(accessToLletya, lletyaFruitTreePatchEmpty), lletyaFruitTreePatchPlant); - steps.addStep(new Conditions(accessToLletya, lletyaFruitTreePatchHarvestable), lletyaFruitTreePatchClear); - steps.addStep(new Conditions(accessToLletya, lletyaFruitTreePatchIsStump), lletyaFruitTreePatchDig); - - steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodTreePatchNotChecked), eastHardwoodTreePatchCheckHealth); - steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodTreePatchEmpty), eastHardwoodTreePatchPlant); - steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodTreePatchHarvestable), eastHardwoodTreePatchClear); - steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodTreePatchIsStump), eastHardwoodTreePatchDig); - - steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodTreePatchNotChecked), middleHardwoodTreePatchCheckHealth); - steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodTreePatchEmpty), middleHardwoodTreePatchPlant); - steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodTreePatchHarvestable), middleHardwoodTreePatchClear); - steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodTreePatchIsStump), middleHardwoodTreePatchDig); - - steps.addStep(new Conditions(accessToFossilIsland, westHardwoodTreePatchNotChecked), westHardwoodTreePatchCheckHealth); - steps.addStep(new Conditions(accessToFossilIsland, westHardwoodTreePatchEmpty), westHardwoodTreePatchPlant); - steps.addStep(new Conditions(accessToFossilIsland, westHardwoodTreePatchHarvestable), westHardwoodTreePatchClear); - steps.addStep(new Conditions(accessToFossilIsland, westHardwoodTreePatchIsStump), westHardwoodTreePatchDig); + steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreeStates.getIsUnchecked()), farmingGuildTreePatchCheckHealth); + steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreeStates.getIsHarvestable()), farmingGuildTreePatchClear); + steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreeStates.getIsStump()), farmingGuildTreePatchDig); + steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreeStates.getIsEmpty()), farmingGuildTreePatchPlant); + + steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitStates.getIsUnchecked()), farmingGuildFruitTreePatchCheckHealth); + steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitStates.getIsHarvestable()), farmingGuildTreePatchClear); + steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitStates.getIsStump()), farmingGuildFruitTreePatchPlant); + steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitStates.getIsEmpty()), farmingGuildTreePatchDig); + + steps.addStep(lumbridgeStates.getIsUnchecked(), lumbridgeTreePatchCheckHealth); + steps.addStep(lumbridgeStates.getIsEmpty(), lumbridgeTreePatchPlant); + steps.addStep(lumbridgeStates.getIsHarvestable(), lumbridgeTreePatchClear); + steps.addStep(lumbridgeStates.getIsStump(), lumbridgeTreePatchDig); + + steps.addStep(faladorStates.getIsUnchecked(), faladorTreePatchCheckHealth); + steps.addStep(faladorStates.getIsEmpty(), faladorTreePatchPlant); + steps.addStep(faladorStates.getIsHarvestable(), faladorTreePatchClear); + steps.addStep(faladorStates.getIsStump(), faladorTreePatchDig); + + steps.addStep(taverleyStates.getIsUnchecked(), taverleyTreePatchCheckHealth); + steps.addStep(taverleyStates.getIsEmpty(), taverleyTreePatchPlant); + steps.addStep(taverleyStates.getIsHarvestable(), taverleyTreePatchClear); + steps.addStep(taverleyStates.getIsStump(), taverleyTreePatchDig); + + steps.addStep(varrockStates.getIsUnchecked(), varrockTreePatchCheckHealth); + steps.addStep(varrockStates.getIsEmpty(), varrockTreePatchPlant); + steps.addStep(varrockStates.getIsHarvestable(), varrockTreePatchClear); + steps.addStep(varrockStates.getIsStump(), varrockTreePatchDig); + + steps.addStep(gnomeStrongholdFruitStates.getIsUnchecked(), gnomeStrongholdFruitTreePatchCheckHealth); + steps.addStep(gnomeStrongholdFruitStates.getIsEmpty(), gnomeStrongholdFruitTreePatchPlant); + steps.addStep(gnomeStrongholdFruitStates.getIsHarvestable(), gnomeStrongholdFruitTreePatchClear); + steps.addStep(gnomeStrongholdFruitStates.getIsStump(), gnomeStrongholdFruitTreePatchDig); + + steps.addStep(gnomeStrongholdTreeStates.getIsUnchecked(), gnomeStrongholdTreePatchCheckHealth); + steps.addStep(gnomeStrongholdTreeStates.getIsEmpty(), gnomeStrongholdFruitTreePatchPlant); + steps.addStep(gnomeStrongholdTreeStates.getIsHarvestable(), gnomeStrongholdTreePatchClear); + steps.addStep(gnomeStrongholdTreeStates.getIsStump(), gnomeStrongholdTreePatchDig); + + steps.addStep(gnomeVillageStates.getIsUnchecked(), gnomeVillageFruitTreePatchCheckHealth); + steps.addStep(gnomeVillageStates.getIsEmpty(), gnomeVillageFruitTreePatchPlant); + steps.addStep(gnomeVillageStates.getIsHarvestable(), gnomeVillageFruitTreePatchClear); + steps.addStep(gnomeVillageStates.getIsStump(), gnomeVillageFruitTreePatchDig); + + steps.addStep(brimhavenStates.getIsUnchecked(), brimhavenFruitTreePatchCheckHealth); + steps.addStep(brimhavenStates.getIsEmpty(), brimhavenFruitTreePatchPlant); + steps.addStep(brimhavenStates.getIsHarvestable(), brimhavenFruitTreePatchClear); + steps.addStep(brimhavenStates.getIsStump(), brimhavenFruitTreePatchDig); + + steps.addStep(catherbyStates.getIsUnchecked(), catherbyFruitTreePatchCheckHealth); + steps.addStep(catherbyStates.getIsEmpty(), catherbyFruitTreePatchPlant); + steps.addStep(catherbyStates.getIsHarvestable(), catherbyFruitTreePatchClear); + steps.addStep(catherbyStates.getIsStump(), catherbyFruitTreePatchDig); + + steps.addStep(new Conditions(accessToLletya, lletyaStates.getIsUnchecked()), lletyaFruitTreePatchCheckHealth); + steps.addStep(new Conditions(accessToLletya, lletyaStates.getIsEmpty()), lletyaFruitTreePatchPlant); + steps.addStep(new Conditions(accessToLletya, lletyaStates.getIsHarvestable()), lletyaFruitTreePatchClear); + steps.addStep(new Conditions(accessToLletya, lletyaStates.getIsStump()), lletyaFruitTreePatchDig); + + steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodStates.getIsUnchecked()), eastHardwoodTreePatchCheckHealth); + steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodStates.getIsEmpty()), eastHardwoodTreePatchPlant); + steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodStates.getIsHarvestable()), eastHardwoodTreePatchClear); + steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodStates.getIsStump()), eastHardwoodTreePatchDig); + + steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodStates.getIsUnchecked()), middleHardwoodTreePatchCheckHealth); + steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodStates.getIsEmpty()), middleHardwoodTreePatchPlant); + steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodStates.getIsHarvestable()), middleHardwoodTreePatchClear); + steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodStates.getIsStump()), middleHardwoodTreePatchDig); + + steps.addStep(new Conditions(accessToFossilIsland, westHardwoodStates.getIsUnchecked()), westHardwoodTreePatchCheckHealth); + steps.addStep(new Conditions(accessToFossilIsland, westHardwoodStates.getIsEmpty()), westHardwoodTreePatchPlant); + steps.addStep(new Conditions(accessToFossilIsland, westHardwoodStates.getIsHarvestable()), westHardwoodTreePatchClear); + steps.addStep(new Conditions(accessToFossilIsland, westHardwoodStates.getIsStump()), westHardwoodTreePatchDig); return steps; } @@ -240,46 +219,6 @@ public QuestStep loadStep() private void setupConditions() { // Tree Patch Ready Requirements - lumbridgeTreePatchHarvestable = new ManualRequirement(); - faladorTreePatchHarvestable = new ManualRequirement(); - taverleyTreePatchHarvestable = new ManualRequirement(); - varrockTreePatchHarvestable = new ManualRequirement(); - gnomeStrongholdTreePatchHarvestable = new ManualRequirement(); - farmingGuildTreePatchHarvestable = new ManualRequirement(); - - // Tree Patch Empty Requirements - lumbridgeTreePatchEmpty = new ManualRequirement(); - faladorTreePatchEmpty = new ManualRequirement(); - taverleyTreePatchEmpty = new ManualRequirement(); - varrockTreePatchEmpty = new ManualRequirement(); - gnomeStrongholdTreePatchEmpty = new ManualRequirement(); - farmingGuildTreePatchEmpty = new ManualRequirement(); - - // Fruit Patch Ready Requirements - gnomeStrongholdFruitTreePatchHarvestable = new ManualRequirement(); - gnomeVillageFruitTreePatchHarvestable = new ManualRequirement(); - brimhavenFruitTreePatchHarvestable = new ManualRequirement(); - lletyaFruitTreePatchHarvestable = new ManualRequirement(); - catherbyFruitTreePatchHarvestable = new ManualRequirement(); - farmingGuildFruitTreePatchHarvestable = new ManualRequirement(); - - // Fruit Patch Empty Requirements - gnomeStrongholdFruitTreePatchEmpty = new ManualRequirement(); - gnomeVillageFruitTreePatchEmpty = new ManualRequirement(); - brimhavenFruitTreePatchEmpty = new ManualRequirement(); - lletyaFruitTreePatchEmpty = new ManualRequirement(); - catherbyFruitTreePatchEmpty = new ManualRequirement(); - farmingGuildFruitTreePatchEmpty = new ManualRequirement(); - - // Hardwood Tree Ready Requirements - eastHardwoodTreePatchReady = new ManualRequirement(); - westHardwoodTreePatchReady = new ManualRequirement(); - middleHardwoodTreePatchReady = new ManualRequirement(); - - // Hardwood Tree Empty Requirements - eastHardwoodTreePatchEmpty = new ManualRequirement(); - westHardwoodTreePatchEmpty = new ManualRequirement(); - middleHardwoodTreePatchEmpty = new ManualRequirement(); // Access Requirements // ME1 partial completion required only, however much easier to access when finished. @@ -292,68 +231,25 @@ private void setupConditions() new SkillRequirement(Skill.FARMING, 85) ); - // Tree Not Checked - lumbridgeTreePatchNotChecked = new ManualRequirement(); - lumbridgeTreePatchHarvestable = new ManualRequirement(); - lumbridgeTreePatchIsStump = new ManualRequirement(); - - faladorTreePatchNotChecked = new ManualRequirement(); - faladorTreePatchHarvestable = new ManualRequirement(); - faladorTreePatchIsStump = new ManualRequirement(); - - taverleyTreePatchNotChecked = new ManualRequirement(); - taverleyTreePatchHarvestable = new ManualRequirement(); - taverleyTreePatchIsStump = new ManualRequirement(); - - varrockTreePatchNotChecked = new ManualRequirement(); - varrockTreePatchHarvestable = new ManualRequirement(); - varrockTreePatchIsStump = new ManualRequirement(); - - gnomeStrongholdTreePatchNotChecked = new ManualRequirement(); - gnomeStrongholdTreePatchHarvestable = new ManualRequirement(); - gnomeStrongholdTreePatchIsStump = new ManualRequirement(); - - farmingGuildTreePatchNotChecked = new ManualRequirement(); - farmingGuildTreePatchHarvestable = new ManualRequirement(); - farmingGuildTreePatchIsStump = new ManualRequirement(); - - // Fruit Tree Not Checked - gnomeStrongholdFruitTreePatchNotChecked = new ManualRequirement(); - gnomeStrongholdFruitTreePatchHarvestable = new ManualRequirement(); - gnomeStrongholdFruitTreePatchIsStump = new ManualRequirement(); - - gnomeVillageFruitTreePatchNotChecked = new ManualRequirement(); - gnomeVillageFruitTreePatchHarvestable = new ManualRequirement(); - gnomeVillageFruitTreePatchIsStump = new ManualRequirement(); - - brimhavenFruitTreePatchNotChecked = new ManualRequirement(); - brimhavenFruitTreePatchHarvestable = new ManualRequirement(); - brimhavenFruitTreePatchIsStump = new ManualRequirement(); - - lletyaFruitTreePatchNotChecked = new ManualRequirement(); - lletyaFruitTreePatchHarvestable = new ManualRequirement(); - lletyaFruitTreePatchIsStump = new ManualRequirement(); - - catherbyFruitTreePatchNotChecked = new ManualRequirement(); - catherbyFruitTreePatchHarvestable = new ManualRequirement(); - catherbyFruitTreePatchIsStump = new ManualRequirement(); - - farmingGuildFruitTreePatchNotChecked = new ManualRequirement(); - farmingGuildFruitTreePatchHarvestable = new ManualRequirement(); - farmingGuildFruitTreePatchIsStump = new ManualRequirement(); - - // Hardwood Tree Not Checked - eastHardwoodTreePatchNotChecked = new ManualRequirement(); - eastHardwoodTreePatchHarvestable = new ManualRequirement(); - eastHardwoodTreePatchIsStump = new ManualRequirement(); - - westHardwoodTreePatchNotChecked = new ManualRequirement(); - westHardwoodTreePatchHarvestable = new ManualRequirement(); - westHardwoodTreePatchIsStump = new ManualRequirement(); - - middleHardwoodTreePatchNotChecked = new ManualRequirement(); - middleHardwoodTreePatchHarvestable = new ManualRequirement(); - middleHardwoodTreePatchIsStump = new ManualRequirement(); + // Trees + lumbridgeStates = new PatchStates("Lumbridge"); + faladorStates = new PatchStates("Falador"); + taverleyStates = new PatchStates("Taverley"); + varrockStates = new PatchStates("Varrock"); + gnomeStrongholdTreeStates = new PatchStates("Tree Gnome Stronghold"); + farmingGuildTreeStates = new PatchStates("Farming Guild", accessToFarmingGuildFruitTreePatch); + + // Fruit trees + catherbyStates = new PatchStates("Catherby"); + brimhavenStates = new PatchStates("Brimhaven"); + gnomeVillageStates = new PatchStates("Tree Gnome Village"); + gnomeStrongholdFruitStates = new PatchStates("Gnome Stronghold"); + lletyaStates = new PatchStates("Lletya", accessToLletya); + farmingGuildFruitStates = new PatchStates("Farming Guild", accessToFarmingGuildFruitTreePatch); + + westHardwoodStates = new PatchStates("Fossil Island", "West"); + middleHardwoodStates = new PatchStates("Fossil Island", "Middle"); + eastHardwoodStates = new PatchStates("Fossil Island", "East"); } @Override @@ -363,39 +259,33 @@ public void setupRequirements() spade = new ItemRequirement("Spade", ItemID.SPADE); rake = new ItemRequirement("Rake", ItemID.RAKE) .hideConditioned(new VarbitRequirement(Varbits.AUTOWEED, 2)); - coins = new ItemRequirement("Coins to quickly remove trees.", ItemID.COINS_995); + coins = new ItemRequirement("Coins to quickly remove trees.", ItemID.COINS_995) + .showConditioned(new RuneliteRequirement(configManager, PAY_OR_CUT, PayOrCut.PAY.name())); axe = new ItemRequirement("Any axe you can use", ItemCollections.AXES); - treeSapling = FarmingUtils.createSeedRequirement( - configManager, - QuestHelperConfig.QUEST_BACKGROUND_GROUP, - TREE_SAPLING, - TreeSapling.OAK, - ItemID.OAK_SAPLING - ); + TreeSapling treeSaplingEnum = TreeSapling.valueOf(FarmingUtils.getEnumFromConfig(configManager, TreeSapling.MAGIC)); + treeSapling = treeSaplingEnum.getPlantableItemRequirement(itemManager); treeSapling.setHighlightInInventory(true); allTreeSaplings = treeSapling.copy(); - fruitTreeSapling = FarmingUtils.createSeedRequirement( - configManager, - QuestHelperConfig.QUEST_BACKGROUND_GROUP, - FRUIT_TREE_SAPLING, - FruitTreeSapling.APPLE, - ItemID.APPLE_SAPLING - ); + protectionItemTree = treeSaplingEnum.getProtectionItemRequirement(itemManager); + + FruitTreeSapling fruitTreeSaplingEnum = FruitTreeSapling.valueOf(FarmingUtils.getEnumFromConfig(configManager, FruitTreeSapling.APPLE)); + fruitTreeSapling = fruitTreeSaplingEnum.getPlantableItemRequirement(itemManager); fruitTreeSapling.setHighlightInInventory(true); allFruitSaplings = fruitTreeSapling.copy(); - hardwoodSapling = FarmingUtils.createSeedRequirement( - configManager, - QuestHelperConfig.QUEST_BACKGROUND_GROUP, - HARDWOOD_TREE_SAPLING, - HardwoodTreeSapling.TEAK, - ItemID.TEAK_SAPLING - ); + protectionItemFruitTree = fruitTreeSaplingEnum.getProtectionItemRequirement(itemManager); + + HardwoodTreeSapling hardwoodTreeSaplingEnum = HardwoodTreeSapling.valueOf(FarmingUtils.getEnumFromConfig(configManager, HardwoodTreeSapling.TEAK)); + hardwoodSapling = hardwoodTreeSaplingEnum.getPlantableItemRequirement(itemManager); hardwoodSapling.setHighlightInInventory(true); + allHardwoodSaplings = hardwoodSapling.copy(); + + protectionItemHardwood = hardwoodTreeSaplingEnum.getProtectionItemRequirement(itemManager); compost = new ItemRequirement("Compost", ItemCollections.COMPOST); + compost.setDisplayMatchedItemName(true); // Teleport Items farmingGuildTeleport = new ItemRequirement("Farming Guild Teleport", ItemCollections.SKILLS_NECKLACES); @@ -464,27 +354,27 @@ private void setupSteps() // Tree Patch Clear Steps lumbridgeTreePatchClear = new NpcStep(this, NpcID.FARMER, new WorldPoint(3193, 3231, 0), - "Speak to the farmer to clear the patch.", coins.quantity(200)); + "Speak to the farmer to clear the patch."); lumbridgeTreePatchClear.addDialogStep("Yes."); faladorTreePatchClear = new NpcStep(this, NpcID.FAYETH, new WorldPoint(3004, 3373, 0), - "Speak to Fayeth to clear the patch.", coins.quantity(200)); + "Speak to Fayeth to clear the patch."); faladorTreePatchClear.addDialogStep("Yes."); taverleyTreePatchClear = new NpcStep(this, NpcID.ALAIN, new WorldPoint(2936, 3438, 0), - "Speak to Alain to clear the patch.", coins.quantity(200)); + "Speak to Alain to clear the patch."); taverleyTreePatchClear.addDialogStep("Yes."); varrockTreePatchClear = new NpcStep(this, NpcID.TREZNOR_11957, new WorldPoint(3229, 3459, 0), - "Speak to Treznor to clear the patch.", coins.quantity(200)); + "Speak to Treznor to clear the patch."); varrockTreePatchClear.addDialogStep("Yes."); gnomeStrongholdTreePatchClear = new NpcStep(this, NpcID.PRISSY_SCILLA, new WorldPoint(2436, 3415, 0), - "Speak to Prissy Scilla to clear the patch.", coins.quantity(200)); + "Speak to Prissy Scilla to clear the patch."); gnomeStrongholdTreePatchClear.addDialogStep("Yes."); farmingGuildTreePatchClear = new NpcStep(this, NpcID.ROSIE, new WorldPoint(1232, 3736, 0), - "Speak to Rosie to clear the patch.", coins.quantity(200)); + "Speak to Rosie to clear the patch."); farmingGuildTreePatchClear.addDialogStep("Yes."); // Tree Patch Steps @@ -544,17 +434,17 @@ private void setupSteps() // Dig lumbridgeTreePatchDig = new ObjectStep(this, NullObjectID.NULL_8391, new WorldPoint(3193, 3231, 0), - "Dig up the tree stump in Lumbridge.", spade); + "Dig up the tree stump in Lumbridge."); faladorTreePatchDig = new ObjectStep(this, NullObjectID.NULL_8389, new WorldPoint(3004, 3373, 0), - "Dig up the tree stump in Falador.", spade); + "Dig up the tree stump in Falador."); taverleyTreePatchDig = new ObjectStep(this, NullObjectID.NULL_8388, new WorldPoint(2936, 3438, 0), - "Dig up the tree stump in Taverley.", spade); + "Dig up the tree stump in Taverley."); varrockTreePatchDig = new ObjectStep(this, NullObjectID.NULL_8390, new WorldPoint(3229, 3459, 0), - "Dig up the tree stump in Varrock.", spade); + "Dig up the tree stump in Varrock."); gnomeStrongholdTreePatchDig = new ObjectStep(this, NullObjectID.NULL_19147, new WorldPoint(2436, 3415, 0), - "Dig up the tree stump in the Tree Gnome Stronghold.", spade); + "Dig up the tree stump in the Tree Gnome Stronghold."); farmingGuildTreePatchDig = new ObjectStep(this, NullObjectID.NULL_33732, new WorldPoint(1232, 3736, 0), - "Dig up the tree stump in the Farming Guild tree patch.", spade); + "Dig up the tree stump in the Farming Guild tree patch."); faladorTreePatchClear.addSubSteps(faladorTreePatchDig); taverleyTreePatchClear.addSubSteps(taverleyTreePatchDig); @@ -622,22 +512,22 @@ private void setupSteps() // Clear gnomeStrongholdFruitTreePatchClear = new NpcStep(this, NpcID.BOLONGO, new WorldPoint(2476, 3446, 0), - "Pay Bolongo 200 coins to clear the fruit tree, or pick all the fruit and cut it down.", coins.quantity(200)); + "Pay Bolongo 200 coins to clear the fruit tree, or pick all the fruit and cut it down."); gnomeStrongholdFruitTreePatchClear.addDialogStep("Yes."); gnomeVillageFruitTreePatchClear = new NpcStep(this, NpcID.GILETH, new WorldPoint(2490, 3180, 0), - "Pay Gileth 200 coins to clear the fruit tree, or pick all the fruit and cut it down.", coins.quantity(200)); + "Pay Gileth 200 coins to clear the fruit tree, or pick all the fruit and cut it down."); gnomeVillageFruitTreePatchClear.addDialogStep("Yes."); brimhavenFruitTreePatchClear = new NpcStep(this, NpcID.GARTH, new WorldPoint(2765, 3213, 0), - "Pay Garth 200 coins to clear the fruit tree, or pick all the fruit and cut it down.", coins.quantity(200)); + "Pay Garth 200 coins to clear the fruit tree, or pick all the fruit and cut it down."); brimhavenFruitTreePatchClear.addDialogStep("Yes."); catherbyFruitTreePatchClear = new NpcStep(this, NpcID.ELLENA, new WorldPoint(2681, 3434, 0), - "Pay Ellena 200 coins to clear the fruit tree, or pick all the fruit and cut it down.", coins.quantity(200)); + "Pay Ellena 200 coins to clear the fruit tree, or pick all the fruit and cut it down."); catherbyFruitTreePatchClear.addDialogStep("Yes."); lletyaFruitTreePatchClear = new NpcStep(this, NpcID.LILIWEN, new WorldPoint(2347, 3162, 0), - "Pay Liliwen 200 coins to clear the fruit tree, or pick all the fruit and cut it down.", coins.quantity(200)); + "Pay Liliwen 200 coins to clear the fruit tree, or pick all the fruit and cut it down."); lletyaFruitTreePatchClear.addDialogStep("Yes."); farmingGuildFruitTreePatchClear = new NpcStep(this, NpcID.NIKKIE, new WorldPoint(1243, 3760, 0), - "Pay Nikkie 200 coins to clear the fruit tree, or pick all the fruit and cut it down.", coins.quantity(200)); + "Pay Nikkie 200 coins to clear the fruit tree, or pick all the fruit and cut it down."); farmingGuildFruitTreePatchClear.addDialogStep("Yes."); // Dig Fruit Tree Steps @@ -686,11 +576,11 @@ private void setupSteps() eastHardwoodTreePatchCheckHealth.addSubSteps(eastHardwoodTreePatchPlant); westHardwoodTreePatchClear = new NpcStep(this, NpcID.SQUIRREL_7756, new WorldPoint(3702, 3837, 0), - "Pay the brown squirrel to remove the west tree.", coins.quantity(200)); + "Pay the brown squirrel to remove the west tree."); middleHardwoodTreePatchClear = new NpcStep(this, NpcID.SQUIRREL_7755, new WorldPoint(3702, 3837, 0), - "Pay the black squirrel to remove the middle tree.", coins.quantity(200)); + "Pay the black squirrel to remove the middle tree."); eastHardwoodTreePatchClear = new NpcStep(this, NpcID.SQUIRREL_7754, new WorldPoint(3702, 3837, 0), - "Pay the grey squirrel to remove the east tree.", coins.quantity(200)); + "Pay the grey squirrel to remove the east tree."); westHardwoodTreePatchDig = new ObjectStep(this, NullObjectID.NULL_30481, new WorldPoint(3702, 3837, 0), "Dig up the western hardwood tree's stump on Fossil Island."); @@ -707,130 +597,48 @@ private void setupSteps() @Subscribe public void onGameTick(GameTick event) { - int numberOfTreeSaplings = 0; - for (FarmingPatch treePatch : farmingWorld.getTabs().get(Tab.TREE)) - { - CropState treeState = farmingHandler.predictPatch(treePatch); - boolean isTreePatchPlantable = treeState == CropState.EMPTY || treeState == CropState.DEAD; - - boolean isTreeUnchecked = treeState == CropState.UNCHECKED; // 'Check health' - boolean isTreePatchHarvestable = treeState == CropState.HARVESTABLE; // 'Chop' - boolean isTreeStump = treeState == CropState.STUMP; // 'Clear' - - if (treeState != CropState.GROWING) - { - numberOfTreeSaplings++; - } - - switch (treePatch.getRegion().getName()) - { - case "Lumbridge": - lumbridgeTreePatchHarvestable.setShouldPass(isTreePatchHarvestable); - lumbridgeTreePatchEmpty.setShouldPass(isTreePatchPlantable); - lumbridgeTreePatchNotChecked.setShouldPass(isTreeUnchecked); - lumbridgeTreePatchIsStump.setShouldPass(isTreeStump); - break; - case "Varrock": - varrockTreePatchHarvestable.setShouldPass(isTreePatchHarvestable); - varrockTreePatchEmpty.setShouldPass(isTreePatchPlantable); - varrockTreePatchNotChecked.setShouldPass(isTreeUnchecked); - varrockTreePatchIsStump.setShouldPass(isTreeStump); - break; - case "Falador": - faladorTreePatchHarvestable.setShouldPass(isTreePatchHarvestable); - faladorTreePatchEmpty.setShouldPass(isTreePatchPlantable); - faladorTreePatchNotChecked.setShouldPass(isTreeUnchecked); - faladorTreePatchIsStump.setShouldPass(isTreeStump); - break; - case "Gnome Stronghold": - gnomeStrongholdTreePatchHarvestable.setShouldPass(isTreePatchHarvestable); - gnomeStrongholdTreePatchEmpty.setShouldPass(isTreePatchPlantable); - gnomeStrongholdTreePatchNotChecked.setShouldPass(isTreeUnchecked); - gnomeStrongholdTreePatchIsStump.setShouldPass(isTreeStump); - break; - case "Taverley": - taverleyTreePatchHarvestable.setShouldPass(isTreePatchHarvestable); - taverleyTreePatchEmpty.setShouldPass(isTreePatchPlantable); - taverleyTreePatchNotChecked.setShouldPass(isTreeUnchecked); - taverleyTreePatchIsStump.setShouldPass(isTreeStump); - break; - case "Farming Guild": - farmingGuildTreePatchHarvestable.setShouldPass(isTreePatchHarvestable); - farmingGuildTreePatchEmpty.setShouldPass(isTreePatchPlantable); - farmingGuildTreePatchNotChecked.setShouldPass(isTreeUnchecked); - farmingGuildTreePatchIsStump.setShouldPass(isTreeStump); - if (!accessToFarmingGuildTreePatch.check(client)) - { - numberOfTreeSaplings--; - } - break; - } - } - allTreeSaplings.quantity(numberOfTreeSaplings); + coins.setQuantity(0); + handleTreePatches(PatchImplementation.TREE, List.of(farmingGuildTreeStates), farmingWorld.getTabs().get(Tab.TREE), allTreeSaplings); + handleTreePatches(PatchImplementation.FRUIT_TREE, List.of(farmingGuildTreeStates), farmingWorld.getTabs().get(Tab.FRUIT_TREE), allFruitSaplings); + handleTreePatches(PatchImplementation.HARDWOOD_TREE, List.of(farmingGuildTreeStates), farmingWorld.getTabs().get(Tab.TREE), allHardwoodSaplings); + } - int numberOfFruitTreeSaplings = 0; - for (FarmingPatch fruitTreePatch : farmingWorld.getTabs().get(Tab.FRUIT_TREE)) + public void handleTreePatches(PatchImplementation implementation, List regions, Set patches, ItemRequirement allSaplings) + { + int numberOfSaplings = 0; + for (FarmingPatch patch : patches) { - CropState fruitTreeState = farmingHandler.predictPatch(fruitTreePatch); - boolean isFruitTreePatchPlantable = fruitTreeState == CropState.EMPTY || fruitTreeState == CropState.DEAD; - boolean isFruitTreeUnchecked = fruitTreeState == CropState.UNCHECKED; // 'Check health' - boolean isFruitTreePatchHarvestable = fruitTreeState == CropState.HARVESTABLE; // 'Chop' - boolean isFruitTreeStump = fruitTreeState == CropState.STUMP; // 'Clear' + CropState state = farmingHandler.predictPatch(patch); + boolean isPlantable = state == CropState.EMPTY || state == CropState.DEAD; + boolean isUnchecked = state == CropState.UNCHECKED; // 'Check health' + boolean isHarvestable = state == CropState.HARVESTABLE; // 'Chop' + boolean isStump = state == CropState.STUMP; // 'Clear' - if (fruitTreeState != CropState.GROWING) + if (state != CropState.GROWING && patch.getImplementation() == implementation) { - numberOfFruitTreeSaplings++; + numberOfSaplings++; } - switch (fruitTreePatch.getRegion().getName()) + PatchStates region = regions.stream() + .filter(r -> r.getRegionName().equals(patch.getRegion().getName())) + .filter(r -> r.getPatchName() == null || r.getPatchName().equals(patch.getName())) + .findFirst() + .orElse(null); + + if (region != null) { - case "Catherby": - catherbyFruitTreePatchHarvestable.setShouldPass(isFruitTreePatchHarvestable); - catherbyFruitTreePatchEmpty.setShouldPass(isFruitTreePatchPlantable); - catherbyFruitTreePatchNotChecked.setShouldPass(isFruitTreeUnchecked); - catherbyFruitTreePatchIsStump.setShouldPass(isFruitTreeStump); - break; - case "Brimhaven": - brimhavenFruitTreePatchHarvestable.setShouldPass(isFruitTreePatchHarvestable); - brimhavenFruitTreePatchEmpty.setShouldPass(isFruitTreePatchPlantable); - brimhavenFruitTreePatchNotChecked.setShouldPass(isFruitTreeUnchecked); - brimhavenFruitTreePatchIsStump.setShouldPass(isFruitTreeStump); - break; - case "Tree Gnome Village": - gnomeVillageFruitTreePatchHarvestable.setShouldPass(isFruitTreePatchHarvestable); - gnomeVillageFruitTreePatchEmpty.setShouldPass(isFruitTreePatchPlantable); - gnomeVillageFruitTreePatchNotChecked.setShouldPass(isFruitTreeUnchecked); - gnomeVillageFruitTreePatchIsStump.setShouldPass(isFruitTreeStump); - break; - case "Gnome Stronghold": - gnomeStrongholdFruitTreePatchHarvestable.setShouldPass(isFruitTreePatchHarvestable); - gnomeStrongholdFruitTreePatchEmpty.setShouldPass(isFruitTreePatchPlantable); - gnomeStrongholdFruitTreePatchNotChecked.setShouldPass(isFruitTreeUnchecked); - gnomeStrongholdFruitTreePatchIsStump.setShouldPass(isFruitTreeStump); - break; - case "Lletya": - lletyaFruitTreePatchHarvestable.setShouldPass(isFruitTreePatchHarvestable); - lletyaFruitTreePatchEmpty.setShouldPass(isFruitTreePatchPlantable); - lletyaFruitTreePatchNotChecked.setShouldPass(isFruitTreeUnchecked); - lletyaFruitTreePatchIsStump.setShouldPass(isFruitTreeStump); - if (!accessToLletya.check(client)) - { - numberOfFruitTreeSaplings--; - } - break; - case "Farming Guild": - farmingGuildFruitTreePatchHarvestable.setShouldPass(isFruitTreePatchHarvestable); - farmingGuildFruitTreePatchEmpty.setShouldPass(isFruitTreePatchPlantable); - farmingGuildFruitTreePatchNotChecked.setShouldPass(isFruitTreeUnchecked); - farmingGuildFruitTreePatchIsStump.setShouldPass(isFruitTreeStump); - if (!accessToFarmingGuildFruitTreePatch.check(client)) - { - numberOfFruitTreeSaplings--; - } - break; + region.getIsHarvestable().setShouldPass(isHarvestable); + region.getIsEmpty().setShouldPass(isPlantable); + region.getIsUnchecked().setShouldPass(isUnchecked); + region.getIsStump().setShouldPass(isStump); + if (!region.canAccess(client)) + { + numberOfSaplings--; + } } } - allFruitSaplings.quantity(numberOfFruitTreeSaplings); + allSaplings.setQuantity(numberOfSaplings); + coins.setQuantity(coins.getQuantity() + (200 * numberOfSaplings)); } @Subscribe @@ -840,7 +648,6 @@ public void onConfigChanged(ConfigChanged event) { return; } - FarmingConfigChangeHandler.handleFarmingEnumConfigChange(event, TREE_SAPLING, TreeSapling.class, this::updateTreeSapling, TreeSapling.OAK, configManager, questHelperPlugin); FarmingConfigChangeHandler.handleFarmingEnumConfigChange(event, FRUIT_TREE_SAPLING, FruitTreeSapling.class, @@ -848,11 +655,14 @@ public void onConfigChanged(ConfigChanged event) FarmingConfigChangeHandler.handleFarmingEnumConfigChange(event, HARDWOOD_TREE_SAPLING, HardwoodTreeSapling.class, this::updateHardwoodTreeSapling, HardwoodTreeSapling.TEAK, configManager, questHelperPlugin); - if (event.getKey().equals(GRACEFUL_OR_FARMING)) + if (event.getKey().equals(GRACEFUL_OR_FARMING) || event.getKey().equals(PAY_OR_CUT) || event.getKey().equals(PAY_OR_COMPOST)) { questHelperPlugin.refreshBank(); } } + private final String TREE_SAPLING = "treeSaplings"; + private final String FRUIT_TREE_SAPLING = "fruitTreeSaplings"; + private final String HARDWOOD_TREE_SAPLING = "hardwoodTreeSaplings"; @Override public List getConfigs() @@ -861,13 +671,15 @@ public List getConfigs() HelperConfig fruitTreesConfig = new HelperConfig("Fruit Trees", FRUIT_TREE_SAPLING, FruitTreeSapling.values()); HelperConfig hardwoodTreesConfig = new HelperConfig("Hardwood Trees", HARDWOOD_TREE_SAPLING, HardwoodTreeSapling.values()); HelperConfig outfitConfig = new HelperConfig("Outfit", GRACEFUL_OR_FARMING, GracefulOrFarming.values()); - return Arrays.asList(treesConfig, fruitTreesConfig, hardwoodTreesConfig, outfitConfig); + HelperConfig payOrCutConfig = new HelperConfig("Pay or cut tree removal", PAY_OR_CUT, PayOrCut.values()); + HelperConfig payOrCompostConfig = new HelperConfig("Pay farmer or compost", PAY_OR_COMPOST, PayOrCompost.values()); + return Arrays.asList(treesConfig, fruitTreesConfig, hardwoodTreesConfig, outfitConfig, payOrCutConfig, payOrCompostConfig); } @Override public List getItemRequirements() { - return Arrays.asList(spade, rake, coins, allTreeSaplings, allFruitSaplings, hardwoodSapling); + return Arrays.asList(spade, rake, compost, coins, allTreeSaplings, allFruitSaplings, allHardwoodSaplings); } @Override @@ -880,41 +692,19 @@ public List getItemRecommended() public List getPanels() { List allSteps = new ArrayList<>(); - allSteps.add(new PanelDetails("Farming Guild", Arrays.asList(farmingGuildTreePatchCheckHealth, farmingGuildTreePatchClear, farmingGuildFruitTreePatchCheckHealth, farmingGuildFruitTreePatchClear), - Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), - Arrays.asList(gracefulOutfit, farmersOutfit, farmingGuildTeleport))); - allSteps.add(new PanelDetails("Lumbridge", Arrays.asList(lumbridgeTreePatchCheckHealth, lumbridgeTreePatchClear), - Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), - Arrays.asList(gracefulOutfit, farmersOutfit, lumbridgeTeleport))); - allSteps.add(new PanelDetails("Falador", Arrays.asList(faladorTreePatchCheckHealth, faladorTreePatchClear), - Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), - Arrays.asList(gracefulOutfit, farmersOutfit, faladorTeleport))); - allSteps.add(new PanelDetails("Taverley", Arrays.asList(taverleyTreePatchCheckHealth, taverleyTreePatchClear), - Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), - Arrays.asList(gracefulOutfit, farmersOutfit))); - allSteps.add(new PanelDetails("Varrock", Arrays.asList(varrockTreePatchCheckHealth, varrockTreePatchClear), - Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), - Arrays.asList(gracefulOutfit, farmersOutfit, varrockTeleport))); - allSteps.add(new PanelDetails("Gnome Stronghold", Arrays.asList(gnomeVillageFruitTreePatchCheckHealth, gnomeVillageFruitTreePatchClear, gnomeStrongholdTreePatchCheckHealth, gnomeStrongholdTreePatchClear), - Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), - Arrays.asList(gracefulOutfit, farmersOutfit))); - allSteps.add(new PanelDetails("Tree Gnome Village", Arrays.asList(gnomeVillageFruitTreePatchCheckHealth, gnomeVillageFruitTreePatchClear), - Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), - Arrays.asList(gracefulOutfit, farmersOutfit))); - allSteps.add(new PanelDetails("Catherby", Arrays.asList(catherbyFruitTreePatchCheckHealth, catherbyFruitTreePatchClear), - Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), - Arrays.asList(gracefulOutfit, farmersOutfit, catherbyTeleport))); - allSteps.add(new PanelDetails("Brimhaven", Arrays.asList(brimhavenFruitTreePatchCheckHealth, brimhavenFruitTreePatchClear), - Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), - Arrays.asList(gracefulOutfit, farmersOutfit))); - allSteps.add(new PanelDetails("Llyeta", Arrays.asList(lletyaFruitTreePatchCheckHealth, lletyaFruitTreePatchClear), - Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), - Arrays.asList(gracefulOutfit, farmersOutfit))); + allSteps.add(new PanelDetails("Farming Guild", Arrays.asList(farmingGuildTreePatchCheckHealth, farmingGuildTreePatchClear, farmingGuildFruitTreePatchCheckHealth, farmingGuildFruitTreePatchClear))); + allSteps.add(new PanelDetails("Lumbridge", Arrays.asList(lumbridgeTreePatchCheckHealth, lumbridgeTreePatchClear))); + allSteps.add(new PanelDetails("Falador", Arrays.asList(faladorTreePatchCheckHealth, faladorTreePatchClear))); + allSteps.add(new PanelDetails("Taverley", Arrays.asList(taverleyTreePatchCheckHealth, taverleyTreePatchClear))); + allSteps.add(new PanelDetails("Varrock", Arrays.asList(varrockTreePatchCheckHealth, varrockTreePatchClear))); + allSteps.add(new PanelDetails("Gnome Stronghold", Arrays.asList(gnomeVillageFruitTreePatchCheckHealth, gnomeVillageFruitTreePatchClear, gnomeStrongholdTreePatchCheckHealth, gnomeStrongholdTreePatchClear))); + allSteps.add(new PanelDetails("Tree Gnome Village", Arrays.asList(gnomeVillageFruitTreePatchCheckHealth, gnomeVillageFruitTreePatchClear))); + allSteps.add(new PanelDetails("Catherby", Arrays.asList(catherbyFruitTreePatchCheckHealth, catherbyFruitTreePatchClear))); + allSteps.add(new PanelDetails("Brimhaven", Arrays.asList(brimhavenFruitTreePatchCheckHealth, brimhavenFruitTreePatchClear))); + allSteps.add(new PanelDetails("Llyeta", Arrays.asList(lletyaFruitTreePatchCheckHealth, lletyaFruitTreePatchClear))); allSteps.add(new PanelDetails("Fossil Island", Arrays.asList(eastHardwoodTreePatchCheckHealth, eastHardwoodTreePatchClear, middleHardwoodTreePatchCheckHealth, middleHardwoodTreePatchClear, - westHardwoodTreePatchCheckHealth, westHardwoodTreePatchClear), - Arrays.asList(spade, rake, coins, treeSapling, fruitTreeSapling, hardwoodSapling), - Arrays.asList(gracefulOutfit, farmersOutfit, fossilIslandTeleport))); + westHardwoodTreePatchCheckHealth, westHardwoodTreePatchClear))); return allSteps; } From a106d32b3836c4444126460948a8e111da26738b Mon Sep 17 00:00:00 2001 From: Zoinkwiz Date: Thu, 6 Jun 2024 17:47:52 +0100 Subject: [PATCH 16/20] Fix farming item display reqs for bank --- .../banktab/QuestHelperBankTagService.java | 11 +- .../farmruns/FarmingConfigChangeHandler.java | 24 +++ .../mischelpers/farmruns/FarmingUtils.java | 37 ++++- .../mischelpers/farmruns/PatchStates.java | 24 +++ .../helpers/mischelpers/farmruns/TreeRun.java | 155 ++++++++++++++---- .../tools/QuestHelperWorldMapPoint.java | 1 - 6 files changed, 214 insertions(+), 38 deletions(-) diff --git a/src/main/java/com/questhelper/bank/banktab/QuestHelperBankTagService.java b/src/main/java/com/questhelper/bank/banktab/QuestHelperBankTagService.java index de7f07a1bc..917d330cff 100644 --- a/src/main/java/com/questhelper/bank/banktab/QuestHelperBankTagService.java +++ b/src/main/java/com/questhelper/bank/banktab/QuestHelperBankTagService.java @@ -150,9 +150,18 @@ public ArrayList getPluginBankTagItemsForSections(boolean onlyGetM { BankTabItems allRequiredItems = new BankTabItems("Required items"); List allRequired = plugin.getSelectedQuest().getItemRequirements(); + List items; if (allRequired != null && allRequired.size() > 0) { - allRequired.forEach(item -> getItemsFromRequirement(allRequiredItems.getItems(), item, item)); + items = allRequired.stream() + .filter(Objects::nonNull) + .map(ItemRequirement.class::cast) + .filter(i -> (!onlyGetMissingItems + || !i.check(plugin.getClient(), false, questBank.getBankItems())) + && i.shouldDisplayText(plugin.getClient())) + .collect(Collectors.toList()); + + items.forEach(item -> getItemsFromRequirement(allRequiredItems.getItems(), item, item)); } newList.add(allRequiredItems); } diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java index 3f06cee83a..53e6ee3682 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java @@ -1,3 +1,27 @@ +/* + * Copyright (c) 2024, Kerpackie + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package com.questhelper.helpers.mischelpers.farmruns; import com.questhelper.QuestHelperConfig; diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java index 3575453eee..6ec32a6dc4 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingUtils.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2024, Zoinkwiz + * Copyright (c) 2024, Kerpackie + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package com.questhelper.helpers.mischelpers.farmruns; import com.questhelper.QuestHelperConfig; @@ -98,16 +123,22 @@ public static boolean getPatchState(Client client, int[] patchStates, int varbit return false; } - public static String getEnumFromConfig(ConfigManager configManager, ConfigEnum configEnum) + public static ConfigEnum getEnumFromConfig(ConfigManager configManager, ConfigEnum configEnum) { try { - return configManager.getRSProfileConfiguration(QuestHelperConfig.QUEST_BACKGROUND_GROUP, configEnum.getConfigKey()); + ConfigEnum fetchedEnum = configManager.getRSProfileConfiguration(QuestHelperConfig.QUEST_BACKGROUND_GROUP, configEnum.getConfigKey(), configEnum.getClass()); + if (fetchedEnum == null) + { + configManager.setRSProfileConfiguration(QuestHelperConfig.QUEST_BACKGROUND_GROUP, configEnum.getDefault().getConfigKey(), configEnum.getDefault()); + return configEnum.getDefault(); + } + return configManager.getRSProfileConfiguration(QuestHelperConfig.QUEST_BACKGROUND_GROUP, configEnum.getConfigKey(), configEnum.getClass()); } catch (Exception err) { configManager.setRSProfileConfiguration(QuestHelperConfig.QUEST_BACKGROUND_GROUP, configEnum.getDefault().getConfigKey(), configEnum.getDefault()); - return null; + return configEnum.getDefault(); } } diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchStates.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchStates.java index 5d700ce9e5..15ab6206b1 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchStates.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchStates.java @@ -1,3 +1,27 @@ +/* + * Copyright (c) 2024, Zoinkwiz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package com.questhelper.helpers.mischelpers.farmruns; import com.questhelper.requirements.ManualRequirement; diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java index b0b2df84b3..a4557090f3 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2024, Zoinkwiz + * Copyright (c) 2024, Kerpackie + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package com.questhelper.helpers.mischelpers.farmruns; import com.google.inject.Inject; @@ -42,7 +67,6 @@ import net.runelite.client.events.ConfigChanged; import net.runelite.client.game.ItemManager; import net.runelite.client.plugins.timetracking.Tab; -import net.runelite.client.util.Text; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -97,7 +121,8 @@ public class TreeRun extends ComplexStateQuestHelper DetailedQuestStep eastHardwoodTreePatchClear, westHardwoodTreePatchClear, middleHardwoodTreePatchClear; // Farming Items - ItemRequirement coins, spade, rake, allTreeSaplings, treeSapling, allFruitSaplings, fruitTreeSapling, allHardwoodSaplings, hardwoodSapling, compost, axe, protectionItemTree, protectionItemFruitTree, protectionItemHardwood; + ItemRequirement coins, spade, rake, allTreeSaplings, treeSapling, allFruitSaplings, fruitTreeSapling, allHardwoodSaplings, hardwoodSapling, compost, axe, + protectionItemTree, allProtectionItemTree, protectionItemFruitTree, allProtectionItemFruitTree, protectionItemHardwood, allProtectionItemHardwood; // Teleport Items // TODO: Add these... @@ -112,6 +137,8 @@ public class TreeRun extends ComplexStateQuestHelper // Access Requirements Requirement accessToFarmingGuildTreePatch, accessToFarmingGuildFruitTreePatch, accessToLletya, accessToFossilIsland; + Requirement payingForRemoval, payingForProtection, usingCompost; + PatchStates faladorStates, lumbridgeStates, farmingGuildTreeStates, taverleyStates, varrockStates, gnomeStrongholdTreeStates; PatchStates gnomeStrongholdFruitStates, gnomeVillageStates, brimhavenStates, catherbyStates, lletyaStates, farmingGuildFruitStates; @@ -125,13 +152,11 @@ public class TreeRun extends ComplexStateQuestHelper @Override public QuestStep loadStep() { - farmingHandler = new FarmingHandler(client, configManager); - setupRequirements(); - setupConditions(); setupSteps(); + farmingHandler = new FarmingHandler(client, configManager); ConditionalStep steps = new ConditionalStep(this, waitForTree, spade, coins, rake, compost, treeSapling, - fruitTreeSapling, hardwoodSapling, farmersOutfit, gracefulOutfit); + fruitTreeSapling, hardwoodSapling, farmersOutfit, gracefulOutfit, protectionItemTree, protectionItemFruitTree, protectionItemHardwood); // Farming Guild Tree -> Farming Guild Fruit Tree -> Lumbridge -> Falador -> Taverley // Varrock -> Gnome Stronghold Fruit -> Gnome Stronghold Tree -> Gnome Village -> Brimhaven @@ -250,41 +275,49 @@ private void setupConditions() westHardwoodStates = new PatchStates("Fossil Island", "West"); middleHardwoodStates = new PatchStates("Fossil Island", "Middle"); eastHardwoodStates = new PatchStates("Fossil Island", "East"); + + payingForRemoval = new RuneliteRequirement(configManager, PAY_OR_CUT, PayOrCut.PAY.name()); + payingForProtection = new RuneliteRequirement(configManager, PAY_OR_COMPOST, PayOrCompost.PAY.name()); + usingCompost = new RuneliteRequirement(configManager, PAY_OR_COMPOST, PayOrCompost.COMPOST.name()); } @Override public void setupRequirements() { + setupConditions(); // Farming Item Requirements spade = new ItemRequirement("Spade", ItemID.SPADE); rake = new ItemRequirement("Rake", ItemID.RAKE) .hideConditioned(new VarbitRequirement(Varbits.AUTOWEED, 2)); coins = new ItemRequirement("Coins to quickly remove trees.", ItemID.COINS_995) - .showConditioned(new RuneliteRequirement(configManager, PAY_OR_CUT, PayOrCut.PAY.name())); + .showConditioned(payingForRemoval); axe = new ItemRequirement("Any axe you can use", ItemCollections.AXES); - TreeSapling treeSaplingEnum = TreeSapling.valueOf(FarmingUtils.getEnumFromConfig(configManager, TreeSapling.MAGIC)); + TreeSapling treeSaplingEnum = (TreeSapling) FarmingUtils.getEnumFromConfig(configManager, TreeSapling.MAGIC); treeSapling = treeSaplingEnum.getPlantableItemRequirement(itemManager); treeSapling.setHighlightInInventory(true); allTreeSaplings = treeSapling.copy(); - protectionItemTree = treeSaplingEnum.getProtectionItemRequirement(itemManager); + protectionItemTree = treeSaplingEnum.getProtectionItemRequirement(itemManager).showConditioned(payingForProtection); + allProtectionItemTree = protectionItemTree.copy(); - FruitTreeSapling fruitTreeSaplingEnum = FruitTreeSapling.valueOf(FarmingUtils.getEnumFromConfig(configManager, FruitTreeSapling.APPLE)); + FruitTreeSapling fruitTreeSaplingEnum = (FruitTreeSapling) FarmingUtils.getEnumFromConfig(configManager, FruitTreeSapling.APPLE); fruitTreeSapling = fruitTreeSaplingEnum.getPlantableItemRequirement(itemManager); fruitTreeSapling.setHighlightInInventory(true); allFruitSaplings = fruitTreeSapling.copy(); - protectionItemFruitTree = fruitTreeSaplingEnum.getProtectionItemRequirement(itemManager); + protectionItemFruitTree = fruitTreeSaplingEnum.getProtectionItemRequirement(itemManager).showConditioned(payingForProtection); + allProtectionItemFruitTree = protectionItemFruitTree.copy(); - HardwoodTreeSapling hardwoodTreeSaplingEnum = HardwoodTreeSapling.valueOf(FarmingUtils.getEnumFromConfig(configManager, HardwoodTreeSapling.TEAK)); + HardwoodTreeSapling hardwoodTreeSaplingEnum = (HardwoodTreeSapling) FarmingUtils.getEnumFromConfig(configManager, HardwoodTreeSapling.TEAK); hardwoodSapling = hardwoodTreeSaplingEnum.getPlantableItemRequirement(itemManager); hardwoodSapling.setHighlightInInventory(true); allHardwoodSaplings = hardwoodSapling.copy(); - protectionItemHardwood = hardwoodTreeSaplingEnum.getProtectionItemRequirement(itemManager); + protectionItemHardwood = hardwoodTreeSaplingEnum.getProtectionItemRequirement(itemManager).showConditioned(payingForProtection); + allProtectionItemHardwood = protectionItemHardwood.copy(); - compost = new ItemRequirement("Compost", ItemCollections.COMPOST); + compost = new ItemRequirement("Compost", ItemCollections.COMPOST).showConditioned(usingCompost); compost.setDisplayMatchedItemName(true); // Teleport Items @@ -593,17 +626,24 @@ private void setupSteps() eastHardwoodTreePatchClear.addSubSteps(eastHardwoodTreePatchDig); } - @Subscribe public void onGameTick(GameTick event) { coins.setQuantity(0); - handleTreePatches(PatchImplementation.TREE, List.of(farmingGuildTreeStates), farmingWorld.getTabs().get(Tab.TREE), allTreeSaplings); - handleTreePatches(PatchImplementation.FRUIT_TREE, List.of(farmingGuildTreeStates), farmingWorld.getTabs().get(Tab.FRUIT_TREE), allFruitSaplings); - handleTreePatches(PatchImplementation.HARDWOOD_TREE, List.of(farmingGuildTreeStates), farmingWorld.getTabs().get(Tab.TREE), allHardwoodSaplings); + allProtectionItemTree.setQuantity(protectionItemTree.getQuantity()); + allProtectionItemFruitTree.setQuantity(protectionItemFruitTree.getQuantity()); + allProtectionItemHardwood.setQuantity(protectionItemHardwood.getQuantity()); + handleTreePatches(PatchImplementation.TREE, + List.of(farmingGuildTreeStates, varrockStates, faladorStates, taverleyStates, lumbridgeStates, gnomeStrongholdTreeStates), + farmingWorld.getTabs().get(Tab.TREE), allTreeSaplings, allProtectionItemTree); + handleTreePatches(PatchImplementation.FRUIT_TREE, + List.of(farmingGuildTreeStates, brimhavenStates, catherbyStates, gnomeStrongholdFruitStates, gnomeVillageStates, lletyaStates), + farmingWorld.getTabs().get(Tab.FRUIT_TREE), allFruitSaplings, allProtectionItemFruitTree); + handleTreePatches(PatchImplementation.HARDWOOD_TREE, List.of(westHardwoodStates, middleHardwoodStates, eastHardwoodStates), + farmingWorld.getTabs().get(Tab.TREE), allHardwoodSaplings, allProtectionItemHardwood); } - public void handleTreePatches(PatchImplementation implementation, List regions, Set patches, ItemRequirement allSaplings) + public void handleTreePatches(PatchImplementation implementation, List regions, Set patches, ItemRequirement allSaplings, ItemRequirement allPayment) { int numberOfSaplings = 0; for (FarmingPatch patch : patches) @@ -639,6 +679,7 @@ public void handleTreePatches(PatchImplementation implementation, List { - questHelperPlugin.refreshBank(); - } + FarmingConfigChangeHandler.handleFarmingEnumConfigChange(event, TREE_SAPLING, TreeSapling.class, + this::updateTreeSapling, TreeSapling.OAK, configManager, questHelperPlugin); + FarmingConfigChangeHandler.handleFarmingEnumConfigChange(event, FRUIT_TREE_SAPLING, FruitTreeSapling.class, + this::updateFruitTreeSapling, FruitTreeSapling.APPLE, configManager, questHelperPlugin); + FarmingConfigChangeHandler.handleFarmingEnumConfigChange(event, HARDWOOD_TREE_SAPLING, HardwoodTreeSapling.class, + this::updateHardwoodTreeSapling, HardwoodTreeSapling.TEAK, configManager, questHelperPlugin); + + if (event.getKey().equals(GRACEFUL_OR_FARMING) || event.getKey().equals(PAY_OR_CUT) || event.getKey().equals(PAY_OR_COMPOST)) + { + questHelperPlugin.refreshBank(); + } + }); } private final String TREE_SAPLING = "treeSaplings"; private final String FRUIT_TREE_SAPLING = "fruitTreeSaplings"; @@ -679,7 +723,7 @@ public List getConfigs() @Override public List getItemRequirements() { - return Arrays.asList(spade, rake, compost, coins, allTreeSaplings, allFruitSaplings, allHardwoodSaplings); + return Arrays.asList(spade, rake, compost, coins, allTreeSaplings, allFruitSaplings, allHardwoodSaplings, allProtectionItemTree, allProtectionItemFruitTree, allProtectionItemHardwood); } @Override @@ -712,18 +756,63 @@ public List getPanels() private void updateTreeSapling(TreeSapling selectedTreeSapling) { treeSapling.setId(selectedTreeSapling.treeSaplingID); - treeSapling.setName(Text.titleCase(selectedTreeSapling) + " sapling"); + treeSapling.setName(itemManager.getItemComposition(selectedTreeSapling.getPlantableItemId()).getName()); + + allTreeSaplings.setId(selectedTreeSapling.treeSaplingID); + allTreeSaplings.setName(itemManager.getItemComposition(selectedTreeSapling.getPlantableItemId()).getName()); + updateTreePaymentItem(selectedTreeSapling); } private void updateFruitTreeSapling(FruitTreeSapling selectedFruitTreeSapling) { fruitTreeSapling.setId(selectedFruitTreeSapling.fruitTreeSaplingId); - fruitTreeSapling.setName(Text.titleCase(selectedFruitTreeSapling) + " sapling"); + fruitTreeSapling.setName(itemManager.getItemComposition(selectedFruitTreeSapling.getPlantableItemId()).getName()); + + allFruitSaplings.setId(selectedFruitTreeSapling.fruitTreeSaplingId); + allFruitSaplings.setName(itemManager.getItemComposition(selectedFruitTreeSapling.getPlantableItemId()).getName()); + updateFruitTreePaymentItem(selectedFruitTreeSapling); } private void updateHardwoodTreeSapling(HardwoodTreeSapling selectedHardwoodTreeSapling) { hardwoodSapling.setId(selectedHardwoodTreeSapling.hardwoodTreeSaplingId); - hardwoodSapling.setName(Text.titleCase(selectedHardwoodTreeSapling) + " sapling"); + hardwoodSapling.setName(itemManager.getItemComposition(selectedHardwoodTreeSapling.getPlantableItemId()).getName()); + + allHardwoodSaplings.setId(selectedHardwoodTreeSapling.hardwoodTreeSaplingId); + allHardwoodSaplings.setName(itemManager.getItemComposition(selectedHardwoodTreeSapling.getPlantableItemId()).getName()); + updateHardwoodTreePaymentItem(selectedHardwoodTreeSapling); + } + + private void updateTreePaymentItem(TreeSapling treeSapling) + { + protectionItemTree.setId(treeSapling.protectionItemId); + protectionItemTree.setName(itemManager.getItemComposition(treeSapling.protectionItemId).getName()); + protectionItemTree.setQuantity(treeSapling.protectionItemQuantity); + + allProtectionItemTree.setId(treeSapling.protectionItemId); + allProtectionItemTree.setName(itemManager.getItemComposition(treeSapling.protectionItemId).getName()); + allProtectionItemTree.setQuantity(treeSapling.protectionItemQuantity); + } + + private void updateFruitTreePaymentItem(FruitTreeSapling treeSapling) + { + protectionItemFruitTree.setId(treeSapling.protectionItemId); + protectionItemFruitTree.setName(itemManager.getItemComposition(treeSapling.protectionItemId).getName()); + protectionItemFruitTree.setQuantity(treeSapling.protectionItemQuantity); + + allProtectionItemFruitTree.setId(treeSapling.protectionItemId); + allProtectionItemFruitTree.setName(itemManager.getItemComposition(treeSapling.protectionItemId).getName()); + allProtectionItemFruitTree.setQuantity(treeSapling.protectionItemQuantity); + } + + private void updateHardwoodTreePaymentItem(HardwoodTreeSapling treeSapling) + { + protectionItemHardwood.setId(treeSapling.protectionItemId); + protectionItemHardwood.setName(itemManager.getItemComposition(treeSapling.protectionItemId).getName()); + protectionItemHardwood.setQuantity(treeSapling.protectionItemQuantity); + + allProtectionItemHardwood.setId(treeSapling.protectionItemId); + allProtectionItemHardwood.setName(itemManager.getItemComposition(treeSapling.protectionItemId).getName()); + allProtectionItemHardwood.setQuantity(treeSapling.protectionItemQuantity); } } diff --git a/src/main/java/com/questhelper/tools/QuestHelperWorldMapPoint.java b/src/main/java/com/questhelper/tools/QuestHelperWorldMapPoint.java index 71f0613315..65702b296a 100644 --- a/src/main/java/com/questhelper/tools/QuestHelperWorldMapPoint.java +++ b/src/main/java/com/questhelper/tools/QuestHelperWorldMapPoint.java @@ -80,7 +80,6 @@ public QuestHelperWorldMapPoint(final WorldPoint worldPoint, BufferedImage image public void onWorldMapAreaChanged(WorldMapAreaChanged worldMapAreaChanged) { - System.out.println(worldMapArea); if (worldMapArea != null && worldMapArea != WorldMapArea.ANY && worldMapArea != worldMapAreaChanged.getWorldMapArea()) From 0acdcd8c58027b5f819fc699f5f32da49019947a Mon Sep 17 00:00:00 2001 From: Zoinkwiz Date: Thu, 6 Jun 2024 19:23:41 +0100 Subject: [PATCH 17/20] Fix various state issues with the Tree Run --- .../farmruns/FarmingConfigChangeHandler.java | 1 - .../mischelpers/farmruns/FarmingHandler.java | 15 +- .../mischelpers/farmruns/FarmingPatch.java | 1 - .../mischelpers/farmruns/FarmingWorld.java | 9 + .../farmruns/PatchImplementation.java | 272 +++++++++--------- .../mischelpers/farmruns/PatchStates.java | 1 + .../mischelpers/farmruns/PaymentTracker.java | 196 +++++++++++++ .../helpers/mischelpers/farmruns/TreeRun.java | 175 ++++++++--- .../java/com/questhelper/steps/QuestStep.java | 5 + .../steps/widget/WidgetHighlight.java | 17 +- 10 files changed, 505 insertions(+), 187 deletions(-) create mode 100644 src/main/java/com/questhelper/helpers/mischelpers/farmruns/PaymentTracker.java diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java index 53e6ee3682..bb27f40773 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingConfigChangeHandler.java @@ -32,7 +32,6 @@ public class FarmingConfigChangeHandler { - public static > void handleFarmingEnumConfigChange(ConfigChanged event, String configKey, Class enumClass, Consumer updateAction, T defaultValue, ConfigManager configManager, QuestHelperPlugin questHelperPlugin) { diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingHandler.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingHandler.java index 1b73bc8c23..4096491dbc 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingHandler.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingHandler.java @@ -82,7 +82,14 @@ public CropState predictPatch(FarmingPatch patch, String profile) if (state == null) return null; if (state.getCropState() == CropState.EMPTY) return CropState.EMPTY; if (state.getProduce() == Produce.WEEDS) return CropState.EMPTY; - if (state.getCropState() == CropState.DEAD) return CropState.DEAD; + if (state.getCropState() == CropState.UNCHECKED) return CropState.UNCHECKED; + if (state.getCropState() == CropState.STUMP) return CropState.STUMP; + if (state.getCropState() == CropState.HARVESTABLE) + { + System.out.println(patch.getRegion().getName()); + System.out.println("HARVESTABLE"); + return CropState.HARVESTABLE; + } if (unixTime <= 0) { @@ -109,11 +116,7 @@ public CropState predictPatch(FarmingPatch patch, String profile) if (unixNow >= doneEstimate) { - if (state.getCropState() == CropState.GROWING) - { - - } - return CropState.HARVESTABLE; + return CropState.UNCHECKED; } return CropState.GROWING; diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingPatch.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingPatch.java index b557d786d5..ad02549c09 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingPatch.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingPatch.java @@ -58,7 +58,6 @@ class FarmingPatch this(name, varbit, implementation, farmer, -1); } - FarmingPatch(String name, @Varbit int varbit, PatchImplementation implementation, int farmer, int patchNumber) { this.name = name; diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingWorld.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingWorld.java index d96afdf06e..fcbc95093c 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingWorld.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingWorld.java @@ -29,6 +29,7 @@ import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; import com.google.inject.Singleton; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; @@ -36,6 +37,7 @@ import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; +import java.util.stream.Collectors; import lombok.Getter; import net.runelite.api.NpcID; import net.runelite.api.Varbits; @@ -352,4 +354,11 @@ private void add(FarmingRegion r, int... extraRegions) .add(p); } } + + Collection getRegionsForLocation(WorldPoint location) + { + return this.regions.get(location.getRegionID()).stream() + .filter(region -> region.isInBounds(location)) + .collect(Collectors.toSet()); + } } diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchImplementation.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchImplementation.java index f7cf0d73ad..e3325a92fc 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchImplementation.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchImplementation.java @@ -42,7 +42,7 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 3) { // Belladonna patch[Rake,Inspect,Guide] 7560,7559,7558,7557 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3 - value); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3 - value); } if (value >= 4 && value <= 7) { @@ -67,7 +67,7 @@ PatchState forVarbitValue(int value) if (value >= 15 && value <= 255) { // Belladonna patch[Rake,Inspect,Guide] 7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560,7560 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } return null; } @@ -80,7 +80,7 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 3) { // Mushroom patch[Rake,Inspect,Guide] 8314,8313,8312,8311 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3 - value); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3 - value); } if (value >= 4 && value <= 9) { @@ -105,7 +105,7 @@ PatchState forVarbitValue(int value) if (value >= 26 && value <= 255) { // Mushroom patch[Rake,Inspect,Guide] 8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314,8314 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } return null; } @@ -118,7 +118,7 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 3) { // Hespori patch[Rake,Inspect,Guide] 33722,33723,33724,33725 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3 - value); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3 - value); } if (value >= 4 && value <= 6) { @@ -133,7 +133,7 @@ PatchState forVarbitValue(int value) if (value == 9) { // Hespori patch[Rake,Inspect,Guide] 33722 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } return null; } @@ -146,12 +146,12 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 3) { // Allotment[Rake,Inspect,Guide] 8576,8575,8574,8573 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3 - value); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3 - value); } if (value >= 4 && value <= 5) { // Allotment[Rake,Inspect,Guide] 8576,8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 6 && value <= 9) { @@ -236,7 +236,7 @@ PatchState forVarbitValue(int value) if (value >= 74 && value <= 76) { // Allotment[Rake,Inspect,Guide] 8576,8576,8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 77 && value <= 80) { @@ -246,7 +246,7 @@ PatchState forVarbitValue(int value) if (value >= 81 && value <= 83) { // Allotment[Rake,Inspect,Guide] 8576,8576,8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 84 && value <= 87) { @@ -256,7 +256,7 @@ PatchState forVarbitValue(int value) if (value >= 88 && value <= 90) { // Allotment[Rake,Inspect,Guide] 8576,8576,8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 91 && value <= 94) { @@ -266,7 +266,7 @@ PatchState forVarbitValue(int value) if (value >= 95 && value <= 97) { // Allotment[Rake,Inspect,Guide] 8576,8576,8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 98 && value <= 103) { @@ -276,7 +276,7 @@ PatchState forVarbitValue(int value) if (value >= 104 && value <= 106) { // Allotment[Rake,Inspect,Guide] 8576,8576,8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 107 && value <= 112) { @@ -286,7 +286,7 @@ PatchState forVarbitValue(int value) if (value >= 113 && value <= 115) { // Allotment[Rake,Inspect,Guide] 8576,8576,8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 116 && value <= 123) { @@ -296,7 +296,7 @@ PatchState forVarbitValue(int value) if (value >= 124 && value <= 127) { // Allotment[Rake,Inspect,Guide] 8576,8576,8576,8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 128 && value <= 134) { @@ -316,7 +316,7 @@ PatchState forVarbitValue(int value) if (value == 141) { // Allotment[Rake,Inspect,Guide] 8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 142 && value <= 144) { @@ -326,7 +326,7 @@ PatchState forVarbitValue(int value) if (value >= 145 && value <= 148) { // Allotment[Rake,Inspect,Guide] 8576,8576,8576,8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 149 && value <= 151) { @@ -336,7 +336,7 @@ PatchState forVarbitValue(int value) if (value >= 152 && value <= 155) { // Allotment[Rake,Inspect,Guide] 8576,8576,8576,8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 156 && value <= 158) { @@ -346,7 +346,7 @@ PatchState forVarbitValue(int value) if (value >= 159 && value <= 162) { // Allotment[Rake,Inspect,Guide] 8576,8576,8576,8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 163 && value <= 167) { @@ -356,7 +356,7 @@ PatchState forVarbitValue(int value) if (value >= 168 && value <= 171) { // Allotment[Rake,Inspect,Guide] 8576,8576,8576,8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 172 && value <= 176) { @@ -366,7 +366,7 @@ PatchState forVarbitValue(int value) if (value >= 177 && value <= 180) { // Allotment[Rake,Inspect,Guide] 8576,8576,8576,8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 181 && value <= 187) { @@ -376,7 +376,7 @@ PatchState forVarbitValue(int value) if (value >= 188 && value <= 192) { // Allotment[Rake,Inspect,Guide] 8576,8576,8576,8576,8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 193 && value <= 195) { @@ -401,7 +401,7 @@ PatchState forVarbitValue(int value) if (value == 205) { // Allotment[Rake,Inspect,Guide] 8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 206 && value <= 208) { @@ -416,7 +416,7 @@ PatchState forVarbitValue(int value) if (value == 212) { // Allotment[Rake,Inspect,Guide] 8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 213 && value <= 215) { @@ -426,7 +426,7 @@ PatchState forVarbitValue(int value) if (value >= 216 && value <= 219) { // Allotment[Rake,Inspect,Guide] 8576,8576,8576,8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 220 && value <= 222) { @@ -436,7 +436,7 @@ PatchState forVarbitValue(int value) if (value >= 223 && value <= 226) { // Allotment[Rake,Inspect,Guide] 8576,8576,8576,8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 227 && value <= 231) { @@ -446,7 +446,7 @@ PatchState forVarbitValue(int value) if (value >= 232 && value <= 235) { // Allotment[Rake,Inspect,Guide] 8576,8576,8576,8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 236 && value <= 240) { @@ -456,7 +456,7 @@ PatchState forVarbitValue(int value) if (value >= 241 && value <= 244) { // Allotment[Rake,Inspect,Guide] 8576,8576,8576,8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 245 && value <= 251) { @@ -466,7 +466,7 @@ PatchState forVarbitValue(int value) if (value >= 252 && value <= 255) { // Allotment[Rake,Inspect,Guide] 8576,8576,8576,8576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } return null; } @@ -479,7 +479,7 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 3) { // Herb patch[Rake,Inspect,Guide] 8135,8134,8133,8132 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3 - value); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3 - value); } if (value >= 4 && value <= 7) { @@ -564,7 +564,7 @@ PatchState forVarbitValue(int value) if (value >= 60 && value <= 67) { // Herb patch[Rake,Inspect,Guide] 8135,8135,8135,8135,8135,8135,8135,8135 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 68 && value <= 71) { @@ -704,7 +704,7 @@ PatchState forVarbitValue(int value) if (value >= 173 && value <= 191) { // Herb patch[Rake,Inspect,Guide] 8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 192 && value <= 195) { @@ -729,12 +729,12 @@ PatchState forVarbitValue(int value) if (value >= 204 && value <= 219) { // Herb patch[Rake,Inspect,Guide] 8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 221 && value <= 255) { // Herb patch[Rake,Inspect,Guide] 8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135,8135 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } return null; } @@ -747,12 +747,12 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 3) { // Flower Patch[Rake,Inspect,Guide] 7843,7842,7841,7840 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3 - value); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3 - value); } if (value >= 4 && value <= 7) { // Flower Patch[Rake,Inspect,Guide] 7843,7843,7843,7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 8 && value <= 11) { @@ -827,7 +827,7 @@ PatchState forVarbitValue(int value) if (value >= 42 && value <= 71) { // Flower Patch[Rake,Inspect,Guide] 7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 72 && value <= 75) { @@ -837,7 +837,7 @@ PatchState forVarbitValue(int value) if (value == 76) { // Flower Patch[Rake,Inspect,Guide] 7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 77 && value <= 80) { @@ -847,7 +847,7 @@ PatchState forVarbitValue(int value) if (value == 81) { // Flower Patch[Rake,Inspect,Guide] 7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 82 && value <= 85) { @@ -857,7 +857,7 @@ PatchState forVarbitValue(int value) if (value == 86) { // Flower Patch[Rake,Inspect,Guide] 7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 87 && value <= 90) { @@ -867,7 +867,7 @@ PatchState forVarbitValue(int value) if (value == 91) { // Flower Patch[Rake,Inspect,Guide] 7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 92 && value <= 95) { @@ -877,7 +877,7 @@ PatchState forVarbitValue(int value) if (value >= 96 && value <= 100) { // Flower Patch[Rake,Inspect,Guide] 7843,7843,7843,7843,7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 101 && value <= 104) { @@ -887,7 +887,7 @@ PatchState forVarbitValue(int value) if (value >= 105 && value <= 136) { // Flower Patch[Rake,Inspect,Guide] 7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 137 && value <= 139) { @@ -897,7 +897,7 @@ PatchState forVarbitValue(int value) if (value >= 140 && value <= 141) { // Flower Patch[Rake,Inspect,Guide] 7843,7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 142 && value <= 144) { @@ -907,7 +907,7 @@ PatchState forVarbitValue(int value) if (value >= 145 && value <= 146) { // Flower Patch[Rake,Inspect,Guide] 7843,7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 147 && value <= 149) { @@ -917,7 +917,7 @@ PatchState forVarbitValue(int value) if (value >= 150 && value <= 151) { // Flower Patch[Rake,Inspect,Guide] 7843,7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 152 && value <= 154) { @@ -927,7 +927,7 @@ PatchState forVarbitValue(int value) if (value >= 155 && value <= 156) { // Flower Patch[Rake,Inspect,Guide] 7843,7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 157 && value <= 159) { @@ -937,7 +937,7 @@ PatchState forVarbitValue(int value) if (value >= 160 && value <= 165) { // Flower Patch[Rake,Inspect,Guide] 7843,7843,7843,7843,7843,7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 166 && value <= 168) { @@ -947,7 +947,7 @@ PatchState forVarbitValue(int value) if (value >= 169 && value <= 200) { // Flower Patch[Rake,Inspect,Guide] 7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 201 && value <= 204) { @@ -957,7 +957,7 @@ PatchState forVarbitValue(int value) if (value == 205) { // Flower Patch[Rake,Inspect,Guide] 7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 206 && value <= 209) { @@ -967,7 +967,7 @@ PatchState forVarbitValue(int value) if (value == 210) { // Flower Patch[Rake,Inspect,Guide] 7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 211 && value <= 214) { @@ -977,7 +977,7 @@ PatchState forVarbitValue(int value) if (value == 215) { // Flower Patch[Rake,Inspect,Guide] 7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 216 && value <= 219) { @@ -987,7 +987,7 @@ PatchState forVarbitValue(int value) if (value == 220) { // Flower Patch[Rake,Inspect,Guide] 7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 221 && value <= 224) { @@ -997,7 +997,7 @@ PatchState forVarbitValue(int value) if (value >= 225 && value <= 229) { // Flower Patch[Rake,Inspect,Guide] 7843,7843,7843,7843,7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 230 && value <= 233) { @@ -1007,7 +1007,7 @@ PatchState forVarbitValue(int value) if (value >= 234 && value <= 255) { // Flower Patch[Rake,Inspect,Guide] 7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843,7843 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } return null; } @@ -1020,12 +1020,12 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 3) { // Bush Patch[Rake,Inspect,Guide] 7576,7575,7574,7573 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3 - value); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3 - value); } if (value == 4) { // Bush Patch[Rake,Inspect,Guide] 7576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 5 && value <= 9) { @@ -1080,7 +1080,7 @@ PatchState forVarbitValue(int value) if (value >= 64 && value <= 69) { // Bush Patch[Rake,Inspect,Guide] 7576,7576,7576,7576,7576,7576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 70 && value <= 74) { @@ -1090,7 +1090,7 @@ PatchState forVarbitValue(int value) if (value >= 75 && value <= 79) { // Bush Patch[Rake,Inspect,Guide] 7576,7576,7576,7576,7576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 80 && value <= 85) { @@ -1100,7 +1100,7 @@ PatchState forVarbitValue(int value) if (value >= 86 && value <= 90) { // Bush Patch[Rake,Inspect,Guide] 7576,7576,7576,7576,7576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 91 && value <= 97) { @@ -1110,7 +1110,7 @@ PatchState forVarbitValue(int value) if (value >= 98 && value <= 102) { // Bush Patch[Rake,Inspect,Guide] 7576,7576,7576,7576,7576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 103 && value <= 110) { @@ -1120,7 +1120,7 @@ PatchState forVarbitValue(int value) if (value >= 111 && value <= 115) { // Bush Patch[Rake,Inspect,Guide] 7576,7576,7576,7576,7576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 116 && value <= 123) { @@ -1130,7 +1130,7 @@ PatchState forVarbitValue(int value) if (value >= 124 && value <= 133) { // Bush Patch[Rake,Inspect,Guide] 7576,7576,7576,7576,7576,7576,7576,7576,7576,7576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 134 && value <= 138) { @@ -1140,7 +1140,7 @@ PatchState forVarbitValue(int value) if (value >= 139 && value <= 143) { // Bush Patch[Rake,Inspect,Guide] 7576,7576,7576,7576,7576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 144 && value <= 149) { @@ -1150,7 +1150,7 @@ PatchState forVarbitValue(int value) if (value >= 150 && value <= 154) { // Bush Patch[Rake,Inspect,Guide] 7576,7576,7576,7576,7576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 155 && value <= 161) { @@ -1160,7 +1160,7 @@ PatchState forVarbitValue(int value) if (value >= 162 && value <= 166) { // Bush Patch[Rake,Inspect,Guide] 7576,7576,7576,7576,7576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 167 && value <= 174) { @@ -1170,7 +1170,7 @@ PatchState forVarbitValue(int value) if (value >= 175 && value <= 179) { // Bush Patch[Rake,Inspect,Guide] 7576,7576,7576,7576,7576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 180 && value <= 187) { @@ -1180,7 +1180,7 @@ PatchState forVarbitValue(int value) if (value >= 188 && value <= 196) { // Bush Patch[Rake,Inspect,Guide] 7576,7576,7576,7576,7576,7576,7576,7576,7576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 197 && value <= 204) { @@ -1210,7 +1210,7 @@ PatchState forVarbitValue(int value) if (value >= 226 && value <= 249) { // Bush Patch[Rake,Inspect,Guide] 7576,7576,7576,7576,7576,7576,7576,7576,7576,7576,7576,7576,7576,7576,7576,7576,7576,7576,7576,7576,7576,7576,7576,7576 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value == 250) { @@ -1253,12 +1253,12 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 3) { // Fruit Tree Patch[Rake,Inspect,Guide] 8050,8049,8048,8047 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3 - value); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3 - value); } if (value >= 4 && value <= 7) { // Fruit Tree Patch[Rake,Inspect,Guide] 8050,8050,8050,8050 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 8 && value <= 13) { @@ -1323,7 +1323,7 @@ PatchState forVarbitValue(int value) if (value >= 62 && value <= 71) { // Fruit Tree Patch[Rake,Inspect,Guide] 8050,8050,8050,8050,8050,8050,8050,8050,8050,8050 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 72 && value <= 77) { @@ -1393,7 +1393,7 @@ PatchState forVarbitValue(int value) if (value >= 126 && value <= 135) { // Fruit Tree Patch[Rake,Inspect,Guide] 8050,8050,8050,8050,8050,8050,8050,8050,8050,8050 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 136 && value <= 141) { @@ -1458,7 +1458,7 @@ PatchState forVarbitValue(int value) if (value >= 190 && value <= 199) { // Fruit Tree Patch[Rake,Inspect,Guide] 8050,8050,8050,8050,8050,8050,8050,8050,8050,8050 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 200 && value <= 205) { @@ -1523,7 +1523,7 @@ PatchState forVarbitValue(int value) if (value >= 254 && value <= 255) { // Fruit Tree Patch[Rake,Inspect,Guide] 8050,8050 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } return null; } @@ -1536,7 +1536,7 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 3) { // Hops Patch[Rake,Inspect,Guide] 8210,8209,8208,8207 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3 - value); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3 - value); } if (value >= 4 && value <= 7) { @@ -1611,7 +1611,7 @@ PatchState forVarbitValue(int value) if (value >= 64 && value <= 67) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 68 && value <= 71) { @@ -1621,7 +1621,7 @@ PatchState forVarbitValue(int value) if (value >= 72 && value <= 74) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 75 && value <= 79) { @@ -1631,7 +1631,7 @@ PatchState forVarbitValue(int value) if (value >= 80 && value <= 82) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 83 && value <= 88) { @@ -1641,7 +1641,7 @@ PatchState forVarbitValue(int value) if (value >= 89 && value <= 91) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 92 && value <= 98) { @@ -1651,7 +1651,7 @@ PatchState forVarbitValue(int value) if (value >= 99 && value <= 101) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 102 && value <= 109) { @@ -1661,7 +1661,7 @@ PatchState forVarbitValue(int value) if (value >= 110 && value <= 112) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 113 && value <= 116) { @@ -1671,7 +1671,7 @@ PatchState forVarbitValue(int value) if (value >= 117 && value <= 119) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 120 && value <= 124) { @@ -1681,7 +1681,7 @@ PatchState forVarbitValue(int value) if (value >= 125 && value <= 132) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210,8210,8210,8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 133 && value <= 135) { @@ -1691,7 +1691,7 @@ PatchState forVarbitValue(int value) if (value >= 136 && value <= 139) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 140 && value <= 143) { @@ -1701,7 +1701,7 @@ PatchState forVarbitValue(int value) if (value >= 144 && value <= 147) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 148 && value <= 152) { @@ -1711,7 +1711,7 @@ PatchState forVarbitValue(int value) if (value >= 153 && value <= 156) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 157 && value <= 162) { @@ -1721,7 +1721,7 @@ PatchState forVarbitValue(int value) if (value >= 163 && value <= 166) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 167 && value <= 173) { @@ -1731,7 +1731,7 @@ PatchState forVarbitValue(int value) if (value >= 174 && value <= 177) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 178 && value <= 180) { @@ -1741,12 +1741,12 @@ PatchState forVarbitValue(int value) if (value == 181) { // Hops Patch[Rake,Inspect,Guide] 8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 183 && value <= 184) { // Hops Patch[Rake,Inspect,Guide] 8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 185 && value <= 188) { @@ -1756,7 +1756,7 @@ PatchState forVarbitValue(int value) if (value >= 189 && value <= 196) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210,8210,8210,8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 197 && value <= 199) { @@ -1766,7 +1766,7 @@ PatchState forVarbitValue(int value) if (value >= 200 && value <= 203) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 204 && value <= 207) { @@ -1776,7 +1776,7 @@ PatchState forVarbitValue(int value) if (value >= 208 && value <= 211) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 212 && value <= 216) { @@ -1786,7 +1786,7 @@ PatchState forVarbitValue(int value) if (value >= 217 && value <= 220) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 221 && value <= 226) { @@ -1796,7 +1796,7 @@ PatchState forVarbitValue(int value) if (value >= 227 && value <= 230) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 231 && value <= 237) { @@ -1806,7 +1806,7 @@ PatchState forVarbitValue(int value) if (value >= 238 && value <= 241) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 242 && value <= 244) { @@ -1816,7 +1816,7 @@ PatchState forVarbitValue(int value) if (value >= 245 && value <= 248) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 249 && value <= 252) { @@ -1826,7 +1826,7 @@ PatchState forVarbitValue(int value) if (value >= 253 && value <= 255) { // Hops Patch[Rake,Inspect,Guide] 8210,8210,8210 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } return null; } @@ -1839,12 +1839,12 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 3) { // Tree patch[Rake,Inspect,Guide] 8395,8394,8393,8392 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3 - value); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3 - value); } if (value >= 4 && value <= 7) { // Tree patch[Rake,Inspect,Guide] 8395,8395,8395,8395 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 8 && value <= 11) { @@ -1949,7 +1949,7 @@ PatchState forVarbitValue(int value) if (value >= 63 && value <= 72) { // Tree patch[Rake,Inspect,Guide] 8395,8395,8395,8395,8395,8395,8395,8395,8395,8395 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 73 && value <= 75) { @@ -1964,7 +1964,7 @@ PatchState forVarbitValue(int value) if (value >= 78 && value <= 79) { // Tree patch[Rake,Inspect,Guide] 8395,8395 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 80 && value <= 84) { @@ -1979,7 +1979,7 @@ PatchState forVarbitValue(int value) if (value >= 87 && value <= 88) { // Tree patch[Rake,Inspect,Guide] 8395,8395 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 89 && value <= 95) { @@ -1994,7 +1994,7 @@ PatchState forVarbitValue(int value) if (value >= 98 && value <= 99) { // Tree patch[Rake,Inspect,Guide] 8395,8395 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 100 && value <= 108) { @@ -2009,7 +2009,7 @@ PatchState forVarbitValue(int value) if (value >= 111 && value <= 112) { // Tree patch[Rake,Inspect,Guide] 8395,8395 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 113 && value <= 123) { @@ -2024,7 +2024,7 @@ PatchState forVarbitValue(int value) if (value >= 126 && value <= 136) { // Tree patch[Rake,Inspect,Guide] 8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 137 && value <= 139) { @@ -2039,7 +2039,7 @@ PatchState forVarbitValue(int value) if (value >= 142 && value <= 143) { // Tree patch[Rake,Inspect,Guide] 8395,8395 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 144 && value <= 148) { @@ -2054,7 +2054,7 @@ PatchState forVarbitValue(int value) if (value >= 151 && value <= 152) { // Tree patch[Rake,Inspect,Guide] 8395,8395 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 153 && value <= 159) { @@ -2069,7 +2069,7 @@ PatchState forVarbitValue(int value) if (value >= 162 && value <= 163) { // Tree patch[Rake,Inspect,Guide] 8395,8395 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 164 && value <= 172) { @@ -2084,7 +2084,7 @@ PatchState forVarbitValue(int value) if (value >= 175 && value <= 176) { // Tree patch[Rake,Inspect,Guide] 8395,8395 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 177 && value <= 187) { @@ -2099,7 +2099,7 @@ PatchState forVarbitValue(int value) if (value >= 190 && value <= 191) { // Tree patch[Rake,Inspect,Guide] 8395,8395 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 192 && value <= 197) { @@ -2109,7 +2109,7 @@ PatchState forVarbitValue(int value) if (value >= 198 && value <= 255) { // Tree patch[Rake,Inspect,Guide] 8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395,8395 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } return null; } @@ -2122,12 +2122,12 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 3) { // Tree patch[Rake,Inspect,Guide] 30479,30478,30477,30476 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3 - value); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3 - value); } if (value >= 4 && value <= 7) { // Tree patch[Rake,Inspect,Guide] 30479,30479,30479,30479 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 8 && value <= 14) { @@ -2192,7 +2192,7 @@ PatchState forVarbitValue(int value) if (value >= 55 && value <= 255) { // Tree patch[Rake,Inspect,Guide] 30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479,30479 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } return null; } @@ -2205,12 +2205,12 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 3) { // Redwood tree patch[Rake,Inspect,Guide] 34050,34049,34048,34047 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3 - value); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3 - value); } if (value >= 4 && value <= 7) { // Redwood tree patch[Rake,Inspect,Guide] 34050,34050,34050,34050 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 8 && value <= 17) { @@ -2253,12 +2253,12 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 3) { // Spirit Tree Patch[Rake,Inspect,Guide] 8342,8341,8340,8339 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3 - value); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3 - value); } if (value >= 4 && value <= 7) { // Spirit Tree Patch[Rake,Inspect,Guide] 8342,8342,8342,8342 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 8 && value <= 19) { @@ -2288,7 +2288,7 @@ PatchState forVarbitValue(int value) if (value >= 45 && value <= 63) { // Spirit Tree Patch[Rake,Inspect,Guide] 8342,8342,8342,8342,8342,8342,8342,8342,8342,8342,8342,8342,8342,8342,8342,8342,8342,8342,8342 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } return null; } @@ -2301,12 +2301,12 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 3) { // Anima patch[Rake,Inspect,Guide] 33983,33982,33981,33980 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3 - value); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3 - value); } if (value >= 4 && value <= 7) { // Anima patch[Rake,Inspect,Guide] 33983,33983,33983,33983 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 8 && value <= 16) { @@ -2335,7 +2335,7 @@ PatchState forVarbitValue(int value) if (value >= 35 && value <= 255) { // Anima patch[Rake,Inspect,Guide] 33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983,33983 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } return null; } @@ -2348,12 +2348,12 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 3) { // Cactus patch[Rake,Inspect,Guide] 7746,7745,7744,7743 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3 - value); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3 - value); } if (value >= 4 && value <= 7) { // Cactus patch[Rake,Inspect,Guide] 7746,7746,7746,7746 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 8 && value <= 14) { @@ -2408,7 +2408,7 @@ PatchState forVarbitValue(int value) if (value >= 59 && value <= 255) { // Cactus patch[Rake,Inspect,Guide] 7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746,7746 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } return null; } @@ -2421,7 +2421,7 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 3) { // Seaweed patch[Rake,Inspect,Guide] 30486,30485,30484,30483 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3 - value); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3 - value); } if (value >= 4 && value <= 7) { @@ -2446,7 +2446,7 @@ PatchState forVarbitValue(int value) if (value >= 17 && value <= 255) { // Seaweed patch[Rake,Inspect,Guide] 30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486,30486 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } return null; } @@ -2459,7 +2459,7 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 3) { // Calquat patch[Rake,Inspect,Guide] 7775,7774,7773,7772 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3 - value); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3 - value); } if (value >= 4 && value <= 11) { @@ -2489,7 +2489,7 @@ PatchState forVarbitValue(int value) if (value >= 35 && value <= 255) { // Calquat patch[Rake,Inspect,Guide] 7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775,7775 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } return null; } @@ -2502,12 +2502,12 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 3) { // Celastrus patch[Rake,Inspect,Guide] 33698,33697,33696,33695 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3 - value); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3 - value); } if (value >= 4 && value <= 7) { // Celastrus patch[Rake,Inspect,Guide] 33698,33698,33698,33698 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 8 && value <= 12) { @@ -2547,7 +2547,7 @@ PatchState forVarbitValue(int value) if (value >= 29 && value <= 255) { // Celastrus patch[Rake,Inspect,Guide] 33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698,33698 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } return null; } @@ -2560,7 +2560,7 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 1) { // Empty, empty+fertilizer - return new PatchState(Produce.WEEDS, CropState.GROWING, 3); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3); } if (value >= 2 && value <= 9) { @@ -2585,7 +2585,7 @@ PatchState forVarbitValue(int value) if (value >= 0 && value <= 3) { // Crystal tree patch[Rake,Inspect,Guide] 34910,34909,34908,34907 - return new PatchState(Produce.WEEDS, CropState.GROWING, 3 - value); + return new PatchState(Produce.WEEDS, CropState.EMPTY, 3 - value); } if (value >= 8 && value <= 13) { diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchStates.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchStates.java index 15ab6206b1..f03e2f5e8b 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchStates.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchStates.java @@ -38,6 +38,7 @@ public class PatchStates private final ManualRequirement isEmpty = new ManualRequirement(); private final ManualRequirement isUnchecked = new ManualRequirement(); private final ManualRequirement isStump = new ManualRequirement(); + private final ManualRequirement isProtected = new ManualRequirement(); private final Requirement requirement; public PatchStates(String regionName) diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PaymentTracker.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PaymentTracker.java new file mode 100644 index 0000000000..320da5dd44 --- /dev/null +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PaymentTracker.java @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2022, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.questhelper.helpers.mischelpers.farmruns; + +import com.google.common.collect.ImmutableSet; +import java.util.Set; +import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import net.runelite.api.Client; +import net.runelite.api.MenuAction; +import net.runelite.api.ScriptID; +import net.runelite.api.events.GameTick; +import net.runelite.api.events.MenuOptionClicked; +import net.runelite.api.events.ScriptPreFired; +import net.runelite.api.widgets.ComponentID; +import net.runelite.api.widgets.Widget; +import net.runelite.api.widgets.WidgetModelType; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.plugins.timetracking.TimeTrackingConfig; + +@Slf4j +@RequiredArgsConstructor( + access = AccessLevel.PRIVATE, + onConstructor = @__({@Inject}) +) +@Singleton +public class PaymentTracker +{ + private static final Set PAYMENT_TEXT = ImmutableSet.of( + "That'll do nicely, sir. Leave it with me - I'll make sure
that patch grows for you.", + "That'll do nicely, madam. Leave it with me - I'll make
sure that patch grows for you.", + "That'll do nicely, iknami. Leave it with me - I'll make
sure that patch grows for you.", + "I'm already looking after that patch for you." + ); + + private final Client client; + private final ConfigManager configManager; + private final FarmingWorld farmingWorld; + + private int lastSelectedOption; + + @Subscribe + public void onGameTick(GameTick gameTick) + { + Widget text = client.getWidget(ComponentID.DIALOG_NPC_TEXT); + if (text == null || !PAYMENT_TEXT.contains(text.getText())) + { + return; + } + + Widget name = client.getWidget(ComponentID.DIALOG_NPC_NAME); + Widget head = client.getWidget(ComponentID.DIALOG_NPC_HEAD_MODEL); + if (name == null || head == null || head.getModelType() != WidgetModelType.NPC_CHATHEAD) + { + return; + } + + final int npcId = head.getModelId(); + final FarmingPatch patch = findPatchForNpc(npcId); + if (patch == null) + { + return; + } + + if (getProtectedState(patch)) + { + return; + } + + log.debug("Detected patch payment for {} ({}) patch {}", name.getText(), npcId, patch); + setProtectedState(patch, true); + } + + @Subscribe + public void onMenuOptionClicked(MenuOptionClicked opt) + { + var action = opt.getMenuAction(); + // look for resume_pausebutton from click + if (action == MenuAction.WIDGET_CONTINUE) + { + var w = opt.getWidget(); + if (w != null && w.getId() == ComponentID.DIALOG_OPTION_OPTIONS && w.getIndex() > -1 && isPatchOption(w.getText())) + { + lastSelectedOption = w.getIndex() - 1; // subid 0 is "Select an Option" + log.debug("Selected option via click: {}", lastSelectedOption); + } + } + // look for selecting the Pay NPC option + else if ((action == MenuAction.NPC_THIRD_OPTION || action == MenuAction.NPC_FOURTH_OPTION) && opt.getMenuOption().startsWith("Pay")) + { + lastSelectedOption = action == MenuAction.NPC_THIRD_OPTION ? 0 : 1; + log.debug("Selected option via npc op: {}", lastSelectedOption); + } + } + + @Subscribe + public void onScriptPreFired(ScriptPreFired scriptPreFired) + { + // look for resume_pausebutton from keypress + if (scriptPreFired.getScriptId() == ScriptID.CHATBOX_KEYINPUT_MATCHED) + { + int[] intStack = client.getIntStack(); + + int componentId = intStack[0]; + int subId = intStack[1]; + + var w = client.getWidget(componentId).getChild(subId); + if (componentId == ComponentID.DIALOG_OPTION_OPTIONS && subId > -1 && isPatchOption(w.getText())) + { + lastSelectedOption = subId - 1; // subid 0 is "Select an Option" + log.debug("Selected option via keypress: {}", lastSelectedOption); + } + } + } + + private static boolean isPatchOption(String name) + { + if (name == null) + { + return false; + } + + return name.contains("Patch") || name.contains("allotment"); + } + + private static String configKey(FarmingPatch fp) + { + return fp.configKey() + "." + TimeTrackingConfig.PROTECTED; + } + + void setProtectedState(FarmingPatch fp, boolean state) + { + if (!state) + { + configManager.unsetRSProfileConfiguration(TimeTrackingConfig.CONFIG_GROUP, configKey(fp)); + } + else + { + configManager.setRSProfileConfiguration(TimeTrackingConfig.CONFIG_GROUP, configKey(fp), state); + } + } + + boolean getProtectedState(FarmingPatch fp) + { + return Boolean.TRUE.equals(configManager.getRSProfileConfiguration( + TimeTrackingConfig.CONFIG_GROUP, + configKey(fp), + Boolean.class)); + } + + private FarmingPatch findPatchForNpc(int npcId) + { + FarmingPatch p = null; + for (FarmingRegion region : farmingWorld.getRegionsForLocation(client.getLocalPlayer().getWorldLocation())) + { + for (FarmingPatch patch : region.getPatches()) + { + if (patch.getFarmer() == npcId) + { + // lastSelectedOption is only valid when interacting with multi-patch farmers. + if (patch.getPatchNumber() == -1 || patch.getPatchNumber() == lastSelectedOption) + { + p = patch; + } + } + } + } + return p; + } +} diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java index a4557090f3..4d63444433 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java @@ -45,6 +45,8 @@ import com.questhelper.requirements.player.SkillRequirement; import com.questhelper.requirements.quest.QuestRequirement; import com.questhelper.requirements.runelite.RuneliteRequirement; +import static com.questhelper.requirements.util.LogicHelper.nor; +import static com.questhelper.requirements.util.LogicHelper.or; import com.questhelper.requirements.util.LogicType; import com.questhelper.requirements.var.VarbitRequirement; import com.questhelper.steps.ConditionalStep; @@ -74,16 +76,17 @@ /* * * TODO LIST: -* Add option for protection of items, have as config option. -* Add steps to highlight farmer for clearing. -* Config for chop or clear? -* PRIORITY: Add checked or notchecked checks, varbits used for patch checked status? +* Add last hardwood patch +* Add better direction for using spirit trees and such * */ public class TreeRun extends ComplexStateQuestHelper { @Inject private FarmingWorld farmingWorld; + @Inject + private PaymentTracker paymentTracker; + @Inject ItemManager itemManager; @@ -102,6 +105,8 @@ public class TreeRun extends ComplexStateQuestHelper DetailedQuestStep lumbridgeTreePatchDig, faladorTreePatchDig, taverleyTreePatchDig, varrockTreePatchDig, gnomeStrongholdTreePatchDig, farmingGuildTreePatchDig; + DetailedQuestStep farmingGuildTreePayForProtection, lumbridgeTreeProtect, faladorTreeProtect, taverleyTreeProtect, varrockTreeProtect, strongholdTreeProtect; + // Fruit Trees DetailedQuestStep farmingGuildFruitTreePatchCheckHealth, gnomeStrongholdFruitTreePatchCheckHealth, gnomeVillageFruitTreePatchCheckHealth, brimhavenFruitTreePatchCheckHealth, lletyaFruitTreePatchCheckHealth, catherbyFruitTreePatchCheckHealth; @@ -113,6 +118,9 @@ public class TreeRun extends ComplexStateQuestHelper DetailedQuestStep farmingGuildFruitTreePatchDig, gnomeStrongholdFruitTreePatchDig, gnomeVillageFruitTreePatchDig, brimhavenFruitTreePatchDig, lletyaFruitTreePatchDig, catherbyFruitTreePatchDig; + DetailedQuestStep guildFruitProtect, strongholdFruitProtect, villageFruitProtect, brimhavenFruitProtect, + lletyaFruitProtect, catherbyFruitProtect; + // Hardwood Trees DetailedQuestStep eastHardwoodTreePatchCheckHealth, westHardwoodTreePatchCheckHealth, middleHardwoodTreePatchCheckHealth; DetailedQuestStep eastHardwoodTreePatchPlant, westHardwoodTreePatchPlant, middleHardwoodTreePatchPlant; @@ -120,6 +128,8 @@ public class TreeRun extends ComplexStateQuestHelper DetailedQuestStep eastHardwoodTreePatchClear, westHardwoodTreePatchClear, middleHardwoodTreePatchClear; + DetailedQuestStep eastHardwoodProtect, westHardwoodProtect, middleHardwoodProtect; + // Farming Items ItemRequirement coins, spade, rake, allTreeSaplings, treeSapling, allFruitSaplings, fruitTreeSapling, allHardwoodSaplings, hardwoodSapling, compost, axe, protectionItemTree, allProtectionItemTree, protectionItemFruitTree, allProtectionItemFruitTree, protectionItemHardwood, allProtectionItemHardwood; @@ -137,7 +147,7 @@ public class TreeRun extends ComplexStateQuestHelper // Access Requirements Requirement accessToFarmingGuildTreePatch, accessToFarmingGuildFruitTreePatch, accessToLletya, accessToFossilIsland; - Requirement payingForRemoval, payingForProtection, usingCompost; + Requirement payingForRemoval, payingForProtection, usingCompostorNothing; PatchStates faladorStates, lumbridgeStates, farmingGuildTreeStates, taverleyStates, varrockStates, gnomeStrongholdTreeStates; @@ -167,76 +177,91 @@ public QuestStep loadStep() steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreeStates.getIsHarvestable()), farmingGuildTreePatchClear); steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreeStates.getIsStump()), farmingGuildTreePatchDig); steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreeStates.getIsEmpty()), farmingGuildTreePatchPlant); + steps.addStep(new Conditions(accessToFarmingGuildTreePatch, nor(farmingGuildTreeStates.getIsProtected(), usingCompostorNothing)), farmingGuildTreePayForProtection); steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitStates.getIsUnchecked()), farmingGuildFruitTreePatchCheckHealth); - steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitStates.getIsHarvestable()), farmingGuildTreePatchClear); - steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitStates.getIsStump()), farmingGuildFruitTreePatchPlant); - steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitStates.getIsEmpty()), farmingGuildTreePatchDig); + steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitStates.getIsHarvestable()), farmingGuildFruitTreePatchClear); + steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitStates.getIsStump()), farmingGuildTreePatchDig); + steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitStates.getIsEmpty()), farmingGuildTreePatchPlant); + steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, nor(farmingGuildFruitStates.getIsProtected(), usingCompostorNothing)), guildFruitProtect); steps.addStep(lumbridgeStates.getIsUnchecked(), lumbridgeTreePatchCheckHealth); steps.addStep(lumbridgeStates.getIsEmpty(), lumbridgeTreePatchPlant); steps.addStep(lumbridgeStates.getIsHarvestable(), lumbridgeTreePatchClear); steps.addStep(lumbridgeStates.getIsStump(), lumbridgeTreePatchDig); + steps.addStep(nor(usingCompostorNothing, lumbridgeStates.getIsProtected()), lumbridgeTreeProtect); steps.addStep(faladorStates.getIsUnchecked(), faladorTreePatchCheckHealth); steps.addStep(faladorStates.getIsEmpty(), faladorTreePatchPlant); steps.addStep(faladorStates.getIsHarvestable(), faladorTreePatchClear); steps.addStep(faladorStates.getIsStump(), faladorTreePatchDig); + steps.addStep(nor(usingCompostorNothing, faladorStates.getIsProtected()), faladorTreeProtect); steps.addStep(taverleyStates.getIsUnchecked(), taverleyTreePatchCheckHealth); steps.addStep(taverleyStates.getIsEmpty(), taverleyTreePatchPlant); steps.addStep(taverleyStates.getIsHarvestable(), taverleyTreePatchClear); steps.addStep(taverleyStates.getIsStump(), taverleyTreePatchDig); + steps.addStep(nor(usingCompostorNothing, taverleyStates.getIsProtected()), taverleyTreeProtect); steps.addStep(varrockStates.getIsUnchecked(), varrockTreePatchCheckHealth); steps.addStep(varrockStates.getIsEmpty(), varrockTreePatchPlant); steps.addStep(varrockStates.getIsHarvestable(), varrockTreePatchClear); steps.addStep(varrockStates.getIsStump(), varrockTreePatchDig); + steps.addStep(nor(usingCompostorNothing, varrockStates.getIsProtected()), varrockTreeProtect); steps.addStep(gnomeStrongholdFruitStates.getIsUnchecked(), gnomeStrongholdFruitTreePatchCheckHealth); steps.addStep(gnomeStrongholdFruitStates.getIsEmpty(), gnomeStrongholdFruitTreePatchPlant); steps.addStep(gnomeStrongholdFruitStates.getIsHarvestable(), gnomeStrongholdFruitTreePatchClear); steps.addStep(gnomeStrongholdFruitStates.getIsStump(), gnomeStrongholdFruitTreePatchDig); + steps.addStep(nor(usingCompostorNothing, gnomeStrongholdFruitStates.getIsProtected()), strongholdFruitProtect); steps.addStep(gnomeStrongholdTreeStates.getIsUnchecked(), gnomeStrongholdTreePatchCheckHealth); - steps.addStep(gnomeStrongholdTreeStates.getIsEmpty(), gnomeStrongholdFruitTreePatchPlant); + steps.addStep(gnomeStrongholdTreeStates.getIsEmpty(), gnomeStrongholdTreePatchPlant); steps.addStep(gnomeStrongholdTreeStates.getIsHarvestable(), gnomeStrongholdTreePatchClear); steps.addStep(gnomeStrongholdTreeStates.getIsStump(), gnomeStrongholdTreePatchDig); + steps.addStep(nor(usingCompostorNothing, gnomeStrongholdTreeStates.getIsProtected()), strongholdTreeProtect); steps.addStep(gnomeVillageStates.getIsUnchecked(), gnomeVillageFruitTreePatchCheckHealth); steps.addStep(gnomeVillageStates.getIsEmpty(), gnomeVillageFruitTreePatchPlant); steps.addStep(gnomeVillageStates.getIsHarvestable(), gnomeVillageFruitTreePatchClear); steps.addStep(gnomeVillageStates.getIsStump(), gnomeVillageFruitTreePatchDig); + steps.addStep(nor(usingCompostorNothing, gnomeVillageStates.getIsProtected()), villageFruitProtect); steps.addStep(brimhavenStates.getIsUnchecked(), brimhavenFruitTreePatchCheckHealth); steps.addStep(brimhavenStates.getIsEmpty(), brimhavenFruitTreePatchPlant); steps.addStep(brimhavenStates.getIsHarvestable(), brimhavenFruitTreePatchClear); steps.addStep(brimhavenStates.getIsStump(), brimhavenFruitTreePatchDig); + steps.addStep(nor(usingCompostorNothing, brimhavenStates.getIsProtected()), brimhavenFruitProtect); steps.addStep(catherbyStates.getIsUnchecked(), catherbyFruitTreePatchCheckHealth); steps.addStep(catherbyStates.getIsEmpty(), catherbyFruitTreePatchPlant); steps.addStep(catherbyStates.getIsHarvestable(), catherbyFruitTreePatchClear); steps.addStep(catherbyStates.getIsStump(), catherbyFruitTreePatchDig); + steps.addStep(nor(usingCompostorNothing, catherbyStates.getIsProtected()), catherbyFruitProtect); steps.addStep(new Conditions(accessToLletya, lletyaStates.getIsUnchecked()), lletyaFruitTreePatchCheckHealth); steps.addStep(new Conditions(accessToLletya, lletyaStates.getIsEmpty()), lletyaFruitTreePatchPlant); steps.addStep(new Conditions(accessToLletya, lletyaStates.getIsHarvestable()), lletyaFruitTreePatchClear); steps.addStep(new Conditions(accessToLletya, lletyaStates.getIsStump()), lletyaFruitTreePatchDig); + steps.addStep(new Conditions(accessToLletya, nor(usingCompostorNothing, lletyaStates.getIsProtected())), lletyaFruitProtect); steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodStates.getIsUnchecked()), eastHardwoodTreePatchCheckHealth); steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodStates.getIsEmpty()), eastHardwoodTreePatchPlant); steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodStates.getIsHarvestable()), eastHardwoodTreePatchClear); steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodStates.getIsStump()), eastHardwoodTreePatchDig); + steps.addStep(new Conditions(accessToFossilIsland,nor(usingCompostorNothing, eastHardwoodStates.getIsProtected())), eastHardwoodProtect); steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodStates.getIsUnchecked()), middleHardwoodTreePatchCheckHealth); steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodStates.getIsEmpty()), middleHardwoodTreePatchPlant); steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodStates.getIsHarvestable()), middleHardwoodTreePatchClear); steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodStates.getIsStump()), middleHardwoodTreePatchDig); + steps.addStep(new Conditions(accessToFossilIsland, nor(usingCompostorNothing, middleHardwoodStates.getIsProtected())), middleHardwoodProtect); steps.addStep(new Conditions(accessToFossilIsland, westHardwoodStates.getIsUnchecked()), westHardwoodTreePatchCheckHealth); steps.addStep(new Conditions(accessToFossilIsland, westHardwoodStates.getIsEmpty()), westHardwoodTreePatchPlant); steps.addStep(new Conditions(accessToFossilIsland, westHardwoodStates.getIsHarvestable()), westHardwoodTreePatchClear); steps.addStep(new Conditions(accessToFossilIsland, westHardwoodStates.getIsStump()), westHardwoodTreePatchDig); + steps.addStep(new Conditions(accessToFossilIsland, nor(usingCompostorNothing, westHardwoodStates.getIsProtected())), westHardwoodProtect); return steps; } @@ -261,7 +286,7 @@ private void setupConditions() faladorStates = new PatchStates("Falador"); taverleyStates = new PatchStates("Taverley"); varrockStates = new PatchStates("Varrock"); - gnomeStrongholdTreeStates = new PatchStates("Tree Gnome Stronghold"); + gnomeStrongholdTreeStates = new PatchStates("Gnome Stronghold"); farmingGuildTreeStates = new PatchStates("Farming Guild", accessToFarmingGuildFruitTreePatch); // Fruit trees @@ -278,7 +303,8 @@ private void setupConditions() payingForRemoval = new RuneliteRequirement(configManager, PAY_OR_CUT, PayOrCut.PAY.name()); payingForProtection = new RuneliteRequirement(configManager, PAY_OR_COMPOST, PayOrCompost.PAY.name()); - usingCompost = new RuneliteRequirement(configManager, PAY_OR_COMPOST, PayOrCompost.COMPOST.name()); + usingCompostorNothing = or(new RuneliteRequirement(configManager, PAY_OR_COMPOST, PayOrCompost.COMPOST.name()), + new RuneliteRequirement(configManager, PAY_OR_COMPOST, PayOrCompost.NEITHER.name())); } @Override @@ -299,6 +325,7 @@ public void setupRequirements() allTreeSaplings = treeSapling.copy(); protectionItemTree = treeSaplingEnum.getProtectionItemRequirement(itemManager).showConditioned(payingForProtection); + protectionItemTree.addAlternates(protectionItemTree.getId() + 1); allProtectionItemTree = protectionItemTree.copy(); FruitTreeSapling fruitTreeSaplingEnum = (FruitTreeSapling) FarmingUtils.getEnumFromConfig(configManager, FruitTreeSapling.APPLE); @@ -307,6 +334,7 @@ public void setupRequirements() allFruitSaplings = fruitTreeSapling.copy(); protectionItemFruitTree = fruitTreeSaplingEnum.getProtectionItemRequirement(itemManager).showConditioned(payingForProtection); + protectionItemFruitTree.addAlternates(protectionItemFruitTree.getId() + 1); allProtectionItemFruitTree = protectionItemFruitTree.copy(); HardwoodTreeSapling hardwoodTreeSaplingEnum = (HardwoodTreeSapling) FarmingUtils.getEnumFromConfig(configManager, HardwoodTreeSapling.TEAK); @@ -315,9 +343,10 @@ public void setupRequirements() allHardwoodSaplings = hardwoodSapling.copy(); protectionItemHardwood = hardwoodTreeSaplingEnum.getProtectionItemRequirement(itemManager).showConditioned(payingForProtection); + protectionItemHardwood.addAlternates(protectionItemHardwood.getId() + 1); allProtectionItemHardwood = protectionItemHardwood.copy(); - compost = new ItemRequirement("Compost", ItemCollections.COMPOST).showConditioned(usingCompost); + compost = new ItemRequirement("Compost", ItemCollections.COMPOST).showConditioned(usingCompostorNothing); compost.setDisplayMatchedItemName(true); // Teleport Items @@ -386,12 +415,12 @@ private void setupSteps() // Tree Patch Clear Steps - lumbridgeTreePatchClear = new NpcStep(this, NpcID.FARMER, new WorldPoint(3193, 3231, 0), - "Speak to the farmer to clear the patch."); + lumbridgeTreePatchClear = new NpcStep(this, NpcID.FAYETH, new WorldPoint(3193, 3231, 0), + "Speak to Fayeth to clear the patch."); lumbridgeTreePatchClear.addDialogStep("Yes."); - faladorTreePatchClear = new NpcStep(this, NpcID.FAYETH, new WorldPoint(3004, 3373, 0), - "Speak to Fayeth to clear the patch."); + faladorTreePatchClear = new NpcStep(this, NpcID.HESKEL, new WorldPoint(3004, 3373, 0), + "Speak to Heskel to clear the patch."); faladorTreePatchClear.addDialogStep("Yes."); taverleyTreePatchClear = new NpcStep(this, NpcID.ALAIN, new WorldPoint(2936, 3438, 0), @@ -410,6 +439,30 @@ private void setupSteps() "Speak to Rosie to clear the patch."); farmingGuildTreePatchClear.addDialogStep("Yes."); + lumbridgeTreeProtect = new NpcStep(this, NpcID.FAYETH, new WorldPoint(3193, 3231, 0), + "Speak to Fayeth to protect the patch."); + lumbridgeTreeProtect.addDialogStep("Yes."); + + faladorTreeProtect = new NpcStep(this, NpcID.HESKEL, new WorldPoint(3004, 3373, 0), + "Speak to Heskel to protect the patch."); + faladorTreeProtect.addDialogStep("Yes."); + + taverleyTreeProtect = new NpcStep(this, NpcID.ALAIN, new WorldPoint(2936, 3438, 0), + "Speak to Alain to protect the patch."); + taverleyTreeProtect.addDialogStep("Yes."); + + varrockTreeProtect = new NpcStep(this, NpcID.TREZNOR_11957, new WorldPoint(3229, 3459, 0), + "Speak to Treznor to protect the patch."); + varrockTreeProtect.addDialogStep("Yes."); + + strongholdTreeProtect = new NpcStep(this, NpcID.PRISSY_SCILLA, new WorldPoint(2436, 3415, 0), + "Speak to Prissy Scilla to protect the patch."); + strongholdTreeProtect.addDialogStep("Yes."); + + farmingGuildTreePayForProtection = new NpcStep(this, NpcID.ROSIE, new WorldPoint(1232, 3736, 0), + "Speak to Rosie to protect the patch."); + farmingGuildTreePayForProtection.addDialogStep("Yes."); + // Tree Patch Steps lumbridgeTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_8391, new WorldPoint(3193, 3231, 0), "Check the health of the tree planted in Lumbridge."); @@ -479,22 +532,25 @@ private void setupSteps() farmingGuildTreePatchDig = new ObjectStep(this, NullObjectID.NULL_33732, new WorldPoint(1232, 3736, 0), "Dig up the tree stump in the Farming Guild tree patch."); - faladorTreePatchClear.addSubSteps(faladorTreePatchDig); - taverleyTreePatchClear.addSubSteps(taverleyTreePatchDig); - varrockTreePatchClear.addSubSteps(varrockTreePatchDig); - gnomeStrongholdTreePatchClear.addSubSteps(gnomeStrongholdTreePatchDig); - lumbridgeTreePatchClear.addSubSteps(lumbridgeTreePatchDig); - farmingGuildTreePatchClear.addSubSteps(farmingGuildTreePatchDig); + faladorTreePatchClear.addSubSteps(faladorTreePatchDig, faladorTreeProtect); + taverleyTreePatchClear.addSubSteps(taverleyTreePatchDig, taverleyTreeProtect); + varrockTreePatchClear.addSubSteps(varrockTreePatchDig, varrockTreeProtect); + gnomeStrongholdTreePatchClear.addSubSteps(gnomeStrongholdTreePatchDig, strongholdTreeProtect); + lumbridgeTreePatchClear.addSubSteps(lumbridgeTreePatchDig, lumbridgeTreeProtect); + farmingGuildTreePatchClear.addSubSteps(farmingGuildTreePatchDig, farmingGuildTreePatchDig); // Fruit Tree Steps gnomeStrongholdFruitTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_7962, new WorldPoint(2476, 3446, 0), "Check the health of the fruit tree planted in the Tree Gnome Stronghold."); + gnomeStrongholdFruitTreePatchCheckHealth.addWidgetHighlightWithTextRequirement(187, 3, "Gnome Stronghold", true); gnomeVillageFruitTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_7963, new WorldPoint(2490, 3180, 0), "Check the health of the fruit tree planted outside the Tree Gnome Village. Follow Elkoy to get out quickly."); + gnomeVillageFruitTreePatchCheckHealth.addWidgetHighlightWithTextRequirement(187, 3, "Tree Gnome Village", true); brimhavenFruitTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_7964, new WorldPoint(2765, 3213, 0), "Check the health of the fruit tree planted in Brimhaven."); - catherbyFruitTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_7965, new WorldPoint(2681, 3434, 0), - "Check the health of the fruit tree planted in Catherby"); + brimhavenFruitTreePatchCheckHealth.addWidgetHighlightWithTextRequirement(187, 3, "Brimhaven", true); + catherbyFruitTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_7965, new WorldPoint(2860, 3433, 0), + "Check the health of the fruit tree planted in Catherby."); catherbyFruitTreePatchCheckHealth.addTeleport(catherbyTeleport); catherbyFruitTreePatchCheckHealth.addSpellHighlight(NormalSpells.CAMELOT_TELEPORT); catherbyFruitTreePatchCheckHealth.addSpellHighlight(LunarSpells.CATHERBY_TELEPORT); @@ -504,10 +560,11 @@ private void setupSteps() lletyaFruitTreePatchCheckHealth.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToLletya)); lletyaFruitTreePatchCheckHealth.addTeleport(crystalTeleport); - farmingGuildFruitTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_34007, new WorldPoint(1243, 3760, 0), + farmingGuildFruitTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_34007, new WorldPoint(1242, 3758, 0), "Check the health of the fruit tree planted in the Farming Guild."); farmingGuildFruitTreePatchCheckHealth.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildFruitTreePatch)); farmingGuildFruitTreePatchCheckHealth.addTeleport(farmingGuildTeleport); + farmingGuildFruitTreePatchCheckHealth.addWidgetHighlightWithTextRequirement(187, 3, "Farming Guild", true); // Fruit Tree Plant Steps gnomeStrongholdFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7962, new WorldPoint(2476, 3446, 0), @@ -526,7 +583,7 @@ private void setupSteps() brimhavenFruitTreePatchCheckHealth.addSubSteps(brimhavenFruitTreePatchPlant); // Plant - catherbyFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7965, new WorldPoint(2681, 3434, 0), + catherbyFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_7965, new WorldPoint(2860, 3433, 0), "Plant your sapling in the Catherby patch.", fruitTreeSapling); catherbyFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); catherbyFruitTreePatchCheckHealth.addSubSteps(catherbyFruitTreePatchPlant); @@ -537,7 +594,7 @@ private void setupSteps() lletyaFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); lletyaFruitTreePatchCheckHealth.addSubSteps(lletyaFruitTreePatchPlant); - farmingGuildFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_34007, new WorldPoint(1243, 3760, 0), + farmingGuildFruitTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_34007, new WorldPoint(1242, 3758, 0), "Plant your sapling in the Farming Guild patch.", fruitTreeSapling); farmingGuildFruitTreePatchPlant.conditionToHideInSidebar(new Conditions(LogicType.NOR, accessToFarmingGuildFruitTreePatch)); farmingGuildFruitTreePatchPlant.addIcon(fruitTreeSapling.getId()); @@ -553,7 +610,7 @@ private void setupSteps() brimhavenFruitTreePatchClear = new NpcStep(this, NpcID.GARTH, new WorldPoint(2765, 3213, 0), "Pay Garth 200 coins to clear the fruit tree, or pick all the fruit and cut it down."); brimhavenFruitTreePatchClear.addDialogStep("Yes."); - catherbyFruitTreePatchClear = new NpcStep(this, NpcID.ELLENA, new WorldPoint(2681, 3434, 0), + catherbyFruitTreePatchClear = new NpcStep(this, NpcID.ELLENA, new WorldPoint(2860, 3433, 0), "Pay Ellena 200 coins to clear the fruit tree, or pick all the fruit and cut it down."); catherbyFruitTreePatchClear.addDialogStep("Yes."); lletyaFruitTreePatchClear = new NpcStep(this, NpcID.LILIWEN, new WorldPoint(2347, 3162, 0), @@ -563,26 +620,45 @@ private void setupSteps() "Pay Nikkie 200 coins to clear the fruit tree, or pick all the fruit and cut it down."); farmingGuildFruitTreePatchClear.addDialogStep("Yes."); - // Dig Fruit Tree Steps + strongholdFruitProtect = new NpcStep(this, NpcID.BOLONGO, new WorldPoint(2476, 3446, 0), + "Pay Bolongo to protect the patch."); + strongholdFruitProtect.addDialogStep("Yes."); + villageFruitProtect = new NpcStep(this, NpcID.GILETH, new WorldPoint(2490, 3180, 0), + "Pay Gileth to protect the patch."); + villageFruitProtect.addDialogStep("Yes."); + brimhavenFruitProtect = new NpcStep(this, NpcID.GARTH, new WorldPoint(2765, 3213, 0), + "Pay Garth to protect the patch."); + brimhavenFruitProtect.addDialogStep("Yes."); + catherbyFruitProtect = new NpcStep(this, NpcID.ELLENA, new WorldPoint(2860, 3433, 0), + "Pay Ellena to protect the patch."); + catherbyFruitProtect.addDialogStep("Yes."); + lletyaFruitProtect = new NpcStep(this, NpcID.LILIWEN, new WorldPoint(2347, 3162, 0), + "Pay Liliwen to protect the patch."); + lletyaFruitProtect.addDialogStep("Yes."); + guildFruitProtect = new NpcStep(this, NpcID.NIKKIE, new WorldPoint(1243, 3760, 0), + "Pay Nikkie to protect the patch."); + guildFruitProtect.addDialogStep("Yes."); + + // Dig Fruit Tree Steps gnomeStrongholdFruitTreePatchDig = new ObjectStep(this, NullObjectID.NULL_7962, new WorldPoint(2476, 3446, 0), "Dig up the fruit tree's stump in the Tree Gnome Stronghold."); gnomeVillageFruitTreePatchDig = new ObjectStep(this, NullObjectID.NULL_7963, new WorldPoint(2490, 3180, 0), "Dig up the fruit tree's stump outside the Tree Gnome Village."); brimhavenFruitTreePatchDig = new ObjectStep(this, NullObjectID.NULL_7964, new WorldPoint(2765, 3213, 0), "Dig up the fruit tree's stump in Brimhaven."); - catherbyFruitTreePatchDig = new ObjectStep(this, NullObjectID.NULL_7965, new WorldPoint(2681, 3434, 0), + catherbyFruitTreePatchDig = new ObjectStep(this, NullObjectID.NULL_7965, new WorldPoint(2860, 3433, 0), "Check the health of the fruit tree planted in Catherby"); lletyaFruitTreePatchDig = new ObjectStep(this, NullObjectID.NULL_26579, new WorldPoint(2347, 3162, 0), "Dig up the fruit tree's stump in Lletya."); - farmingGuildFruitTreePatchDig = new ObjectStep(this, NullObjectID.NULL_34007, new WorldPoint(1243, 3760, 0), + farmingGuildFruitTreePatchDig = new ObjectStep(this, NullObjectID.NULL_34007, new WorldPoint(1242, 3758, 0), "Dig up the fruit tree's stump in the Farming Guild."); - gnomeStrongholdFruitTreePatchClear.addSubSteps(gnomeStrongholdFruitTreePatchDig); - gnomeVillageFruitTreePatchClear.addSubSteps(gnomeVillageFruitTreePatchDig); - brimhavenFruitTreePatchClear.addSubSteps(brimhavenFruitTreePatchDig); - catherbyFruitTreePatchClear.addSubSteps(catherbyFruitTreePatchDig); - lletyaFruitTreePatchClear.addSubSteps(lletyaFruitTreePatchDig); - farmingGuildFruitTreePatchClear.addSubSteps(farmingGuildFruitTreePatchDig); + gnomeStrongholdFruitTreePatchClear.addSubSteps(gnomeStrongholdFruitTreePatchDig, strongholdFruitProtect); + gnomeVillageFruitTreePatchClear.addSubSteps(gnomeVillageFruitTreePatchDig, villageFruitProtect); + brimhavenFruitTreePatchClear.addSubSteps(brimhavenFruitTreePatchDig, brimhavenFruitProtect); + catherbyFruitTreePatchClear.addSubSteps(catherbyFruitTreePatchDig, catherbyFruitProtect); + lletyaFruitTreePatchClear.addSubSteps(lletyaFruitTreePatchDig, lletyaFruitProtect); + farmingGuildFruitTreePatchClear.addSubSteps(farmingGuildFruitTreePatchDig, guildFruitProtect); // Hardwood Tree Steps westHardwoodTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_30481, new WorldPoint(3702, 3837, 0), @@ -621,9 +697,17 @@ private void setupSteps() "Dig up the centre hardwood tree's stump on Fossil Island."); eastHardwoodTreePatchDig = new ObjectStep(this, NullObjectID.NULL_30482, new WorldPoint(3715, 3835, 0), "Dig up the eastern hardwood tree's stump on Fossil Island."); - westHardwoodTreePatchClear.addSubSteps(westHardwoodTreePatchDig); - middleHardwoodTreePatchClear.addSubSteps(middleHardwoodTreePatchDig); - eastHardwoodTreePatchClear.addSubSteps(eastHardwoodTreePatchDig); + + westHardwoodProtect = new NpcStep(this, NpcID.SQUIRREL_7756, new WorldPoint(3702, 3837, 0), + "Pay the brown squirrel to protect the west tree."); + middleHardwoodProtect = new NpcStep(this, NpcID.SQUIRREL_7755, new WorldPoint(3702, 3837, 0), + "Pay the black squirrel to protect the middle tree."); + eastHardwoodProtect = new NpcStep(this, NpcID.SQUIRREL_7754, new WorldPoint(3702, 3837, 0), + "Pay the grey squirrel to protect the east tree."); + + westHardwoodTreePatchClear.addSubSteps(westHardwoodTreePatchDig, westHardwoodProtect); + middleHardwoodTreePatchClear.addSubSteps(middleHardwoodTreePatchDig, middleHardwoodProtect); + eastHardwoodTreePatchClear.addSubSteps(eastHardwoodTreePatchDig, eastHardwoodProtect); } @Subscribe @@ -637,7 +721,7 @@ public void onGameTick(GameTick event) List.of(farmingGuildTreeStates, varrockStates, faladorStates, taverleyStates, lumbridgeStates, gnomeStrongholdTreeStates), farmingWorld.getTabs().get(Tab.TREE), allTreeSaplings, allProtectionItemTree); handleTreePatches(PatchImplementation.FRUIT_TREE, - List.of(farmingGuildTreeStates, brimhavenStates, catherbyStates, gnomeStrongholdFruitStates, gnomeVillageStates, lletyaStates), + List.of(farmingGuildFruitStates, brimhavenStates, catherbyStates, gnomeStrongholdFruitStates, gnomeVillageStates, lletyaStates), farmingWorld.getTabs().get(Tab.FRUIT_TREE), allFruitSaplings, allProtectionItemFruitTree); handleTreePatches(PatchImplementation.HARDWOOD_TREE, List.of(westHardwoodStates, middleHardwoodStates, eastHardwoodStates), farmingWorld.getTabs().get(Tab.TREE), allHardwoodSaplings, allProtectionItemHardwood); @@ -648,13 +732,19 @@ public void handleTreePatches(PatchImplementation implementation, List additionalText, @NonNull List additionalRequirements) { addTitleToPanel(panelComponent); diff --git a/src/main/java/com/questhelper/steps/widget/WidgetHighlight.java b/src/main/java/com/questhelper/steps/widget/WidgetHighlight.java index b3832378ce..cb432f4471 100644 --- a/src/main/java/com/questhelper/steps/widget/WidgetHighlight.java +++ b/src/main/java/com/questhelper/steps/widget/WidgetHighlight.java @@ -43,6 +43,9 @@ public class WidgetHighlight extends AbstractWidgetHighlight @Getter protected Integer itemIdRequirement; + @Getter + protected String requiredText; + protected final boolean checkChildren; public WidgetHighlight(int groupId, int childId) @@ -70,6 +73,15 @@ public WidgetHighlight(int groupId, int childId, int itemIdRequirement, boolean this.checkChildren = checkChildren; } + public WidgetHighlight(int groupId, int childId, String requiredText, boolean checkChildren) + { + this.groupId = groupId; + this.childId = childId; + this.childChildId = -1; + this.requiredText = requiredText; + this.checkChildren = checkChildren; + } + @Override public void highlightChoices(Graphics2D graphics, Client client, QuestHelperPlugin questHelper) { @@ -111,7 +123,10 @@ private void highlightChoices(Widget parentWidget, Graphics2D graphics, QuestHel @Override protected void highlightWidget(Graphics2D graphics, QuestHelperPlugin questHelper, Widget widgetToHighlight) { - if (widgetToHighlight == null || (itemIdRequirement != null && widgetToHighlight.getItemId() != itemIdRequirement)) return; + if (widgetToHighlight == null || + (itemIdRequirement != null && widgetToHighlight.getItemId() != itemIdRequirement) || + (requiredText != null && (widgetToHighlight.getText() == null || !widgetToHighlight.getText().contains(requiredText))) + ) return; super.highlightWidget(graphics, questHelper, widgetToHighlight); } From 0cc1a14e8c84a73ce5564b2a81c054d2528527e4 Mon Sep 17 00:00:00 2001 From: Zoinkwiz Date: Thu, 6 Jun 2024 19:37:38 +0100 Subject: [PATCH 18/20] Add Savannah to Tree Run --- .../helpers/mischelpers/farmruns/TreeRun.java | 50 +++++++++++++------ 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java index 4d63444433..1348f5b6aa 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java @@ -76,7 +76,6 @@ /* * * TODO LIST: -* Add last hardwood patch * Add better direction for using spirit trees and such * */ public class TreeRun extends ComplexStateQuestHelper @@ -122,13 +121,13 @@ public class TreeRun extends ComplexStateQuestHelper lletyaFruitProtect, catherbyFruitProtect; // Hardwood Trees - DetailedQuestStep eastHardwoodTreePatchCheckHealth, westHardwoodTreePatchCheckHealth, middleHardwoodTreePatchCheckHealth; - DetailedQuestStep eastHardwoodTreePatchPlant, westHardwoodTreePatchPlant, middleHardwoodTreePatchPlant; - DetailedQuestStep eastHardwoodTreePatchDig, westHardwoodTreePatchDig, middleHardwoodTreePatchDig; + DetailedQuestStep eastHardwoodTreePatchCheckHealth, westHardwoodTreePatchCheckHealth, middleHardwoodTreePatchCheckHealth, savannahCheckHealth; + DetailedQuestStep eastHardwoodTreePatchPlant, westHardwoodTreePatchPlant, middleHardwoodTreePatchPlant, savannahPlant; + DetailedQuestStep eastHardwoodTreePatchDig, westHardwoodTreePatchDig, middleHardwoodTreePatchDig, savannahDig; - DetailedQuestStep eastHardwoodTreePatchClear, westHardwoodTreePatchClear, middleHardwoodTreePatchClear; + DetailedQuestStep eastHardwoodTreePatchClear, westHardwoodTreePatchClear, middleHardwoodTreePatchClear, savannahClear; - DetailedQuestStep eastHardwoodProtect, westHardwoodProtect, middleHardwoodProtect; + DetailedQuestStep eastHardwoodProtect, westHardwoodProtect, middleHardwoodProtect, savannahProtect; // Farming Items ItemRequirement coins, spade, rake, allTreeSaplings, treeSapling, allFruitSaplings, fruitTreeSapling, allHardwoodSaplings, hardwoodSapling, compost, axe, @@ -145,7 +144,7 @@ public class TreeRun extends ComplexStateQuestHelper ItemRequirement farmingHat, farmingTop, farmingLegs, farmingBoots, farmersOutfit; // Access Requirements - Requirement accessToFarmingGuildTreePatch, accessToFarmingGuildFruitTreePatch, accessToLletya, accessToFossilIsland; + Requirement accessToFarmingGuildTreePatch, accessToFarmingGuildFruitTreePatch, accessToLletya, accessToFossilIsland, accessToSavannah; Requirement payingForRemoval, payingForProtection, usingCompostorNothing; @@ -153,7 +152,7 @@ public class TreeRun extends ComplexStateQuestHelper PatchStates gnomeStrongholdFruitStates, gnomeVillageStates, brimhavenStates, catherbyStates, lletyaStates, farmingGuildFruitStates; - PatchStates eastHardwoodStates, middleHardwoodStates, westHardwoodStates; + PatchStates eastHardwoodStates, middleHardwoodStates, westHardwoodStates, savannahStates; private final String PAY_OR_CUT = "payOrCutTree"; private final String PAY_OR_COMPOST = "payOrCompostTree"; @@ -165,8 +164,8 @@ public QuestStep loadStep() setupSteps(); farmingHandler = new FarmingHandler(client, configManager); - ConditionalStep steps = new ConditionalStep(this, waitForTree, spade, coins, rake, compost, treeSapling, - fruitTreeSapling, hardwoodSapling, farmersOutfit, gracefulOutfit, protectionItemTree, protectionItemFruitTree, protectionItemHardwood); + ConditionalStep steps = new ConditionalStep(this, waitForTree, spade, coins, rake, compost + , farmersOutfit, gracefulOutfit); // Farming Guild Tree -> Farming Guild Fruit Tree -> Lumbridge -> Falador -> Taverley // Varrock -> Gnome Stronghold Fruit -> Gnome Stronghold Tree -> Gnome Village -> Brimhaven @@ -263,6 +262,12 @@ public QuestStep loadStep() steps.addStep(new Conditions(accessToFossilIsland, westHardwoodStates.getIsStump()), westHardwoodTreePatchDig); steps.addStep(new Conditions(accessToFossilIsland, nor(usingCompostorNothing, westHardwoodStates.getIsProtected())), westHardwoodProtect); + steps.addStep(new Conditions(accessToSavannah, savannahStates.getIsUnchecked()), savannahCheckHealth); + steps.addStep(new Conditions(accessToSavannah, savannahStates.getIsEmpty()), savannahPlant); + steps.addStep(new Conditions(accessToSavannah, savannahStates.getIsHarvestable()), savannahClear); + steps.addStep(new Conditions(accessToSavannah, savannahStates.getIsStump()), savannahDig); + steps.addStep(new Conditions(accessToSavannah, nor(usingCompostorNothing, savannahStates.getIsProtected())), savannahProtect); + return steps; } @@ -280,6 +285,7 @@ private void setupConditions() accessToFarmingGuildFruitTreePatch = new Conditions( new SkillRequirement(Skill.FARMING, 85) ); + accessToSavannah = new QuestRequirement(QuestHelperQuest.THE_RIBBITING_TALE_OF_A_LILY_PAD_LABOUR_DISPUTE, QuestState.FINISHED); // Trees lumbridgeStates = new PatchStates("Lumbridge"); @@ -300,6 +306,7 @@ private void setupConditions() westHardwoodStates = new PatchStates("Fossil Island", "West"); middleHardwoodStates = new PatchStates("Fossil Island", "Middle"); eastHardwoodStates = new PatchStates("Fossil Island", "East"); + savannahStates = new PatchStates("Avium Savannah", accessToSavannah); payingForRemoval = new RuneliteRequirement(configManager, PAY_OR_CUT, PayOrCut.PAY.name()); payingForProtection = new RuneliteRequirement(configManager, PAY_OR_COMPOST, PayOrCompost.PAY.name()); @@ -667,23 +674,28 @@ private void setupSteps() "Check the health of the centre hardwood tree on Fossil Island."); eastHardwoodTreePatchCheckHealth = new ObjectStep(this, NullObjectID.NULL_30482, new WorldPoint(3715, 3835, 0), "Check the health of the eastern hardwood tree on Fossil Island."); + savannahCheckHealth = new ObjectStep(this, NullObjectID.NULL_50692, new WorldPoint(1687, 2972, 0), + "Check the health of the hardwood tree in the Avium Savannah."); // Hardwood Tree Plant Steps westHardwoodTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_30481, new WorldPoint(3702, 3837, 0), - "Plant your sapling on the western hardwood tree on Fossil Island.", hardwoodSapling); + "Plant your sapling on the western hardwood tree patch on Fossil Island.", hardwoodSapling); westHardwoodTreePatchPlant.addIcon(hardwoodSapling.getId()); westHardwoodTreePatchCheckHealth.addSubSteps(westHardwoodTreePatchPlant); middleHardwoodTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_30480, new WorldPoint(3708, 3833, 0), - "Plant your sapling on the centre hardwood tree on Fossil Island.", hardwoodSapling); + "Plant your sapling on the centre hardwood tree patch on Fossil Island.", hardwoodSapling); middleHardwoodTreePatchPlant.addIcon(hardwoodSapling.getId()); middleHardwoodTreePatchCheckHealth.addSubSteps(middleHardwoodTreePatchPlant); eastHardwoodTreePatchPlant = new ObjectStep(this, NullObjectID.NULL_30482, new WorldPoint(3715, 3835, 0), - "Plant your sapling on the eastern hardwood tree on Fossil Island.", hardwoodSapling); + "Plant your sapling on the eastern hardwood tree patch on Fossil Island.", hardwoodSapling); eastHardwoodTreePatchPlant.addIcon(hardwoodSapling.getId()); eastHardwoodTreePatchCheckHealth.addSubSteps(eastHardwoodTreePatchPlant); + savannahPlant = new ObjectStep(this, NullObjectID.NULL_50692, new WorldPoint(1687, 2972, 0), + "Plant your sapling into the hardwood tree in the hardwood tree patch in the Avium Savannah.", hardwoodSapling); + westHardwoodTreePatchClear = new NpcStep(this, NpcID.SQUIRREL_7756, new WorldPoint(3702, 3837, 0), "Pay the brown squirrel to remove the west tree."); middleHardwoodTreePatchClear = new NpcStep(this, NpcID.SQUIRREL_7755, new WorldPoint(3702, 3837, 0), @@ -691,12 +703,17 @@ private void setupSteps() eastHardwoodTreePatchClear = new NpcStep(this, NpcID.SQUIRREL_7754, new WorldPoint(3702, 3837, 0), "Pay the grey squirrel to remove the east tree."); + savannahClear = new NpcStep(this, NpcID.MARCELLUS_12936, new WorldPoint(1687, 2972, 0), + "Pay Marcellus to clear the tree."); + westHardwoodTreePatchDig = new ObjectStep(this, NullObjectID.NULL_30481, new WorldPoint(3702, 3837, 0), "Dig up the western hardwood tree's stump on Fossil Island."); middleHardwoodTreePatchDig = new ObjectStep(this, NullObjectID.NULL_30480, new WorldPoint(3708, 3833, 0), "Dig up the centre hardwood tree's stump on Fossil Island."); eastHardwoodTreePatchDig = new ObjectStep(this, NullObjectID.NULL_30482, new WorldPoint(3715, 3835, 0), "Dig up the eastern hardwood tree's stump on Fossil Island."); + savannahDig = new ObjectStep(this, NullObjectID.NULL_50692, new WorldPoint(1687, 2972, 0), + "Dig up the Savannah hardwood tree's stump."); westHardwoodProtect = new NpcStep(this, NpcID.SQUIRREL_7756, new WorldPoint(3702, 3837, 0), "Pay the brown squirrel to protect the west tree."); @@ -704,10 +721,13 @@ private void setupSteps() "Pay the black squirrel to protect the middle tree."); eastHardwoodProtect = new NpcStep(this, NpcID.SQUIRREL_7754, new WorldPoint(3702, 3837, 0), "Pay the grey squirrel to protect the east tree."); + savannahProtect = new NpcStep(this, NpcID.MARCELLUS_12936, new WorldPoint(1687, 2972, 0), + "Pay Marcellus to protect the hardwood tree."); westHardwoodTreePatchClear.addSubSteps(westHardwoodTreePatchDig, westHardwoodProtect); middleHardwoodTreePatchClear.addSubSteps(middleHardwoodTreePatchDig, middleHardwoodProtect); eastHardwoodTreePatchClear.addSubSteps(eastHardwoodTreePatchDig, eastHardwoodProtect); + savannahClear.addSubSteps(savannahDig, savannahProtect); } @Subscribe @@ -723,7 +743,7 @@ public void onGameTick(GameTick event) handleTreePatches(PatchImplementation.FRUIT_TREE, List.of(farmingGuildFruitStates, brimhavenStates, catherbyStates, gnomeStrongholdFruitStates, gnomeVillageStates, lletyaStates), farmingWorld.getTabs().get(Tab.FRUIT_TREE), allFruitSaplings, allProtectionItemFruitTree); - handleTreePatches(PatchImplementation.HARDWOOD_TREE, List.of(westHardwoodStates, middleHardwoodStates, eastHardwoodStates), + handleTreePatches(PatchImplementation.HARDWOOD_TREE, List.of(westHardwoodStates, middleHardwoodStates, eastHardwoodStates, savannahStates), farmingWorld.getTabs().get(Tab.TREE), allHardwoodSaplings, allProtectionItemHardwood); } @@ -840,7 +860,7 @@ public List getPanels() allSteps.add(new PanelDetails("Fossil Island", Arrays.asList(eastHardwoodTreePatchCheckHealth, eastHardwoodTreePatchClear, middleHardwoodTreePatchCheckHealth, middleHardwoodTreePatchClear, westHardwoodTreePatchCheckHealth, westHardwoodTreePatchClear))); - + allSteps.add(new PanelDetails("Avium Savannah", Arrays.asList(savannahCheckHealth, savannahClear))); return allSteps; } From 8a64ca1c2c83dd55b5d1819d5c25d20f579fcc58 Mon Sep 17 00:00:00 2001 From: Zoinkwiz Date: Thu, 6 Jun 2024 20:18:39 +0100 Subject: [PATCH 19/20] Add skip options for tree run --- .../mischelpers/farmruns/FarmingHandler.java | 2 - .../mischelpers/farmruns/PatchStates.java | 1 + .../helpers/mischelpers/farmruns/TreeRun.java | 305 +++++++++++------- 3 files changed, 194 insertions(+), 114 deletions(-) diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingHandler.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingHandler.java index 4096491dbc..b0ceb4564f 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingHandler.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/FarmingHandler.java @@ -86,8 +86,6 @@ public CropState predictPatch(FarmingPatch patch, String profile) if (state.getCropState() == CropState.STUMP) return CropState.STUMP; if (state.getCropState() == CropState.HARVESTABLE) { - System.out.println(patch.getRegion().getName()); - System.out.println("HARVESTABLE"); return CropState.HARVESTABLE; } diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchStates.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchStates.java index f03e2f5e8b..f9dded0113 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchStates.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/PatchStates.java @@ -39,6 +39,7 @@ public class PatchStates private final ManualRequirement isUnchecked = new ManualRequirement(); private final ManualRequirement isStump = new ManualRequirement(); private final ManualRequirement isProtected = new ManualRequirement(); + private final ManualRequirement isGrowing = new ManualRequirement(); private final Requirement requirement; public PatchStates(String regionName) diff --git a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java index 1348f5b6aa..7d7c5c93ba 100644 --- a/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java +++ b/src/main/java/com/questhelper/helpers/mischelpers/farmruns/TreeRun.java @@ -45,6 +45,7 @@ import com.questhelper.requirements.player.SkillRequirement; import com.questhelper.requirements.quest.QuestRequirement; import com.questhelper.requirements.runelite.RuneliteRequirement; +import static com.questhelper.requirements.util.LogicHelper.and; import static com.questhelper.requirements.util.LogicHelper.nor; import static com.questhelper.requirements.util.LogicHelper.or; import com.questhelper.requirements.util.LogicType; @@ -154,6 +155,9 @@ public class TreeRun extends ComplexStateQuestHelper PatchStates eastHardwoodStates, middleHardwoodStates, westHardwoodStates, savannahStates; + ConditionalStep farmingGuildStep, lumbridgeStep, varrockStep, faladorStep, taverleyStep, strongholdStep, villageStep, lletyaStep, + catherbyStep, brimhavenStep, fossilIslandStep, savannahStep; + private final String PAY_OR_CUT = "payOrCutTree"; private final String PAY_OR_COMPOST = "payOrCompostTree"; private final String GRACEFUL_OR_FARMING = "gracefulOrFarming"; @@ -168,105 +172,145 @@ public QuestStep loadStep() , farmersOutfit, gracefulOutfit); // Farming Guild Tree -> Farming Guild Fruit Tree -> Lumbridge -> Falador -> Taverley - // Varrock -> Gnome Stronghold Fruit -> Gnome Stronghold Tree -> Gnome Village -> Brimhaven - // -> catherby -> lletya -> east hardwood -> middle hardwood -> west hardwood. - - - steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreeStates.getIsUnchecked()), farmingGuildTreePatchCheckHealth); - steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreeStates.getIsHarvestable()), farmingGuildTreePatchClear); - steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreeStates.getIsStump()), farmingGuildTreePatchDig); - steps.addStep(new Conditions(accessToFarmingGuildTreePatch, farmingGuildTreeStates.getIsEmpty()), farmingGuildTreePatchPlant); - steps.addStep(new Conditions(accessToFarmingGuildTreePatch, nor(farmingGuildTreeStates.getIsProtected(), usingCompostorNothing)), farmingGuildTreePayForProtection); - - steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitStates.getIsUnchecked()), farmingGuildFruitTreePatchCheckHealth); - steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitStates.getIsHarvestable()), farmingGuildFruitTreePatchClear); - steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitStates.getIsStump()), farmingGuildTreePatchDig); - steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, farmingGuildFruitStates.getIsEmpty()), farmingGuildTreePatchPlant); - steps.addStep(new Conditions(accessToFarmingGuildFruitTreePatch, nor(farmingGuildFruitStates.getIsProtected(), usingCompostorNothing)), guildFruitProtect); - - steps.addStep(lumbridgeStates.getIsUnchecked(), lumbridgeTreePatchCheckHealth); - steps.addStep(lumbridgeStates.getIsEmpty(), lumbridgeTreePatchPlant); - steps.addStep(lumbridgeStates.getIsHarvestable(), lumbridgeTreePatchClear); - steps.addStep(lumbridgeStates.getIsStump(), lumbridgeTreePatchDig); - steps.addStep(nor(usingCompostorNothing, lumbridgeStates.getIsProtected()), lumbridgeTreeProtect); - - steps.addStep(faladorStates.getIsUnchecked(), faladorTreePatchCheckHealth); - steps.addStep(faladorStates.getIsEmpty(), faladorTreePatchPlant); - steps.addStep(faladorStates.getIsHarvestable(), faladorTreePatchClear); - steps.addStep(faladorStates.getIsStump(), faladorTreePatchDig); - steps.addStep(nor(usingCompostorNothing, faladorStates.getIsProtected()), faladorTreeProtect); - - steps.addStep(taverleyStates.getIsUnchecked(), taverleyTreePatchCheckHealth); - steps.addStep(taverleyStates.getIsEmpty(), taverleyTreePatchPlant); - steps.addStep(taverleyStates.getIsHarvestable(), taverleyTreePatchClear); - steps.addStep(taverleyStates.getIsStump(), taverleyTreePatchDig); - steps.addStep(nor(usingCompostorNothing, taverleyStates.getIsProtected()), taverleyTreeProtect); - - steps.addStep(varrockStates.getIsUnchecked(), varrockTreePatchCheckHealth); - steps.addStep(varrockStates.getIsEmpty(), varrockTreePatchPlant); - steps.addStep(varrockStates.getIsHarvestable(), varrockTreePatchClear); - steps.addStep(varrockStates.getIsStump(), varrockTreePatchDig); - steps.addStep(nor(usingCompostorNothing, varrockStates.getIsProtected()), varrockTreeProtect); - - steps.addStep(gnomeStrongholdFruitStates.getIsUnchecked(), gnomeStrongholdFruitTreePatchCheckHealth); - steps.addStep(gnomeStrongholdFruitStates.getIsEmpty(), gnomeStrongholdFruitTreePatchPlant); - steps.addStep(gnomeStrongholdFruitStates.getIsHarvestable(), gnomeStrongholdFruitTreePatchClear); - steps.addStep(gnomeStrongholdFruitStates.getIsStump(), gnomeStrongholdFruitTreePatchDig); - steps.addStep(nor(usingCompostorNothing, gnomeStrongholdFruitStates.getIsProtected()), strongholdFruitProtect); - - steps.addStep(gnomeStrongholdTreeStates.getIsUnchecked(), gnomeStrongholdTreePatchCheckHealth); - steps.addStep(gnomeStrongholdTreeStates.getIsEmpty(), gnomeStrongholdTreePatchPlant); - steps.addStep(gnomeStrongholdTreeStates.getIsHarvestable(), gnomeStrongholdTreePatchClear); - steps.addStep(gnomeStrongholdTreeStates.getIsStump(), gnomeStrongholdTreePatchDig); - steps.addStep(nor(usingCompostorNothing, gnomeStrongholdTreeStates.getIsProtected()), strongholdTreeProtect); - - steps.addStep(gnomeVillageStates.getIsUnchecked(), gnomeVillageFruitTreePatchCheckHealth); - steps.addStep(gnomeVillageStates.getIsEmpty(), gnomeVillageFruitTreePatchPlant); - steps.addStep(gnomeVillageStates.getIsHarvestable(), gnomeVillageFruitTreePatchClear); - steps.addStep(gnomeVillageStates.getIsStump(), gnomeVillageFruitTreePatchDig); - steps.addStep(nor(usingCompostorNothing, gnomeVillageStates.getIsProtected()), villageFruitProtect); - - steps.addStep(brimhavenStates.getIsUnchecked(), brimhavenFruitTreePatchCheckHealth); - steps.addStep(brimhavenStates.getIsEmpty(), brimhavenFruitTreePatchPlant); - steps.addStep(brimhavenStates.getIsHarvestable(), brimhavenFruitTreePatchClear); - steps.addStep(brimhavenStates.getIsStump(), brimhavenFruitTreePatchDig); - steps.addStep(nor(usingCompostorNothing, brimhavenStates.getIsProtected()), brimhavenFruitProtect); - - steps.addStep(catherbyStates.getIsUnchecked(), catherbyFruitTreePatchCheckHealth); - steps.addStep(catherbyStates.getIsEmpty(), catherbyFruitTreePatchPlant); - steps.addStep(catherbyStates.getIsHarvestable(), catherbyFruitTreePatchClear); - steps.addStep(catherbyStates.getIsStump(), catherbyFruitTreePatchDig); - steps.addStep(nor(usingCompostorNothing, catherbyStates.getIsProtected()), catherbyFruitProtect); - - steps.addStep(new Conditions(accessToLletya, lletyaStates.getIsUnchecked()), lletyaFruitTreePatchCheckHealth); - steps.addStep(new Conditions(accessToLletya, lletyaStates.getIsEmpty()), lletyaFruitTreePatchPlant); - steps.addStep(new Conditions(accessToLletya, lletyaStates.getIsHarvestable()), lletyaFruitTreePatchClear); - steps.addStep(new Conditions(accessToLletya, lletyaStates.getIsStump()), lletyaFruitTreePatchDig); - steps.addStep(new Conditions(accessToLletya, nor(usingCompostorNothing, lletyaStates.getIsProtected())), lletyaFruitProtect); - - steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodStates.getIsUnchecked()), eastHardwoodTreePatchCheckHealth); - steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodStates.getIsEmpty()), eastHardwoodTreePatchPlant); - steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodStates.getIsHarvestable()), eastHardwoodTreePatchClear); - steps.addStep(new Conditions(accessToFossilIsland, eastHardwoodStates.getIsStump()), eastHardwoodTreePatchDig); - steps.addStep(new Conditions(accessToFossilIsland,nor(usingCompostorNothing, eastHardwoodStates.getIsProtected())), eastHardwoodProtect); - - steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodStates.getIsUnchecked()), middleHardwoodTreePatchCheckHealth); - steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodStates.getIsEmpty()), middleHardwoodTreePatchPlant); - steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodStates.getIsHarvestable()), middleHardwoodTreePatchClear); - steps.addStep(new Conditions(accessToFossilIsland, middleHardwoodStates.getIsStump()), middleHardwoodTreePatchDig); - steps.addStep(new Conditions(accessToFossilIsland, nor(usingCompostorNothing, middleHardwoodStates.getIsProtected())), middleHardwoodProtect); - - steps.addStep(new Conditions(accessToFossilIsland, westHardwoodStates.getIsUnchecked()), westHardwoodTreePatchCheckHealth); - steps.addStep(new Conditions(accessToFossilIsland, westHardwoodStates.getIsEmpty()), westHardwoodTreePatchPlant); - steps.addStep(new Conditions(accessToFossilIsland, westHardwoodStates.getIsHarvestable()), westHardwoodTreePatchClear); - steps.addStep(new Conditions(accessToFossilIsland, westHardwoodStates.getIsStump()), westHardwoodTreePatchDig); - steps.addStep(new Conditions(accessToFossilIsland, nor(usingCompostorNothing, westHardwoodStates.getIsProtected())), westHardwoodProtect); - - steps.addStep(new Conditions(accessToSavannah, savannahStates.getIsUnchecked()), savannahCheckHealth); - steps.addStep(new Conditions(accessToSavannah, savannahStates.getIsEmpty()), savannahPlant); - steps.addStep(new Conditions(accessToSavannah, savannahStates.getIsHarvestable()), savannahClear); - steps.addStep(new Conditions(accessToSavannah, savannahStates.getIsStump()), savannahDig); - steps.addStep(new Conditions(accessToSavannah, nor(usingCompostorNothing, savannahStates.getIsProtected())), savannahProtect); + // Varrock -> Gnome Stronghold Fruit -> Gnome Stronghold Tree -> Gnome Village -> catherby + // -> Brimhaven -> lletya -> east hardwood -> middle hardwood -> west hardwood. + + farmingGuildStep = new ConditionalStep(this, farmingGuildTreePatchCheckHealth); + farmingGuildStep.addStep(farmingGuildTreeStates.getIsUnchecked(), farmingGuildTreePatchCheckHealth); + farmingGuildStep.addStep(farmingGuildTreeStates.getIsHarvestable(), farmingGuildTreePatchClear); + farmingGuildStep.addStep(farmingGuildTreeStates.getIsStump(), farmingGuildTreePatchDig); + farmingGuildStep.addStep(farmingGuildTreeStates.getIsEmpty(), farmingGuildTreePatchPlant); + farmingGuildStep.addStep(nor(farmingGuildTreeStates.getIsProtected(), usingCompostorNothing), farmingGuildTreePayForProtection); + + farmingGuildStep.addStep(and(accessToFarmingGuildFruitTreePatch, farmingGuildFruitStates.getIsUnchecked()), farmingGuildFruitTreePatchCheckHealth); + farmingGuildStep.addStep(and(accessToFarmingGuildFruitTreePatch, farmingGuildFruitStates.getIsHarvestable()), farmingGuildFruitTreePatchClear); + farmingGuildStep.addStep(and(accessToFarmingGuildFruitTreePatch, farmingGuildFruitStates.getIsStump()), farmingGuildTreePatchDig); + farmingGuildStep.addStep(and(accessToFarmingGuildFruitTreePatch, farmingGuildFruitStates.getIsEmpty()), farmingGuildTreePatchPlant); + farmingGuildStep.addStep(and(accessToFarmingGuildFruitTreePatch, nor(farmingGuildFruitStates.getIsProtected(), usingCompostorNothing)), guildFruitProtect); + + steps.addStep(and(accessToFarmingGuildTreePatch, nor(farmingGuildTreeStates.getIsGrowing(), + farmingGuildFruitStates.getIsGrowing())), farmingGuildStep); + + lumbridgeStep = new ConditionalStep(this, lumbridgeTreePatchCheckHealth); + lumbridgeStep.addStep(lumbridgeStates.getIsUnchecked(), lumbridgeTreePatchCheckHealth); + lumbridgeStep.addStep(lumbridgeStates.getIsEmpty(), lumbridgeTreePatchPlant); + lumbridgeStep.addStep(lumbridgeStates.getIsHarvestable(), lumbridgeTreePatchClear); + lumbridgeStep.addStep(lumbridgeStates.getIsStump(), lumbridgeTreePatchDig); + lumbridgeStep.addStep(nor(usingCompostorNothing, lumbridgeStates.getIsProtected()), lumbridgeTreeProtect); + + steps.addStep(nor(lumbridgeStates.getIsGrowing()), lumbridgeStep); + + faladorStep = new ConditionalStep(this, faladorTreePatchCheckHealth); + faladorStep.addStep(faladorStates.getIsUnchecked(), faladorTreePatchCheckHealth); + faladorStep.addStep(faladorStates.getIsEmpty(), faladorTreePatchPlant); + faladorStep.addStep(faladorStates.getIsHarvestable(), faladorTreePatchClear); + faladorStep.addStep(faladorStates.getIsStump(), faladorTreePatchDig); + faladorStep.addStep(nor(usingCompostorNothing, faladorStates.getIsProtected()), faladorTreeProtect); + + steps.addStep(nor(faladorStates.getIsGrowing()), faladorStep); + + taverleyStep = new ConditionalStep(this, taverleyTreePatchCheckHealth); + taverleyStep.addStep(taverleyStates.getIsUnchecked(), taverleyTreePatchCheckHealth); + taverleyStep.addStep(taverleyStates.getIsEmpty(), taverleyTreePatchPlant); + taverleyStep.addStep(taverleyStates.getIsHarvestable(), taverleyTreePatchClear); + taverleyStep.addStep(taverleyStates.getIsStump(), taverleyTreePatchDig); + taverleyStep.addStep(nor(usingCompostorNothing, taverleyStates.getIsProtected()), taverleyTreeProtect); + + steps.addStep(nor(taverleyStates.getIsGrowing()), taverleyStep); + + varrockStep = new ConditionalStep(this, varrockTreePatchCheckHealth); + varrockStep.addStep(varrockStates.getIsUnchecked(), varrockTreePatchCheckHealth); + varrockStep.addStep(varrockStates.getIsEmpty(), varrockTreePatchPlant); + varrockStep.addStep(varrockStates.getIsHarvestable(), varrockTreePatchClear); + varrockStep.addStep(varrockStates.getIsStump(), varrockTreePatchDig); + varrockStep.addStep(nor(usingCompostorNothing, varrockStates.getIsProtected()), varrockTreeProtect); + + steps.addStep(nor(varrockStates.getIsGrowing()), varrockStep); + + strongholdStep = new ConditionalStep(this, gnomeStrongholdFruitTreePatchCheckHealth); + strongholdStep.addStep(gnomeStrongholdFruitStates.getIsUnchecked(), gnomeStrongholdFruitTreePatchCheckHealth); + strongholdStep.addStep(gnomeStrongholdFruitStates.getIsEmpty(), gnomeStrongholdFruitTreePatchPlant); + strongholdStep.addStep(gnomeStrongholdFruitStates.getIsHarvestable(), gnomeStrongholdFruitTreePatchClear); + strongholdStep.addStep(gnomeStrongholdFruitStates.getIsStump(), gnomeStrongholdFruitTreePatchDig); + strongholdStep.addStep(nor(usingCompostorNothing, gnomeStrongholdFruitStates.getIsProtected()), strongholdFruitProtect); + + strongholdStep.addStep(gnomeStrongholdTreeStates.getIsUnchecked(), gnomeStrongholdTreePatchCheckHealth); + strongholdStep.addStep(gnomeStrongholdTreeStates.getIsEmpty(), gnomeStrongholdTreePatchPlant); + strongholdStep.addStep(gnomeStrongholdTreeStates.getIsHarvestable(), gnomeStrongholdTreePatchClear); + strongholdStep.addStep(gnomeStrongholdTreeStates.getIsStump(), gnomeStrongholdTreePatchDig); + strongholdStep.addStep(nor(usingCompostorNothing, gnomeStrongholdTreeStates.getIsProtected()), strongholdTreeProtect); + + steps.addStep(nor(gnomeStrongholdTreeStates.getIsGrowing(), + gnomeStrongholdFruitStates.getIsGrowing()), strongholdStep); + + villageStep = new ConditionalStep(this, gnomeVillageFruitTreePatchCheckHealth); + villageStep.addStep(gnomeVillageStates.getIsUnchecked(), gnomeVillageFruitTreePatchCheckHealth); + villageStep.addStep(gnomeVillageStates.getIsEmpty(), gnomeVillageFruitTreePatchPlant); + villageStep.addStep(gnomeVillageStates.getIsHarvestable(), gnomeVillageFruitTreePatchClear); + villageStep.addStep(gnomeVillageStates.getIsStump(), gnomeVillageFruitTreePatchDig); + villageStep.addStep(nor(usingCompostorNothing, gnomeVillageStates.getIsProtected()), villageFruitProtect); + + steps.addStep(nor(gnomeVillageStates.getIsGrowing()), villageStep); + + catherbyStep = new ConditionalStep(this, catherbyFruitTreePatchCheckHealth); + catherbyStep.addStep(catherbyStates.getIsUnchecked(), catherbyFruitTreePatchCheckHealth); + catherbyStep.addStep(catherbyStates.getIsEmpty(), catherbyFruitTreePatchPlant); + catherbyStep.addStep(catherbyStates.getIsHarvestable(), catherbyFruitTreePatchClear); + catherbyStep.addStep(catherbyStates.getIsStump(), catherbyFruitTreePatchDig); + catherbyStep.addStep(nor(usingCompostorNothing, catherbyStates.getIsProtected()), catherbyFruitProtect); + + steps.addStep(nor(catherbyStates.getIsGrowing()), catherbyStep); + + brimhavenStep = new ConditionalStep(this, brimhavenFruitTreePatchCheckHealth); + brimhavenStep.addStep(brimhavenStates.getIsUnchecked(), brimhavenFruitTreePatchCheckHealth); + brimhavenStep.addStep(brimhavenStates.getIsEmpty(), brimhavenFruitTreePatchPlant); + brimhavenStep.addStep(brimhavenStates.getIsHarvestable(), brimhavenFruitTreePatchClear); + brimhavenStep.addStep(brimhavenStates.getIsStump(), brimhavenFruitTreePatchDig); + brimhavenStep.addStep(nor(usingCompostorNothing, brimhavenStates.getIsProtected()), brimhavenFruitProtect); + + steps.addStep(nor(brimhavenStates.getIsGrowing()), brimhavenStep); + + lletyaStep = new ConditionalStep(this, lletyaFruitTreePatchCheckHealth); + lletyaStep.addStep(lletyaStates.getIsUnchecked(), lletyaFruitTreePatchCheckHealth); + lletyaStep.addStep(lletyaStates.getIsEmpty(), lletyaFruitTreePatchPlant); + lletyaStep.addStep(lletyaStates.getIsHarvestable(), lletyaFruitTreePatchClear); + lletyaStep.addStep(lletyaStates.getIsStump(), lletyaFruitTreePatchDig); + lletyaStep.addStep(nor(usingCompostorNothing, lletyaStates.getIsProtected()), lletyaFruitProtect); + + steps.addStep(and(accessToLletya, nor(lletyaStates.getIsGrowing())), lletyaStep); + + fossilIslandStep = new ConditionalStep(this, eastHardwoodTreePatchCheckHealth); + fossilIslandStep.addStep(eastHardwoodStates.getIsUnchecked(), eastHardwoodTreePatchCheckHealth); + fossilIslandStep.addStep(eastHardwoodStates.getIsEmpty(), eastHardwoodTreePatchPlant); + fossilIslandStep.addStep(eastHardwoodStates.getIsHarvestable(), eastHardwoodTreePatchClear); + fossilIslandStep.addStep(eastHardwoodStates.getIsStump(), eastHardwoodTreePatchDig); + fossilIslandStep.addStep(nor(usingCompostorNothing, eastHardwoodStates.getIsProtected()), eastHardwoodProtect); + + fossilIslandStep.addStep(middleHardwoodStates.getIsUnchecked(), middleHardwoodTreePatchCheckHealth); + fossilIslandStep.addStep(middleHardwoodStates.getIsEmpty(), middleHardwoodTreePatchPlant); + fossilIslandStep.addStep(middleHardwoodStates.getIsHarvestable(), middleHardwoodTreePatchClear); + fossilIslandStep.addStep(middleHardwoodStates.getIsStump(), middleHardwoodTreePatchDig); + fossilIslandStep.addStep(nor(usingCompostorNothing, middleHardwoodStates.getIsProtected()), middleHardwoodProtect); + + fossilIslandStep.addStep(westHardwoodStates.getIsUnchecked(), westHardwoodTreePatchCheckHealth); + fossilIslandStep.addStep(westHardwoodStates.getIsEmpty(), westHardwoodTreePatchPlant); + fossilIslandStep.addStep(westHardwoodStates.getIsHarvestable(), westHardwoodTreePatchClear); + fossilIslandStep.addStep(westHardwoodStates.getIsStump(), westHardwoodTreePatchDig); + fossilIslandStep.addStep(nor(usingCompostorNothing, westHardwoodStates.getIsProtected()), westHardwoodProtect); + + steps.addStep(and(accessToFossilIsland, + nor(eastHardwoodStates.getIsGrowing(), westHardwoodStates.getIsGrowing(), middleHardwoodStates.getIsGrowing())), + fossilIslandStep); + + savannahStep = new ConditionalStep(this, savannahCheckHealth); + savannahStep.addStep(savannahStates.getIsUnchecked(), savannahCheckHealth); + savannahStep.addStep(savannahStates.getIsEmpty(), savannahPlant); + savannahStep.addStep(savannahStates.getIsHarvestable(), savannahClear); + savannahStep.addStep(savannahStates.getIsStump(), savannahDig); + savannahStep.addStep(nor(usingCompostorNothing, savannahStates.getIsProtected()), savannahProtect); + + System.out.println(accessToSavannah.check(client)); + steps.addStep(and(accessToSavannah, nor(savannahStates.getIsGrowing())), savannahStep); return steps; } @@ -763,6 +807,7 @@ public void handleTreePatches(PatchImplementation implementation, List getItemRecommended() public List getPanels() { List allSteps = new ArrayList<>(); - allSteps.add(new PanelDetails("Farming Guild", Arrays.asList(farmingGuildTreePatchCheckHealth, farmingGuildTreePatchClear, farmingGuildFruitTreePatchCheckHealth, farmingGuildFruitTreePatchClear))); - allSteps.add(new PanelDetails("Lumbridge", Arrays.asList(lumbridgeTreePatchCheckHealth, lumbridgeTreePatchClear))); - allSteps.add(new PanelDetails("Falador", Arrays.asList(faladorTreePatchCheckHealth, faladorTreePatchClear))); - allSteps.add(new PanelDetails("Taverley", Arrays.asList(taverleyTreePatchCheckHealth, taverleyTreePatchClear))); - allSteps.add(new PanelDetails("Varrock", Arrays.asList(varrockTreePatchCheckHealth, varrockTreePatchClear))); - allSteps.add(new PanelDetails("Gnome Stronghold", Arrays.asList(gnomeVillageFruitTreePatchCheckHealth, gnomeVillageFruitTreePatchClear, gnomeStrongholdTreePatchCheckHealth, gnomeStrongholdTreePatchClear))); - allSteps.add(new PanelDetails("Tree Gnome Village", Arrays.asList(gnomeVillageFruitTreePatchCheckHealth, gnomeVillageFruitTreePatchClear))); - allSteps.add(new PanelDetails("Catherby", Arrays.asList(catherbyFruitTreePatchCheckHealth, catherbyFruitTreePatchClear))); - allSteps.add(new PanelDetails("Brimhaven", Arrays.asList(brimhavenFruitTreePatchCheckHealth, brimhavenFruitTreePatchClear))); - allSteps.add(new PanelDetails("Llyeta", Arrays.asList(lletyaFruitTreePatchCheckHealth, lletyaFruitTreePatchClear))); - allSteps.add(new PanelDetails("Fossil Island", Arrays.asList(eastHardwoodTreePatchCheckHealth, eastHardwoodTreePatchClear, + PanelDetails farmingGuildPanel = new PanelDetails("Farming Guild", Arrays.asList(farmingGuildTreePatchCheckHealth, farmingGuildTreePatchClear, farmingGuildFruitTreePatchCheckHealth, farmingGuildFruitTreePatchClear)); + farmingGuildPanel.setLockingStep(farmingGuildStep); + allSteps.add(farmingGuildPanel); + + PanelDetails lumbridgePanel = new PanelDetails("Lumbridge", Arrays.asList(lumbridgeTreePatchCheckHealth, lumbridgeTreePatchClear)); + lumbridgePanel.setLockingStep(lumbridgeStep); + allSteps.add(lumbridgePanel); + + PanelDetails faladorPanel = new PanelDetails("Falador", Arrays.asList(faladorTreePatchCheckHealth, faladorTreePatchClear)); + faladorPanel.setLockingStep(faladorStep); + allSteps.add(faladorPanel); + PanelDetails taverleyPanel = new PanelDetails("Taverley", Arrays.asList(taverleyTreePatchCheckHealth, taverleyTreePatchClear)); + taverleyPanel.setLockingStep(taverleyStep); + allSteps.add(taverleyPanel); + + PanelDetails varrockPanel = new PanelDetails("Varrock", Arrays.asList(varrockTreePatchCheckHealth, varrockTreePatchClear)); + varrockPanel.setLockingStep(varrockStep); + allSteps.add(varrockPanel); + + PanelDetails gnomeStrongholdPanel = new PanelDetails("Gnome Stronghold", Arrays.asList(gnomeStrongholdFruitTreePatchCheckHealth, gnomeVillageFruitTreePatchClear, + gnomeStrongholdTreePatchCheckHealth, gnomeStrongholdTreePatchClear)); + gnomeStrongholdPanel.setLockingStep(strongholdStep); + allSteps.add(gnomeStrongholdPanel); + + PanelDetails villagePanel = new PanelDetails("Tree Gnome Village", Arrays.asList(gnomeVillageFruitTreePatchCheckHealth, gnomeVillageFruitTreePatchClear)); + villagePanel.setLockingStep(villageStep); + allSteps.add(villagePanel); + + PanelDetails catherbyPanel = new PanelDetails("Catherby", Arrays.asList(catherbyFruitTreePatchCheckHealth, catherbyFruitTreePatchClear)); + catherbyPanel.setLockingStep(catherbyStep); + allSteps.add(catherbyPanel); + + PanelDetails brimhavenPanel = new PanelDetails("Brimhaven", Arrays.asList(brimhavenFruitTreePatchCheckHealth, brimhavenFruitTreePatchClear)); + brimhavenPanel.setLockingStep(brimhavenStep); + allSteps.add(brimhavenPanel); + + PanelDetails lletyaPanel = new PanelDetails("Llyeta", Arrays.asList(lletyaFruitTreePatchCheckHealth, lletyaFruitTreePatchClear)); + lletyaPanel.setLockingStep(lletyaStep); + allSteps.add(lletyaPanel); + + PanelDetails fossilIslandPanel = new PanelDetails("Fossil Island", Arrays.asList(eastHardwoodTreePatchCheckHealth, eastHardwoodTreePatchClear, middleHardwoodTreePatchCheckHealth, middleHardwoodTreePatchClear, - westHardwoodTreePatchCheckHealth, westHardwoodTreePatchClear))); - allSteps.add(new PanelDetails("Avium Savannah", Arrays.asList(savannahCheckHealth, savannahClear))); + westHardwoodTreePatchCheckHealth, westHardwoodTreePatchClear)); + fossilIslandPanel.setLockingStep(fossilIslandStep); + allSteps.add(fossilIslandPanel); + + PanelDetails savannahPanel = new PanelDetails("Avium Savannah", Arrays.asList(savannahCheckHealth, savannahClear, savannahPlant)); + savannahPanel.setLockingStep(savannahStep); + allSteps.add(savannahPanel); return allSteps; } From 8617fc1ba01e899852e44bbecc8fdf7fc9ef771f Mon Sep 17 00:00:00 2001 From: Zoinkwiz Date: Sat, 8 Jun 2024 18:27:55 +0100 Subject: [PATCH 20/20] Mock ItemComposition for tests --- src/test/java/com/questhelper/MockedTest.java | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/test/java/com/questhelper/MockedTest.java b/src/test/java/com/questhelper/MockedTest.java index 2ec36ee684..36a98c0d12 100644 --- a/src/test/java/com/questhelper/MockedTest.java +++ b/src/test/java/com/questhelper/MockedTest.java @@ -31,6 +31,7 @@ import com.questhelper.runeliteobjects.extendedruneliteobjects.RuneliteObjectManager; import com.questhelper.statemanagement.PlayerStateManager; import net.runelite.api.Client; +import net.runelite.api.ItemComposition; import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.Hooks; import net.runelite.client.chat.ChatMessageManager; @@ -40,9 +41,10 @@ import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.overlay.OverlayManager; import org.junit.jupiter.api.BeforeEach; -import org.mockito.Mockito; +import static org.mockito.ArgumentMatchers.anyInt; import javax.inject.Named; import java.util.concurrent.ScheduledExecutorService; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -52,49 +54,49 @@ public abstract class MockedTest extends MockedTestBase { @Bind - protected Client client = Mockito.mock(Client.class); + protected Client client = mock(Client.class); @Bind - protected ConfigManager configManager = Mockito.mock(ConfigManager.class); + protected ConfigManager configManager = mock(ConfigManager.class); @Bind - protected ChatMessageManager chatMessageManager = Mockito.mock(ChatMessageManager.class); + protected ChatMessageManager chatMessageManager = mock(ChatMessageManager.class); @Bind - protected ItemManager itemManager = Mockito.mock(ItemManager.class); + protected ItemManager itemManager = mock(ItemManager.class); @Bind - protected OverlayManager overlayManager = Mockito.mock(OverlayManager.class); + protected OverlayManager overlayManager = mock(OverlayManager.class); @Bind - protected QuestHelperConfig questHelperConfig = Mockito.mock(QuestHelperConfig.class); + protected QuestHelperConfig questHelperConfig = mock(QuestHelperConfig.class); @Bind - protected QuestOverlayManager questOverlayManager = Mockito.mock(QuestOverlayManager.class); + protected QuestOverlayManager questOverlayManager = mock(QuestOverlayManager.class); @Bind - protected RuneliteObjectManager runeliteObjectManager = Mockito.mock(RuneliteObjectManager.class); + protected RuneliteObjectManager runeliteObjectManager = mock(RuneliteObjectManager.class); @Bind - protected Hooks hooks = Mockito.mock(Hooks.class); + protected Hooks hooks = mock(Hooks.class); @Bind - protected PlayerStateManager playerStateManager = Mockito.mock(PlayerStateManager.class); + protected PlayerStateManager playerStateManager = mock(PlayerStateManager.class); @Bind - protected QuestHelperPlugin questHelperPlugin = Mockito.mock(QuestHelperPlugin.class); + protected QuestHelperPlugin questHelperPlugin = mock(QuestHelperPlugin.class); @Bind - protected ClientToolbar clientToolbar = Mockito.mock(ClientToolbar.class); + protected ClientToolbar clientToolbar = mock(ClientToolbar.class); @Bind - protected ClientThread clientThread = Mockito.mock(ClientThread.class); + protected ClientThread clientThread = mock(ClientThread.class); @Bind - protected EventBus eventBus = Mockito.mock(EventBus.class); + protected EventBus eventBus = mock(EventBus.class); @Bind - protected ScheduledExecutorService scheduledExecutorService = Mockito.mock(ScheduledExecutorService.class); + protected ScheduledExecutorService scheduledExecutorService = mock(ScheduledExecutorService.class); @Bind @Named("developerMode") @@ -109,6 +111,10 @@ protected void setUp() when(questHelperPlugin.getPlayerStateManager()).thenReturn(playerStateManager); when(playerStateManager.getAccountType()).thenReturn(AccountType.NORMAL); + ItemComposition item = mock(ItemComposition.class); + when(item.getName()).thenReturn("TestName"); + when(itemManager.getItemComposition(anyInt())).thenReturn(item); + // init client mocks // when(client.getWorldType()).thenReturn(EnumSet.noneOf(WorldType.class)); }