Merge branch 'master' into spawn

This commit is contained in:
James
2019-10-25 00:03:47 -07:00
committed by GitHub
30 changed files with 1009 additions and 683 deletions

View File

@@ -57,9 +57,9 @@ ext {
jna = '5.4.0'
jogamp = '2.3.2'
jopt = '5.0.4'
jooq = '3.12.1'
jooq = '3.12.2'
junit = '4.12'
jupiter = '5.5.2'
jupiter = '5.6.0-M1'
logback = '1.2.3'
lombok = '1.18.10'
mapstruct = '1.3.1.Final'

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -64,8 +64,11 @@ public interface Actor extends Entity, Locatable
* </ul>
*
* @return the actor, null if no interaction is occurring
*
* (getRSInteracting returns the npc/player index, useful for menus)
*/
Actor getInteracting();
int getRSInteracting();
/**
* Gets the health ratio of the actor.

View File

@@ -341,9 +341,12 @@ public interface Client extends GameShell
* Gets the logged in player instance.
*
* @return the logged in player
*
* (getLocalPlayerIndex returns the local index, useful for menus/interacting)
*/
@Nullable
Player getLocalPlayer();
int getLocalPlayerIndex();
/**
* Gets the item composition corresponding to an items ID.

View File

@@ -26,9 +26,30 @@
*/
package net.runelite.client.config;
import java.awt.Color;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
@ConfigGroup("openosrs")
public interface OpenOSRSConfig extends Config
{
@Getter(AccessLevel.PUBLIC)
@AllArgsConstructor
enum SortStyle
{
CATEGORY("Category"),
ALPHABETICALLY("Alphabetically");
private String name;
@Override
public String toString()
{
return getName();
}
}
@ConfigTitleSection(
keyName = "pluginsTitle",
name = "Plugins",
@@ -40,12 +61,215 @@ public interface OpenOSRSConfig extends Config
return new Title();
}
@ConfigTitleSection(
keyName = "pluginSortingTitle",
name = "Sorting",
description = "",
position = 2,
titleSection = "pluginsTitle"
)
default Title pluginSortingTitle()
{
return new Title();
}
@ConfigItem(
position = 3,
keyName = "pluginSortMode",
name = "Sorting mode",
description = "Sorts plugins ",
titleSection = "pluginSortingTitle"
)
default SortStyle pluginSortMode()
{
return SortStyle.CATEGORY;
}
@ConfigTitleSection(
keyName = "hidePluginsTitle",
name = "Hide By Type",
description = "",
position = 4,
titleSection = "pluginsTitle"
)
default Title hidePluginsTitle()
{
return new Title();
}
@ConfigItem(
position = 5,
keyName = "hidePlugins",
name = "Hide All Plugins",
description = "Hides all OpenOSRS plugins if checked",
titleSection = "hidePluginsTitle",
hide = "hidePvmPlugins || hidePvpPlugins || hideSkillingPlugins || hideUtilityPlugins || hideExternalPlugins"
)
default boolean hidePlugins()
{
return false;
}
@ConfigItem(
position = 6,
keyName = "hideExternalPlugins",
name = "Hide External Plugins",
description = "Hides all OpenOSRS external plugins if checked",
titleSection = "hidePluginsTitle",
hide = "hidePlugins"
)
default boolean hideExternalPlugins()
{
return false;
}
@ConfigItem(
position = 7,
keyName = "hidePvmPlugins",
name = "Hide PvM Plugins",
description = "Hides all OpenOSRS PvM plugins if checked",
titleSection = "hidePluginsTitle",
hide = "hidePlugins"
)
default boolean hidePvmPlugins()
{
return false;
}
@ConfigItem(
position = 8,
keyName = "hideSkillingPlugins",
name = "Hide Skilling Plugins",
description = "Hides all OpenOSRS skilling plugins if checked",
titleSection = "hidePluginsTitle",
hide = "hidePlugins"
)
default boolean hideSkillingPlugins()
{
return false;
}
@ConfigItem(
position = 9,
keyName = "hidePvpPlugins",
name = "Hide PvP Plugins",
description = "Hides all OpenOSRS Pvp plugins if checked",
titleSection = "hidePluginsTitle",
hide = "hidePlugins"
)
default boolean hidePvpPlugins()
{
return false;
}
@ConfigItem(
position = 10,
keyName = "hideUtilityPlugins",
name = "Hide Utility Plugins",
description = "Hides all OpenOSRS utility plugins if checked",
titleSection = "hidePluginsTitle",
hide = "hidePlugins"
)
default boolean hideUtilityPlugins()
{
return false;
}
@ConfigTitleSection(
keyName = "pluginsColorTitle",
name = "Colors",
description = "",
position = 11,
titleSection = "pluginsTitle"
)
default Title pluginsColorTitle()
{
return new Title();
}
@Alpha
@ConfigItem(
position = 12,
keyName = "externalColor",
name = "External color",
description = "Configure the color of external plugins",
titleSection = "pluginsColorTitle"
)
default Color externalColor()
{
return new Color(177, 156, 217, 255);
}
@Alpha
@ConfigItem(
position = 13,
keyName = "pvmColor",
name = "PVM color",
description = "Configure the color of PVM related plugins",
titleSection = "pluginsColorTitle"
)
default Color pvmColor()
{
return new Color(119, 221, 119, 255);
}
@Alpha
@ConfigItem(
position = 14,
keyName = "pvpColor",
name = "PVP color",
description = "Configure the color of PVP related plugins",
titleSection = "pluginsColorTitle"
)
default Color pvpColor()
{
return new Color(255, 105, 97, 255);
}
@Alpha
@ConfigItem(
position = 15,
keyName = "skillingColor",
name = "Skilling color",
description = "Configure the color of Skilling related plugins",
titleSection = "pluginsColorTitle"
)
default Color skillingColor()
{
return new Color(252, 252, 100, 255);
}
@Alpha
@ConfigItem(
position = 16,
keyName = "utilityColor",
name = "Utility color",
description = "Configure the color of Utility related plugins",
titleSection = "pluginsColorTitle"
)
default Color utilityColor()
{
return new Color(144, 212, 237, 255);
}
@ConfigTitleSection(
keyName = "externalPluginsTitle",
name = "External",
description = "",
position = 17,
titleSection = "pluginsTitle"
)
default Title externalPluginsTitle()
{
return new Title();
}
@ConfigItem(
keyName = "enablePlugins",
name = "Enable loading of external plugins",
description = "Enable loading of external plugins",
position = 2,
titleSection = "pluginsTitle"
position = 18,
titleSection = "externalPluginsTitle"
)
default boolean enablePlugins()
{
@@ -56,7 +280,7 @@ public interface OpenOSRSConfig extends Config
keyName = "opacityTitle",
name = "Opacity",
description = "",
position = 3
position = 19
)
default Title opacityTitle()
{
@@ -67,7 +291,7 @@ public interface OpenOSRSConfig extends Config
keyName = "enableOpacity",
name = "Enable opacity",
description = "Enables opacity for the whole window.<br>NOTE: This only stays enabled if your pc supports this!",
position = 4,
position = 20,
titleSection = "opacityTitle"
)
default boolean enableOpacity()
@@ -83,7 +307,7 @@ public interface OpenOSRSConfig extends Config
keyName = "opacityPercentage",
name = "Opacity percentage",
description = "Changes the opacity of the window if opacity is enabled",
position = 5,
position = 21,
titleSection = "opacityTitle"
)
default int opacityPercentage()
@@ -95,7 +319,7 @@ public interface OpenOSRSConfig extends Config
keyName = "miscTitle",
name = "Miscellaneous",
description = "",
position = 6
position = 22
)
default Title miscTitle()
{
@@ -106,7 +330,7 @@ public interface OpenOSRSConfig extends Config
keyName = "keyboardPin",
name = "Keyboard bank pin",
description = "Enables you to type your bank pin",
position = 7,
position = 23,
titleSection = "miscTitle"
)
default boolean keyboardPin()
@@ -118,7 +342,7 @@ public interface OpenOSRSConfig extends Config
keyName = "detachHotkey",
name = "Detach Cam",
description = "Detach Camera hotkey, press this and it will activate detatched camera.",
position = 8,
position = 24,
titleSection = "miscTitle"
)
default Keybind detachHotkey()

View File

