Refactor MenuModifier
This commit is contained in:
@@ -31,24 +31,51 @@ import net.runelite.client.config.ConfigItem;
|
|||||||
@ConfigGroup("menumodifier")
|
@ConfigGroup("menumodifier")
|
||||||
public interface MenuModifierConfig extends Config
|
public interface MenuModifierConfig extends Config
|
||||||
{
|
{
|
||||||
@ConfigItem(position = 0, keyName = "hideCancel", name = "Hide Cancel", description = "Hides the 'cancel' option from the right click menu")
|
@ConfigItem(
|
||||||
default boolean hideCancel() { return true; }
|
position = 0,
|
||||||
|
keyName = "hideExamine",
|
||||||
@ConfigItem(position = 1, keyName = "hideExamine", name = "Hide Examine", description = "Hides the 'examine' option from the right click menu")
|
name = "Hide Examine",
|
||||||
|
description = "Hides the 'examine' option from the right click menu"
|
||||||
|
)
|
||||||
default boolean hideExamine() { return true; }
|
default boolean hideExamine() { return true; }
|
||||||
|
|
||||||
@ConfigItem(position = 2, keyName = "hideTradeWith", name = "Hide Trade With", description = "Hides the 'trade with' option from the right click menu")
|
@ConfigItem(
|
||||||
|
position = 1,
|
||||||
|
keyName = "hideTradeWith",
|
||||||
|
name = "Hide Trade With",
|
||||||
|
description = "Hides the 'trade with' option from the right click menu"
|
||||||
|
)
|
||||||
default boolean hideTradeWith() { return true; }
|
default boolean hideTradeWith() { return true; }
|
||||||
|
|
||||||
@ConfigItem(position = 3, keyName = "hideReport", name = "Hide Report", description = "Hides the 'report' option from the right click menu")
|
@ConfigItem(
|
||||||
|
position = 2,
|
||||||
|
keyName = "hideReport",
|
||||||
|
name = "Hide Report",
|
||||||
|
description = "Hides the 'report' option from the right click menu"
|
||||||
|
)
|
||||||
default boolean hideReport() { return true; }
|
default boolean hideReport() { return true; }
|
||||||
|
|
||||||
@ConfigItem(position = 4, keyName = "hideLookup", name = "Hide Lookup", description = "Hides the 'lookup' option from the right click menu")
|
@ConfigItem(
|
||||||
|
position = 3,
|
||||||
|
keyName = "hideLookup",
|
||||||
|
name = "Hide Lookup",
|
||||||
|
description = "Hides the 'lookup' option from the right click menu"
|
||||||
|
)
|
||||||
default boolean hideLookup() { return true; }
|
default boolean hideLookup() { return true; }
|
||||||
|
|
||||||
@ConfigItem(position = 4, keyName = "hideNet", name = "Hide Net", description = "Hides the 'net' option from the right click menu")
|
@ConfigItem(
|
||||||
|
position = 4,
|
||||||
|
keyName = "hideNet",
|
||||||
|
name = "Hide Net",
|
||||||
|
description = "Hides the 'net' option from the right click menu"
|
||||||
|
)
|
||||||
default boolean hideNet() { return true; }
|
default boolean hideNet() { return true; }
|
||||||
|
|
||||||
@ConfigItem(position = 4, keyName = "hideBait", name = "Hide Bait", description = "Hides the 'Bait' option from the right click menu")
|
@ConfigItem(
|
||||||
|
position = 5,
|
||||||
|
keyName = "hideBait",
|
||||||
|
name = "Hide Bait",
|
||||||
|
description = "Hides the 'Bait' option from the right click menu"
|
||||||
|
)
|
||||||
default boolean hideBait() { return true; }
|
default boolean hideBait() { return true; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,12 +24,11 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.menumodifier;
|
package net.runelite.client.plugins.menumodifier;
|
||||||
|
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import javax.inject.Inject;
|
||||||
import net.runelite.client.input.KeyListener;
|
import net.runelite.client.input.KeyListener;
|
||||||
import net.runelite.client.input.MouseAdapter;
|
import net.runelite.client.input.MouseAdapter;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
|
|
||||||
public class MenuModifierInputListener extends MouseAdapter implements KeyListener
|
public class MenuModifierInputListener extends MouseAdapter implements KeyListener
|
||||||
{
|
{
|
||||||
private static final int HOTKEY = KeyEvent.VK_CONTROL;
|
private static final int HOTKEY = KeyEvent.VK_CONTROL;
|
||||||
|
|||||||
@@ -24,18 +24,19 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.menumodifier;
|
package net.runelite.client.plugins.menumodifier;
|
||||||
|
|
||||||
import net.runelite.api.events.MenuOpened;
|
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.inject.Inject;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.MenuEntry;
|
import net.runelite.api.MenuEntry;
|
||||||
import net.runelite.api.Player;
|
import net.runelite.api.Player;
|
||||||
import net.runelite.api.events.GameTick;
|
import net.runelite.api.events.MenuOpened;
|
||||||
import net.runelite.api.events.MenuEntryAdded;
|
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.input.KeyManager;
|
import net.runelite.client.input.KeyManager;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
@@ -43,12 +44,6 @@ import net.runelite.client.plugins.PluginType;
|
|||||||
import net.runelite.client.util.MiscUtils;
|
import net.runelite.client.util.MiscUtils;
|
||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Menu Modifier",
|
name = "Menu Modifier",
|
||||||
description = "Changes right click menu for players",
|
description = "Changes right click menu for players",
|
||||||
@@ -98,37 +93,55 @@ public class MenuModifierPlugin extends Plugin
|
|||||||
Player localPlayer = client.getLocalPlayer();
|
Player localPlayer = client.getLocalPlayer();
|
||||||
|
|
||||||
if (localPlayer == null)
|
if (localPlayer == null)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(MiscUtils.getWildernessLevelFrom(client, localPlayer.getWorldLocation()) >= 0))
|
if (!(MiscUtils.getWildernessLevelFrom(client, localPlayer.getWorldLocation()) >= 0))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (hotKeyPressed)
|
if (hotKeyPressed)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
List<MenuEntry> menu_entries = new ArrayList<MenuEntry>();
|
List<MenuEntry> menu_entries = new ArrayList<>();
|
||||||
|
|
||||||
for (MenuEntry entry : event.getMenuEntries())
|
for (MenuEntry entry : event.getMenuEntries())
|
||||||
{
|
{
|
||||||
String option = Text.removeTags(entry.getOption()).toLowerCase();
|
String option = Text.removeTags(entry.getOption()).toLowerCase();
|
||||||
|
|
||||||
if (option.contains("trade with") && config.hideTradeWith())
|
if (option.contains("trade with") && config.hideTradeWith())
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (option.contains("lookup") && config.hideLookup())
|
if (option.contains("lookup") && config.hideLookup())
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (option.contains("report") && config.hideReport())
|
if (option.contains("report") && config.hideReport())
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (option.contains("examine") && config.hideExamine())
|
if (option.contains("examine") && config.hideExamine())
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (option.contains("net") && config.hideNet())
|
if (option.contains("net") && config.hideNet())
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (option.contains("bait") && config.hideBait())
|
if (option.contains("bait") && config.hideBait())
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int identifier = entry.getIdentifier();
|
int identifier = entry.getIdentifier();
|
||||||
|
|
||||||
@@ -136,7 +149,9 @@ public class MenuModifierPlugin extends Plugin
|
|||||||
Player player = null;
|
Player player = null;
|
||||||
|
|
||||||
if (identifier >= 0 && identifier < players.length)
|
if (identifier >= 0 && identifier < players.length)
|
||||||
|
{
|
||||||
player = players[identifier];
|
player = players[identifier];
|
||||||
|
}
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
@@ -145,7 +160,9 @@ public class MenuModifierPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((option.contains("attack") || option.contains("cast")) && (player.isFriend() || player.isClanMember()))
|
if ((option.contains("attack") || option.contains("cast")) && (player.isFriend() || player.isClanMember()))
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
menu_entries.add(entry);
|
menu_entries.add(entry);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user