Merge branch 'master' into master

This commit is contained in:
ST0NEWALL
2019-10-22 17:54:07 -04:00
committed by GitHub
10 changed files with 419 additions and 454 deletions

View File

@@ -59,7 +59,7 @@ ext {
jopt = '5.0.4'
jooq = '3.12.1'
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

@@ -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

@@ -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

@@ -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

@@ -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"),