Merge pull request #1262 from DevDennis/fix-placeholder-bank-tags

Fix search for placeholder bank tags
This commit is contained in:
Adam
2018-04-05 11:36:42 -04:00
committed by GitHub
3 changed files with 49 additions and 3 deletions

View File

@@ -58,6 +58,23 @@ public interface ItemComposition
*/
int getLinkedNoteId();
/**
* Returns the item ID of the normal/placeholder counterpart. For example, if
* you call this on a monkfish(ID 7946), this method will
* return the ID of a placeholder monkfish(ID 17065), and vice versa.
*
* @return the ID that is linked to this item in normal/placeholder form.
*/
int getPlaceholderId();
/**
* Returns a result that depends on whether the item is in placeholder form or
* not.
*
* @return 14401 if placeholder, -1 if normal
*/
int getPlaceholderTemplateId();
/**
* Returns the store price of the item. Even if the item cannot be found
* in a store, all items have a store price from which the High and Low

View File

@@ -33,6 +33,7 @@ import net.runelite.api.Client;
import net.runelite.api.IntegerNode;
import net.runelite.api.InventoryID;
import net.runelite.api.Item;
import net.runelite.api.ItemComposition;
import net.runelite.api.ItemContainer;
import net.runelite.api.MenuAction;
import net.runelite.api.events.MenuOptionClicked;
@@ -155,6 +156,13 @@ public class BankTagsPlugin extends Plugin
String itemName = stringStack[stringStackSize - 2];
String searchInput = stringStack[stringStackSize - 1];
ItemComposition itemComposition = itemManager.getItemComposition(itemId);
if (itemComposition.getPlaceholderTemplateId() != -1)
{
// if the item is a placeholder then get the item id for the normal item
itemId = itemComposition.getPlaceholderId();
}
String tagsConfig = configManager.getConfiguration(CONFIG_GROUP, ITEM_KEY_PREFIX + itemId);
if (tagsConfig == null || tagsConfig.length() == 0)
{
@@ -211,8 +219,20 @@ public class BankTagsPlugin extends Plugin
{
return;
}
int itemId = item.getId();
String itemName = itemManager.getItemComposition(itemId).getName();
ItemComposition itemComposition = itemManager.getItemComposition(item.getId());
int itemId;
if (itemComposition.getPlaceholderTemplateId() != -1)
{
// if the item is a placeholder then get the item id for the normal item
itemId = itemComposition.getPlaceholderId();
}
else
{
itemId = item.getId();
}
String itemName = itemComposition.getName();
String initialValue = getTags(itemId);
chatboxInputManager.openInputWindow(itemName + " Tags", initialValue, (newTags) ->
@@ -234,7 +254,8 @@ public class BankTagsPlugin extends Plugin
}
Widget bankItemWidget = bankItemWidgets[inventoryIndex];
String[] actions = bankItemWidget.getActions();
if (actions == null || EDIT_TAGS_MENU_INDEX - 1 >= actions.length)
if (actions == null || EDIT_TAGS_MENU_INDEX - 1 >= actions.length
|| itemId != bankItemWidget.getItemId())
{
return;
}

View File

@@ -50,6 +50,14 @@ public interface RSItemComposition extends ItemComposition
@Override
int getLinkedNoteId();
@Import("placeholderId")
@Override
int getPlaceholderId();
@Import("placeholderTemplateId")
@Override
int getPlaceholderTemplateId();
@Import("price")
@Override
int getPrice();