Skip to content

Commit e1385bf

Browse files
authored
Merge branch 'Zoinkwiz:master' into master
2 parents 7416823 + 6f3bcd1 commit e1385bf

File tree

14 files changed

+205
-20
lines changed

14 files changed

+205
-20
lines changed

src/main/java/com/questhelper/QuestHelperPlugin.java

+19
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ protected void startUp() throws IOException
182182
{
183183
questBankManager.startUp(injector, eventBus);
184184
QuestContainerManager.getBankData().setSpecialMethodToObtainItems(() -> questBankManager.getBankItems().toArray(new Item[0]));
185+
QuestContainerManager.getGroupStorageData().setSpecialMethodToObtainItems(() -> questBankManager.getGroupBankItems().toArray(new Item[0]));
185186
eventBus.register(worldMapAreaManager);
186187

187188
injector.injectMembers(playerStateManager);
@@ -260,13 +261,31 @@ public void onItemContainerChanged(ItemContainerChanged event)
260261
{
261262
ItemAndLastUpdated inventoryData = QuestContainerManager.getInventoryData();
262263
inventoryData.update(client.getTickCount(), items);
264+
265+
// Check if it matches last known group inventory state to know if we should update group storage
266+
boolean bankChanged = questBankManager.updateGroupBankOnInventoryChange(items);
267+
if (bankChanged)
268+
{
269+
ItemAndLastUpdated groupBankData = QuestContainerManager.getGroupStorageData();
270+
groupBankData.update(client.getTickCount(), items);
271+
}
263272
}
264273

265274
if (event.getContainerId() == InventoryID.EQUIPMENT.getId())
266275
{
267276
ItemAndLastUpdated equippedData = QuestContainerManager.getEquippedData();
268277
equippedData.update(client.getTickCount(), items);
269278
}
279+
if (event.getContainerId() == InventoryID.GROUP_STORAGE.getId())
280+
{
281+
ItemAndLastUpdated groupBankData = QuestContainerManager.getGroupStorageData();
282+
groupBankData.update(client.getTickCount(), items);
283+
questBankManager.updateLocalGroupBank(client, event.getItemContainer());
284+
}
285+
if (event.getContainerId() == InventoryID.GROUP_STORAGE_INV.getId())
286+
{
287+
questBankManager.updateLocalGroupInventory(items);
288+
}
270289
}
271290

272291
@Subscribe
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
* Copyright (c) 2024, Zoinkwiz <https://github.com/Zoinkwiz>
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright notice, this
9+
* list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright notice,
11+
* this list of conditions and the following disclaimer in the documentation
12+
* and/or other materials provided with the distribution.
13+
*
14+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
package com.questhelper.bank;
26+
27+
import com.google.gson.Gson;
28+
import com.google.inject.Inject;
29+
import com.google.inject.Singleton;
30+
import lombok.Setter;
31+
import lombok.extern.slf4j.Slf4j;
32+
import net.runelite.api.Client;
33+
import net.runelite.api.Item;
34+
import net.runelite.client.config.ConfigManager;
35+
36+
import java.util.Arrays;
37+
38+
@Slf4j
39+
@Singleton
40+
public class GroupBank extends QuestBank
41+
{
42+
43+
@Setter
44+
private Item[] groupBankDuringEditing;
45+
46+
private Item[] groupInventoryDuringEditing;
47+
48+
// Inventory change event occurs once before actual change from group editing
49+
// So we need to allow for this
50+
private int inventoryChangeEvents = 0;
51+
52+
@Inject
53+
public GroupBank(Client client, ConfigManager configManager, Gson gson)
54+
{
55+
super(client, configManager, gson);
56+
}
57+
58+
// Inventory changed. If it matches group Inventory
59+
public boolean updateAfterInventoryChange(Item[] inventoryItems)
60+
{
61+
if (groupBankDuringEditing == null || inventoryItems == null || groupInventoryDuringEditing == null) return false;
62+
if (Arrays.equals(inventoryItems, paddedItems(groupInventoryDuringEditing)))
63+
{
64+
updateLocalBank(groupBankDuringEditing);
65+
groupBankDuringEditing = null;
66+
groupInventoryDuringEditing = null;
67+
return true;
68+
}
69+
70+
inventoryChangeEvents++;
71+
int MAX_INVENTORY_CHANGE_BEFORE_CLEAR = 2;
72+
if (inventoryChangeEvents == MAX_INVENTORY_CHANGE_BEFORE_CLEAR)
73+
{
74+
inventoryChangeEvents = 0;
75+
groupBankDuringEditing = null;
76+
groupInventoryDuringEditing = null;
77+
}
78+
79+
return false;
80+
}
81+
82+
public void setGroupInventoryDuringEditing(Item[] groupInventoryDuringEditing)
83+
{
84+
inventoryChangeEvents = 0;
85+
this.groupInventoryDuringEditing = groupInventoryDuringEditing;
86+
}
87+
88+
private Item[] paddedItems(Item[] oldItems)
89+
{
90+
final int INVENTORY_SIZE = 28;
91+
92+
Item[] newItems = new Item[28];
93+
94+
System.arraycopy(oldItems, 0, newItems, 0, oldItems.length);
95+
96+
for (int i = oldItems.length; i < INVENTORY_SIZE; i++)
97+
{
98+
newItems[i] = new Item(-1, 0);
99+
}
100+
101+
return newItems;
102+
}
103+
104+
@Override
105+
protected String getKey()
106+
{
107+
return "groupbankitems";
108+
}
109+
}
110+

