mesenhanced: add config caching.
This commit is contained in:
@@ -39,6 +39,7 @@ import net.runelite.api.ItemID;
|
|||||||
import net.runelite.api.MenuEntry;
|
import net.runelite.api.MenuEntry;
|
||||||
import net.runelite.api.MenuOpcode;
|
import net.runelite.api.MenuOpcode;
|
||||||
import net.runelite.api.events.AnimationChanged;
|
import net.runelite.api.events.AnimationChanged;
|
||||||
|
import net.runelite.api.events.ConfigChanged;
|
||||||
import net.runelite.api.events.GameTick;
|
import net.runelite.api.events.GameTick;
|
||||||
import net.runelite.api.events.ItemContainerChanged;
|
import net.runelite.api.events.ItemContainerChanged;
|
||||||
import net.runelite.api.events.MenuEntryAdded;
|
import net.runelite.api.events.MenuEntryAdded;
|
||||||
@@ -60,7 +61,9 @@ public class MesEnhanced extends Plugin
|
|||||||
private static final int GOBLIN_SALUTE = 2128;
|
private static final int GOBLIN_SALUTE = 2128;
|
||||||
private static final String LIGHT = "Light";
|
private static final String LIGHT = "Light";
|
||||||
private static final String QUICK_BONE = "Quick Bone";
|
private static final String QUICK_BONE = "Quick Bone";
|
||||||
private static final Set<Integer> TINDER = ImmutableSet.of(ItemID.TINDERBOX, ItemID.GOLDEN_TINDERBOX);
|
private static final Set<Integer> TINDER = ImmutableSet.of(
|
||||||
|
ItemID.TINDERBOX, ItemID.GOLDEN_TINDERBOX
|
||||||
|
);
|
||||||
private static final Set<Integer> LIGHTABLE_LOGS = ImmutableSet.of(
|
private static final Set<Integer> LIGHTABLE_LOGS = ImmutableSet.of(
|
||||||
ItemID.LOGS, ItemID.ACHEY_TREE_LOGS, ItemID.OAK_LOGS,
|
ItemID.LOGS, ItemID.ACHEY_TREE_LOGS, ItemID.OAK_LOGS,
|
||||||
ItemID.WILLOW_LOGS, ItemID.TEAK_LOGS, ItemID.ARCTIC_PINE_LOGS, ItemID.MAPLE_LOGS,
|
ItemID.WILLOW_LOGS, ItemID.TEAK_LOGS, ItemID.ARCTIC_PINE_LOGS, ItemID.MAPLE_LOGS,
|
||||||
@@ -80,14 +83,15 @@ public class MesEnhanced extends Plugin
|
|||||||
private EventBus eventBus;
|
private EventBus eventBus;
|
||||||
@Inject
|
@Inject
|
||||||
private MesEnhancedConfig config;
|
private MesEnhancedConfig config;
|
||||||
|
|
||||||
private boolean tinder;
|
|
||||||
private boolean bones;
|
private boolean bones;
|
||||||
|
private boolean leftClickLog;
|
||||||
|
private boolean quickBone;
|
||||||
private boolean tick;
|
private boolean tick;
|
||||||
private int tinderIdx;
|
private boolean tinder;
|
||||||
private int tinderId;
|
|
||||||
private int bonesIdx;
|
|
||||||
private int bonesId;
|
private int bonesId;
|
||||||
|
private int bonesIdx;
|
||||||
|
private int tinderId;
|
||||||
|
private int tinderIdx;
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
MesEnhancedConfig getConfig(ConfigManager configManager)
|
MesEnhancedConfig getConfig(ConfigManager configManager)
|
||||||
@@ -98,11 +102,12 @@ public class MesEnhanced extends Plugin
|
|||||||
@Override
|
@Override
|
||||||
public void startUp()
|
public void startUp()
|
||||||
{
|
{
|
||||||
|
eventBus.subscribe(AnimationChanged.class, this, this::onAnimationChanged);
|
||||||
|
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
|
||||||
|
eventBus.subscribe(GameTick.class, this, this::onGameTick);
|
||||||
eventBus.subscribe(ItemContainerChanged.class, this, this::onItemContainerChanged);
|
eventBus.subscribe(ItemContainerChanged.class, this, this::onItemContainerChanged);
|
||||||
eventBus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded);
|
eventBus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded);
|
||||||
eventBus.subscribe(MenuOptionClicked.class, this, this::onMenuOptionClicked);
|
eventBus.subscribe(MenuOptionClicked.class, this, this::onMenuOptionClicked);
|
||||||
eventBus.subscribe(AnimationChanged.class, this, this::onAnimationChanged);
|
|
||||||
eventBus.subscribe(GameTick.class, this, this::onGameTick);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -111,6 +116,17 @@ public class MesEnhanced extends Plugin
|
|||||||
eventBus.unregister(this);
|
eventBus.unregister(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onConfigChanged(ConfigChanged event)
|
||||||
|
{
|
||||||
|
if (!event.getGroup().equals("mesEnhanced"))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.quickBone = config.quickBones();
|
||||||
|
this.leftClickLog = config.leftClickLog();
|
||||||
|
}
|
||||||
|
|
||||||
private void onGameTick(GameTick event)
|
private void onGameTick(GameTick event)
|
||||||
{
|
{
|
||||||
if (tick)
|
if (tick)
|
||||||
@@ -132,20 +148,20 @@ public class MesEnhanced extends Plugin
|
|||||||
|
|
||||||
private void onMenuEntryAdded(MenuEntryAdded event)
|
private void onMenuEntryAdded(MenuEntryAdded event)
|
||||||
{
|
{
|
||||||
if (!config.leftClickLog() && !config.quickBones())
|
if (!this.leftClickLog && !this.quickBone)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int id = event.getIdentifier();
|
final int id = event.getIdentifier();
|
||||||
|
|
||||||
if (config.leftClickLog() && tinder && event.getType() == MenuOpcode.ITEM_USE.getId()
|
if (this.leftClickLog && tinder && event.getType() == MenuOpcode.ITEM_USE.getId()
|
||||||
&& LIGHTABLE_LOGS.contains(id))
|
&& LIGHTABLE_LOGS.contains(id))
|
||||||
{
|
{
|
||||||
event.getMenuEntry().setOption(LIGHT);
|
event.getMenuEntry().setOption(LIGHT);
|
||||||
event.setWasModified(true);
|
event.setWasModified(true);
|
||||||
}
|
}
|
||||||
else if (config.quickBones() && bones && event.getType() == MenuOpcode.GAME_OBJECT_FIRST_OPTION.getId()
|
else if (this.quickBone && bones && event.getType() == MenuOpcode.GAME_OBJECT_FIRST_OPTION.getId()
|
||||||
&& event.getTarget().toLowerCase().contains("altar"))
|
&& event.getTarget().toLowerCase().contains("altar"))
|
||||||
{
|
{
|
||||||
event.getMenuEntry().setOption(QUICK_BONE);
|
event.getMenuEntry().setOption(QUICK_BONE);
|
||||||
@@ -155,14 +171,14 @@ public class MesEnhanced extends Plugin
|
|||||||
|
|
||||||
private void onMenuOptionClicked(MenuOptionClicked event)
|
private void onMenuOptionClicked(MenuOptionClicked event)
|
||||||
{
|
{
|
||||||
if (!config.leftClickLog() && !config.quickBones())
|
if (!this.leftClickLog && !this.quickBone)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final MenuEntry entry = event.getMenuEntry();
|
final MenuEntry entry = event.getMenuEntry();
|
||||||
|
|
||||||
if (config.leftClickLog() && tinder && event.getOpcode() == MenuOpcode.ITEM_USE.getId()
|
if (this.leftClickLog && tinder && event.getOpcode() == MenuOpcode.ITEM_USE.getId()
|
||||||
&& event.getOption().equals(LIGHT))
|
&& event.getOption().equals(LIGHT))
|
||||||
{
|
{
|
||||||
entry.setOpcode(MenuOpcode.ITEM_USE_ON_WIDGET_ITEM.getId());
|
entry.setOpcode(MenuOpcode.ITEM_USE_ON_WIDGET_ITEM.getId());
|
||||||
@@ -170,11 +186,11 @@ public class MesEnhanced extends Plugin
|
|||||||
client.setSelectedItemSlot(tinderIdx);
|
client.setSelectedItemSlot(tinderIdx);
|
||||||
client.setSelectedItemID(tinderId);
|
client.setSelectedItemID(tinderId);
|
||||||
}
|
}
|
||||||
else if (config.quickBones() && bones && event.getOption().equals(QUICK_BONE) && tick)
|
else if (this.quickBone && bones && event.getOption().equals(QUICK_BONE) && tick)
|
||||||
{
|
{
|
||||||
event.consume();
|
event.consume();
|
||||||
}
|
}
|
||||||
else if (config.quickBones() && bones && event.getOpcode() == MenuOpcode.GAME_OBJECT_FIRST_OPTION.getId()
|
else if (this.quickBone && bones && event.getOpcode() == MenuOpcode.GAME_OBJECT_FIRST_OPTION.getId()
|
||||||
&& event.getOption().equals(QUICK_BONE))
|
&& event.getOption().equals(QUICK_BONE))
|
||||||
{
|
{
|
||||||
entry.setOpcode(MenuOpcode.ITEM_USE_ON_GAME_OBJECT.getId());
|
entry.setOpcode(MenuOpcode.ITEM_USE_ON_GAME_OBJECT.getId());
|
||||||
@@ -187,6 +203,11 @@ public class MesEnhanced extends Plugin
|
|||||||
|
|
||||||
private void onItemContainerChanged(ItemContainerChanged event)
|
private void onItemContainerChanged(ItemContainerChanged event)
|
||||||
{
|
{
|
||||||
|
if (!this.leftClickLog && !this.quickBone)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final ItemContainer itemContainer = event.getItemContainer();
|
final ItemContainer itemContainer = event.getItemContainer();
|
||||||
final List<Item> items = Arrays.asList(itemContainer.getItems());
|
final List<Item> items = Arrays.asList(itemContainer.getItems());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user