bank: add option to force right click on deposit container buttons

This commit is contained in:
Hydrox6
2019-03-19 00:42:57 +00:00
parent ea9c97aad0
commit 0f3b9a8f3e
2 changed files with 77 additions and 0 deletions

View File

@@ -64,4 +64,37 @@ public interface BankConfig extends Config
{
return false;
}
@ConfigItem(
keyName = "rightClickBankInventory",
name = "Disable left click bank inventory",
description = "Configures whether the bank inventory button will bank your inventory on left click",
position = 4
)
default boolean rightClickBankInventory()
{
return false;
}
@ConfigItem(
keyName = "rightClickBankEquip",
name = "Disable left click bank equipment",
description = "Configures whether the bank equipment button will bank your equipment on left click",
position = 5
)
default boolean rightClickBankEquip()
{
return false;
}
@ConfigItem(
keyName = "rightClickBankLoot",
name = "Disable left click bank looting bag",
description = "Configures whether the bank looting bag button will bank your looting bag contents on left click",
position = 6
)
default boolean rightClickBankLoot()
{
return false;
}
}

View File

@@ -1,6 +1,7 @@
/*
* Copyright (c) 2018, TheLonelyDev <https://github.com/TheLonelyDev>
* Copyright (c) 2018, Jeremy Plsek <https://github.com/jplsek>
* Copyright (c) 2019, Hydrox6 <ikada@protonmail.ch>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -28,6 +29,9 @@ package net.runelite.client.plugins.bank;
import com.google.inject.Provides;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.MenuEntry;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.MenuShouldLeftClick;
import net.runelite.api.events.ScriptCallbackEvent;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager;
@@ -44,6 +48,10 @@ import net.runelite.client.util.StackFormatter;
)
public class BankPlugin extends Plugin
{
private static final String DEPOSIT_WORN = "Deposit worn items";
private static final String DEPOSIT_INVENTORY = "Deposit inventory";
private static final String DEPOSIT_LOOT = "Deposit loot";
@Inject
private Client client;
@@ -59,6 +67,8 @@ public class BankPlugin extends Plugin
@Inject
private BankSearch bankSearch;
private boolean forceRightClickFlag;
@Provides
BankConfig getConfig(ConfigManager configManager)
{
@@ -69,6 +79,40 @@ public class BankPlugin extends Plugin
protected void shutDown()
{
clientThread.invokeLater(() -> bankSearch.reset(false));
forceRightClickFlag = false;
}
@Subscribe
public void onMenuShouldLeftClick(MenuShouldLeftClick event)
{
if (!forceRightClickFlag)
{
return;
}
forceRightClickFlag = false;
MenuEntry[] menuEntries = client.getMenuEntries();
for (MenuEntry entry : menuEntries)
{
if ((entry.getOption().equals(DEPOSIT_WORN) && config.rightClickBankEquip())
|| (entry.getOption().equals(DEPOSIT_INVENTORY) && config.rightClickBankInventory())
|| (entry.getOption().equals(DEPOSIT_LOOT) && config.rightClickBankLoot()))
{
event.setForceRightClick(true);
return;
}
}
}
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded event)
{
if ((event.getOption().equals(DEPOSIT_WORN) && config.rightClickBankEquip())
|| (event.getOption().equals(DEPOSIT_INVENTORY) && config.rightClickBankInventory())
|| (event.getOption().equals(DEPOSIT_LOOT) && config.rightClickBankLoot()))
{
forceRightClickFlag = true;
}
}
@Subscribe