@@ -326,12 +326,21 @@ public class ItemManager
return (int) Math.max(1, getItemDefinition(itemID).getPrice() * HIGH_ALCHEMY_MULTIPLIER);
}
public int getBrokenValue(int itemId)
public int getRepairValue(int itemId)
{
PvPValueBrokenItem b = PvPValueBrokenItem.of(itemId);
return getRepairValue(itemId, false);
}
public int getRepairValue(int itemId, boolean fullValue)
{
final ItemReclaimCost b = ItemReclaimCost.of(itemId);
if (b != null)
{
if (fullValue || b.getItemID() == GRANITE_MAUL_24225 || b.getItemID() == GRANITE_MAUL_24227)
{
return b.getValue();
}
return (int) (b.getValue() * (75.0f / 100.0f));
}

View File

@@ -37,15 +37,21 @@ import net.runelite.api.ItemID;
*/
@AllArgsConstructor
@Getter
public enum PvPValueBrokenItem
public enum ItemReclaimCost
{
// Capes
FIRE_CAPE(ItemID.FIRE_CAPE, 50000),
FIRE_MAX_CAPE(ItemID.FIRE_MAX_CAPE, 50000),
FIRE_MAX_CAPE(ItemID.FIRE_MAX_CAPE, 99000),
INFERNAL_CAPE(ItemID.INFERNAL_CAPE, 50000),
INFERNAL_MAX_CAPE(ItemID.INFERNAL_MAX_CAPE, 50000),
INFERNAL_MAX_CAPE(ItemID.INFERNAL_MAX_CAPE, 99000),
AVAS_ASSEMBLER(ItemID.AVAS_ASSEMBLER, 75000),
ASSEMBLER_MAX_CAPE(ItemID.ASSEMBLER_MAX_CAPE, 75000),
ASSEMBLER_MAX_CAPE(ItemID.ASSEMBLER_MAX_CAPE, 99000),
IMBUED_GUTHIX_CAPE(ItemID.IMBUED_GUTHIX_CAPE, 75000),
IMBUED_GUTHIX_MAX_CAPE(ItemID.GUTHIX_MAX_CAPE, 99000),
IMBUED_SARADOMIN_CAPE(ItemID.IMBUED_SARADOMIN_CAPE, 75000),
IMBUED_SARADOMIN_MAX_CAPE(ItemID.SARADOMIN_MAX_CAPE, 99000),
IMBUED_ZAMORAK_CAPE(ItemID.IMBUED_ZAMORAK_CAPE, 75000),
IMBUED_ZAMORAK_MAX_CAPE(ItemID.ZAMORAK_MAX_CAPE, 99000),
// Defenders
BRONZE_DEFENDER(ItemID.BRONZE_DEFENDER, 1000),
@@ -90,15 +96,19 @@ public enum PvPValueBrokenItem
GOLD_DECORATIVE_LEGS(ItemID.DECORATIVE_ARMOUR_4510, 5000),
GOLD_DECORATIVE_SKIRT(ItemID.DECORATIVE_ARMOUR_11895, 5000),
GOLD_DECORATIVE_SHIELD(ItemID.DECORATIVE_SHIELD_4512, 5000),
GOLD_DECORATIVE_SWORD(ItemID.DECORATIVE_SWORD_4508, 5000);
GOLD_DECORATIVE_SWORD(ItemID.DECORATIVE_SWORD_4508, 5000),
private static final ImmutableMap<Integer, PvPValueBrokenItem> idMap;
// Granite Maul
GRANITE_MAUL(ItemID.GRANITE_MAUL_24225, 375000),
GRANITE_MAUL_OR(ItemID.GRANITE_MAUL_24227, 375000);
private static final ImmutableMap<Integer, ItemReclaimCost> idMap;
static
{
ImmutableMap.Builder<Integer, PvPValueBrokenItem> builder = ImmutableMap.builder();
ImmutableMap.Builder<Integer, ItemReclaimCost> builder = ImmutableMap.builder();
for (PvPValueBrokenItem items : values())
for (ItemReclaimCost items : values())
{
builder.put(items.itemID, items);
}
@@ -110,7 +120,7 @@ public enum PvPValueBrokenItem
private final int value;
@Nullable
public static PvPValueBrokenItem of(int itemId)
public static ItemReclaimCost of(int itemId)
{
return idMap.get(itemId);
}

View File

@@ -91,6 +91,8 @@ public class MenuManager
private MenuEntry leftClickEntry = null;
private MenuEntry firstEntry = null;
private int playerAttackIdx = -1;
@Inject
private MenuManager(Client client, EventBus eventBus)
{
@@ -500,6 +502,29 @@ public class MenuManager
return index;
}
public int getPlayerAttackOpcode()
{
final String[] playerMenuOptions = client.getPlayerOptions();
if (playerAttackIdx != -1 && playerMenuOptions[playerAttackIdx].equals("Attack"))
{
return client.getPlayerMenuTypes()[playerAttackIdx];
}
playerAttackIdx = -1;
for (int i = IDX_LOWER; i < IDX_UPPER; i++)
{
if ("Attack".equals(playerMenuOptions[i]))
{
playerAttackIdx = i;
break;
}
}
return playerAttackIdx >= 0 ? client.getPlayerMenuTypes()[playerAttackIdx] : -1;
}
/**
* Adds to the set of menu entries which when present, will remove all entries except for this one
*/
@@ -522,7 +547,7 @@ public class MenuManager
AbstractComparableEntry entry = newBaseComparableEntry(option, target);
priorityEntries.removeIf(entry::equals);
priorityEntries.remove(entry);
}
@@ -562,7 +587,7 @@ public class MenuManager
public void removePriorityEntry(AbstractComparableEntry entry)
{
priorityEntries.removeIf(entry::equals);
priorityEntries.remove(entry);
}
public void removePriorityEntry(String option)
@@ -571,7 +596,7 @@ public class MenuManager
AbstractComparableEntry entry = newBaseComparableEntry(option, "", false);
priorityEntries.removeIf(entry::equals);
priorityEntries.remove(entry);
}
public void removePriorityEntry(String option, boolean strictOption)
@@ -581,7 +606,17 @@ public class MenuManager
AbstractComparableEntry entry =
newBaseComparableEntry(option, "", -1, -1, false, strictOption);
priorityEntries.removeIf(entry::equals);
priorityEntries.remove(entry);
}
public void addPriorityEntries(Collection<AbstractComparableEntry> entries)
{
priorityEntries.addAll(entries);
}
public void removePriorityEntries(Collection<AbstractComparableEntry> entries)
{
priorityEntries.removeAll(entries);
}
/**

View File

@@ -8,6 +8,5 @@ public enum PluginType
UTILITY,
GENERAL_USE,
EXTERNAL,
PLUGIN_ORGANIZER,
IMPORTANT
}

View File

@@ -26,6 +26,7 @@ package net.runelite.client.plugins.config;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import java.awt.BorderLayout;
import java.awt.Color;
@@ -45,6 +46,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
@@ -105,6 +107,7 @@ import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginInstantiationException;
import net.runelite.client.plugins.PluginManager;
import net.runelite.client.plugins.PluginType;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.DynamicGridLayout;
import net.runelite.client.ui.FontManager;
@@ -137,7 +140,7 @@ public class ConfigPanel extends PluginPanel
private static final String RUNELITE_GROUP_NAME = RuneLiteConfig.class.getAnnotation(ConfigGroup.class).value();
private static final String PINNED_PLUGINS_CONFIG_KEY = "pinnedPlugins";
private static final String RUNELITE_PLUGIN = "RuneLite";
private static final String openosrs_PLUGIN = "OpenOSRS";
private static final String OPENOSRS_PLUGIN = "OpenOSRS";
private static final String CHAT_COLOR_PLUGIN = "Chat Color";
private final PluginManager pluginManager;
private final ConfigManager configManager;
@@ -156,6 +159,9 @@ public class ConfigPanel extends PluginPanel
private boolean showingPluginList = true;
private int scrollBarPosition = 0;
private static final ImmutableList<PluginType> definedOrder = ImmutableList.of(PluginType.IMPORTANT, PluginType.EXTERNAL, PluginType.PVM, PluginType.SKILLING, PluginType.PVP, PluginType.UTILITY, PluginType.GENERAL_USE);
private static final Comparator<PluginListItem> categoryComparator = Comparator.comparing(plugin -> definedOrder.indexOf(plugin.getPluginType()));
static
{
final BufferedImage backIcon = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "config_back_icon.png");
@@ -282,15 +288,15 @@ public class ConfigPanel extends PluginPanel
// set OpenOSRS config on top, as it should always have been
final PluginListItem openosrs = new PluginListItem(this, configManager, OpenOSRSConfig,
configManager.getConfigDescriptor(OpenOSRSConfig),
openosrs_PLUGIN, "OpenOSRS client settings", "client");
openosrs.setPinned(pinnedPlugins.contains(openosrs_PLUGIN));
OPENOSRS_PLUGIN, "OpenOSRS client settings", PluginType.IMPORTANT, "client");
openosrs.setPinned(pinnedPlugins.contains(OPENOSRS_PLUGIN));
openosrs.nameLabel.setForeground(Color.WHITE);
pluginList.add(openosrs);
// set RuneLite config on top, as it should always have been
final PluginListItem runeLite = new PluginListItem(this, configManager, runeLiteConfig,
configManager.getConfigDescriptor(runeLiteConfig),
RUNELITE_PLUGIN, "RuneLite client settings", "client");
RUNELITE_PLUGIN, "RuneLite client settings", PluginType.IMPORTANT, "client");
runeLite.setPinned(pinnedPlugins.contains(RUNELITE_PLUGIN));
runeLite.nameLabel.setForeground(Color.WHITE);
pluginList.add(runeLite);
@@ -307,18 +313,21 @@ public class ConfigPanel extends PluginPanel
final PluginListItem listItem = new PluginListItem(this, configManager, plugin, descriptor, config, configDescriptor);
listItem.setPinned(pinnedPlugins.contains(listItem.getName()));
listItem.setColor(getColorByCategory(OpenOSRSConfig, listItem.getPluginType()));
listItem.setHidden(getHiddenByCategory(OpenOSRSConfig, listItem.getPluginType()));
plugins.add(listItem);
}
);
final PluginListItem chatColor = new PluginListItem(this, configManager, chatColorConfig,
configManager.getConfigDescriptor(chatColorConfig),
CHAT_COLOR_PLUGIN, "Recolor chat text", "colour", "messages");
CHAT_COLOR_PLUGIN, "Recolor chat text", PluginType.GENERAL_USE, "colour", "messages");
chatColor.setPinned(pinnedPlugins.contains(CHAT_COLOR_PLUGIN));
chatColor.nameLabel.setForeground(Color.WHITE);
plugins.add(chatColor);
pluginList.addAll(plugins);
ConfigPanel.sortPluginList(OpenOSRSConfig, null);
}
void refreshPluginList()
@@ -466,10 +475,17 @@ public class ConfigPanel extends PluginPanel
String name = listItem.getName();
JLabel title = new JLabel(name);
title.setForeground(Color.WHITE);
title.setForeground(listItem.getColor());
title.setToolTipText("<html>" + name + ":<br>" + listItem.getDescription() + "</html>");
topPanel.add(title);
IconButton toggleButton = new IconButton(PluginListItem.OFF_SWITCHER);
toggleButton.setPreferredSize(new Dimension(25, 0));
listItem.updateToggleButton(toggleButton);
listItem.attachToggleButtonListener(toggleButton);
topPanel.add(toggleButton, BorderLayout.EAST);
final Map<String, JPanel> sectionWidgets = new HashMap<>();
final Map<String, JPanel> titleSectionWidgets = new HashMap<>();
@@ -1379,4 +1395,70 @@ public class ConfigPanel extends PluginPanel
{
openGroupConfigPanel(listItem, config, cd, true);
}
public static Color getColorByCategory(OpenOSRSConfig openOSRSConfig, PluginType pluginType)
{
switch (pluginType)
{
case EXTERNAL:
return openOSRSConfig.externalColor();
case PVM:
return openOSRSConfig.pvmColor();
case PVP:
return openOSRSConfig.pvpColor();
case SKILLING:
return openOSRSConfig.skillingColor();
case UTILITY:
return openOSRSConfig.utilityColor();
}
return null;
}
public static boolean getHiddenByCategory(OpenOSRSConfig openOSRSConfig, PluginType pluginType)
{
if (pluginType == PluginType.IMPORTANT || pluginType == PluginType.GENERAL_USE)
{
return false;
}
if (openOSRSConfig.hidePlugins())
{
return true;
}
switch (pluginType)
{
case EXTERNAL:
return openOSRSConfig.hideExternalPlugins();
case PVM:
return openOSRSConfig.hidePvmPlugins();
case PVP:
return openOSRSConfig.hidePvpPlugins();
case SKILLING:
return openOSRSConfig.hideSkillingPlugins();
case UTILITY:
return openOSRSConfig.hideUtilityPlugins();
}
return false;
}
public static void sortPluginList(OpenOSRSConfig openOSRSConfig, Comparator<PluginListItem> comparator)
{
if (comparator != null)
{
ConfigPanel.pluginList.sort(comparator.thenComparing(PluginListItem::getName));
return;
}
if (openOSRSConfig.pluginSortMode() == net.runelite.client.config.OpenOSRSConfig.SortStyle.CATEGORY)
{
ConfigPanel.pluginList.sort(categoryComparator.thenComparing(PluginListItem::getName));
}
else
{
ConfigPanel.pluginList.sort(Comparator.comparing(PluginListItem::getName));
}
}
}

View File

@@ -25,6 +25,7 @@
package net.runelite.client.plugins.config;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.image.BufferedImage;
@@ -43,6 +44,7 @@ import net.runelite.client.config.ConfigDescriptor;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.PluginPanel;
import net.runelite.client.ui.components.IconButton;
@@ -58,7 +60,7 @@ public class PluginListItem extends JPanel
private static final ImageIcon CONFIG_ICON;
private static final ImageIcon CONFIG_ICON_HOVER;
private static final ImageIcon ON_SWITCHER;
private static final ImageIcon OFF_SWITCHER;
public static final ImageIcon OFF_SWITCHER;
private static final ImageIcon ON_STAR;
private static final ImageIcon OFF_STAR;
@@ -82,12 +84,16 @@ public class PluginListItem extends JPanel
@Getter(AccessLevel.PUBLIC)
private final String description;
@Getter(AccessLevel.PUBLIC)
private final PluginType pluginType;
private final List<String> keywords = new ArrayList<>();
private final IconButton pinButton = new IconButton(OFF_STAR);
private final IconButton configButton = new IconButton(CONFIG_ICON, CONFIG_ICON_HOVER);
private final IconButton toggleButton = new IconButton(OFF_SWITCHER);
@Getter
private boolean isPluginEnabled = false;
@Getter
@@ -96,6 +102,8 @@ public class PluginListItem extends JPanel
@Getter
private boolean isHidden = false;
private Color color = null;
static
{
BufferedImage configIcon = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "config_edit_icon.png");
@@ -131,20 +139,20 @@ public class PluginListItem extends JPanel
@Nullable Config config, @Nullable ConfigDescriptor configDescriptor)
{
this(configPanel, configManager, plugin, config, configDescriptor,
descriptor.name(), descriptor.description(), descriptor.tags());
descriptor.name(), descriptor.description(), descriptor.type(), descriptor.tags());
}
/**
* Creates a new {@code PluginListItem} for a core configuration.
*/
PluginListItem(ConfigPanel configPanel, ConfigManager configManager, Config config, ConfigDescriptor configDescriptor,
String name, String description, String... tags)
String name, String description, PluginType pluginType, String... tags)
{
this(configPanel, configManager, null, config, configDescriptor, name, description, tags);
this(configPanel, configManager, null, config, configDescriptor, name, description, pluginType, tags);
}
private PluginListItem(ConfigPanel configPanel, ConfigManager configManager, @Nullable Plugin plugin, @Nullable Config config,
@Nullable ConfigDescriptor configDescriptor, String name, String description, String... tags)
@Nullable ConfigDescriptor configDescriptor, String name, String description, PluginType pluginType, String... tags)
{
this.configPanel = configPanel;
this.plugin = plugin;
@@ -152,6 +160,7 @@ public class PluginListItem extends JPanel
this.configDescriptor = configDescriptor;
this.name = name;
this.description = description;
this.pluginType = pluginType;
Collections.addAll(keywords, name.toLowerCase().split(" "));
Collections.addAll(keywords, description.toLowerCase().split(" "));
Collections.addAll(keywords, tags);
@@ -206,7 +215,7 @@ public class PluginListItem extends JPanel
buttonPanel.add(toggleButton);
}
private void attachToggleButtonListener(IconButton button)
void attachToggleButtonListener(IconButton button)
{
// no need for a listener if there is no plugin to enable / disable
if (plugin == null)
@@ -231,15 +240,6 @@ public class PluginListItem extends JPanel
});
}
IconButton createToggleButton()
{
IconButton button = new IconButton(OFF_SWITCHER);
button.setPreferredSize(new Dimension(25, 0));
updateToggleButton(button);
attachToggleButtonListener(button);
return button;
}
void setPluginEnabled(boolean enabled)
{
isPluginEnabled = enabled;
@@ -253,12 +253,28 @@ public class PluginListItem extends JPanel
pinButton.setToolTipText(pinned ? "Unpin plugin" : "Pin plugin");
}
Color getColor()
{
return this.color == null ? Color.WHITE : this.color;
}
public void setColor(Color color)
{
if (color == null)
{
return;
}
this.color = color;
this.nameLabel.setForeground(color);
}
public void setHidden(boolean hidden)
{
isHidden = hidden;
}
private void updateToggleButton(IconButton button)
void updateToggleButton(IconButton button)
{
button.setIcon(isPluginEnabled ? ON_SWITCHER : OFF_SWITCHER);
button.setToolTipText(isPluginEnabled ? "Disable plugin" : "Enable plugin");

View File

@@ -472,14 +472,25 @@ public interface ItemChargeConfig extends Config
return true;
}
@ConfigItem(
keyName = "showBasketCharges",
name = "Show Basket Quantity",
description = "Configures if the number of fruit in a basket is shown",
position = 26
)
default boolean showBasketCharges()
{
return true;
}
@ConfigItem(
keyName = "showInfoboxes",
name = "Show Infoboxes",
description = "Configures whether to show an infobox equipped charge items",
position = 26
position = 27
)
default boolean showInfoboxes()
{
return false;
}
}
}

