Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Tree Run Helper #1586

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public class QuestHelperBankTagService
@Inject
private QuestBank questBank;

private final String RECOMMENDED_TAB_NAME = "Recommended items";

public ArrayList<Integer> itemsToTag()
{
ArrayList<BankTabItems> sortedItems = getPluginBankTagItemsForSections(true);
Expand Down Expand Up @@ -95,8 +97,8 @@ public ArrayList<BankTabItems> 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);
}
Expand Down Expand Up @@ -137,7 +139,31 @@ public ArrayList<BankTabItems> 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<ItemRequirement> allRequired = plugin.getSelectedQuest().getItemRequirements();
List<ItemRequirement> items;
if (allRequired != null && allRequired.size() > 0)
{
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);
}

return newList;
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2024, Kerpackie </~https://github.com/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;
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 <T extends Enum<T>> void handleFarmingEnumConfigChange(ConfigChanged event, String configKey,
Class<T> enumClass, Consumer<T> updateAction, T defaultValue, ConfigManager configManager, QuestHelperPlugin questHelperPlugin)
{
if (event.getKey().equals(configKey))
{
try
{
T selectedEnumValue = Enum.valueOf(enumClass, event.getNewValue());
updateAction.accept(selectedEnumValue);
questHelperPlugin.refreshBank();
}
catch (IllegalArgumentException e)
{
configManager.setConfiguration(QuestHelperConfig.QUEST_BACKGROUND_GROUP, configKey, defaultValue.name());
}
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
* (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;
import net.runelite.api.Client;
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
Expand Down Expand Up @@ -83,7 +82,12 @@ 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)
{
return CropState.HARVESTABLE;
}

if (unixTime <= 0)
{
Expand All @@ -108,7 +112,10 @@ public CropState predictPatch(FarmingPatch patch, String profile)
doneEstimate = getTickTime(tickrate, stages - 1 - stage, tickTime, profile);
}

if (unixNow >= doneEstimate) return CropState.HARVESTABLE;
if (unixNow >= doneEstimate)
{
return CropState.UNCHECKED;
}

return CropState.GROWING;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading
Loading