src/main/java/com/questhelper/bank/QuestBank.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public class QuestBank
5050
private final Gson gson;
5151

5252
private static final String CONFIG_GROUP = QuestHelperConfig.QUEST_HELPER_GROUP;
53-
private static final String BANK_KEY = "bankitems";
5453

5554
private List<Item> bankItems;
5655
private final QuestBankData questBankData;
@@ -111,7 +110,7 @@ private void loadBankFromConfig()
111110
rsProfileKey = configManager.getRSProfileKey();
112111
worldType = RuneScapeProfileType.getCurrent(client);
113112

114-
String json = configManager.getRSProfileConfiguration(CONFIG_GROUP, BANK_KEY);
113+
String json = configManager.getRSProfileConfiguration(CONFIG_GROUP, getKey());
115114
try
116115
{
117116
questBankData.setIdAndQuantity(gson.fromJson(json, int[].class));
@@ -132,7 +131,7 @@ public void saveBankToConfig()
132131
return;
133132
}
134133

135-
configManager.setConfiguration(CONFIG_GROUP, rsProfileKey, BANK_KEY, gson.toJson(questBankData.getIdAndQuantity()));
134+
configManager.setConfiguration(CONFIG_GROUP, rsProfileKey, getKey(), gson.toJson(questBankData.getIdAndQuantity()));
136135
}
137136

138137
private String getCurrentKey()
@@ -151,4 +150,8 @@ private String getCurrentKey()
151150
key.append(client.getLocalPlayer().getName());
152151
return key.toString();
153152
}
153+
protected String getKey()
154+
{
155+
return "bankitems";
156+
}
154157
}

src/main/java/com/questhelper/collections/ItemCollections.java

+1
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ public enum ItemCollections
203203
ItemID.ZARYTE_CROSSBOW,
204204
ItemID.ARMADYL_CROSSBOW,
205205
ItemID.DRAGON_HUNTER_CROSSBOW,
206+
ItemID.HUNTERS_SUNLIGHT_CROSSBOW,
206207
ItemID.HUNTERS_CROSSBOW,
207208
ItemID.DORGESHUUN_CROSSBOW,
208209
ItemID.BLURITE_CROSSBOW,

src/main/java/com/questhelper/helpers/achievementdiaries/fremennik/FremennikMedium.java

+1
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ public List<Requirement> getGeneralRequirements()
418418
req.add(olafsQuest);
419419
req.add(eaglesPeak);
420420
req.add(betweenARock);
421+
req.add(horrorFromTheDeep);
421422
return req;
422423
}
423424

src/main/java/com/questhelper/helpers/quests/contact/Contact.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -331,16 +331,16 @@ public List<PanelDetails> getPanels()
331331
{
332332
List<PanelDetails> allSteps = new ArrayList<>();
333333

334-
allSteps.add(new PanelDetails("Starting off", Arrays.asList(talkToHighPriest, talkToJex), lightSource, tinderbox));
334+
allSteps.add(new PanelDetails("Starting off", Arrays.asList(talkToHighPriest, talkToJex), lightSource, tinderbox, antipoison));
335335

336336
allSteps.add(new PanelDetails("Explore the dungeon",
337337
Arrays.asList(goDownToBank, goDownToDungeon, goDownToChasm, searchKaleef, readParchment,
338-
talkToMaisa, talkToOsman), lightSource, tinderbox));
338+
talkToMaisa, talkToOsman), lightSource, tinderbox, antipoison));
339339