View File

@@ -36,9 +36,11 @@ import static net.runelite.client.plugins.itemcharges.ItemChargeType.ABYSSAL_BRA
import static net.runelite.client.plugins.itemcharges.ItemChargeType.BELLOWS;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.FUNGICIDE_SPRAY;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.IMPBOX;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.SACK;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.TELEPORT;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERCAN;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERSKIN;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.FRUIT_BASKET;
import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.overlay.WidgetItemOverlay;
import net.runelite.client.ui.overlay.components.TextComponent;
@@ -160,6 +162,8 @@ class ItemChargeOverlay extends WidgetItemOverlay
|| (type == WATERCAN && !plugin.isShowWateringCanCharges())
|| (type == WATERSKIN && !plugin.isShowWaterskinCharges())
|| (type == BELLOWS && !plugin.isShowBellowCharges())
|| (type == FRUIT_BASKET && !plugin.isShowBasketCharges())
|| (type == SACK && !plugin.isShowSackCharges())
|| (type == ABYSSAL_BRACELET && !plugin.isShowAbyssalBraceletCharges()))
{
return;
@@ -180,7 +184,7 @@ class ItemChargeOverlay extends WidgetItemOverlay
{
return plugin.isShowTeleportCharges() || plugin.isShowDodgyCount() || plugin.isShowFungicideCharges()
|| plugin.isShowImpCharges() || plugin.isShowWateringCanCharges() || plugin.isShowWaterskinCharges()
|| plugin.isShowBellowCharges() || plugin.isShowAbyssalBraceletCharges() || plugin.isShowExplorerRingCharges()
|| plugin.isShowBellowCharges() || plugin.isShowBasketCharges() || plugin.isShowSackCharges() || plugin.isShowAbyssalBraceletCharges() || plugin.isShowExplorerRingCharges()
|| plugin.isShowRingOfForgingCount();
}
}
}

View File

@@ -956,6 +956,7 @@ public class ItemChargePlugin extends Plugin
this.showXericTalismanCharges = config.showXericTalismanCharges();
this.showrecoil = config.showrecoil();
this.chronicle = config.chronicle();
this.showBasketCharges = config.showBasketCharges();
this.showSackCharges = config.showSackCharges();
}
}

View File

@@ -1,113 +0,0 @@
/*
* Copyright (c) 2018, TheStonedTurtle <https://github.com/TheStonedTurtle>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.itemskeptondeath;
import com.google.common.collect.ImmutableMap;
import javax.annotation.Nullable;
import lombok.AllArgsConstructor;
import net.runelite.api.ItemID;
/**
* Some non tradeable items are kept on death inside low level wilderness (1-20) but are turned into a broken variant.
*
* The non-broken variant will be shown inside the interface.
*/
@AllArgsConstructor
enum BrokenOnDeathItem
{
// Capes
FIRE_CAPE(ItemID.FIRE_CAPE, 50000),
FIRE_MAX_CAPE(ItemID.FIRE_MAX_CAPE, 50000),
INFERNAL_CAPE(ItemID.INFERNAL_CAPE, 50000),
INFERNAL_MAX_CAPE(ItemID.INFERNAL_MAX_CAPE, 50000),
AVAS_ASSEMBLER(ItemID.AVAS_ASSEMBLER, 75000),
ASSEMBLER_MAX_CAPE(ItemID.ASSEMBLER_MAX_CAPE, 75000),
// Defenders
BRONZE_DEFENDER(ItemID.BRONZE_DEFENDER, 1000),
IRON_DEFENDER(ItemID.IRON_DEFENDER, 2000),
STEEL_DEFENDER(ItemID.STEEL_DEFENDER, 2500),
BLACK_DEFENDER(ItemID.BLACK_DEFENDER, 5000),
MITHRIL_DEFENDER(ItemID.MITHRIL_DEFENDER, 15000),
ADAMANT_DEFENDER(ItemID.ADAMANT_DEFENDER, 25000),
RUNE_DEFENDER(ItemID.RUNE_DEFENDER, 35000),
DRAGON_DEFENDER(ItemID.DRAGON_DEFENDER, 40000),
AVERNIC_DEFENDER(ItemID.AVERNIC_DEFENDER, 1000000),
// Void
VOID_MAGE_HELM(ItemID.VOID_MAGE_HELM, 40000),
VOID_RANGER_HELM(ItemID.VOID_RANGER_HELM, 40000),
VOID_MELEE_HELM(ItemID.VOID_MELEE_HELM, 40000),
VOID_KNIGHT_TOP(ItemID.VOID_KNIGHT_TOP, 45000),
VOID_KNIGHT_ROBE(ItemID.VOID_KNIGHT_ROBE, 45000),
VOID_KNIGHT_GLOVES(ItemID.VOID_KNIGHT_GLOVES, 30000),
ELITE_VOID_TOP(ItemID.ELITE_VOID_TOP, 50000),
ELITE_VOID_ROBE(ItemID.ELITE_VOID_ROBE, 50000),
// Barb Assault
FIGHTER_HAT(ItemID.FIGHTER_HAT, 45000),
RANGER_HAT(ItemID.RANGER_HAT, 45000),
HEALER_HAT(ItemID.HEALER_HAT, 45000),
FIGHTER_TORSO(ItemID.FIGHTER_TORSO, 50000),
PENANCE_SKIRT(ItemID.PENANCE_SKIRT, 20000),
// Castle Wars
SARADOMIN_HALO(ItemID.SARADOMIN_HALO, 25000),
ZAMORAK_HALO(ItemID.ZAMORAK_HALO, 25000),
GUTHIX_HALO(ItemID.GUTHIX_HALO, 25000),
DECORATIVE_MAGIC_HAT(ItemID.DECORATIVE_ARMOUR_11898, 5000),
DECORATIVE_MAGIC_ROBE_TOP(ItemID.DECORATIVE_ARMOUR_11896, 5000),
DECORATIVE_MAGIC_ROBE_LEGS(ItemID.DECORATIVE_ARMOUR_11897, 5000),
DECORATIVE_RANGE_TOP(ItemID.DECORATIVE_ARMOUR_11899, 5000),
DECORATIVE_RANGE_BOTTOM(ItemID.DECORATIVE_ARMOUR_11900, 5000),
DECORATIVE_RANGE_QUIVER(ItemID.DECORATIVE_ARMOUR_11901, 5000),
GOLD_DECORATIVE_HELM(ItemID.DECORATIVE_HELM_4511, 5000),
GOLD_DECORATIVE_BODY(ItemID.DECORATIVE_ARMOUR_4509, 5000),
GOLD_DECORATIVE_LEGS(ItemID.DECORATIVE_ARMOUR_4510, 5000),
GOLD_DECORATIVE_SKIRT(ItemID.DECORATIVE_ARMOUR_11895, 5000),
GOLD_DECORATIVE_SHIELD(ItemID.DECORATIVE_SHIELD_4512, 5000),
GOLD_DECORATIVE_SWORD(ItemID.DECORATIVE_SWORD_4508, 5000);
private final int itemID;
private final int repairPrice;
private static final ImmutableMap<Integer, Integer> REPAIR_MAP;
static
{
final ImmutableMap.Builder<Integer, Integer> map = new ImmutableMap.Builder<>();
for (final BrokenOnDeathItem p : values())
{
map.put(p.itemID, p.repairPrice);
}
REPAIR_MAP = map.build();
}
@Nullable
static Integer getRepairPrice(int itemId)
{
return REPAIR_MAP.get(itemId);
}
}

View File

@@ -26,7 +26,9 @@
package net.runelite.client.plugins.itemskeptondeath;
import com.google.common.annotations.VisibleForTesting;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumSet;
@@ -44,8 +46,8 @@ import net.runelite.api.Constants;
import net.runelite.api.FontID;
import net.runelite.api.InventoryID;
import net.runelite.api.Item;
import net.runelite.api.ItemDefinition;
import net.runelite.api.ItemContainer;
import net.runelite.api.ItemDefinition;
import net.runelite.api.ItemID;
import net.runelite.api.ScriptID;
import net.runelite.api.SkullIcon;
@@ -60,8 +62,10 @@ import net.runelite.api.widgets.WidgetType;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.ItemManager;
import net.runelite.client.game.ItemMapping;
import net.runelite.client.game.ItemReclaimCost;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.QuantityFormatter;
@PluginDescriptor(
@@ -354,7 +358,7 @@ public class ItemsKeptOnDeathPlugin extends Plugin
if (!Pets.isPet(id)
&& !LostIfNotProtected.isLostIfNotProtected(id)
&& !isTradeable(itemManager.getItemDefinition(id)) && wildyLevel <= DEEP_WILDY
&& (wildyLevel <= 0 || BrokenOnDeathItem.getRepairPrice(i.getId()) != null))
&& (wildyLevel <= 0 || ItemReclaimCost.of(id) != null))
{
keptItems.add(new ItemStack(id, qty));
}
@@ -460,10 +464,10 @@ public class ItemsKeptOnDeathPlugin extends Plugin
}
// Jagex uses the repair price when determining which items are kept on death.
final Integer repairPrice = BrokenOnDeathItem.getRepairPrice(canonicalizedItemId);
final ItemReclaimCost repairPrice = ItemReclaimCost.of(canonicalizedItemId);
if (repairPrice != null)
{
exchangePrice = repairPrice;
exchangePrice = repairPrice.getValue();
}
if (exchangePrice == 0)
@@ -573,20 +577,51 @@ public class ItemsKeptOnDeathPlugin extends Plugin
textWidget.revalidate();
// Update Items lost total value
long total = 0;
long theyGet = 0;
long youLose = 0;
for (final Widget w : lostItems)
{
int cid = itemManager.canonicalize(w.getItemId());
final int cid = itemManager.canonicalize(w.getItemId());
final TrueItemValue trueItemValue = TrueItemValue.map(cid);
final Collection<Integer> mapping = ItemMapping.map(cid);
final int breakValue = itemManager.getRepairValue(cid);
if (breakValue != 0)
{
youLose -= breakValue;
theyGet += breakValue;
}
if (trueItemValue != null)
{
int truePrice = 0;
for (int id : trueItemValue.getDeconstructedItem())
{
if (mapping.contains(id))
{
continue;
}
truePrice += itemManager.getItemPrice(id);
}
youLose += truePrice;
}
int price = itemManager.getItemPrice(cid);
if (price == 0)
if (price == 0 && breakValue == 0)
{
// Default to alch price
price = (int) (itemManager.getItemDefinition(cid).getPrice() * Constants.HIGH_ALCHEMY_MULTIPLIER);
}
total += (long) price * w.getItemQuantity();
theyGet += (long) price * w.getItemQuantity();
}
final Widget lostValue = client.getWidget(WidgetInfo.ITEMS_LOST_VALUE);
lostValue.setText(QuantityFormatter.quantityToStackSize(total) + " gp");
lostValue.setText("They get: " + QuantityFormatter.quantityToStackSize(theyGet) +
"<br>You lose: " + ColorUtil.prependColorTag("(" + QuantityFormatter.quantityToStackSize(theyGet + youLose) + ")", Color.red));
// Update Max items kept
final Widget max = client.getWidget(WidgetInfo.ITEMS_KEPT_MAX);