340340
allSteps.add(new PanelDetails("Help Osman",
341341
Arrays.asList(talkToOsmanOutsideSoph, goDownToBankAgain, goDownToDungeonAgain,
342342
goDownToChasmAgain, killGiantScarab, talkToOsmanChasm, pickUpKeris, returnToHighPriest), combatGear, food, prayerPotions,
343-
lightSource, tinderbox));
343+
lightSource, tinderbox, antipoison));
344344

345345
return allSteps;
346346
}

src/main/java/com/questhelper/helpers/quests/entertheabyss/EnterTheAbyss.java

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ public void setupSteps()
146146
goDownInWizardsTower.addDialogStep("Wizard's Tower");
147147
talkToSedridor = new NpcStep(this, NpcID.ARCHMAGE_SEDRIDOR, new WorldPoint(3104, 9571, 0),
148148
"Teleport to the essence mine with Sedridor in the Wizard Tower's basement.", scryingOrb);
149+
((NpcStep) talkToSedridor).addAlternateNpcs(5034);
149150
talkToSedridor.addDialogStep("Can you teleport me to the Rune Essence Mine?");
150151
talkToSedridor.addSubSteps(goDownInWizardsTower);
151152

src/main/java/com/questhelper/helpers/quests/whileguthixsleeps/WhileGuthixSleeps.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ public void setupSteps()
11221122
"Bring the unconscious broav to the Feldip Hills hunting expert.", unconsciousBroav);
11231123
returnBroavToHuntingExpert.addDialogSteps("Do you think you could train this broav for me?", "A creature to help track down a person.");
11241124

1125-
goToBrokenTable = new DetailedQuestStep(this, new WorldPoint(2519, 3248, 0), "Go to the broken table in the middle of the khazard side of the gnome/khazard battlefield.", broav);
1125+
goToBrokenTable = new DetailedQuestStep(this, new WorldPoint(2519, 3248, 0), "Go to the broken table in the middle of the Khazard side of the Khazard-Gnome battlefield.", broav);
11261126
goToBrokenTable.addTeleport(khazardTeleport);
11271127
goToBrokenTable.setHighlightZone(nearTable);
11281128

@@ -1133,7 +1133,7 @@ public void setupSteps()
11331133

11341134
searchBrokenTable = new ObjectStep(this, NullObjectID.NULL_53889, new WorldPoint(2519, 3249, 0), "Search the broken table.");
11351135

1136-
enterMovarioBase = new ObjectStep(this, ObjectID.TRAPDOOR_53279, new WorldPoint(2519, 3249, 0), "Enter movario's base under the broken table in the Khazard Battlefield.");
1136+
enterMovarioBase = new ObjectStep(this, ObjectID.TRAPDOOR_53279, new WorldPoint(2519, 3249, 0), "Enter Movario's base under the broken table in the Khazard Battlefield.");
11371137

11381138
// TODO: Update hardcoded 54117 to CHEST_54117
11391139
claimRunes = new ObjectStep(this, 54117, new WorldPoint(4124, 4984, 0), "Search the open chest in the far north of the area for some runes.");
@@ -1227,8 +1227,8 @@ public void setupSteps()
12271227
searchChestForTraps = new ObjectStep(this, ObjectID.BED_CHEST_53951, new WorldPoint(4179, 4954, 2), "RIGHT-CLICK search the bed chest for traps.");
12281228
getNotesFromChest = new ObjectStep(this, ObjectID.BED_CHEST_53952, new WorldPoint(4179, 4954, 2), "Take the second pair of notes from the bed chest.");
12291229
((ObjectStep) getNotesFromChest).addAlternateObjects(ObjectID.BED_CHEST_53951);
1230-
readNotes1 = new DetailedQuestStep(this, "Read the movario notes 1.", movariosNotesV1.highlighted());
1231-
readNotes2 = new DetailedQuestStep(this, "Read the movario notes 2.", movariosNotesV2.highlighted());
1230+
readNotes1 = new DetailedQuestStep(this, "Read Movario's notes (vol. 1).", movariosNotesV1.highlighted());
1231+
readNotes2 = new DetailedQuestStep(this, "Read Movario's notes (vol. 2).", movariosNotesV2.highlighted());
12321232
goDownFromHiddenRoom = new ObjectStep(this, ObjectID.STAIRS_53948, new WorldPoint(4173, 4956, 2), "Go back downstairs.");
12331233
inspectPainting = new ObjectStep(this, ObjectID.PAINTING_53885, new WorldPoint(4179, 4948, 1), "Inspect the painting in the south of the room.");
12341234
inspectPainting.addDialogStep("Pull the lever.");

src/main/java/com/questhelper/managers/QuestBankManager.java