View File

@@ -0,0 +1,45 @@
package net.runelite.client.plugins.itemskeptondeath;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.util.Set;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import static net.runelite.api.ItemID.ABYSSAL_TENTACLE;
import static net.runelite.api.ItemID.ABYSSAL_WHIP;
import static net.runelite.api.ItemID.GRANITE_CLAMP;
import static net.runelite.api.ItemID.GRANITE_MAUL;
import static net.runelite.api.ItemID.GRANITE_MAUL_24225;
import static net.runelite.api.ItemID.GRANITE_MAUL_24227;
import static net.runelite.api.ItemID.KRAKEN_TENTACLE;
import static net.runelite.api.ItemID.ORNATE_MAUL_HANDLE;
@Getter
@RequiredArgsConstructor
public enum TrueItemValue
{
GRANITE_MAUL_HANDLE(GRANITE_MAUL_24225, ImmutableSet.of(ORNATE_MAUL_HANDLE, GRANITE_MAUL)),
GRANITE_MAUL_HANDLE_OR(GRANITE_MAUL_24227, ImmutableSet.of(ORNATE_MAUL_HANDLE, GRANITE_MAUL, GRANITE_CLAMP)),
TENTACLE_WHIP(ABYSSAL_TENTACLE, ImmutableSet.of(ABYSSAL_WHIP, KRAKEN_TENTACLE));
private static final ImmutableMap<Integer, TrueItemValue> TRUE_ITEM_VALUE_MAP;
private final int itemID;
private final Set<Integer> deconstructedItem;
static
{
ImmutableMap.Builder<Integer, TrueItemValue> map = ImmutableMap.builder();
for (TrueItemValue p : values())
{
map.put(p.getItemID(), p);
}
TRUE_ITEM_VALUE_MAP = map.build();
}
public static TrueItemValue map(int itemId)
{
return TRUE_ITEM_VALUE_MAP.getOrDefault(itemId, null);
}
}

View File

@@ -118,7 +118,7 @@ public class LootRecordWriter
{
totalBrackets++;
}
else if (line.contains("}"))
if (line.contains("}"))
{
totalBrackets--;
}

View File

@@ -27,6 +27,8 @@
package net.runelite.client.plugins.openosrs;
import java.awt.event.KeyEvent;
import java.util.Arrays;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
@@ -37,7 +39,6 @@ import net.runelite.api.events.ScriptCallbackEvent;
import net.runelite.api.widgets.WidgetID;
import static net.runelite.api.widgets.WidgetInfo.*;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.Keybind;
import net.runelite.client.config.OpenOSRSConfig;
import net.runelite.client.eventbus.EventBus;
@@ -45,6 +46,8 @@ import net.runelite.client.input.KeyListener;
import net.runelite.client.input.KeyManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType;
import net.runelite.client.plugins.config.ConfigPanel;
import net.runelite.client.util.HotkeyListener;
@PluginDescriptor(
@@ -57,6 +60,8 @@ import net.runelite.client.util.HotkeyListener;
public class OpenOSRSPlugin extends Plugin
{
private final openosrsKeyListener keyListener = new openosrsKeyListener();
private final List<String> colorOptions = Arrays.asList("externalColor", "pvmColor", "pvpColor", "skillingColor", "utilityColor");
@Inject
private OpenOSRSConfig config;
@@ -72,9 +77,6 @@ public class OpenOSRSPlugin extends Plugin
@Inject
private EventBus eventbus;
@Inject
private ConfigManager configManager;
private HotkeyListener hotkeyListener = new HotkeyListener(() -> this.keybind)
{
@Override
@@ -94,7 +96,6 @@ public class OpenOSRSPlugin extends Plugin
@Override
protected void startUp() throws Exception
{
migrateConfigs();
addSubscriptions();
entered = -1;
@@ -123,6 +124,16 @@ public class OpenOSRSPlugin extends Plugin
return;
}
if (colorOptions.stream().anyMatch(option -> option.equals(event.getKey())))
{
updatePlugins();
}
if (event.getKey().equals("pluginSortMode"))
{
ConfigPanel.sortPluginList(config, null);
}
this.keybind = config.detachHotkey();
if (!config.keyboardPin())
@@ -254,35 +265,17 @@ public class OpenOSRSPlugin extends Plugin
}
}
/**
* Migrates configs from runenergy and regenmeter to this plugin and deletes the old config values.
* This method should be removed after a reasonable amount of time.
*/
@Deprecated
private void migrateConfigs()
private void updatePlugins()
{
migrateConfig("runeliteplus", "enableOpacity");
migrateConfig("runeliteplus", "opacityPercentage");
migrateConfig("runeliteplus", "keyboardPin");
migrateConfig("runeliteplus", "enablePlugins");
migrateConfig("runeliteplus", "detachHotkey");
}
/**
* Wrapper for migrating individual config options
* This method should be removed after a reasonable amount of time.
*
* @param group old group name
* @param key key name to migrate
*/
@Deprecated
private void migrateConfig(String group, String key)
{
String value = configManager.getConfiguration(group, key);
if (value != null)
ConfigPanel.pluginList.forEach(listItem ->
{
configManager.setConfiguration("openosrs", key, value);
configManager.unsetConfiguration(group, key);
}
if (listItem.getPluginType() == PluginType.GENERAL_USE || listItem.getPluginType() == PluginType.IMPORTANT)
{
return;
}
listItem.setColor(ConfigPanel.getColorByCategory(config, listItem.getPluginType()));
listItem.setHidden(ConfigPanel.getHiddenByCategory(config, listItem.getPluginType()));
});
}
}

View File

@@ -24,6 +24,7 @@
*/
package net.runelite.client.plugins.opponentinfo;
import java.awt.Color;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@@ -65,12 +66,47 @@ public interface OpponentInfoConfig extends Config
}
@ConfigItem(
keyName = "showOpponentsInMenu",
name = "Show opponents in menu",
description = "Marks opponents names in the menu which you are attacking or are attacking you (NPC only)",
position = 3
keyName = "showAttackersMenu",
name = "Show attackers in menu",
description = "Marks attackers' names in menus with a *<br>",
position = 3,
warning = "NOTE: This'll also mark people who are following you/interacting with you in any other way. Don't blindly trust this in pvp!"
)
default boolean showOpponentsInMenu()
default boolean showAttackersMenu()
{
return false;
}
@ConfigItem(
keyName = "showAttackingMenu",
name = "Green main target",
description = "Display main target's name colored in menus (Players and NPCs)",
position = 4,
warning = "NOTE: This'll also show green when following/interacting in any other way. Don't blindly trust this in pvp!"
)
default boolean showAttackingMenu()
{
return false;
}
@ConfigItem(
keyName = "attackingColor",
name = "Target color",
description = "The color your target will be highlighted with",
position = 5
)
default Color attackingColor()
{
return Color.GREEN;
}
@ConfigItem(
keyName = "showHitpointsMenu",
name = "Show NPC hp in menu",
description = "Show NPC hp in menu. Useful when barraging",
position = 6
)
default boolean showHitpointsMenu()
{
return false;
}

View File

@@ -36,11 +36,7 @@ import javax.inject.Singleton;
import net.runelite.api.Actor;
import net.runelite.api.Client;
import static net.runelite.api.MenuOpcode.RUNELITE_OVERLAY_CONFIG;
import net.runelite.api.NPC;
import net.runelite.api.Player;
import net.runelite.api.Varbits;
import net.runelite.client.game.HiscoreManager;
import net.runelite.client.game.NPCManager;
import net.runelite.client.ui.overlay.Overlay;
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
import net.runelite.client.ui.overlay.OverlayMenuEntry;
@@ -51,7 +47,6 @@ import net.runelite.client.ui.overlay.components.PanelComponent;
import net.runelite.client.ui.overlay.components.ProgressBarComponent;
import net.runelite.client.ui.overlay.components.TitleComponent;
import net.runelite.api.util.Text;
import net.runelite.http.api.hiscore.HiscoreResult;
@Singleton
class OpponentInfoOverlay extends Overlay
@@ -61,8 +56,6 @@ class OpponentInfoOverlay extends Overlay
private final Client client;
private final OpponentInfoPlugin opponentInfoPlugin;
private final HiscoreManager hiscoreManager;
private final NPCManager npcManager;
private final PanelComponent panelComponent = new PanelComponent();
@@ -75,15 +68,11 @@ class OpponentInfoOverlay extends Overlay
@Inject
private OpponentInfoOverlay(
final Client client,
final OpponentInfoPlugin opponentInfoPlugin,
final HiscoreManager hiscoreManager,
final NPCManager npcManager)
final OpponentInfoPlugin opponentInfoPlugin)
{
super(opponentInfoPlugin);
this.client = client;
this.opponentInfoPlugin = opponentInfoPlugin;
this.hiscoreManager = hiscoreManager;
this.npcManager = npcManager;
setPosition(OverlayPosition.TOP_LEFT);
setPriority(OverlayPriority.HIGH);
@@ -110,23 +99,7 @@ class OpponentInfoOverlay extends Overlay
lastHealthScale = opponent.getHealth();
opponentName = Text.removeTags(opponent.getName());
lastMaxHealth = -1;
if (opponent instanceof NPC)
{
lastMaxHealth = npcManager.getHealth(((NPC) opponent).getId());
}
else if (opponent instanceof Player)
{
final HiscoreResult hiscoreResult = hiscoreManager.lookupAsync(opponentName, opponentInfoPlugin.getHiscoreEndpoint());
if (hiscoreResult != null)
{
final int hp = hiscoreResult.getHitpoints().getLevel();
if (hp > 0)
{
lastMaxHealth = hp;
}
}
}
lastMaxHealth = opponentInfoPlugin.getMaxHp(opponent);
final Actor opponentsOpponent = opponent.getInteracting();
if (opponentsOpponent != null
@@ -168,37 +141,7 @@ class OpponentInfoOverlay extends Overlay
if ((displayStyle == HitpointsDisplayStyle.HITPOINTS || displayStyle == HitpointsDisplayStyle.BOTH)
&& lastMaxHealth != -1)
{
// This is the reverse of the calculation of healthRatio done by the server
// which is: healthRatio = 1 + (healthScale - 1) * health / maxHealth (if health > 0, 0 otherwise)
// It's able to recover the exact health if maxHealth <= healthScale.
int health = 0;
if (lastRatio > 0)
{
int minHealth = 1;
int maxHealth;
if (lastHealthScale > 1)
{
if (lastRatio > 1)
{
// This doesn't apply if healthRatio = 1, because of the special case in the server calculation that
// health = 0 forces healthRatio = 0 instead of the expected healthRatio = 1
minHealth = (lastMaxHealth * (lastRatio - 1) + lastHealthScale - 2) / (lastHealthScale - 1);
}
maxHealth = (lastMaxHealth * lastRatio - 1) / (lastHealthScale - 1);
if (maxHealth > lastMaxHealth)
{
maxHealth = lastMaxHealth;
}
}
else
{
// If healthScale is 1, healthRatio will always be 1 unless health = 0
// so we know nothing about the upper limit except that it can't be higher than maxHealth
maxHealth = lastMaxHealth;
}
// Take the average of min and max possible healths
health = (minHealth + maxHealth + 1) / 2;
}
int health = getExactHp(lastRatio, lastHealthScale, lastMaxHealth);
// Show both the hitpoint and percentage values if enabled in the config
final ProgressBarComponent.LabelDisplayMode progressBarDisplayMode = displayStyle == HitpointsDisplayStyle.BOTH ?
@@ -229,4 +172,47 @@ class OpponentInfoOverlay extends Overlay
return panelComponent.render(graphics);
}
static int getExactHp(int ratio, int health, int maxHp)
{
if (ratio < 0 || health <= 0 || maxHp == -1)
{
return -1;
}
int exactHealth = 0;
// This is the reverse of the calculation of healthRatio done by the server
// which is: healthRatio = 1 + (healthScale - 1) * health / maxHealth (if health > 0, 0 otherwise)
// It's able to recover the exact health if maxHealth <= healthScale.
if (ratio > 0)
{
int minHealth = 1;
int maxHealth;
if (health > 1)
{
if (ratio > 1)
{
// This doesn't apply if healthRatio = 1, because of the special case in the server calculation that
// health = 0 forces healthRatio = 0 instead of the expected healthRatio = 1
minHealth = (maxHp * (ratio - 1) + health - 2) / (health - 1);
}
maxHealth = (maxHp * ratio - 1) / (health - 1);
if (maxHealth > maxHp)
{
maxHealth = maxHp;
}
}
else
{
// If healthScale is 1, healthRatio will always be 1 unless health = 0
// so we know nothing about the upper limit except that it can't be higher than maxHealth
maxHealth = maxHp;
}
// Take the average of min and max possible healths
exactHealth = (minHealth + maxHealth + 1) / 2;
}
return exactHealth;
}
}

View File

@@ -33,24 +33,33 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Actor;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.MenuEntry;
import net.runelite.api.MenuOpcode;
import net.runelite.api.NPC;
import net.runelite.api.Player;
import net.runelite.api.WorldType;
import net.runelite.api.events.BeforeRender;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.InteractingChanged;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.MenuOpened;
import net.runelite.api.util.Text;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.HiscoreManager;
import net.runelite.client.game.NPCManager;
import net.runelite.client.menus.MenuManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.util.ColorUtil;
import net.runelite.http.api.hiscore.HiscoreEndpoint;
import net.runelite.http.api.hiscore.HiscoreResult;
@PluginDescriptor(
name = "Opponent Information",
@@ -58,9 +67,12 @@ import net.runelite.http.api.hiscore.HiscoreEndpoint;
tags = {"combat", "health", "hitpoints", "npcs", "overlay"}
)
@Singleton
@Slf4j
public class OpponentInfoPlugin extends Plugin
{
private static final Duration WAIT = Duration.ofSeconds(5);
private static final Object MENU = new Object();
private static final int COLOR_TAG_LENGTH = 12;
@Inject
private Client client;
@@ -80,6 +92,15 @@ public class OpponentInfoPlugin extends Plugin
@Inject
private EventBus eventBus;
@Inject
private HiscoreManager hiscoreManager;
@Inject
private MenuManager menuManager;
@Inject
private NPCManager npcManager;
@Getter(AccessLevel.PACKAGE)
private HiscoreEndpoint hiscoreEndpoint = HiscoreEndpoint.NORMAL;
@@ -95,6 +116,11 @@ public class OpponentInfoPlugin extends Plugin
@Getter(AccessLevel.PACKAGE)
private boolean showOpponentsOpponent;
private String attackingColTag;
private boolean showAttackers;
private boolean showAttacking;
private boolean showHitpoints;
@Provides
OpponentInfoConfig provideConfig(ConfigManager configManager)
{
@@ -104,6 +130,11 @@ public class OpponentInfoPlugin extends Plugin
@Override
protected void startUp() throws Exception
{
this.attackingColTag = ColorUtil.colorTag(config.attackingColor());
this.showAttackers = config.showAttackersMenu();
this.showAttacking = config.showAttackingMenu();
this.showHitpoints = config.showHitpointsMenu();
updateConfig();
addSubscriptions();
@@ -115,6 +146,7 @@ public class OpponentInfoPlugin extends Plugin
protected void shutDown() throws Exception
{
eventBus.unregister(this);
eventBus.unregister(MENU);
lastOpponent = null;
lastTime = null;
@@ -128,7 +160,20 @@ public class OpponentInfoPlugin extends Plugin
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventBus.subscribe(InteractingChanged.class, this, this::onInteractingChanged);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
eventBus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded);
updateMenuSubs();
}
private void updateMenuSubs()
{
if (showAttackers || showAttacking || showHitpoints)
{
eventBus.subscribe(BeforeRender.class, MENU, this::onBeforeRender);
eventBus.subscribe(MenuOpened.class, MENU, this::onMenuOpened);
}
else
{
eventBus.unregister(MENU);
}
}
private void onGameStateChanged(GameStateChanged gameStateChanged)
@@ -194,6 +239,25 @@ public class OpponentInfoPlugin extends Plugin
return;
}
switch (event.getKey())
{
case "showAttackersMenu":
this.showAttackers = config.showAttackersMenu();
updateMenuSubs();
break;
case "showAttackingMenu":
this.showAttacking = config.showAttackingMenu();
updateMenuSubs();
break;
case "showHitpointsMenu":
this.showHitpoints = config.showHitpointsMenu();
updateMenuSubs();
break;
case "attackingColor":
attackingColTag = ColorUtil.colorTag(config.attackingColor());
break;
}
updateConfig();
}
@@ -204,27 +268,253 @@ public class OpponentInfoPlugin extends Plugin
this.showOpponentsOpponent = config.showOpponentsOpponent();
}
private void onMenuEntryAdded(MenuEntryAdded menuEntryAdded)
private void onBeforeRender(BeforeRender event)
{
if (menuEntryAdded.getOpcode() != MenuOpcode.NPC_SECOND_OPTION.getId()
|| !menuEntryAdded.getOption().equals("Attack")
|| !config.showOpponentsInMenu())
if (client.getMenuOptionCount() <= 0)
{
return;
}
int npcIndex = menuEntryAdded.getIdentifier();
NPC npc = client.getCachedNPCs()[npcIndex];
if (npc == null)
if (client.isMenuOpen())
{
boolean changed = false;
final MenuEntry[] entries = client.getMenuEntries();
for (final MenuEntry entry : entries)
{
changed |= fixup(entry);
}
if (changed)
{
client.setMenuEntries(entries);
}
return;
}
if (npc.getInteracting() == client.getLocalPlayer() || lastOpponent == npc)
final MenuEntry entry = client.getLeftClickMenuEntry();
if (modify(entry))
{
MenuEntry[] menuEntries = client.getMenuEntries();
menuEntries[menuEntries.length - 1].setTarget("*" + menuEntryAdded.getTarget());
client.setMenuEntries(menuEntries);
client.setLeftClickMenuEntry(entry);
}
}
private void onMenuOpened(MenuOpened event)
{
boolean changed = false;
for (MenuEntry entry : event.getMenuEntries())
{
changed |= modify(entry);
}
if (changed)
{
event.setModified();
}
}
private boolean modify(MenuEntry entry)
{
if (isNotAttackEntry(entry))
{
return false;
}
boolean changed = false;
int index = entry.getIdentifier();
Actor actor = getActorFromIndex(index);
if (actor == null)
{
return false;
}
if (actor instanceof Player)
{
index -= 32768;
}
String target = entry.getTarget();
if (showAttacking &&
client.getLocalPlayer().getRSInteracting() == index)
{
target = attackingColTag + target.substring(COLOR_TAG_LENGTH);
changed = true;
}
if (showAttackers &&
actor.getRSInteracting() - 32768 == client.getLocalPlayerIndex())
{
target = '*' + target;
changed = true;
}
if (showHitpoints &&
actor.getHealth() > 0)
{
int lvlIndex = target.lastIndexOf("(level-");
if (lvlIndex != -1)
{
String levelReplacement = getHpString(actor, true);
target = target.substring(0, lvlIndex) + levelReplacement;
changed = true;
}
}
if (changed)
{
entry.setTarget(target);
return true;
}
return false;
}
private boolean fixup(MenuEntry entry)
{
if (isNotAttackEntry(entry))
{
return false;
}
int index = entry.getIdentifier();
Actor actor = getActorFromIndex(index);
if (actor == null)
{
return false;
}
if (actor instanceof Player)
{
index -= 32768;
}
String target = entry.getTarget();
boolean hasAggro = actor.getRSInteracting() - 32768 == client.getLocalPlayerIndex();
boolean hadAggro = target.charAt(0) == '*';
boolean isTarget = client.getLocalPlayer().getRSInteracting() == index;
boolean hasHp = showHitpoints && actor instanceof NPC && actor.getHealth() > 0;
boolean aggroChanged = showAttackers && hasAggro != hadAggro;
boolean targetChanged = showAttacking && isTarget != target.startsWith(attackingColTag, aggroChanged ? 1 : 0);
boolean hpChanged = showHitpoints && hasHp == target.contains("(level-");
if (!aggroChanged &&
!targetChanged &&
!hasHp &&
!hpChanged)
{
return false;
}
if (targetChanged)
{
boolean player = actor instanceof Player;
final int start = hadAggro ? 1 + COLOR_TAG_LENGTH : COLOR_TAG_LENGTH;
target =
(hasAggro ? '*' : "") +
(isTarget ? attackingColTag :
player ? ColorUtil.colorStartTag(0xffffff) : ColorUtil.colorStartTag(0xffff00)) +
target.substring(start);
}
else if (aggroChanged)
{
if (hasAggro)
{
target = '*' + target;
}
else
{
target = target.substring(1);
}
}
if (hpChanged || hasHp)
{
final int braceIdx;
if (!hasHp)
{
braceIdx = target.lastIndexOf("<col=ff0000>(");
if (braceIdx != -1)
{
target = target.substring(0, braceIdx - 1) + "(level-" + actor.getCombatLevel() + ")";
}
}
else if ((braceIdx = target.lastIndexOf('(')) != -1)
{
final String hpString = getHpString(actor, hpChanged);
target = target.substring(0, braceIdx) + hpString;
}
}
entry.setTarget(target);
return true;
}
private boolean isNotAttackEntry(MenuEntry entry)
{
return entry.getOpcode() != MenuOpcode.NPC_SECOND_OPTION.getId() &&
entry.getOpcode() != menuManager.getPlayerAttackOpcode()
|| !entry.getOption().equals("Attack");
}
private String getHpString(Actor actor, boolean withColorTag)
{
int maxHp = getMaxHp(actor);
int health = actor.getHealth();
int ratio = actor.getHealthRatio();
final String result;
if (maxHp != -1)
{
final int exactHealth = OpponentInfoOverlay.getExactHp(ratio, health, maxHp);
result = "(" + exactHealth + "/" + maxHp + ")";
}
else
{
result = "(" + (100 * ratio) / health + "%)";
}
return withColorTag ? ColorUtil.colorStartTag(0xff0000) + result : result;
}
int getMaxHp(Actor actor)
{
if (actor instanceof NPC)
{
return npcManager.getHealth(((NPC) actor).getId());
}
else
{
final HiscoreResult hiscoreResult = hiscoreManager.lookupAsync(Text.removeTags(actor.getName()), getHiscoreEndpoint());
if (hiscoreResult != null)
{
final int hp = hiscoreResult.getHitpoints().getLevel();
if (hp > 0)
{
return hp;
}
}
return -1;
}
}
private Actor getActorFromIndex(int index)
{
if (index < 32768)
{
return client.getCachedNPCs()[index];
}
else
{
return client.getCachedPlayers()[index - 32768];
}
}
}