+40-5
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,16 @@
2525
package com.questhelper.managers;
2626

2727
import com.google.inject.Injector;
28-
import com.questhelper.QuestHelperPlugin;
28+
import com.questhelper.bank.GroupBank;
2929
import com.questhelper.bank.QuestBank;
3030
import com.questhelper.bank.banktab.QuestBankTab;
3131
import com.questhelper.bank.banktab.QuestHelperBankTagService;
3232
import lombok.Getter;
33-
import net.runelite.api.Client;
34-
import net.runelite.api.Item;
35-
import net.runelite.api.ItemContainer;
36-
import net.runelite.api.Player;
33+
import net.runelite.api.*;
3734
import net.runelite.client.eventbus.EventBus;
3835
import javax.inject.Inject;
3936
import javax.inject.Singleton;
37+
import java.util.Arrays;
4038
import java.util.List;
4139

4240
@Singleton
@@ -45,6 +43,9 @@ public class QuestBankManager
4543
@Inject
4644
private QuestBank questBank;
4745

46+
@Inject
47+
private GroupBank groupBank;
48+
4849
@Getter
4950
@Inject
5051
private QuestHelperBankTagService bankTagService;
@@ -88,6 +89,7 @@ public void setUnknownInitialState()
8889
public void loadState()
8990
{
9091
questBank.loadState();
92+
groupBank.loadState();
9193
}
9294

9395
public void startUpQuest()
@@ -105,6 +107,11 @@ public List<Item> getBankItems()
105107
return questBank.getBankItems();
106108
}
107109

110+
public List<Item> getGroupBankItems()
111+
{
112+
return groupBank.getBankItems();
113+
}
114+
108115
public void refreshBankTab()
109116
{
110117
questBankTab.refreshBankTab();
@@ -115,18 +122,46 @@ public void updateLocalBank(ItemContainer itemContainer)
115122
questBank.updateLocalBank(itemContainer.getItems());
116123
}
117124

125+
public void updateLocalGroupBank(Client client, ItemContainer itemContainer)
126+
{
127+
boolean hasChangedGroupStorage = client.getVarbitValue(4602) == 1;
128+
if (hasChangedGroupStorage)
129+
{
130+
// If editing, group bank not actually 'saved', so don't update yet
131+
groupBank.setGroupBankDuringEditing(itemContainer.getItems());
132+
}
133+
else
134+
{
135+
groupBank.updateLocalBank(itemContainer.getItems());
136+
}
137+
}
138+
139+
public void updateLocalGroupInventory(Item[] items)
140+
{
141+
groupBank.setGroupInventoryDuringEditing(items);
142+
}
143+
144+
public boolean updateGroupBankOnInventoryChange(Item[] inventoryItems)
145+
{
146+
return groupBank.updateAfterInventoryChange(inventoryItems);
147+
}
148+
118149
public void updateBankForQuestSpeedrunningWorld()
119150
{
120151
questBank.updateLocalBank(new Item[]{ });
152+
groupBank.updateLocalBank(new Item[]{ });
121153
}
122154

155+
123156
public void saveBankToConfig()
124157
{
125158
questBank.saveBankToConfig();
159+
groupBank.saveBankToConfig();
126160
}
127161

128162
public void emptyState()
129163
{
130164
questBank.emptyState();
165+
groupBank.emptyState();
131166
}
132167
}

src/main/java/com/questhelper/managers/QuestContainerManager.java

+3
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ public class QuestContainerManager
4040

4141
@Getter
4242
private final static ItemAndLastUpdated potionData = new ItemAndLastUpdated(TrackedContainers.POTION_STORAGE);
43+
44+
@Getter
45+
private final static ItemAndLastUpdated groupStorageData = new ItemAndLastUpdated(TrackedContainers.GROUP_STORAGE);
4346
}

src/main/java/com/questhelper/panel/QuestRequirementsPanel.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
package com.questhelper.panel;
2727

2828
import com.questhelper.QuestHelperPlugin;
29-
import com.questhelper.bank.QuestBank;
3029
import com.questhelper.managers.QuestManager;
3130
import com.questhelper.questhelpers.QuestHelper;
3231
import com.questhelper.requirements.Requirement;
@@ -297,6 +296,10 @@ else if (newColor == Color.ORANGE)
297296
{
298297
label.setToolTipText("On steel key ring");
299298
}
299+
else if (newColor == Color.LIGHT_GRAY)
300+
{
301+
label.setToolTipText("Possibly in Group Storage");
302+
}
300303
else
301304
{
302305
label.setToolTipText("");

0 commit comments

Comments
 (0)