View File

@@ -63,7 +63,7 @@ import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.ItemManager;
import net.runelite.client.game.ItemMapping;
import net.runelite.client.game.PvPValueBrokenItem;
import net.runelite.client.game.ItemReclaimCost;
import net.runelite.client.game.WorldLocation;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
@@ -370,10 +370,10 @@ public class PlayerScouter extends Plugin
continue;
}
if (PvPValueBrokenItem.breaksOnDeath(id))
if (ItemReclaimCost.breaksOnDeath(id))
{
prices.put(id, itemManager.getBrokenValue(id));
log.debug("Item has a broken value: Id {}, Value {}", id, itemManager.getBrokenValue(id));
prices.put(id, itemManager.getRepairValue(id));
log.debug("Item has a broken value: Id {}, Value {}", id, itemManager.getRepairValue(id));
continue;
}

View File

@@ -1,245 +0,0 @@
/*
* Copyright (c) 2018, https://openosrs.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.pluginsorter;
import java.awt.Color;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.runelite.client.config.Alpha;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.ConfigTitleSection;
import net.runelite.client.config.Title;
@ConfigGroup("pluginsorter")
public interface PluginSorterConfig extends Config
{
@Getter(AccessLevel.PACKAGE)
@AllArgsConstructor
enum SortStyle
{
CATEGORY("Category"),
ALPHABETICALLY("Alphabetically");
private String name;
@Override
public String toString()
{
return getName();
}
}
@ConfigTitleSection(
keyName = "pluginSortingTitle",
name = "Sorting",
description = "",
position = 0
)
default Title pluginSortingTitle()
{
return new Title();
}
@ConfigItem(
position = 1,
keyName = "pluginSortMode",
name = "Sorting mode",
description = "Sorts plugins ",
titleSection = "pluginSortingTitle"
)
default SortStyle pluginSortMode()
{
return SortStyle.CATEGORY;
}
@ConfigTitleSection(
keyName = "hidePluginsTitle",
name = "Hide By Type",
description = "",
position = 2
)
default Title hidePluginsTitle()
{
return new Title();
}
@ConfigItem(
position = 3,
keyName = "hidePlugins",
name = "Hide All Plugins",
description = "Hides all OpenOSRS plugins if checked",
titleSection = "hidePluginsTitle",
hide = "hidePvmPlugins || hidePvpPlugins || hideSkillingPlugins || hideUtilityPlugins || hideExternalPlugins"
)
default boolean hidePlugins()
{
return false;
}
@ConfigItem(
position = 4,
keyName = "hideExternalPlugins",
name = "Hide External Plugins",
description = "Hides all OpenOSRS external plugins if checked",
titleSection = "hidePluginsTitle",
hide = "hidePlugins"
)
default boolean hideExternalPlugins()
{
return false;
}
@ConfigItem(
position = 5,
keyName = "hidePvmPlugins",
name = "Hide PvM Plugins",
description = "Hides all OpenOSRS PvM plugins if checked",
titleSection = "hidePluginsTitle",
hide = "hidePlugins"
)
default boolean hidePvmPlugins()
{
return false;
}
@ConfigItem(
position = 6,
keyName = "hideSkillingPlugins",
name = "Hide Skilling Plugins",
description = "Hides all OpenOSRS skilling plugins if checked",
titleSection = "hidePluginsTitle",
hide = "hidePlugins"
)
default boolean hideSkillingPlugins()
{
return false;
}
@ConfigItem(
position = 7,
keyName = "hidePvpPlugins",
name = "Hide PvP Plugins",
description = "Hides all OpenOSRS Pvp plugins if checked",
titleSection = "hidePluginsTitle",
hide = "hidePlugins"
)
default boolean hidePvpPlugins()
{
return false;
}
@ConfigItem(
position = 8,
keyName = "hideUtilityPlugins",
name = "Hide Utility Plugins",
description = "Hides all OpenOSRS utility plugins if checked",
titleSection = "hidePluginsTitle",
hide = "hidePlugins"
)
default boolean hideUtilityPlugins()
{
return false;
}
@ConfigTitleSection(
keyName = "pluginsColorTitle",
name = "Colors",
description = "",
position = 9
)
default Title pluginsColorTitle()
{
return new Title();
}
@Alpha
@ConfigItem(
position = 10,
keyName = "externalColor",
name = "External color",
description = "Configure the color of external plugins",
titleSection = "pluginsColorTitle"
)
default Color externalColor()
{
return new Color(177, 156, 217, 255);
}
@Alpha
@ConfigItem(
position = 11,
keyName = "pvmColor",
name = "PVM color",
description = "Configure the color of PVM related plugins",
titleSection = "pluginsColorTitle"
)
default Color pvmColor()
{
return new Color(119, 221, 119, 255);
}
@Alpha
@ConfigItem(
position = 12,
keyName = "pvpColor",
name = "PVP color",
description = "Configure the color of PVP related plugins",
titleSection = "pluginsColorTitle"
)
default Color pvpColor()
{
return new Color(255, 105, 97, 255);
}
@Alpha
@ConfigItem(
position = 13,
keyName = "skillingColor",
name = "Skilling color",
description = "Configure the color of Skilling related plugins",
titleSection = "pluginsColorTitle"
)
default Color skillingColor()
{
return new Color(252, 252, 100, 255);
}
@Alpha
@ConfigItem(
position = 14,
keyName = "utilityColor",
name = "Utility color",
description = "Configure the color of Utility related plugins",
titleSection = "pluginsColorTitle"
)
default Color utilityColor()
{
return new Color(144, 212, 237, 255);
}
}

View File

@@ -24,168 +24,64 @@
*/
package net.runelite.client.plugins.pluginsorter;
import com.google.common.collect.ImmutableList;
import com.google.inject.Provides;
import java.awt.Color;
import java.util.Comparator;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.events.ConfigChanged;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.events.PluginChanged;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType;
import net.runelite.client.plugins.config.ConfigPanel;
import net.runelite.client.plugins.config.PluginListItem;
@PluginDescriptor(
name = "Plugin Organizer",
description = "Hides and colors 3rd party plugins for better control",
tags = {"plugins", "organizer"},
type = PluginType.PLUGIN_ORGANIZER
hidden = true
)
@Singleton
public class PluginSorterPlugin extends Plugin
{
@Inject
private PluginSorterConfig config;
private ConfigManager configManager;
@Inject
private EventBus eventBus;
private PluginSorterConfig.SortStyle pluginSortMode;
private Color externalColor;
private Color pvmColor;
private Color pvpColor;
private Color skillingColor;
private Color utilityColor;
private final ImmutableList<PluginType> definedOrder = ImmutableList.of(PluginType.IMPORTANT, PluginType.EXTERNAL, PluginType.PVM, PluginType.SKILLING, PluginType.PVP, PluginType.UTILITY, PluginType.GENERAL_USE, PluginType.PLUGIN_ORGANIZER);
private final Comparator<PluginListItem> pluginTypeComparator = Comparator.comparing(plugin ->
/**
* Migrates configs from plugin organizer to the OpenOSRS global plugin and deletes the old config values.
* This method should be removed after a reasonable amount of time.
*/
@Deprecated
private void migrateConfigs()
{
PluginType type = PluginType.GENERAL_USE;
Plugin sortPlugin = plugin.getPlugin();
if (sortPlugin != null)
{
type = sortPlugin.getClass().getAnnotation(PluginDescriptor.class).type();
}
else if (plugin.configDescriptor.getGroup().value().equals("openosrs") || plugin.configDescriptor.getGroup().value().equals("runelite"))
{
type = PluginType.IMPORTANT;
}
migrateConfig("pluginsorter", "pluginSortMode");
migrateConfig("pluginsorter", "hidePlugins");
migrateConfig("pluginsorter", "hideExternalPlugins");
migrateConfig("pluginsorter", "hidePvmPlugins");
migrateConfig("pluginsorter", "hideSkillingPlugins");
migrateConfig("pluginsorter", "hidePvpPlugins");
migrateConfig("pluginsorter", "hideUtilityPlugins");
migrateConfig("pluginsorter", "externalColor");
migrateConfig("pluginsorter", "pvmColor");
migrateConfig("pluginsorter", "pvpColor");
migrateConfig("pluginsorter", "skillingColor");
migrateConfig("pluginsorter", "utilityColor");
}
return definedOrder.indexOf(type);
});
@Provides
PluginSorterConfig provideConfig(ConfigManager configManager)
/**
* Wrapper for migrating individual config options
* This method should be removed after a reasonable amount of time.
*
* @param group old group name
* @param key key name to migrate
*/
@Deprecated
private void migrateConfig(String group, String key)
{
return configManager.getConfig(PluginSorterConfig.class);
String value = configManager.getConfiguration(group, key);
if (value != null)
{
configManager.setConfiguration("openosrs", key, value);
configManager.unsetConfiguration(group, key);
}
}
@Override
protected void startUp() throws Exception
{
updateConfig();
addSubscriptions();
updatePlugins();
}
@Override
protected void shutDown() throws Exception
{
eventBus.unregister(this);
}
private void addSubscriptions()
{
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(PluginChanged.class, this, this::onPluginChanged);
}
private void onPluginChanged(PluginChanged pluginChanged)
{
validatePlugins();
}
private void validatePlugins()
{
updatePlugins();
}
private void onConfigChanged(ConfigChanged configChanged)
{
if (!configChanged.getGroup().equals("pluginsorter"))
{
return;
}
updateConfig();
updatePlugins();
}
private void updatePlugins()
{
boolean hidePlugins = config.hidePlugins();
boolean hidePvmPlugins = config.hidePvmPlugins();
boolean hidePvpPlugins = config.hidePvpPlugins();
boolean hideSkillingPlugins = config.hideSkillingPlugins();
boolean hideUtilityPlugins = config.hideUtilityPlugins();
boolean hideExternalPlugins = config.hideExternalPlugins();
for (PluginListItem pli : ConfigPanel.pluginList)
{
if (pli.getPlugin() != null)
{
switch (pli.getPlugin().getClass().getAnnotation(PluginDescriptor.class).type())
{
case EXTERNAL:
pli.nameLabel.setForeground(this.externalColor);
pli.setHidden(hidePlugins || hideExternalPlugins);
break;
case PVM:
pli.nameLabel.setForeground(this.pvmColor);
pli.setHidden(hidePlugins || hidePvmPlugins);
break;
case PVP:
pli.nameLabel.setForeground(this.pvpColor);
pli.setHidden(hidePlugins || hidePvpPlugins);
break;
case SKILLING:
pli.nameLabel.setForeground(this.skillingColor);
pli.setHidden(hidePlugins || hideSkillingPlugins);
break;
case UTILITY:
pli.nameLabel.setForeground(this.utilityColor);
pli.setHidden(hidePlugins || hideUtilityPlugins);
break;
default:
pli.nameLabel.setForeground(Color.WHITE);
break;
}
}
}
if (this.pluginSortMode == PluginSorterConfig.SortStyle.CATEGORY)
{
ConfigPanel.pluginList.sort(pluginTypeComparator.thenComparing(PluginListItem::getName));
}
else
{
ConfigPanel.pluginList.sort(Comparator.comparing(PluginListItem::getName));
}
}
private void updateConfig()
{
this.pluginSortMode = config.pluginSortMode();
this.externalColor = config.externalColor();
this.pvmColor = config.pvmColor();
this.pvpColor = config.pvpColor();
this.skillingColor = config.skillingColor();
this.utilityColor = config.utilityColor();
migrateConfigs();
}
}

View File

@@ -114,7 +114,7 @@ class QuestGuideLinks
new Link("My Arm's Big Adventure", "https://www.youtube.com/watch?v=xa1KWOewgYA"),
new Link("Enlightened Journey", "https://www.youtube.com/watch?v=XAPthC8d7k0"),
new Link("Eagles' Peak", "https://www.youtube.com/watch?v=KDxIrrwXp7U"),
new Link("Animal Magnetism", "https://www.youtube.com/watch?v=kUyjXA7TaFU"),
new Link("Animal Magnetism", "https://www.youtube.com/watch?v=_JldgJTnc7I"),
new Link("Contact!", "https://www.youtube.com/watch?v=czn-yWABBWs"),
new Link("Cold War", "https://www.youtube.com/watch?v=0m1KpP-qKWI"),
new Link("The Fremennik Isles", "https://www.youtube.com/watch?v=EvxhiOWmraY"),

File diff suppressed because one or more lines are too long

View File

@@ -36,6 +36,7 @@ import net.runelite.api.Item;
import net.runelite.api.ItemDefinition;
import net.runelite.api.ItemID;
import net.runelite.client.game.ItemManager;
import net.runelite.client.game.ItemReclaimCost;
import static net.runelite.client.plugins.itemskeptondeath.ItemsKeptOnDeathPlugin.DeathItems;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -637,8 +638,8 @@ public class ItemsKeptOnDeathPluginTest
{
final Item defender = mItem(ItemID.AVERNIC_DEFENDER, 1, "Avernic defender", false, 0);
final int defenderOffset = FixedPriceItem.AVERNIC_DEFENDER.getOffset();
final Integer defenderBrokenPrice = BrokenOnDeathItem.getRepairPrice(ItemID.AVERNIC_DEFENDER);
final int defenderExpectedPrice = (defenderBrokenPrice == null ? 0 : defenderBrokenPrice) + defenderOffset;
final ItemReclaimCost defenderBrokenPrice = ItemReclaimCost.of(ItemID.AVERNIC_DEFENDER);
final int defenderExpectedPrice = (defenderBrokenPrice == null ? 0 : defenderBrokenPrice.getValue()) + defenderOffset;
assertEquals(defenderExpectedPrice, plugin.getDeathPrice(defender));
final Item[] inv = new Item[]

View File

@@ -30,6 +30,7 @@ import net.runelite.mapping.Import;
public interface RSActor extends RSEntity, Actor
{
@Import("targetIndex")
@Override
int getRSInteracting();
// Overhead text

View File

@@ -208,6 +208,10 @@ public interface RSClient extends RSGameShell, Client
@Override
RSPlayer getLocalPlayer();
@Import("localPlayerIndex")
@Override
int getLocalPlayerIndex();
@Import("npcCount")
int getNpcIndexesCount();