Merge branch 'master' into loot-tracker-reset

This commit is contained in:
Tyler Bochard
2019-07-08 19:36:32 -04:00
committed by GitHub
1232 changed files with 51400 additions and 46135 deletions

View File

@@ -83,13 +83,13 @@ import org.slf4j.LoggerFactory;
@Slf4j
public class RuneLite
{
public static final String RUNELIT_VERSION = "2.0.1-1";
public static final String RUNELIT_VERSION = "2.0.2";
public static final File RUNELITE_DIR = new File(System.getProperty("user.home"), ".runelite");
public static final File PROFILES_DIR = new File(RUNELITE_DIR, "profiles");
public static final File PLUGIN_DIR = new File(RUNELITE_DIR, "plugins");
public static final File SCREENSHOT_DIR = new File(RUNELITE_DIR, "screenshots");
static final RuneLiteSplashScreen splashScreen = new RuneLiteSplashScreen();
public static final File LOGS_DIR = new File(RUNELITE_DIR, "logs");
private static final RuneLiteSplashScreen splashScreen = new RuneLiteSplashScreen();
@Getter
private static Injector injector;

View File

@@ -41,6 +41,7 @@ import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.config.ChatColorConfig;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.config.RuneLitePlusConfig;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.ItemManager;
import net.runelite.client.menus.MenuManager;
@@ -117,6 +118,13 @@ public class RuneLiteModule extends AbstractModule
return configManager.getConfig(RuneLiteConfig.class);
}
@Provides
@Singleton
RuneLitePlusConfig providePlusConfig(ConfigManager configManager)
{
return configManager.getConfig(RuneLitePlusConfig.class);
}
@Provides
@Singleton
ChatColorConfig provideChatColorConfig(ConfigManager configManager)

View File

@@ -31,17 +31,18 @@ import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
import net.runelite.client.plugins.runeliteplus.RuneLitePlusPlugin;
import net.runelite.client.config.RuneLitePlusConfig;
@Singleton
@Slf4j
public class RuneLiteProperties
{
public static String discordAppID = "409416265891971072";
private static final String RUNELITE_TITLE = "runelite.title";
private static final String RUNELITE_VERSION = "runelite.version";
private static final String RUNELIT_VERSION = "runelit.version";
private static final String RUNESCAPE_VERSION = "runescape.version";
private static final String DISCORD_APP_ID = "runelite.discord.appid";
private static final String DISCORD_APP_ID_PLUS = "runelite.plus.discord.appid";
private static final String DISCORD_INVITE = "runelite.discord.invite";
private static final String GITHUB_LINK = "runelite.github.link";
private static final String WIKI_LINK = "runelite.wiki.link";
@@ -50,9 +51,26 @@ public class RuneLiteProperties
private final Properties properties = new Properties();
private final RuneLitePlusConfig runeLitePlusConfig;
@Inject
public RuneLiteProperties(final RuneLitePlusConfig runeLiteConfig)
{
this.runeLitePlusConfig = runeLiteConfig;
try (InputStream in = getClass().getResourceAsStream("runelite.properties"))
{
properties.load(in);
}
catch (IOException ex)
{
log.warn("unable to load propertries", ex);
}
}
public RuneLiteProperties()
{
runeLitePlusConfig = null;
try (InputStream in = getClass().getResourceAsStream("runelite.properties"))
{
properties.load(in);
@@ -79,6 +97,11 @@ public class RuneLiteProperties
return properties.getProperty(RUNELITE_VERSION);
}
public String getRunelitVersion()
{
return properties.getProperty(RUNELIT_VERSION);
}
public String getRunescapeVersion()
{
return properties.getProperty(RUNESCAPE_VERSION);
@@ -86,9 +109,14 @@ public class RuneLiteProperties
public String getDiscordAppId()
{
if (RuneLitePlusPlugin.customPresenceEnabled)
if (this.runeLitePlusConfig == null)
{
return properties.getProperty(RuneLitePlusPlugin.rlPlusDiscordApp);
return properties.getProperty(DISCORD_APP_ID);
}
if (this.runeLitePlusConfig.customPresence())
{
return properties.getProperty(DISCORD_APP_ID_PLUS);
}
else
{

View File

@@ -36,7 +36,7 @@ import net.runelite.api.Client;
@Slf4j
public class ClientThread
{
private ConcurrentLinkedQueue<BooleanSupplier> invokes = new ConcurrentLinkedQueue<>();
private final ConcurrentLinkedQueue<BooleanSupplier> invokes = new ConcurrentLinkedQueue<>();
@Inject
private Client client;

View File

@@ -87,9 +87,6 @@ public class Hooks implements Callbacks
private static final OverlayRenderer renderer = injector.getInstance(OverlayRenderer.class);
private static final OverlayManager overlayManager = injector.getInstance(OverlayManager.class);
private static final GameTick GAME_TICK = new GameTick();
private static final BeforeRender BEFORE_RENDER = new BeforeRender();
@Inject
private EventBus eventBus;
@@ -151,13 +148,13 @@ public class Hooks implements Callbacks
deferredEventBus.replay();
eventBus.post(GAME_TICK);
eventBus.post(GameTick.INSTANCE);
int tick = client.getTickCount();
client.setTickCount(tick + 1);
}
eventBus.post(BEFORE_RENDER);
eventBus.post(BeforeRender.INSTANCE);
clientThread.invoke();

View File

@@ -115,7 +115,7 @@ public class ChatMessageManager
boolean isChatboxTransparent = client.isResized() && client.getVar(Varbits.TRANSPARENT_CHATBOX) == 1;
Color usernameColor = null;
Color senderColor = null;
Color senderColor;
switch (chatMessageType)
{

View File

@@ -53,10 +53,7 @@ public class ConfigDescriptor
Collection<ConfigItemDescriptor> allItems = new ArrayList<>();
for (ConfigItemsGroup g : itemGroups)
{
for (ConfigItemDescriptor item : g.getItems())
{
allItems.add(item);
}
allItems.addAll(g.getItems());
}
return allItems;
}

View File

@@ -81,7 +81,6 @@ public class ConfigManager
@Inject
EventBus eventBus;
private final ScheduledExecutorService executor;
private final ConfigInvocationHandler handler = new ConfigInvocationHandler(this);
private final Properties properties = new Properties();
private final Map<String, Object> configObjectCache = new HashMap<>();
@@ -90,9 +89,8 @@ public class ConfigManager
@Inject
public ConfigManager(ScheduledExecutorService scheduledExecutorService)
{
this.executor = scheduledExecutorService;
executor.scheduleWithFixedDelay(this::sendConfig, 30, 30, TimeUnit.SECONDS);
scheduledExecutorService.scheduleWithFixedDelay(this::sendConfig, 30, 30, TimeUnit.SECONDS);
}
public final void switchSession()
@@ -245,12 +243,10 @@ public class ConfigManager
throw new RuntimeException("Non-public configuration classes can't have default methods invoked");
}
T t = (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class<?>[]
return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class<?>[]
{
clazz
}, handler);
return t;
}
public List<String> getConfigurationKeys(String prefix)

View File

@@ -60,7 +60,7 @@ public class Keybind
private final int keyCode;
private final int modifiers;
protected Keybind(int keyCode, int modifiers, boolean ignoreModifiers)
Keybind(int keyCode, int modifiers, boolean ignoreModifiers)
{
modifiers &= KEYBOARD_MODIFIER_MASK;
@@ -108,7 +108,7 @@ public class Keybind
return matches(e, false);
}
protected boolean matches(KeyEvent e, boolean ignoreModifiers)
boolean matches(KeyEvent e, boolean ignoreModifiers)
{
if (NOT_SET.equals(this))
{
@@ -177,7 +177,7 @@ public class Keybind
return mod;
}
public static String getModifiersExText(int modifiers)
private static String getModifiersExText(int modifiers)
{
StringBuilder buf = new StringBuilder();
if ((modifiers & InputEvent.META_DOWN_MASK) != 0)

View File

@@ -33,10 +33,10 @@ import net.runelite.client.ui.FontManager;
public interface RuneLiteConfig extends Config
{
@ConfigItem(
keyName = "gameSize",
name = "Game size",
description = "The game will resize to this resolution upon starting the client",
position = 10
keyName = "gameSize",
name = "Game size",
description = "The game will resize to this resolution upon starting the client",
position = 10
)
default Dimension gameSize()
{
@@ -44,10 +44,10 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "automaticResizeType",
name = "Resize type",
description = "Choose how the window should resize when opening and closing panels",
position = 11
keyName = "automaticResizeType",
name = "Resize type",
description = "Choose how the window should resize when opening and closing panels",
position = 11
)
default ExpandResizeType automaticResizeType()
{
@@ -55,10 +55,10 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "lockWindowSize",
name = "Lock window size",
description = "Determines if the window resizing is allowed or not",
position = 12
keyName = "lockWindowSize",
name = "Lock window size",
description = "Determines if the window resizing is allowed or not",
position = 12
)
default boolean lockWindowSize()
{
@@ -66,21 +66,10 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "enablePlugins",
name = "Enable loading of external plugins",
description = "Enable loading of external plugins",
position = 10
)
default boolean enablePlugins()
{
return true;
}
@ConfigItem(
keyName = "containInScreen",
name = "Contain in screen",
description = "Makes the client stay contained in the screen when attempted to move out of it.<br>Note: Only works if custom chrome is enabled.",
position = 13
keyName = "containInScreen",
name = "Contain in screen",
description = "Makes the client stay contained in the screen when attempted to move out of it.<br>Note: Only works if custom chrome is enabled.",
position = 13
)
default boolean containInScreen()
{
@@ -88,10 +77,10 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "rememberScreenBounds",
name = "Remember client position",
description = "Save the position and size of the client after exiting",
position = 14
keyName = "rememberScreenBounds",
name = "Remember client position",
description = "Save the position and size of the client after exiting",
position = 14
)
default boolean rememberScreenBounds()
{
@@ -99,11 +88,11 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "uiEnableCustomChrome",
name = "Enable custom window chrome",
description = "Use Runelite's custom window title and borders.",
warning = "Please restart your client after changing this setting",
position = 15
keyName = "uiEnableCustomChrome",
name = "Enable custom window chrome",
description = "Use Runelite's custom window title and borders.",
warning = "Please restart your client after changing this setting",
position = 15
)
default boolean enableCustomChrome()
{
@@ -111,10 +100,10 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "gameAlwaysOnTop",
name = "Enable client always on top",
description = "The game will always be on the top of the screen",
position = 16
keyName = "gameAlwaysOnTop",
name = "Enable client always on top",
description = "The game will always be on the top of the screen",
position = 16
)
default boolean gameAlwaysOnTop()
{
@@ -122,10 +111,10 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "warningOnExit",
name = "Display warning on exit",
description = "Toggles a warning popup when trying to exit the client",
position = 17
keyName = "warningOnExit",
name = "Display warning on exit",
description = "Toggles a warning popup when trying to exit the client",
position = 17
)
default WarningOnExit warningOnExit()
{
@@ -133,10 +122,10 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "usernameInTitle",
name = "Show display name in title",
description = "Toggles displaying of local player's display name in client title",
position = 18
keyName = "usernameInTitle",
name = "Show display name in title",
description = "Toggles displaying of local player's display name in client title",
position = 18
)
default boolean usernameInTitle()
{
@@ -144,10 +133,10 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "notificationTray",
name = "Enable tray notifications",
description = "Enables tray notifications",
position = 20
keyName = "notificationTray",
name = "Enable tray notifications",
description = "Enables tray notifications",
position = 20
)
default boolean enableTrayNotifications()
{
@@ -155,10 +144,10 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "notificationRequestFocus",
name = "Request focus on notification",
description = "Toggles window focus request",
position = 21
keyName = "notificationRequestFocus",
name = "Request focus on notification",
description = "Toggles window focus request",
position = 21
)
default boolean requestFocusOnNotification()
{
@@ -166,10 +155,10 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "notificationSound",
name = "Enable sound on notifications",
description = "Enables the playing of a beep sound when notifications are displayed",
position = 22
keyName = "notificationSound",
name = "Enable sound on notifications",
description = "Enables the playing of a beep sound when notifications are displayed",
position = 22
)
default boolean enableNotificationSound()
{
@@ -177,10 +166,10 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "notificationGameMessage",
name = "Enable game message notifications",
description = "Puts a notification message in the chatbox",
position = 23
keyName = "notificationGameMessage",
name = "Enable game message notifications",
description = "Puts a notification message in the chatbox",
position = 23
)
default boolean enableGameMessageNotification()
{
@@ -188,10 +177,10 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "notificationFlash",
name = "Enable flash notification",
description = "Flashes the game frame as a notification",
position = 24
keyName = "notificationFlash",
name = "Enable flash notification",
description = "Flashes the game frame as a notification",
position = 24
)
default FlashNotification flashNotification()
{
@@ -199,10 +188,10 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "notificationFocused",
name = "Send notifications when focused",
description = "Toggles all notifications for when the client is focused",
position = 25
keyName = "notificationFocused",
name = "Send notifications when focused",
description = "Toggles all notifications for when the client is focused",
position = 25
)
default boolean sendNotificationsWhenFocused()
{
@@ -221,10 +210,10 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "fontType",
name = "Dynamic Overlay Font",
description = "Configures what font type is used for in-game overlays such as player name, ground items, etc.",
position = 30
keyName = "fontType",
name = "Dynamic Overlay Font",
description = "Configures what font type is used for in-game overlays such as player name, ground items, etc.",
position = 30
)
default FontType fontType()
{
@@ -232,10 +221,10 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "tooltipFontType",
name = "Tooltip Font",
description = "Configures what font type is used for in-game tooltips such as food stats, NPC names, etc.",
position = 31
keyName = "tooltipFontType",
name = "Tooltip Font",
description = "Configures what font type is used for in-game tooltips such as food stats, NPC names, etc.",
position = 31
)
default FontType tooltipFontType()
{
@@ -243,10 +232,10 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "interfaceFontType",
name = "Interface Overlay Font",
description = "Configures what font type is used for in-game interface overlays such as panels, opponent info, clue scrolls etc.",
position = 32
keyName = "interfaceFontType",
name = "Interface Overlay Font",
description = "Configures what font type is used for in-game interface overlays such as panels, opponent info, clue scrolls etc.",
position = 32
)
default FontType interfaceFontType()
{
@@ -254,10 +243,10 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "menuEntryShift",
name = "Require Shift for overlay menu",
description = "Overlay right-click menu will require shift to be added",
position = 33
keyName = "menuEntryShift",
name = "Require Shift for overlay menu",
description = "Overlay right-click menu will require shift to be added",
position = 33
)
default boolean menuEntryShift()
{
@@ -265,10 +254,10 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "infoBoxVertical",
name = "Display infoboxes vertically",
description = "Toggles the infoboxes to display vertically",
position = 40
keyName = "infoBoxVertical",
name = "Display infoboxes vertically",
description = "Toggles the infoboxes to display vertically",
position = 40
)
default boolean infoBoxVertical()
{
@@ -276,10 +265,10 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "infoBoxWrap",
name = "Infobox wrap count",
description = "Configures the amount of infoboxes shown before wrapping",
position = 41
keyName = "infoBoxWrap",
name = "Infobox wrap count",
description = "Configures the amount of infoboxes shown before wrapping",
position = 41
)
default int infoBoxWrap()
{
@@ -287,22 +276,22 @@ public interface RuneLiteConfig extends Config
}
@ConfigItem(
keyName = "infoBoxSize",
name = "Infobox size (px)",
description = "Configures the size of each infobox in pixels",
position = 42
keyName = "infoBoxSize",
name = "Infobox size (px)",
description = "Configures the size of each infobox in pixels",
position = 42
)
default int infoBoxSize()
{
return 35;
}
@Range( max = 100, min = 0 )
@Range(max = 100, min = 0)
@ConfigItem(
keyName = "volume",
name = "Runelite Volume",
description = "Sets the volume of custom Runelite sounds (not the client sounds)",
position = 43
keyName = "volume",
name = "Runelite Volume",
description = "Sets the volume of custom Runelite sounds (not the client sounds)",
position = 43
)
default int volume()
{

View File

@@ -24,7 +24,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.runelite.client.plugins.runeliteplus;
package net.runelite.client.config;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
@@ -81,4 +81,15 @@ public interface RuneLitePlusConfig extends Config
{
return false;
}
@ConfigItem(
keyName = "enablePlugins",
name = "Enable loading of external plugins",
description = "Enable loading of external plugins",
position = 10
)
default boolean enablePlugins()
{
return false;
}
}

View File

@@ -49,7 +49,7 @@ import net.runelite.discord.DiscordUser;
public class DiscordService implements AutoCloseable
{
private final EventBus eventBus;
public final RuneLiteProperties runeLiteProperties;
private final RuneLiteProperties runeLiteProperties;
private final ScheduledExecutorService executorService;
private final DiscordRPC discordRPC;
@@ -106,7 +106,7 @@ public class DiscordService implements AutoCloseable
discordEventHandlers.joinGame = this::joinGame;
discordEventHandlers.spectateGame = this::spectateGame;
discordEventHandlers.joinRequest = this::joinRequest;
discordRPC.Discord_Initialize(RuneLiteProperties.discordAppID, discordEventHandlers, true, null);
discordRPC.Discord_Initialize(runeLiteProperties.getDiscordAppId(), discordEventHandlers, true, null);
executorService.scheduleAtFixedRate(discordRPC::Discord_RunCallbacks, 0, 2, TimeUnit.SECONDS);
}

View File

@@ -36,6 +36,7 @@ import static net.runelite.client.game.HiscoreManager.NONE;
import net.runelite.http.api.hiscore.HiscoreClient;
import net.runelite.http.api.hiscore.HiscoreEndpoint;
import net.runelite.http.api.hiscore.HiscoreResult;
import org.jetbrains.annotations.NotNull;
@Slf4j
class HiscoreLoader extends CacheLoader<HiscoreManager.HiscoreKey, HiscoreResult>
@@ -50,7 +51,7 @@ class HiscoreLoader extends CacheLoader<HiscoreManager.HiscoreKey, HiscoreResult
}
@Override
public HiscoreResult load(HiscoreManager.HiscoreKey hiscoreKey) throws Exception
public HiscoreResult load(@NotNull HiscoreManager.HiscoreKey hiscoreKey) throws Exception
{
return EMPTY;
}

View File

@@ -168,6 +168,7 @@ import net.runelite.client.eventbus.Subscribe;
import net.runelite.http.api.item.ItemClient;
import net.runelite.http.api.item.ItemPrice;
import net.runelite.http.api.item.ItemStats;
import org.jetbrains.annotations.NotNull;
@Singleton
@Slf4j
@@ -279,7 +280,7 @@ public class ItemManager
.build(new CacheLoader<ImageKey, AsyncBufferedImage>()
{
@Override
public AsyncBufferedImage load(ImageKey key) throws Exception
public AsyncBufferedImage load(@NotNull ImageKey key) throws Exception
{
return loadImage(key.itemId, key.itemQuantity, key.stackable);
}
@@ -291,7 +292,7 @@ public class ItemManager
.build(new CacheLoader<Integer, ItemDefinition>()
{
@Override
public ItemDefinition load(Integer key) throws Exception
public ItemDefinition load(@NotNull Integer key) throws Exception
{
return client.getItemDefinition(key);
}
@@ -303,7 +304,7 @@ public class ItemManager
.build(new CacheLoader<OutlineKey, BufferedImage>()
{
@Override
public BufferedImage load(OutlineKey key) throws Exception
public BufferedImage load(@NotNull OutlineKey key) throws Exception
{
return loadItemOutline(key.itemId, key.itemQuantity, key.outlineColor);
}

View File

@@ -40,7 +40,7 @@ public class SkillIconManager
public BufferedImage getSkillImage(Skill skill, boolean small)
{
int skillIdx = skill.ordinal() + (small ? Skill.values().length : 0);
BufferedImage skillImage = null;
BufferedImage skillImage;
if (imgCache[skillIdx] != null)
{

View File

@@ -20,10 +20,10 @@ public enum Sound
RESTORED_SPECIAL_ATTACK(16, "net/runelite/client/game/sounds/restorespec.wav"),
IDLE(17, "net/runelite/client/game/sounds/idle.wav");
private String filePath;
private int id;
private final String filePath;
private final int id;
private Sound(int id, String filePath)
Sound(int id, String filePath)
{
this.id = id;
this.filePath = filePath;

View File

@@ -54,7 +54,7 @@ public class SpriteManager
@Inject
private ClientThread clientThread;
public Cache<Long, BufferedImage> cache = CacheBuilder.newBuilder()
private final Cache<Long, BufferedImage> cache = CacheBuilder.newBuilder()
.maximumSize(128L)
.expireAfterAccess(1, TimeUnit.HOURS)
.build();
@@ -110,12 +110,8 @@ public class SpriteManager
public void addSpriteTo(JButton c, int archive, int file)
{
getSpriteAsync(archive, file, img ->
{
SwingUtilities.invokeLater(() ->
{
c.setIcon(new ImageIcon(img));
});
});
c.setIcon(new ImageIcon(img))));
}
/**
@@ -124,12 +120,8 @@ public class SpriteManager
public void addSpriteTo(JLabel c, int archive, int file)
{
getSpriteAsync(archive, file, img ->
{
SwingUtilities.invokeLater(() ->
{
c.setIcon(new ImageIcon(img));
});
});
c.setIcon(new ImageIcon(img))));
}
public void addSpriteOverrides(SpriteOverride[] add)

View File

@@ -27,13 +27,13 @@ package net.runelite.client.game.chatbox;
/**
* A modal input that lives in the chatbox panel.
*/
public abstract class ChatboxInput
abstract class ChatboxInput
{
protected void open()
void open()
{
}
protected void close()
void close()
{
}
}

View File

@@ -156,12 +156,12 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
return this;
}
public ChatboxTextInput cursorAt(int index)
private ChatboxTextInput cursorAt(int index)
{
return cursorAt(index, index);
}
public ChatboxTextInput cursorAt(int indexA, int indexB)
private ChatboxTextInput cursorAt(int indexA, int indexB)
{
if (indexA < 0)
{
@@ -722,9 +722,6 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
newPos++;
break;
case KeyEvent.VK_UP:
ev.consume();
newPos = getLineOffset.applyAsInt(code);
break;
case KeyEvent.VK_DOWN:
ev.consume();
newPos = getLineOffset.applyAsInt(code);

View File

@@ -27,6 +27,7 @@ package net.runelite.client.menus;
import joptsimple.internal.Strings;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import net.runelite.api.MenuEntry;
import static net.runelite.client.menus.MenuManager.LEVEL_PATTERN;
import net.runelite.client.util.Text;
@@ -52,6 +53,16 @@ public class ComparableEntry
@Getter
private boolean strictTarget;
/**
* If two entries are both suppose to be left click,
* the entry with the higher priority will be selected.
* This only effects left click priority entries.
*/
@Getter
@Setter
@EqualsAndHashCode.Exclude
private int priority;
public ComparableEntry(String option, String target)
{
this(option, target, -1, -1, true, true);
@@ -70,6 +81,7 @@ public class ComparableEntry
this.type = type;
this.strictOption = strictOption;
this.strictTarget = strictTarget;
this.priority = 0;
}
// This is only used for type checking, which is why it has everything but target
@@ -80,6 +92,7 @@ public class ComparableEntry
this.id = e.getIdentifier();
this.type = e.getType();
this.strictOption = true;
this.priority = 0;
}
boolean matches(MenuEntry entry)

View File

@@ -31,17 +31,20 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -60,6 +63,7 @@ import net.runelite.api.events.NpcActionChanged;
import net.runelite.api.events.PlayerMenuOptionClicked;
import net.runelite.api.events.PlayerMenuOptionsChanged;
import net.runelite.api.events.WidgetMenuOptionClicked;
import net.runelite.api.events.WidgetPressed;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
@@ -78,7 +82,6 @@ public class MenuManager
private final Client client;
private final EventBus eventBus;
private final Prioritizer prioritizer;
//Maps the indexes that are being used to the menu option.
private final Map<Integer, String> playerMenuIndexMap = new HashMap<>();
@@ -86,24 +89,23 @@ public class MenuManager
private final Multimap<Integer, WidgetMenuOption> managedMenuOptions = HashMultimap.create();
private final Set<String> npcMenuOptions = new HashSet<>();
private final Set<ComparableEntry> priorityEntries = new HashSet<>();
private final Set<MenuEntry> currentPriorityEntries = new HashSet<>();
private final Set<ComparableEntry> hiddenEntries = new HashSet<>();
private final Set<MenuEntry> currentHiddenEntries = new HashSet<>();
private final Map<ComparableEntry, ComparableEntry> swaps = new HashMap<>();
private final Map<ComparableEntry, MenuEntry> currentSwaps = new HashMap<>();
private final HashSet<ComparableEntry> priorityEntries = new HashSet<>();
private HashMap<MenuEntry, ComparableEntry> currentPriorityEntries = new HashMap<>();
private final ConcurrentHashMap<MenuEntry, ComparableEntry> safeCurrentPriorityEntries = new ConcurrentHashMap<>();
private final HashSet<ComparableEntry> hiddenEntries = new HashSet<>();
private HashSet<MenuEntry> currentHiddenEntries = new HashSet<>();
private final HashMap<ComparableEntry, ComparableEntry> swaps = new HashMap<>();
private final LinkedHashSet<MenuEntry> entries = Sets.newLinkedHashSet();
private MenuEntry leftClickEntry = null;
private int leftClickType = -1;
private MenuEntry firstEntry = null;
@Inject
private MenuManager(Client client, EventBus eventBus)
{
this.client = client;
this.eventBus = eventBus;
this.prioritizer = new Prioritizer();
}
/**
@@ -147,22 +149,11 @@ public class MenuManager
public void onMenuOpened(MenuOpened event)
{
currentPriorityEntries.clear();
currentHiddenEntries.clear();
// Need to reorder the list to normal, then rebuild with swaps
MenuEntry[] oldEntries = event.getMenuEntries();
for (MenuEntry entry : oldEntries)
{
if (entry == leftClickEntry)
{
entry.setType(leftClickType);
break;
}
}
leftClickEntry = null;
leftClickType = -1;
firstEntry = null;
client.sortMenuEntries();
@@ -192,7 +183,7 @@ public class MenuManager
{
shouldDeprioritize = true;
}
currentPriorityEntries.add(entry);
currentPriorityEntries.put(entry, p);
newEntries.remove(entry);
continue prioritizer;
}
@@ -221,8 +212,8 @@ public class MenuManager
}
}
// Do not need to swap with itself
if (swapFrom != null && swapFrom != entry)
// Do not need to swap with itself or if the swapFrom is already the first entry
if (swapFrom != null && swapFrom != entry && swapFrom != Iterables.getLast(newEntries))
{
// Deprioritize entries if the swaps are not in similar type groups
if ((swapFrom.getType() >= 1000 && entry.getType() < 1000) || (entry.getType() >= 1000 && swapFrom.getType() < 1000) && !shouldDeprioritize)
@@ -250,12 +241,19 @@ public class MenuManager
}
}
if (!priorityEntries.isEmpty())
if (!currentPriorityEntries.isEmpty())
{
newEntries.addAll(currentPriorityEntries);
newEntries.addAll(currentPriorityEntries.entrySet().stream()
.sorted(Comparator.comparingInt(e -> e.getValue().getPriority()))
.map(Map.Entry::getKey)
.collect(Collectors.toList()));
}
event.setMenuEntries(newEntries.toArray(new MenuEntry[0]));
MenuEntry[] arrayEntries = newEntries.toArray(new MenuEntry[0]);
// Need to set the event entries to prevent conflicts
event.setMenuEntries(arrayEntries);
client.setMenuEntries(arrayEntries);
}
@Subscribe
@@ -282,77 +280,63 @@ public class MenuManager
}
}
@Subscribe
public void onBeforeRender(BeforeRender event)
{
leftClickEntry = null;
leftClickType = -1;
rebuildLeftClickMenu();
}
private MenuEntry rebuildLeftClickMenu()
{
if (client.isMenuOpen())
{
return;
return null;
}
firstEntry = null;
entries.clear();
entries.addAll(Arrays.asList(client.getMenuEntries()));
if (entries.size() < 2)
{
return;
return null;
}
currentPriorityEntries.clear();
currentHiddenEntries.clear();
currentSwaps.clear();
prioritizer.prioritize();
while (prioritizer.isRunning())
if (!hiddenEntries.isEmpty())
{
// wait
}
currentHiddenEntries.clear();
indexHiddenEntries(entries);
entries.removeAll(currentHiddenEntries);
for (MenuEntry entry : currentPriorityEntries)
{
if (entries.contains(entry))
if (!currentHiddenEntries.isEmpty())
{
leftClickEntry = entry;
leftClickType = entry.getType();
entries.remove(leftClickEntry);
leftClickEntry.setType(MenuAction.WIDGET_DEFAULT.getId());
entries.add(leftClickEntry);
break;
entries.removeAll(currentHiddenEntries);
}
}
if (leftClickEntry == null)
if (!priorityEntries.isEmpty())
{
MenuEntry first = Iterables.getLast(entries);
indexPriorityEntries(entries);
}
for (ComparableEntry swap : currentSwaps.keySet())
{
if (swap.matches(first))
{
leftClickEntry = currentSwaps.get(swap);
leftClickType = leftClickEntry.getType();
entries.remove(leftClickEntry);
leftClickEntry.setType(MenuAction.WIDGET_DEFAULT.getId());
entries.add(leftClickEntry);
break;
}
}
if (firstEntry == null && !swaps.isEmpty())
{
indexSwapEntries(entries);
}
if (firstEntry != null)
{
entries.remove(firstEntry);
entries.add(firstEntry);
}
else if (!currentHiddenEntries.isEmpty())
{
firstEntry = Iterables.getLast(entries, null);
}
client.setMenuEntries(entries.toArray(new MenuEntry[0]));
}
return firstEntry;
}
public void addPlayerMenuItem(String menuText)
{
@@ -455,14 +439,29 @@ public class MenuManager
}
}
@Subscribe
public void onWidgetPressed(WidgetPressed event)
{
leftClickEntry = rebuildLeftClickMenu();
}
@Subscribe
public void onMenuOptionClicked(MenuOptionClicked event)
{
if (leftClickEntry != null && leftClickType != -1)
if (!client.isMenuOpen() && event.isAuthentic())
{
leftClickEntry.setType(leftClickType);
event.setMenuEntry(leftClickEntry);
leftClickEntry = null;
// The mouse button will not be 0 if a non draggable widget was clicked,
// otherwise the left click entry will have been set in onWidgetPressed
if (client.getMouseCurrentButton() != 0)
{
leftClickEntry = rebuildLeftClickMenu();
}
if (leftClickEntry != null)
{
event.setMenuEntry(leftClickEntry);
leftClickEntry = null;
}
}
if (event.getMenuAction() != MenuAction.RUNELITE)
@@ -534,7 +533,7 @@ public class MenuManager
/**
* Adds to the set of menu entries which when present, will remove all entries except for this one
*/
public void addPriorityEntry(String option, String target)
public ComparableEntry addPriorityEntry(String option, String target)
{
option = Text.standardize(option);
target = Text.standardize(target);
@@ -542,6 +541,8 @@ public class MenuManager
ComparableEntry entry = new ComparableEntry(option, target);
priorityEntries.add(entry);
return entry;
}
public void removePriorityEntry(String option, String target)
@@ -559,13 +560,15 @@ public class MenuManager
* Adds to the set of menu entries which when present, will remove all entries except for this one
* This method will add one with strict option, but not-strict target (contains for target, equals for option)
*/
public void addPriorityEntry(String option)
public ComparableEntry addPriorityEntry(String option)
{
option = Text.standardize(option);
ComparableEntry entry = new ComparableEntry(option, "", false);
priorityEntries.add(entry);
return entry;
}
public void removePriorityEntry(String option)
@@ -789,115 +792,67 @@ public class MenuManager
hiddenEntries.remove(entry);
}
private class Prioritizer
private void indexHiddenEntries(Set<MenuEntry> entries)
{
private MenuEntry[] entries;
private AtomicInteger state = new AtomicInteger(0);
boolean isRunning()
currentHiddenEntries = entries.parallelStream().filter(entry ->
{
return state.get() != 0;
}
void prioritize()
{
if (state.get() != 0)
for (ComparableEntry p : hiddenEntries)
{
return;
}
entries = client.getMenuEntries();
state.set(3);
if (!hiddenEntries.isEmpty())
{
hiddenFinder.run();
}
else
{
state.decrementAndGet();
}
if (!priorityEntries.isEmpty())
{
priorityFinder.run();
}
else
{
state.decrementAndGet();
}
if (!swaps.isEmpty())
{
swapFinder.run();
}
else
{
state.decrementAndGet();
}
}
private Thread hiddenFinder = new Thread()
{
@Override
public void run()
{
Arrays.stream(entries).parallel().forEach(entry ->
if (p.matches(entry))
{
for (ComparableEntry p : hiddenEntries)
{
if (p.matches(entry))
{
currentHiddenEntries.add(entry);
return;
}
}
});
state.decrementAndGet();
return true;
}
}
};
private Thread priorityFinder = new Thread()
{
@Override
public void run()
{
Arrays.stream(entries).parallel().forEach(entry ->
{
for (ComparableEntry p : priorityEntries)
{
if (p.matches(entry))
{
currentPriorityEntries.add(entry);
return;
}
}
});
state.decrementAndGet();
}
};
private Thread swapFinder = new Thread()
{
@Override
public void run()
{
Arrays.stream(entries).parallel().forEach(entry ->
{
for (Map.Entry<ComparableEntry, ComparableEntry> p : swaps.entrySet())
{
if (p.getValue().matches(entry))
{
currentSwaps.put(p.getKey(), entry);
return;
}
}
});
state.decrementAndGet();
}
};
return false;
}).collect(Collectors.toCollection(HashSet::new));
}
}
// This could use some optimization
private void indexPriorityEntries(Set<MenuEntry> entries)
{
safeCurrentPriorityEntries.clear();
entries.parallelStream().forEach(entry ->
{
for (ComparableEntry p : priorityEntries)
{
if (p.matches(entry))
{
safeCurrentPriorityEntries.put(entry, p);
break;
}
}
});
firstEntry = Iterables.getLast(safeCurrentPriorityEntries.entrySet().stream()
.sorted(Comparator.comparingInt(e -> e.getValue().getPriority()))
.map(Map.Entry::getKey)
.collect(Collectors.toList()), null);
}
private void indexSwapEntries(Set<MenuEntry> entries)
{
MenuEntry first = Iterables.getLast(entries);
List<ComparableEntry> values = new ArrayList<>();
for (Map.Entry<ComparableEntry, ComparableEntry> pair : swaps.entrySet())
{
if (pair.getKey().matches(first))
{
values.add(pair.getValue());
}
}
firstEntry = entries.parallelStream().filter(entry ->
{
for (ComparableEntry value : values)
{
if (value.matches(entry))
{
return true;
}
}
return false;
}).findFirst().orElse(null);
}
}

View File

@@ -43,11 +43,16 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.stream.Collectors;
import javax.inject.Inject;
@@ -228,7 +233,6 @@ public class PluginManager
.directed()
.build();
List<Plugin> scannedPlugins = new ArrayList<>();
ClassPath classPath = ClassPath.from(classLoader);
ImmutableSet<ClassInfo> classes = packageName == null ? classPath.getAllClasses()
@@ -285,24 +289,47 @@ public class PluginManager
throw new RuntimeException("Plugin dependency graph contains a cycle!");
}
List<Class<? extends Plugin>> sortedPlugins = topologicalSort(graph);
List<List<Class<? extends Plugin>>> sortedPlugins = topologicalGroupSort(graph);
sortedPlugins = Lists.reverse(sortedPlugins);
for (Class<? extends Plugin> pluginClazz : sortedPlugins)
{
Plugin plugin;
try
{
plugin = instantiate(scannedPlugins, (Class<Plugin>) pluginClazz);
}
catch (PluginInstantiationException ex)
{
log.warn("Error instantiating plugin!", ex);
continue;
}
final long start = System.currentTimeMillis();
scannedPlugins.add(plugin);
}
// some plugins get stuck on IO, so add some extra threads
ExecutorService exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
List<Plugin> scannedPlugins = new CopyOnWriteArrayList<>();
sortedPlugins.forEach(group ->
{
List<Future<?>> curGroup = new ArrayList<>();
group.forEach(pluginClazz ->
curGroup.add(exec.submit(() ->
{
Plugin plugin;
try
{
plugin = instantiate(scannedPlugins, (Class<Plugin>) pluginClazz);
}
catch (PluginInstantiationException e)
{
log.warn("Error instantiating plugin!", e);
return;
}
scannedPlugins.add(plugin);
})));
curGroup.forEach(future ->
{
try
{
future.get();
}
catch (InterruptedException | ExecutionException e)
{
e.printStackTrace();
}
});
});
log.info("Plugin instantiation took {}ms", System.currentTimeMillis() - start);
return scannedPlugins;
}
@@ -515,40 +542,54 @@ public class PluginManager
}
/**
* Topologically sort a graph. Uses Kahn's algorithm.
*
* Topologically sort a graph into separate groups.
* Each group represents the dependency level of the plugins.
* Plugins in group (index) 0 has no dependents.
* Plugins in group 1 has dependents in group 0.
* Plugins in group 2 has dependents in group 1, etc.
* This allows for loading dependent groups serially, starting from the last group,
* while loading plugins within each group in parallel.
* @param graph
* @param <T>
* @return
*/
private <T> List<T> topologicalSort(Graph<T> graph)
private <T> List<List<T>> topologicalGroupSort(Graph<T> graph)
{
MutableGraph<T> graphCopy = Graphs.copyOf(graph);
List<T> l = new ArrayList<>();
Set<T> s = graphCopy.nodes().stream()
.filter(node -> graphCopy.inDegree(node) == 0)
final Set<T> root = graph.nodes().stream()
.filter(node -> graph.inDegree(node) == 0)
.collect(Collectors.toSet());
while (!s.isEmpty())
{
Iterator<T> it = s.iterator();
T n = it.next();
it.remove();
final Map<T, Integer> dependencyCount = new HashMap<>();
l.add(n);
root.forEach(n -> dependencyCount.put(n, 0));
root.forEach(n -> graph.successors(n)
.forEach(m -> incrementChildren(graph, dependencyCount, m, dependencyCount.get(n) + 1)));
for (T m : graphCopy.successors(n))
// create list<list> dependency grouping
final List<List<T>> dependencyGroups = new ArrayList<>();
final int[] curGroup = {-1};
dependencyCount.entrySet().stream()
.sorted(Map.Entry.comparingByValue())
.forEach(entry ->
{
graphCopy.removeEdge(n, m);
if (graphCopy.inDegree(m) == 0)
if (entry.getValue() != curGroup[0])
{
s.add(m);
curGroup[0] = entry.getValue();
dependencyGroups.add(new ArrayList<>());
}
}
}
if (!graphCopy.edges().isEmpty())
dependencyGroups.get(dependencyGroups.size() - 1).add(entry.getKey());
});
return dependencyGroups;
}
private <T> void incrementChildren(Graph<T> graph, Map<T, Integer> dependencyCount, T n, int val)
{
if (!dependencyCount.containsKey(n) || dependencyCount.get(n) < val)
{
throw new RuntimeException("Graph has at least one cycle");
dependencyCount.put(n, val);
graph.successors(n).forEach(m ->
incrementChildren(graph, dependencyCount, m, val + 1));
}
return l;
}
}

View File

@@ -45,7 +45,7 @@ import lombok.extern.slf4j.Slf4j;
import net.runelite.client.RuneLite;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.config.RuneLitePlusConfig;
@Singleton
@Slf4j
@@ -53,7 +53,7 @@ public class PluginWatcher extends Thread
{
private static final File BASE = RuneLite.PLUGIN_DIR;
private final RuneLiteConfig runeliteConfig;
private final RuneLitePlusConfig runelitePlusConfig;
private final PluginManager pluginManager;
private final WatchService watchService;
private final WatchKey watchKey;
@@ -62,9 +62,9 @@ public class PluginWatcher extends Thread
private ConfigManager configManager;
@Inject
public PluginWatcher(RuneLiteConfig runeliteConfig, PluginManager pluginManager) throws IOException
public PluginWatcher(RuneLitePlusConfig runelitePlusConfig, PluginManager pluginManager) throws IOException
{
this.runeliteConfig = runeliteConfig;
this.runelitePlusConfig = runelitePlusConfig;
this.pluginManager = pluginManager;
setName("Plugin Watcher");
@@ -84,7 +84,7 @@ public class PluginWatcher extends Thread
@Override
public void run()
{
if (runeliteConfig.enablePlugins())
if (runelitePlusConfig.enablePlugins())
{
scan();
}
@@ -96,7 +96,7 @@ public class PluginWatcher extends Thread
WatchKey key = watchService.take();
Thread.sleep(50);
if (!runeliteConfig.enablePlugins())
if (!runelitePlusConfig.enablePlugins())
{
key.reset();
continue;

View File

@@ -27,6 +27,7 @@ package net.runelite.client.plugins.account;
import java.awt.image.BufferedImage;
import java.util.concurrent.ScheduledExecutorService;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.swing.JOptionPane;
import lombok.extern.slf4j.Slf4j;
import net.runelite.client.account.AccountSession;
@@ -47,6 +48,7 @@ import net.runelite.client.util.ImageUtil;
loadWhenOutdated = true
)
@Slf4j
@Singleton
public class AccountPlugin extends Plugin
{
@Inject

View File

@@ -32,6 +32,7 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client;
import net.runelite.api.FontTypeFace;
@@ -66,6 +67,7 @@ import net.runelite.client.util.Text;
description = "Display level requirements in Achievement Diary interface",
tags = {"achievements", "tasks"}
)
@Singleton
public class DiaryRequirementsPlugin extends Plugin
{
private static final String AND_JOINER = ", ";
@@ -122,10 +124,6 @@ public class DiaryRequirementsPlugin extends Plugin
}
Map<String, String> skillRequirements = buildRequirements(requirements.getRequirements());
if (skillRequirements == null)
{
return;
}
int offset = 0;
String taskBuffer = "";

View File

@@ -32,6 +32,7 @@ import java.awt.Polygon;
import java.awt.geom.Area;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.Point;
import net.runelite.api.Tile;
@@ -42,23 +43,23 @@ import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayUtil;
@Singleton
class AgilityOverlay extends Overlay
{
private static final int MAX_DISTANCE = 2350;
private static final Color SHORTCUT_HIGH_LEVEL_COLOR = Color.ORANGE;
private final Client client;
private final AgilityPlugin plugin;
private final AgilityConfig config;
@Inject
private AgilityOverlay(Client client, AgilityPlugin plugin, AgilityConfig config)
private AgilityOverlay(final Client client, final AgilityPlugin plugin)
{
super(plugin);
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ABOVE_SCENE);
this.client = client;
this.plugin = plugin;
this.config = config;
}
@Override
@@ -69,14 +70,15 @@ class AgilityOverlay extends Overlay
final List<Tile> marksOfGrace = plugin.getMarksOfGrace();
plugin.getObstacles().forEach((object, obstacle) ->
{
if (Obstacles.SHORTCUT_OBSTACLE_IDS.containsKey(object.getId()) && !config.highlightShortcuts() ||
Obstacles.TRAP_OBSTACLE_IDS.contains(object.getId()) && !config.showTrapOverlay())
if (Obstacles.SHORTCUT_OBSTACLE_IDS.containsKey(object.getId()) && !plugin.isHighlightShortcuts() ||
Obstacles.TRAP_OBSTACLE_IDS.contains(object.getId()) && !plugin.isShowTrapOverlay())
{
return;
}
Tile tile = obstacle.getTile();
if (tile.getPlane() == client.getPlane())
if (tile.getPlane() == client.getPlane()
&& object.getLocalLocation().distanceTo(playerLocation) < MAX_DISTANCE)
{
// This assumes that the obstacle is not clickable.
if (Obstacles.TRAP_OBSTACLE_IDS.contains(object.getId()))
@@ -84,7 +86,7 @@ class AgilityOverlay extends Overlay
Polygon polygon = object.getCanvasTilePoly();
if (polygon != null)
{
OverlayUtil.renderPolygon(graphics, polygon, config.getTrapColor());
OverlayUtil.renderPolygon(graphics, polygon, plugin.getTrapColor());
}
return;
}
@@ -92,10 +94,10 @@ class AgilityOverlay extends Overlay
if (objectClickbox != null)
{
AgilityShortcut agilityShortcut = obstacle.getShortcut();
Color configColor = agilityShortcut == null || agilityShortcut.getLevel() <= plugin.getAgilityLevel() ? config.getOverlayColor() : SHORTCUT_HIGH_LEVEL_COLOR;
if (config.highlightMarks() && !marksOfGrace.isEmpty())
Color configColor = agilityShortcut == null || agilityShortcut.getLevel() <= plugin.getAgilityLevel() ? plugin.getOverlayColor() : SHORTCUT_HIGH_LEVEL_COLOR;
if (plugin.isHighlightMarks() && !marksOfGrace.isEmpty())
{
configColor = config.getMarkColor();
configColor = plugin.getMarkColor();
}
if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
@@ -115,11 +117,12 @@ class AgilityOverlay extends Overlay
});
if (config.highlightMarks() && !marksOfGrace.isEmpty())
if (plugin.isHighlightMarks() && !marksOfGrace.isEmpty())
{
for (Tile markOfGraceTile : marksOfGrace)
{
if (markOfGraceTile.getPlane() == client.getPlane() && markOfGraceTile.getItemLayer() != null)
if (markOfGraceTile.getPlane() == client.getPlane() && markOfGraceTile.getItemLayer() != null
&& markOfGraceTile.getLocalLocation().distanceTo(playerLocation) < MAX_DISTANCE)
{
final Polygon poly = markOfGraceTile.getItemLayer().getCanvasTilePoly();
@@ -128,7 +131,7 @@ class AgilityOverlay extends Overlay
continue;
}
OverlayUtil.renderPolygon(graphics, poly, config.getMarkColor());
OverlayUtil.renderPolygon(graphics, poly, plugin.getMarkColor());
}
}
}

View File

@@ -32,6 +32,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client;
@@ -83,14 +85,15 @@ import net.runelite.client.util.ColorUtil;
tags = {"grace", "marks", "overlay", "shortcuts", "skilling", "traps"}
)
@Slf4j
@Singleton
public class AgilityPlugin extends Plugin
{
private static final int AGILITY_ARENA_REGION_ID = 11157;
@Getter
@Getter(AccessLevel.PACKAGE)
private final Map<TileObject, Obstacle> obstacles = new HashMap<>();
@Getter
@Getter(AccessLevel.PACKAGE)
private final List<Tile> marksOfGrace = new ArrayList<>();
@Inject
@@ -117,13 +120,13 @@ public class AgilityPlugin extends Plugin
@Inject
private ItemManager itemManager;
@Getter
@Getter(AccessLevel.PACKAGE)
private AgilitySession session;
private int lastAgilityXp;
private WorldPoint lastArenaTicketPosition;
@Getter
@Getter(AccessLevel.PACKAGE)
private int agilityLevel;
@Provides
@@ -132,9 +135,36 @@ public class AgilityPlugin extends Plugin
return configManager.getConfig(AgilityConfig.class);
}
// Config values
@Getter(AccessLevel.PACKAGE)
private boolean showLapCount;
@Getter(AccessLevel.PACKAGE)
private int lapTimeout;
@Getter(AccessLevel.PACKAGE)
private boolean lapsToLevel;
@Getter(AccessLevel.PACKAGE)
private boolean lapsToGoal;
@Getter(AccessLevel.PACKAGE)
private Color overlayColor;
@Getter(AccessLevel.PACKAGE)
private boolean highlightMarks;
@Getter(AccessLevel.PACKAGE)
private Color markColor;
@Getter(AccessLevel.PACKAGE)
private boolean highlightShortcuts;
@Getter(AccessLevel.PACKAGE)
private boolean showTrapOverlay;
@Getter(AccessLevel.PACKAGE)
private Color trapColor;
private boolean notifyAgilityArena;
private boolean showAgilityArenaTimer;
private boolean showShortcutLevel;
@Override
protected void startUp() throws Exception
{
updateConfig();
overlayManager.add(agilityOverlay);
overlayManager.add(lapCounterOverlay);
agilityLevel = client.getBoostedSkillLevel(Skill.AGILITY);
@@ -179,16 +209,40 @@ public class AgilityPlugin extends Plugin
@Subscribe
public void onConfigChanged(ConfigChanged event)
{
if (!config.showAgilityArenaTimer())
if (!event.getGroup().equals("agility"))
{
return;
}
updateConfig();
if (!this.showAgilityArenaTimer)
{
removeAgilityArenaTimer();
}
}
public void updateConfig()
{
this.showLapCount = config.showLapCount();
this.lapTimeout = config.lapTimeout();
this.lapsToLevel = config.lapsToLevel();
this.lapsToGoal = config.lapsToGoal();
this.overlayColor = config.getOverlayColor();
this.highlightMarks = config.highlightMarks();
this.markColor = config.getMarkColor();
this.highlightShortcuts = config.highlightShortcuts();
this.showTrapOverlay = config.showTrapOverlay();
this.trapColor = config.getTrapColor();
this.notifyAgilityArena = config.notifyAgilityArena();
this.showAgilityArenaTimer = config.showAgilityArenaTimer();
this.showShortcutLevel = config.showShortcutLevel();
}
@Subscribe
public void onExperienceChanged(ExperienceChanged event)
{
if (event.getSkill() != AGILITY || !config.showLapCount())
if (event.getSkill() != AGILITY || !this.showLapCount)
{
return;
}
@@ -272,12 +326,12 @@ public class AgilityPlugin extends Plugin
{
log.debug("Ticked position moved from {} to {}", oldTickPosition, newTicketPosition);
if (config.notifyAgilityArena())
if (this.notifyAgilityArena)
{
notifier.notify("Ticket location changed");
}
if (config.showAgilityArenaTimer())
if (this.showAgilityArenaTimer)
{
showNewAgilityArenaTimer();
}
@@ -430,7 +484,7 @@ public class AgilityPlugin extends Plugin
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded event)
{
if (!config.showShortcutLevel())
if (!this.showShortcutLevel)
{
return;
}

View File

@@ -42,7 +42,7 @@ class AgilitySession
private int lapsTillLevel;
private int lapsTillGoal;
AgilitySession(Courses course)
AgilitySession(final Courses course)
{
this.course = course;
}

View File

@@ -26,6 +26,7 @@ package net.runelite.client.plugins.agility;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.coords.WorldPoint;
@@ -50,16 +51,16 @@ enum Courses
private final static Map<Integer, Courses> coursesByRegion;
@Getter
@Getter(AccessLevel.PACKAGE)
private final double totalXp;
@Getter
@Getter(AccessLevel.PACKAGE)
private final int lastObstacleXp;
@Getter
@Getter(AccessLevel.PACKAGE)
private final int regionId;
@Getter
@Getter(AccessLevel.PACKAGE)
private final WorldPoint[] courseEndWorldPoints;
static

View File

@@ -29,6 +29,7 @@ import java.awt.Graphics2D;
import java.time.Duration;
import java.time.Instant;
import javax.inject.Inject;
import javax.inject.Singleton;
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
import net.runelite.client.ui.overlay.Overlay;
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
@@ -39,21 +40,20 @@ import net.runelite.client.ui.overlay.components.PanelComponent;
import net.runelite.client.ui.overlay.components.table.TableAlignment;
import net.runelite.client.ui.overlay.components.table.TableComponent;
@Singleton
class LapCounterOverlay extends Overlay
{
private final AgilityPlugin plugin;
private final AgilityConfig config;
private final PanelComponent panelComponent = new PanelComponent();
@Inject
private LapCounterOverlay(AgilityPlugin plugin, AgilityConfig config)
private LapCounterOverlay(final AgilityPlugin plugin)
{
super(plugin);
setPosition(OverlayPosition.TOP_LEFT);
setPriority(OverlayPriority.LOW);
this.plugin = plugin;
this.config = config;
getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Agility overlay"));
}
@@ -62,7 +62,7 @@ class LapCounterOverlay extends Overlay
{
AgilitySession session = plugin.getSession();
if (!config.showLapCount() ||
if (!plugin.isShowLapCount() ||
session == null ||
session.getLastLapCompleted() == null ||
session.getCourse() == null)
@@ -70,7 +70,7 @@ class LapCounterOverlay extends Overlay
return null;
}
Duration lapTimeout = Duration.ofMinutes(config.lapTimeout());
Duration lapTimeout = Duration.ofMinutes(plugin.getLapTimeout());
Duration sinceLap = Duration.between(session.getLastLapCompleted(), Instant.now());
if (sinceLap.compareTo(lapTimeout) >= 0)
@@ -85,12 +85,12 @@ class LapCounterOverlay extends Overlay
tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT);
tableComponent.addRow("Total Laps:", Integer.toString(session.getTotalLaps()));
if (config.lapsToLevel() && session.getLapsTillLevel() > 0)
if (plugin.isLapsToLevel() && session.getLapsTillLevel() > 0)
{
tableComponent.addRow("Laps until level:", Integer.toString(session.getLapsTillLevel()));
}
if (config.lapsToGoal() && session.getLapsTillGoal() > 0)
if (plugin.isLapsToGoal() && session.getLapsTillGoal() > 0)
{
tableComponent.addRow("Laps until goal:", Integer.toString(session.getLapsTillGoal()));
}

View File

@@ -54,7 +54,7 @@ class HydraOverlay extends Overlay
private final PanelComponent panelComponent = new PanelComponent();
@Inject
HydraOverlay(HydraPlugin plugin, Client client, SpriteManager spriteManager)
HydraOverlay(final HydraPlugin plugin, final Client client, final SpriteManager spriteManager)
{
this.plugin = plugin;
this.client = client;

View File

@@ -30,6 +30,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
@@ -59,6 +60,7 @@ import net.runelite.client.ui.overlay.OverlayManager;
enabledByDefault = false
)
@Slf4j
@Singleton
public class HydraPlugin extends Plugin
{
@Getter(AccessLevel.PACKAGE)

View File

@@ -55,7 +55,7 @@ class HydraSceneOverlay extends Overlay
private final Client client;
@Inject
public HydraSceneOverlay(Client client, HydraPlugin plugin)
public HydraSceneOverlay(final Client client, final HydraPlugin plugin)
{
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.UNDER_WIDGETS);

View File

@@ -29,6 +29,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.Duration;
import java.time.Instant;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.ui.overlay.infobox.Counter;
@@ -36,11 +37,11 @@ import net.runelite.client.util.StackFormatter;
class AmmoCounter extends Counter
{
@Getter
@Getter(AccessLevel.PACKAGE)
private int itemID;
private String name;
private int total;
private Instant time;
private final String name;
private final int total;
private final Instant time;
private BigDecimal ammoPerHour;
AmmoCounter(Plugin plugin, int itemID, int count, String name, BufferedImage image)

View File

@@ -26,6 +26,7 @@ package net.runelite.client.plugins.ammo;
import java.awt.image.BufferedImage;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.EquipmentInventorySlot;
import net.runelite.api.InventoryID;
@@ -45,6 +46,7 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
description = "Shows the current ammo the player has equipped",
tags = {"bolts", "darts", "chinchompa", "equipment"}
)
@Singleton
public class AmmoPlugin extends Plugin
{
@Inject

View File

@@ -26,6 +26,7 @@ package net.runelite.client.plugins.animsmoothing;
import com.google.inject.Provides;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.events.ConfigChanged;
import net.runelite.client.config.ConfigManager;
@@ -39,6 +40,7 @@ import net.runelite.client.plugins.PluginDescriptor;
tags = {"npcs", "objects", "players"},
enabledByDefault = false
)
@Singleton
public class AnimationSmoothingPlugin extends Plugin
{
static final String CONFIG_GROUP = "animationSmoothing";

View File

@@ -37,7 +37,6 @@ import net.runelite.client.config.ModifierlessKeybind;
@ConfigGroup("antiDrag")
public interface AntiDragConfig extends Config
{
@ConfigItem(
position = 0,
keyName = "alwaysOn",

View File

@@ -42,13 +42,13 @@ public class AntiDragOverlay extends Overlay
{
private static final int RADIUS = 20;
private Client client;
private AntiDragConfig config;
private final Client client;
private final AntiDragPlugin plugin;
@Inject
private AntiDragOverlay(Client client, AntiDragConfig config)
private AntiDragOverlay(final Client client, final AntiDragPlugin plugin)
{
this.config = config;
this.plugin = plugin;
this.client = client;
setPosition(OverlayPosition.TOOLTIP);
setPriority(OverlayPriority.HIGHEST);
@@ -58,7 +58,7 @@ public class AntiDragOverlay extends Overlay
@Override
public Dimension render(Graphics2D g)
{
final Color color = config.color();
final Color color = plugin.getColor();
g.setColor(color);
final net.runelite.api.Point mouseCanvasPosition = client.getMouseCanvasPosition();

View File

@@ -26,11 +26,16 @@
package net.runelite.client.plugins.antidrag;
import com.google.inject.Provides;
import java.awt.Color;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.Client;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.FocusChanged;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.Keybind;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.input.KeyManager;
import net.runelite.client.plugins.Plugin;
@@ -48,11 +53,11 @@ import net.runelite.client.util.HotkeyListener;
type = PluginType.UTILITY,
enabledByDefault = false
)
@Singleton
public class AntiDragPlugin extends Plugin
{
private static final int DEFAULT_DELAY = 5;
private boolean toggleDrag;
@Inject
@@ -82,14 +87,27 @@ public class AntiDragPlugin extends Plugin
return configManager.getConfig(AntiDragConfig.class);
}
private boolean alwaysOn;
private boolean keybind;
private Keybind key;
private int dragDelay;
private boolean reqfocus;
@Getter(AccessLevel.PACKAGE)
private boolean configOverlay;
@Getter(AccessLevel.PACKAGE)
private Color color;
private boolean changeCursor;
private CustomCursor selectedCursor;
@Override
protected void startUp() throws Exception
{
if (config.keybind())
updateConfig();
if (this.keybind)
{
keyManager.registerKeyListener(hotkeyListener);
}
client.setInventoryDragDelay(config.alwaysOn() ? config.dragDelay() : DEFAULT_DELAY);
client.setInventoryDragDelay(this.alwaysOn ? this.dragDelay : DEFAULT_DELAY);
}
@Override
@@ -106,9 +124,11 @@ public class AntiDragPlugin extends Plugin
{
if (event.getGroup().equals("antiDrag"))
{
updateConfig();
if (event.getKey().equals("keybind"))
{
if (config.keybind())
if (this.keybind)
{
keyManager.registerKeyListener(hotkeyListener);
}
@@ -119,51 +139,60 @@ public class AntiDragPlugin extends Plugin
}
if (event.getKey().equals("alwaysOn"))
{
client.setInventoryDragDelay(config.alwaysOn() ? config.dragDelay() : DEFAULT_DELAY);
client.setInventoryDragDelay(this.alwaysOn ? this.dragDelay : DEFAULT_DELAY);
}
}
}
private void updateConfig()
{
this.alwaysOn = config.alwaysOn();
this.keybind = config.keybind();
this.key = config.key();
this.dragDelay = config.dragDelay();
this.reqfocus = config.reqfocus();
this.configOverlay = config.overlay();
this.color = config.color();
this.changeCursor = config.changeCursor();
this.selectedCursor = config.selectedCursor();
}
@Subscribe
public void onFocusChanged(FocusChanged focusChanged)
{
if (!config.alwaysOn())
if (!this.alwaysOn && !focusChanged.isFocused() && this.reqfocus)
{
if (!focusChanged.isFocused() && config.reqfocus())
{
client.setInventoryDragDelay(DEFAULT_DELAY);
overlayManager.remove(overlay);
}
client.setInventoryDragDelay(DEFAULT_DELAY);
overlayManager.remove(overlay);
}
}
private final HotkeyListener hotkeyListener = new HotkeyListener(() -> config.key())
private final HotkeyListener hotkeyListener = new HotkeyListener(() -> this.key)
{
@Override
public void hotkeyPressed()
{
if (!config.alwaysOn())
if (!alwaysOn)
{
toggleDrag = !toggleDrag;
if (toggleDrag)
{
if (config.overlay())
if (configOverlay)
{
overlayManager.add(overlay);
}
if (config.changeCursor())
if (changeCursor)
{
CustomCursor selectedCursor = config.selectedCursor();
clientUI.setCursor(selectedCursor.getCursorImage(), selectedCursor.toString());
}
client.setInventoryDragDelay(config.dragDelay());
client.setInventoryDragDelay(dragDelay);
}
else
{
overlayManager.remove(overlay);
client.setInventoryDragDelay(DEFAULT_DELAY);
if (config.changeCursor())
if (changeCursor)
{
net.runelite.client.plugins.customcursor.CustomCursor selectedCursor = configManager.getConfig(CustomCursorConfig.class).selectedCursor();
clientUI.setCursor(selectedCursor.getCursorImage(), selectedCursor.toString());
@@ -172,4 +201,4 @@ public class AntiDragPlugin extends Plugin
}
}
};
}
}

View File

@@ -25,6 +25,7 @@
package net.runelite.client.plugins.antidrag;
import java.awt.image.BufferedImage;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.client.plugins.customcursor.CustomCursorPlugin;
import net.runelite.client.util.ImageUtil;
@@ -43,7 +44,8 @@ public enum CustomCursor
ZAMORAK_GODSWORD("Zamorak Godsword", "cursor-zamorak-godsword.png");
private final String name;
@Getter
@Getter(AccessLevel.PACKAGE)
private final BufferedImage cursorImage;
CustomCursor(String name, String icon)

View File

@@ -28,11 +28,12 @@
package net.runelite.client.plugins.aoewarnings;
import java.time.Instant;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.runelite.api.coords.LocalPoint;
@Getter
@Getter(AccessLevel.PACKAGE)
@AllArgsConstructor
class AoeProjectile
{

View File

@@ -37,6 +37,7 @@ import java.time.Instant;
import java.util.Iterator;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
@@ -48,6 +49,7 @@ import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayUtil;
import static net.runelite.client.util.ColorUtil.setAlphaComponent;
@Singleton
public class AoeWarningOverlay extends Overlay
{
private static final int FILL_START_ALPHA = 25;
@@ -55,16 +57,14 @@ public class AoeWarningOverlay extends Overlay
private final Client client;
private final AoeWarningPlugin plugin;
private final AoeWarningConfig config;
@Inject
public AoeWarningOverlay(Client client, AoeWarningPlugin plugin, AoeWarningConfig config)
public AoeWarningOverlay(final Client client, final AoeWarningPlugin plugin)
{
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.UNDER_WIDGETS);
this.client = client;
this.plugin = plugin;
this.config = config;
}
@Override
@@ -115,7 +115,7 @@ public class AoeWarningOverlay extends Overlay
int tickProgress = aoeProjectile.getFinalTick() - client.getTickCount();
int fillAlpha, outlineAlpha;
if (config.isFadeEnabled())
if (plugin.isConfigFadeEnabled())
{
fillAlpha = (int) ((1 - progress) * FILL_START_ALPHA);//alpha drop off over lifetime
outlineAlpha = (int) ((1 - progress) * OUTLINE_START_ALPHA);
@@ -152,20 +152,18 @@ public class AoeWarningOverlay extends Overlay
outlineAlpha = 255;
}
if (config.isOutlineEnabled())
if (plugin.isConfigOutlineEnabled())
{
graphics.setColor(new Color(setAlphaComponent(config.overlayColor().getRGB(), outlineAlpha), true));
graphics.setColor(new Color(setAlphaComponent(plugin.getOverlayColor().getRGB(), outlineAlpha), true));
graphics.drawPolygon(tilePoly);
}
if (config.tickTimers())
if (plugin.isTickTimers() && tickProgress >= 0)
{
if (tickProgress >= 0)
{
OverlayUtil.renderTextLocation(graphics, Integer.toString(tickProgress), plugin.getTextSize(),
plugin.getFontStyle(), color, centerPoint(tilePoly.getBounds()), plugin.isShadows(), 0);
}
OverlayUtil.renderTextLocation(graphics, Integer.toString(tickProgress), plugin.getTextSize(),
plugin.getFontStyle(), color, centerPoint(tilePoly.getBounds()), plugin.isShadows(), 0);
}
graphics.setColor(new Color(setAlphaComponent(config.overlayColor().getRGB(), fillAlpha), true));
graphics.setColor(new Color(setAlphaComponent(plugin.getOverlayColor().getRGB(), fillAlpha), true));
graphics.fillPolygon(tilePoly);
}
return null;

View File

@@ -28,6 +28,7 @@ package net.runelite.client.plugins.aoewarnings;
import com.google.inject.Provides;
import java.awt.Color;
import java.time.Instant;
import java.util.ArrayList;
import java.util.HashMap;
@@ -35,6 +36,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
@@ -70,12 +72,13 @@ import net.runelite.client.ui.overlay.OverlayManager;
type = PluginType.PVM,
enabledByDefault = false
)
@Singleton
@Slf4j
public class AoeWarningPlugin extends Plugin
{
@Getter
@Getter(AccessLevel.PACKAGE)
private final Map<WorldPoint, CrystalBomb> bombs = new HashMap<>();
@Getter(AccessLevel.PACKAGE)
private final Map<Projectile, AoeProjectile> projectiles = new HashMap<>();
@Inject
public AoeWarningConfig config;
@@ -97,12 +100,6 @@ public class AoeWarningPlugin extends Plugin
private List<WorldPoint> CrystalSpike = new ArrayList<>();
@Getter(AccessLevel.PACKAGE)
private List<WorldPoint> WintertodtSnowFall = new ArrayList<>();
@Getter(AccessLevel.PACKAGE)
private boolean shadows;
@Getter(AccessLevel.PACKAGE)
private int textSize;
@Getter(AccessLevel.PACKAGE)
private int fontStyle;
@Provides
AoeWarningConfig getConfig(ConfigManager configManager)
@@ -110,17 +107,73 @@ public class AoeWarningPlugin extends Plugin
return configManager.getConfig(AoeWarningConfig.class);
}
Map<Projectile, AoeProjectile> getProjectiles()
{
return projectiles;
}
// Config values
private boolean aoeNotifyAll;
@Getter(AccessLevel.PACKAGE)
private Color overlayColor;
@Getter(AccessLevel.PACKAGE)
private boolean configOutlineEnabled;
private int delay;
@Getter(AccessLevel.PACKAGE)
private boolean configFadeEnabled;
@Getter(AccessLevel.PACKAGE)
private boolean tickTimers;
@Getter(AccessLevel.PACKAGE)
private int fontStyle;
@Getter(AccessLevel.PACKAGE)
private int textSize;
@Getter(AccessLevel.PACKAGE)
private boolean shadows;
private boolean configShamansEnabled;
private boolean configShamansNotifyEnabled;
private boolean configArchaeologistEnabled;
private boolean configArchaeologistNotifyEnabled;
private boolean configIceDemonEnabled;
private boolean configIceDemonNotifyEnabled;
private boolean configVasaEnabled;
private boolean configVasaNotifyEnabled;
private boolean configTektonEnabled;
private boolean configTektonNotifyEnabled;
private boolean configVorkathEnabled;
private boolean configVorkathNotifyEnabled;
private boolean configGalvekEnabled;
private boolean configGalvekNotifyEnabled;
private boolean configGargBossEnabled;
private boolean configGargBossNotifyEnabled;
private boolean configVetionEnabled;
private boolean configVetionNotifyEnabled;
private boolean configChaosFanaticEnabled;
private boolean configChaosFanaticNotifyEnabled;
private boolean configOlmEnabled;
private boolean configOlmNotifyEnabled;
@Getter(AccessLevel.PACKAGE)
private boolean configbombDisplay;
private boolean configbombDisplayNotifyEnabled;
private boolean configLightningTrail;
private boolean configLightningTrailNotifyEnabled;
private boolean configCorpEnabled;
private boolean configCorpNotifyEnabled;
private boolean configWintertodtEnabled;
private boolean configWintertodtNotifyEnabled;
private boolean configXarpusEnabled;
private boolean configXarpusNotifyEnabled;
private boolean configaddyDrags;
private boolean configaddyDragsNotifyEnabled;
private boolean configDrakeEnabled;
private boolean configDrakeNotifyEnabled;
private boolean configCerbFireEnabled;
private boolean configCerbFireNotifyEnabled;
private boolean configDemonicGorillaEnabled;
private boolean configDemonicGorillaNotifyEnabled;
@Override
protected void startUp() throws Exception
{
updateConfig();
overlayManager.add(coreOverlay);
overlayManager.add(bombOverlay);
reset(true);
reset();
}
@Override
@@ -128,7 +181,7 @@ public class AoeWarningPlugin extends Plugin
{
overlayManager.remove(coreOverlay);
overlayManager.remove(bombOverlay);
reset(false);
reset();
}
@Subscribe
@@ -139,18 +192,7 @@ public class AoeWarningPlugin extends Plugin
return;
}
switch (event.getKey())
{
case "fontStyle":
fontStyle = config.fontStyle().getFont();
break;
case "textSize":
textSize = config.textSize();
break;
case "shadows":
shadows = config.shadows();
break;
}
updateConfig();
}
@Subscribe
@@ -159,7 +201,7 @@ public class AoeWarningPlugin extends Plugin
Projectile projectile = event.getProjectile();
int projectileId = projectile.getId();
int projectileLifetime = config.delay() + (projectile.getRemainingCycles() * 20);
int projectileLifetime = this.delay + (projectile.getRemainingCycles() * 20);
int ticksRemaining = projectile.getRemainingCycles() / 30;
if (!isTickTimersEnabledForProjectileID(projectileId))
{
@@ -174,7 +216,7 @@ public class AoeWarningPlugin extends Plugin
AoeProjectile aoeProjectile = new AoeProjectile(Instant.now(), targetPoint, aoeProjectileInfo, projectileLifetime, tickCycle);
projectiles.put(projectile, aoeProjectile);
if (config.aoeNotifyAll() || isConfigEnabledForProjectileId(projectileId, true))
if (this.aoeNotifyAll || isConfigEnabledForProjectileId(projectileId, true))
{
notifier.notify("AoE attack detected!");
}
@@ -192,7 +234,7 @@ public class AoeWarningPlugin extends Plugin
case ObjectID.CRYSTAL_BOMB:
bombs.put(wp, new CrystalBomb(gameObject, client.getTickCount()));
if (config.aoeNotifyAll() || config.bombDisplayNotifyEnabled())
if (this.aoeNotifyAll || this.configbombDisplayNotifyEnabled)
{
notifier.notify("Bomb!");
}
@@ -205,11 +247,11 @@ public class AoeWarningPlugin extends Plugin
break;
case NullObjectID.NULL_26690:
//Wintertodt Snowfall
if (config.isWintertodtEnabled())
if (this.configWintertodtEnabled)
{
WintertodtSnowFall.add(wp);
if (config.aoeNotifyAll() || config.isWintertodtNotifyEnabled())
if (this.aoeNotifyAll || this.configWintertodtNotifyEnabled)
{
notifier.notify("Snow Fall!");
}
@@ -236,7 +278,7 @@ public class AoeWarningPlugin extends Plugin
break;
case NullObjectID.NULL_26690:
//Wintertodt Snowfall
if (config.isWintertodtEnabled())
if (this.configWintertodtEnabled)
{
WintertodtSnowFall.remove(wp);
}
@@ -256,7 +298,7 @@ public class AoeWarningPlugin extends Plugin
@Subscribe
public void onGameTick(GameTick event)
{
if (config.LightningTrail())
if (this.configLightningTrail)
{
LightningTrail.clear();
for (GraphicsObject o : client.getGraphicsObjects())
@@ -265,7 +307,7 @@ public class AoeWarningPlugin extends Plugin
{
LightningTrail.add(WorldPoint.fromLocal(client, o.getLocation()));
if (config.aoeNotifyAll() || config.LightningTrailNotifyEnabled())
if (this.aoeNotifyAll || this.configLightningTrailNotifyEnabled)
{
notifier.notify("Lightning!");
}
@@ -350,7 +392,7 @@ public class AoeWarningPlugin extends Plugin
return false;
}
if (notify && config.aoeNotifyAll())
if (notify && this.aoeNotifyAll)
{
return true;
}
@@ -358,57 +400,110 @@ public class AoeWarningPlugin extends Plugin
switch (projectileInfo)
{
case LIZARDMAN_SHAMAN_AOE:
return notify ? config.isShamansNotifyEnabled() : config.isShamansEnabled();
return notify ? this.configShamansNotifyEnabled : this.configShamansEnabled;
case CRAZY_ARCHAEOLOGIST_AOE:
return notify ? config.isArchaeologistNotifyEnabled() : config.isArchaeologistEnabled();
return notify ? this.configArchaeologistNotifyEnabled : this.configArchaeologistEnabled;
case ICE_DEMON_RANGED_AOE:
case ICE_DEMON_ICE_BARRAGE_AOE:
return notify ? config.isIceDemonNotifyEnabled() : config.isIceDemonEnabled();
return notify ? this.configIceDemonNotifyEnabled : this.configIceDemonEnabled;
case VASA_AWAKEN_AOE:
case VASA_RANGED_AOE:
return notify ? config.isVasaNotifyEnabled() : config.isVasaEnabled();
return notify ? this.configVasaNotifyEnabled : this.configVasaEnabled;
case TEKTON_METEOR_AOE:
return notify ? config.isTektonNotifyEnabled() : config.isTektonEnabled();
return notify ? this.configTektonNotifyEnabled : this.configTektonEnabled;
case VORKATH_BOMB:
case VORKATH_POISON_POOL:
case VORKATH_SPAWN:
case VORKATH_TICK_FIRE:
return notify ? config.isVorkathNotifyEnabled() : config.isVorkathEnabled();
return notify ? this.configVorkathNotifyEnabled : this.configVorkathEnabled;
case VETION_LIGHTNING:
return notify ? config.isVetionNotifyEnabled() : config.isVetionEnabled();
return notify ? this.configVetionNotifyEnabled : this.configVetionEnabled;
case CHAOS_FANATIC:
return notify ? config.isChaosFanaticNotifyEnabled() : config.isChaosFanaticEnabled();
return notify ? this.configChaosFanaticNotifyEnabled : this.configChaosFanaticEnabled;
case GALVEK_BOMB:
case GALVEK_MINE:
return notify ? config.isGalvekNotifyEnabled() : config.isGalvekEnabled();
return notify ? this.configGalvekNotifyEnabled : this.configGalvekEnabled;
case DAWN_FREEZE:
case DUSK_CEILING:
return notify ? config.isGargBossNotifyEnabled() : config.isGargBossEnabled();
return notify ? this.configGargBossNotifyEnabled : this.configGargBossEnabled;
case OLM_FALLING_CRYSTAL:
case OLM_BURNING:
case OLM_FALLING_CRYSTAL_TRAIL:
case OLM_ACID_TRAIL:
case OLM_FIRE_LINE:
return notify ? config.isOlmNotifyEnabled() : config.isOlmEnabled();
return notify ? this.configOlmNotifyEnabled : this.configOlmEnabled;
case CORPOREAL_BEAST:
case CORPOREAL_BEAST_DARK_CORE:
return notify ? config.isCorpNotifyEnabled() : config.isCorpEnabled();
return notify ? this.configCorpNotifyEnabled : this.configCorpEnabled;
case XARPUS_POISON_AOE:
return notify ? config.isXarpusNotifyEnabled() : config.isXarpusEnabled();
return notify ? this.configXarpusNotifyEnabled : this.configXarpusEnabled;
case ADDY_DRAG_POISON:
return notify ? config.addyDragsNotifyEnabled() : config.addyDrags();
return notify ? this.configaddyDragsNotifyEnabled : this.configaddyDrags;
case DRAKE_BREATH:
return notify ? config.isDrakeNotifyEnabled() : config.isDrakeEnabled();
return notify ? this.configDrakeNotifyEnabled : this.configDrakeEnabled;
case CERB_FIRE:
return notify ? config.isCerbFireNotifyEnabled() : config.isCerbFireEnabled();
return notify ? this.configCerbFireNotifyEnabled : this.configCerbFireEnabled;
case DEMONIC_GORILLA_BOULDER:
return notify ? config.isDemonicGorillaNotifyEnabled() : config.isDemonicGorillaEnabled();
return notify ? this.configDemonicGorillaNotifyEnabled : this.configDemonicGorillaEnabled;
}
return false;
}
private void reset(boolean setConfig)
private void updateConfig()
{
this.aoeNotifyAll = config.aoeNotifyAll();
this.overlayColor = config.overlayColor();
this.configOutlineEnabled = config.isOutlineEnabled();
this.delay = config.delay();
this.configFadeEnabled = config.isFadeEnabled();
this.tickTimers = config.tickTimers();
this.fontStyle = config.fontStyle().getFont();
this.textSize = config.textSize();
this.shadows = config.shadows();
this.configShamansEnabled = config.isShamansEnabled();
this.configShamansNotifyEnabled = config.isShamansNotifyEnabled();
this.configArchaeologistEnabled = config.isArchaeologistEnabled();
this.configArchaeologistNotifyEnabled = config.isArchaeologistNotifyEnabled();
this.configIceDemonEnabled = config.isIceDemonEnabled();
this.configIceDemonNotifyEnabled = config.isIceDemonNotifyEnabled();
this.configVasaEnabled = config.isVasaEnabled();
this.configVasaNotifyEnabled = config.isVasaNotifyEnabled();
this.configTektonEnabled = config.isTektonEnabled();
this.configTektonNotifyEnabled = config.isTektonNotifyEnabled();
this.configVorkathEnabled = config.isVorkathEnabled();
this.configVorkathNotifyEnabled = config.isVorkathNotifyEnabled();
this.configGalvekEnabled = config.isGalvekEnabled();
this.configGalvekNotifyEnabled = config.isGalvekNotifyEnabled();
this.configGargBossEnabled = config.isGargBossEnabled();
this.configGargBossNotifyEnabled = config.isGargBossNotifyEnabled();
this.configVetionEnabled = config.isVetionEnabled();
this.configVetionNotifyEnabled = config.isVetionNotifyEnabled();
this.configChaosFanaticEnabled = config.isChaosFanaticEnabled();
this.configChaosFanaticNotifyEnabled = config.isChaosFanaticNotifyEnabled();
this.configOlmEnabled = config.isOlmEnabled();
this.configOlmNotifyEnabled = config.isOlmNotifyEnabled();
this.configbombDisplay = config.bombDisplay();
this.configbombDisplayNotifyEnabled = config.bombDisplayNotifyEnabled();
this.configLightningTrail = config.LightningTrail();
this.configLightningTrailNotifyEnabled = config.LightningTrailNotifyEnabled();
this.configCorpEnabled = config.isCorpEnabled();
this.configCorpNotifyEnabled = config.isCorpNotifyEnabled();
this.configWintertodtEnabled = config.isWintertodtEnabled();
this.configWintertodtNotifyEnabled = config.isWintertodtNotifyEnabled();
this.configXarpusEnabled = config.isXarpusEnabled();
this.configXarpusNotifyEnabled = config.isXarpusNotifyEnabled();
this.configaddyDrags = config.addyDrags();
this.configaddyDragsNotifyEnabled = config.addyDragsNotifyEnabled();
this.configDrakeEnabled = config.isDrakeEnabled();
this.configDrakeNotifyEnabled = config.isDrakeNotifyEnabled();
this.configCerbFireEnabled = config.isCerbFireEnabled();
this.configCerbFireNotifyEnabled = config.isCerbFireNotifyEnabled();
this.configDemonicGorillaEnabled = config.isDemonicGorillaEnabled();
this.configDemonicGorillaNotifyEnabled = config.isDemonicGorillaNotifyEnabled();
}
private void reset()
{
LightningTrail.clear();
AcidTrail.clear();
@@ -416,11 +511,5 @@ public class AoeWarningPlugin extends Plugin
WintertodtSnowFall.clear();
bombs.clear();
projectiles.clear();
if (setConfig)
{
fontStyle = config.fontStyle().getFont();
textSize = config.textSize();
shadows = config.shadows();
}
}
}
}

View File

@@ -32,10 +32,10 @@ import java.awt.Polygon;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.time.Instant;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client;
import net.runelite.api.Perspective;
@@ -50,6 +50,7 @@ import net.runelite.client.ui.overlay.OverlayPriority;
import net.runelite.client.ui.overlay.OverlayUtil;
@Slf4j
@Singleton
public class BombOverlay extends Overlay
{
@@ -81,15 +82,13 @@ public class BombOverlay extends Overlay
}
private final Client client;
private final AoeWarningConfig config;
private final AoeWarningPlugin plugin;
@Inject
public BombOverlay(Client client, AoeWarningPlugin plugin, AoeWarningConfig config)
public BombOverlay(final Client client, final AoeWarningPlugin plugin)
{
this.client = client;
this.plugin = plugin;
this.config = config;
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ABOVE_SCENE);
setPriority(OverlayPriority.MED);
@@ -98,7 +97,7 @@ public class BombOverlay extends Overlay
@Override
public Dimension render(Graphics2D graphics)
{
if (config.bombDisplay())
if (plugin.isConfigbombDisplay())
{
drawBombs(graphics);
}
@@ -108,10 +107,8 @@ public class BombOverlay extends Overlay
private void drawBombs(Graphics2D graphics)
//I can condense drawDangerZone into this. Ambivalent though.
{
Iterator<Map.Entry<WorldPoint, CrystalBomb>> it = plugin.getBombs().entrySet().iterator();
while (it.hasNext())
for (Map.Entry<WorldPoint, CrystalBomb> entry : plugin.getBombs().entrySet())
{
Map.Entry<WorldPoint, CrystalBomb> entry = it.next();
CrystalBomb bomb = entry.getValue();
drawDangerZone(graphics, bomb);
}

View File

@@ -25,6 +25,7 @@
package net.runelite.client.plugins.aoewarnings;
import java.time.Instant;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.GameObject;
@@ -33,20 +34,20 @@ import net.runelite.api.coords.WorldPoint;
@Slf4j
class CrystalBomb
{
@Getter
@Getter(AccessLevel.PACKAGE)
private Instant plantedOn;
@Getter
@Getter(AccessLevel.PACKAGE)
private Instant lastClockUpdate;
@Getter
@Getter(AccessLevel.PACKAGE)
private int objectId;
@Getter
@Getter(AccessLevel.PACKAGE)
private int tickStarted;
//
@Getter
@Getter(AccessLevel.PACKAGE)
private WorldPoint worldLocation;
CrystalBomb(GameObject gameObject, int startTick)

View File

@@ -28,6 +28,7 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import javax.inject.Inject;
import javax.inject.Singleton;
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
import net.runelite.client.ui.overlay.Overlay;
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
@@ -36,19 +37,18 @@ import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.PanelComponent;
import net.runelite.client.ui.overlay.components.TitleComponent;
@Singleton
class AttackStylesOverlay extends Overlay
{
private final AttackStylesPlugin plugin;
private final AttackStylesConfig config;
private final PanelComponent panelComponent = new PanelComponent();
@Inject
private AttackStylesOverlay(AttackStylesPlugin plugin, AttackStylesConfig config)
private AttackStylesOverlay(final AttackStylesPlugin plugin)
{
super(plugin);
setPosition(OverlayPosition.ABOVE_CHATBOX_RIGHT);
this.plugin = plugin;
this.config = config;
getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Attack style overlay"));
}
@@ -58,7 +58,7 @@ class AttackStylesOverlay extends Overlay
panelComponent.getChildren().clear();
boolean warnedSkillSelected = plugin.isWarnedSkillSelected();
if (warnedSkillSelected || config.alwaysShowStyle())
if (warnedSkillSelected || plugin.isAlwaysShowStyle())
{
final String attackStyleString = plugin.getAttackStyle().getName();

View File

@@ -31,6 +31,9 @@ import com.google.inject.Provides;
import java.util.HashSet;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.Skill;
@@ -60,6 +63,7 @@ import net.runelite.client.ui.overlay.OverlayManager;
description = "Show your current attack style as an overlay",
tags = {"combat", "defence", "magic", "overlay", "ranged", "strength", "warn", "pure"}
)
@Singleton
public class AttackStylesPlugin extends Plugin
{
private int attackStyleVarbit = -1;
@@ -91,9 +95,22 @@ public class AttackStylesPlugin extends Plugin
return configManager.getConfig(AttackStylesConfig.class);
}
// config values
@Getter(AccessLevel.PACKAGE)
private boolean alwaysShowStyle;
private boolean warnForDefence;
private boolean warnForAttack;
private boolean warnForStrength;
private boolean warnForRanged;
private boolean warnForMagic;
private boolean hideAutoRetaliate;
private boolean removeWarnedStyles;
@Override
protected void startUp() throws Exception
{
updateConfig();
overlayManager.add(overlay);
if (client.getGameState() == GameState.LOGGED_IN)
@@ -104,11 +121,11 @@ public class AttackStylesPlugin extends Plugin
private void start()
{
updateWarnedSkills(config.warnForAttack(), Skill.ATTACK);
updateWarnedSkills(config.warnForStrength(), Skill.STRENGTH);
updateWarnedSkills(config.warnForDefence(), Skill.DEFENCE);
updateWarnedSkills(config.warnForRanged(), Skill.RANGED);
updateWarnedSkills(config.warnForMagic(), Skill.MAGIC);
updateWarnedSkills(warnForAttack, Skill.ATTACK);
updateWarnedSkills(warnForStrength, Skill.STRENGTH);
updateWarnedSkills(warnForDefence, Skill.DEFENCE);
updateWarnedSkills(warnForRanged, Skill.RANGED);
updateWarnedSkills(warnForMagic, Skill.MAGIC);
attackStyleVarbit = client.getVar(VarPlayer.ATTACK_STYLE);
equippedWeaponTypeVarbit = client.getVar(Varbits.EQUIPPED_WEAPON_TYPE);
castingModeVarbit = client.getVar(Varbits.DEFENSIVE_CASTING_MODE);
@@ -134,7 +151,7 @@ public class AttackStylesPlugin extends Plugin
return attackStyle;
}
public boolean isWarnedSkillSelected()
boolean isWarnedSkillSelected()
{
return warnedSkillSelected;
}
@@ -175,7 +192,7 @@ public class AttackStylesPlugin extends Plugin
hideWidget(client.getWidget(widgetKey), widgetsToHide.get(equippedWeaponType, widgetKey));
}
}
hideWidget(client.getWidget(WidgetInfo.COMBAT_AUTO_RETALIATE), config.hideAutoRetaliate());
hideWidget(client.getWidget(WidgetInfo.COMBAT_AUTO_RETALIATE), this.hideAutoRetaliate);
}
@Subscribe
@@ -183,11 +200,11 @@ public class AttackStylesPlugin extends Plugin
{
if (event.getGameState() == GameState.LOGGED_IN)
{
updateWarnedSkills(config.warnForAttack(), Skill.ATTACK);
updateWarnedSkills(config.warnForStrength(), Skill.STRENGTH);
updateWarnedSkills(config.warnForDefence(), Skill.DEFENCE);
updateWarnedSkills(config.warnForRanged(), Skill.RANGED);
updateWarnedSkills(config.warnForMagic(), Skill.MAGIC);
updateWarnedSkills(this.warnForAttack, Skill.ATTACK);
updateWarnedSkills(this.warnForStrength, Skill.STRENGTH);
updateWarnedSkills(this.warnForDefence, Skill.DEFENCE);
updateWarnedSkills(this.warnForRanged, Skill.RANGED);
updateWarnedSkills(this.warnForMagic, Skill.MAGIC);
}
}
@@ -224,6 +241,8 @@ public class AttackStylesPlugin extends Plugin
{
if (event.getGroup().equals("attackIndicator"))
{
updateConfig();
boolean enabled = event.getNewValue().equals("true");
switch (event.getKey())
{
@@ -250,6 +269,18 @@ public class AttackStylesPlugin extends Plugin
}
}
private void updateConfig()
{
this.alwaysShowStyle = config.alwaysShowStyle();
this.warnForDefence = config.warnForDefence();
this.warnForAttack = config.warnForAttack();
this.warnForStrength = config.warnForStrength();
this.warnForRanged = config.warnForRanged();
this.warnForMagic = config.warnForMagic();
this.hideAutoRetaliate = config.hideAutoRetaliate();
this.removeWarnedStyles = config.removeWarnedStyles();
}
private void updateAttackStyle(int equippedWeaponType, int attackStyleIndex, int castingMode)
{
AttackStyle[] attackStyles = WeaponType.getWeaponType(equippedWeaponType).getAttackStyles();
@@ -289,16 +320,16 @@ public class AttackStylesPlugin extends Plugin
{
if (warnedSkills.contains(skill))
{
if (weaponSwitch)
{
// TODO : chat message to warn players that their weapon switch also caused an unwanted attack style change
}
// if (weaponSwitch)
// {
// // TODO : chat message to warn players that their weapon switch also caused an unwanted attack style change
// }
warnedSkillSelected = true;
break;
}
}
}
hideWarnedStyles(config.removeWarnedStyles());
hideWarnedStyles(this.removeWarnedStyles);
}
private void hideWarnedStyles(boolean enabled)

View File

@@ -58,7 +58,7 @@ class BankCalculation
Varbits.BANK_TAB_NINE_COUNT
);
private final BankConfig config;
private final BankPlugin plugin;
private final ItemManager itemManager;
private final Client client;
@@ -72,10 +72,10 @@ class BankCalculation
private long haPrice;
@Inject
BankCalculation(ItemManager itemManager, BankConfig config, Client client)
BankCalculation(ItemManager itemManager, BankPlugin plugin, Client client)
{
this.itemManager = itemManager;
this.config = config;
this.plugin = plugin;
this.client = client;
}
@@ -142,12 +142,12 @@ class BankCalculation
continue;
}
if (config.showGE())
if (plugin.isShowGE())
{
itemIds.add(item.getId());
}
if (config.showHA())
if (plugin.isShowHA())
{
long alchValue = itemManager.getAlchValue(item.getId());
@@ -159,7 +159,7 @@ class BankCalculation
}
// Now do the calculations
if (config.showGE() && !itemIds.isEmpty())
if (plugin.isShowGE() && !itemIds.isEmpty())
{
for (Item item : items)
{

View File

@@ -28,8 +28,12 @@ package net.runelite.client.plugins.bank;
import com.google.inject.Provides;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.Client;
import net.runelite.api.MenuEntry;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.MenuShouldLeftClick;
import net.runelite.api.events.ScriptCallbackEvent;
@@ -46,6 +50,7 @@ import net.runelite.client.util.StackFormatter;
description = "Modifications to the banking interface",
tags = {"grand", "exchange", "high", "alchemy", "prices", "deposit"}
)
@Singleton
public class BankPlugin extends Plugin
{
private static final String DEPOSIT_WORN = "Deposit worn items";
@@ -75,6 +80,21 @@ public class BankPlugin extends Plugin
return configManager.getConfig(BankConfig.class);
}
@Getter(AccessLevel.PACKAGE)
private boolean showGE;
@Getter(AccessLevel.PACKAGE)
private boolean showHA;
private boolean showExact;
private boolean rightClickBankInventory;
private boolean rightClickBankEquip;
private boolean rightClickBankLoot;
@Override
protected void startUp() throws Exception
{
updateConfig();
}
@Override
protected void shutDown()
{
@@ -94,9 +114,9 @@ public class BankPlugin extends Plugin
MenuEntry[] menuEntries = client.getMenuEntries();
for (MenuEntry entry : menuEntries)
{
if ((entry.getOption().equals(DEPOSIT_WORN) && config.rightClickBankEquip())
|| (entry.getOption().equals(DEPOSIT_INVENTORY) && config.rightClickBankInventory())
|| (entry.getOption().equals(DEPOSIT_LOOT) && config.rightClickBankLoot()))
if ((entry.getOption().equals(DEPOSIT_WORN) && this.rightClickBankEquip)
|| (entry.getOption().equals(DEPOSIT_INVENTORY) && this.rightClickBankInventory)
|| (entry.getOption().equals(DEPOSIT_LOOT) && this.rightClickBankLoot))
{
event.setForceRightClick(true);
return;
@@ -107,9 +127,9 @@ public class BankPlugin extends Plugin
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded event)
{
if ((event.getOption().equals(DEPOSIT_WORN) && config.rightClickBankEquip())
|| (event.getOption().equals(DEPOSIT_INVENTORY) && config.rightClickBankInventory())
|| (event.getOption().equals(DEPOSIT_LOOT) && config.rightClickBankLoot()))
if ((event.getOption().equals(DEPOSIT_WORN) && this.rightClickBankEquip)
|| (event.getOption().equals(DEPOSIT_INVENTORY) && this.rightClickBankInventory)
|| (event.getOption().equals(DEPOSIT_LOOT) && this.rightClickBankLoot))
{
forceRightClickFlag = true;
}
@@ -128,16 +148,16 @@ public class BankPlugin extends Plugin
long gePrice = bankCalculation.getGePrice();
long haPrice = bankCalculation.getHaPrice();
if (config.showGE() && gePrice != 0)
if (this.showGE && gePrice != 0)
{
strCurrentTab += " (";
if (config.showHA())
if (this.showHA)
{
strCurrentTab += "EX: ";
}
if (config.showExact())
if (this.showExact)
{
strCurrentTab += StackFormatter.formatNumber(gePrice) + ")";
}
@@ -147,16 +167,16 @@ public class BankPlugin extends Plugin
}
}
if (config.showHA() && haPrice != 0)
if (this.showHA && haPrice != 0)
{
strCurrentTab += " (";
if (config.showGE())
if (this.showGE)
{
strCurrentTab += "HA: ";
}
if (config.showExact())
if (this.showExact)
{
strCurrentTab += StackFormatter.formatNumber(haPrice) + ")";
}
@@ -171,4 +191,25 @@ public class BankPlugin extends Plugin
stringStack[stringStackSize - 1] += strCurrentTab;
}
@Subscribe
public void onConfigChanged(ConfigChanged event)
{
if (!event.getGroup().equals("bank"))
{
return;
}
updateConfig();
}
private void updateConfig()
{
this.showGE = config.showGE();
this.showHA = config.showHA();
this.showExact = config.showExact();
this.rightClickBankInventory = config.rightClickBankInventory();
this.rightClickBankEquip = config.rightClickBankEquip();
this.rightClickBankLoot = config.rightClickBankLoot();
}
}

View File

@@ -36,6 +36,7 @@ import java.util.Collection;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.InventoryID;
import net.runelite.api.Item;
@@ -82,6 +83,7 @@ import net.runelite.client.util.Text;
tags = {"searching", "tagging"}
)
@PluginDependency(ClueScrollPlugin.class)
@Singleton
public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyListener
{
public static final String CONFIG_GROUP = "banktags";
@@ -244,10 +246,8 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
intStack[intStackSize - 1] = 0;
break;
case "hideLine":
// hide the widget for the line separator
intStack[intStackSize - 1] = 1;
break;
case "hideTabText":
// hide the widget for the line separator
// hide the widget for the "Tab x" text
intStack[intStackSize - 1] = 1;
break;

View File

@@ -66,7 +66,7 @@ public class TagManager
this.clueScrollService = clueScrollService;
}
String getTagString(int itemId, boolean variation)
private String getTagString(int itemId, boolean variation)
{
itemId = getItemId(itemId, variation);

View File

@@ -53,8 +53,8 @@ import net.runelite.api.Client;
import net.runelite.api.Constants;
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.MenuAction;
import net.runelite.api.MenuEntry;
import net.runelite.api.Point;
@@ -579,11 +579,14 @@ public class TabInterface
if (event.getOption().startsWith(CHANGE_ICON + " ("))
{
ItemDefinition item = getItem(event.getActionParam0());
int itemId = itemManager.canonicalize(item.getId());
iconToSet.setIconItemId(itemId);
iconToSet.getIcon().setItemId(itemId);
tabManager.setIcon(iconToSet.getTag(), itemId + "");
event.consume();
if (item != null)
{
int itemId = itemManager.canonicalize(item.getId());
iconToSet.setIconItemId(itemId);
iconToSet.getIcon().setItemId(itemId);
tabManager.setIcon(iconToSet.getTag(), itemId + "");
event.consume();
}
}
// Reset icon selection even when we do not clicked item with icon
@@ -613,9 +616,13 @@ public class TabInterface
// Add "remove" menu entry to all items in bank while tab is selected
event.consume();
final ItemDefinition item = getItem(event.getActionParam0());
final int itemId = item.getId();
tagManager.removeTag(itemId, activeTab.getTag());
bankSearch.search(InputType.SEARCH, TAG_SEARCH + activeTab.getTag(), true);
final int itemId;
if (item != null)
{
itemId = item.getId();
tagManager.removeTag(itemId, activeTab.getTag());
bankSearch.search(InputType.SEARCH, TAG_SEARCH + activeTab.getTag(), true);
}
}
else if (event.getMenuAction() == MenuAction.RUNELITE
&& ((event.getActionParam1() == WidgetInfo.BANK_DEPOSIT_INVENTORY.getId() && event.getOption().equals(TAG_INVENTORY))
@@ -669,15 +676,11 @@ public class TabInterface
updateTabIfActive(Lists.newArrayList(Text.standardize(draggedOn.getName())));
}
}
else if (parent.getId() == draggedOn.getId() && parent.getId() == draggedWidget.getId())
else if (parent.getId() == draggedOn.getId() && parent.getId() == draggedWidget.getId() && !Strings.isNullOrEmpty(draggedOn.getName()))
{
// Reorder tag tabs
if (!Strings.isNullOrEmpty(draggedOn.getName()))
{
tabManager.move(draggedWidget.getName(), draggedOn.getName());
tabManager.save();
updateTabs();
}
tabManager.move(draggedWidget.getName(), draggedOn.getName());
tabManager.save();
updateTabs();
}
}
else if (draggedWidget.getItemId() > 0)
@@ -1010,8 +1013,17 @@ public class TabInterface
private ItemDefinition getItem(int idx)
{
ItemContainer bankContainer = client.getItemContainer(InventoryID.BANK);
Item item = bankContainer.getItems()[idx];
return itemManager.getItemDefinition(item.getId());
Item item = null;
if (bankContainer != null)
{
item = bankContainer.getItems()[idx];
}
if (item != null)
{
return itemManager.getItemDefinition(item.getId());
}
return null;
}
private void openTag(final String tag)

View File

@@ -8,13 +8,11 @@ import net.runelite.client.config.ConfigItem;
public interface BanListConfig extends Config
{
@ConfigItem(
keyName = "bannedPlayers",
name = "Manual Scammer List",
description = "Players you add to this list will be shown when you join a clan.",
position = 0
keyName = "bannedPlayers",
name = "Manual Scammer List",
description = "Manually add players seperated by commas that you wish to be warned about while in a clan/cox/tob party",
position = 0
)
default String getBannedPlayers()
{
@@ -22,28 +20,39 @@ public interface BanListConfig extends Config
}
@ConfigItem(
keyName = "bannedPlayers",
name = "",
description = ""
keyName = "bannedPlayers",
name = "",
description = ""
)
void setBannedPlayers(String key);
@ConfigItem(
position = 1,
keyName = "enableWDR",
name = "Enable WDR Scammer List",
description = "Incorporate WDR Scammer list"
position = 1,
keyName = "enableWDRScam",
name = "Enable WDR Scammer List",
description = "Incorporate WDR Scammer list"
)
default boolean enableWDR()
default boolean enableWDRScam()
{
return true;
}
@ConfigItem(
position = 2,
keyName = "enableRuneWatch",
name = "Enable RuneWatch Scammer List",
description = "Incorporate RuneWatch Scammer list"
position = 2,
keyName = "enableWDRToxic",
name = "Enable WDR Toxic List",
description = "Incorporate WDR Toxic list"
)
default boolean enableWDRToxic()
{
return true;
}
@ConfigItem(
position = 3,
keyName = "enableRuneWatch",
name = "Enable RuneWatch List",
description = "Incorporate RuneWatch potential scammer list"
)
default boolean enableRuneWatch()
{
@@ -51,10 +60,10 @@ public interface BanListConfig extends Config
}
@ConfigItem(
position = 3,
keyName = "highlightInClan",
name = "Highlight red in Clan Chat",
description = "Highlights Scammer\'s name in your current clan chat."
position = 4,
keyName = "highlightInClan",
name = "Highlight red in Clan Chat",
description = "Highlights Scammer\'s name in your current clan chat."
)
default boolean highlightInClan()
{
@@ -62,14 +71,13 @@ public interface BanListConfig extends Config
}
@ConfigItem(
position = 4,
keyName = "highlightInTrade",
name = "Highlight red in trade screen",
description = "Highlights Scammer\'s name in your trade window"
position = 5,
keyName = "highlightInTrade",
name = "Highlight red in trade screen",
description = "Highlights Scammer\'s name in your trade window"
)
default boolean highlightInTrade()
{
return true;
}
}
}

View File

@@ -26,21 +26,29 @@
*/
package net.runelite.client.plugins.banlist;
import com.google.common.base.Splitter;
import com.google.inject.Provides;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.ChatMessageType;
import net.runelite.api.ClanMember;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.Varbits;
import net.runelite.api.events.ClanMemberJoined;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.WidgetHiddenChanged;
import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.widgets.Widget;
import static net.runelite.api.widgets.WidgetID.TRADING_SCREEN;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.chat.ChatColorType;
@@ -67,26 +75,28 @@ import okhttp3.Response;
type = PluginType.UTILITY,
enabledByDefault = false
)
@Singleton
@Slf4j
public class BanListPlugin extends Plugin
{
private final Set<String> wdrScamSet = new HashSet<>();
private final Set<String> wdrToxicSet = new HashSet<>();
private final Set<String> runeWatchSet = new HashSet<>();
private final Set<String> manualBans = new HashSet<>();
@Inject
private Client client;
@Inject
private ClientThread clientThread;
@Inject
private BanListConfig config;
@Inject
private ChatMessageManager chatMessageManager;
private ArrayList<String> wdrScamArrayList = new ArrayList<>();
private ArrayList<String> wdrToxicArrayList = new ArrayList<>();
private ArrayList<String> runeWatchArrayList = new ArrayList<>();
private ArrayList<String> manualBans = new ArrayList<>();
private String tobNames = "";
private boolean enableWDRScam;
private boolean enableWDRToxic;
private boolean enableRuneWatch;
private boolean highlightInClan;
private boolean highlightInTrade;
@Provides
BanListConfig getConfig(ConfigManager configManager)
@@ -97,37 +107,55 @@ public class BanListPlugin extends Plugin
@Override
protected void startUp() throws Exception
{
manualBans.addAll(Text.fromCSV(config.getBannedPlayers()));
updateConfig();
List<String> bannedPlayers = Splitter
.on(",")
.trimResults()
.omitEmptyStrings()
.splitToList(config.getBannedPlayers());
manualBans.addAll(bannedPlayers);
fetchFromWebsites();
}
@Override
protected void shutDown() throws Exception
{
wdrScamArrayList.clear();
wdrToxicArrayList.clear();
runeWatchArrayList.clear();
wdrScamSet.clear();
wdrToxicSet.clear();
runeWatchSet.clear();
manualBans.clear();
}
@Subscribe
public void onConfigChanged(ConfigChanged event)
{
if (event.getGroup().equals("banlist"))
if (event.getGroup().equals("banlist") && event.getKey().equals("bannedPlayers"))
{
if (event.getKey().equals("bannedPlayers"))
List<String> bannedPlayers = Splitter
.on(",")
.trimResults()
.omitEmptyStrings()
.splitToList(config.getBannedPlayers());
for (String bannedPlayer : bannedPlayers)
{
for (String manual : Text.fromCSV(config.getBannedPlayers()))
if (!manualBans.contains(bannedPlayer))
{
if (!manualBans.contains(manual))
{
manualBans.add(Text.standardize(manual));
}
manualBans.add(Text.standardize(bannedPlayer));
}
}
}
}
private void updateConfig()
{
this.enableWDRScam = config.enableWDRScam();
this.enableWDRToxic = config.enableWDRToxic();
this.enableRuneWatch = config.enableRuneWatch();
this.highlightInClan = config.highlightInClan();
this.highlightInTrade = config.highlightInTrade();
}
/**
* Event to keep making sure player names are highlighted red in clan chat, since the red name goes away frequently
*/
@@ -138,7 +166,7 @@ public class BanListPlugin extends Plugin
|| client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN) != null
|| client.getViewportWidget() == null
|| client.getWidget(WidgetInfo.CLAN_CHAT) == null
|| !config.highlightInClan())
|| !this.highlightInClan)
{
return;
}
@@ -157,13 +185,15 @@ public class BanListPlugin extends Plugin
public void onClanMemberJoined(ClanMemberJoined event)
{
ClanMember member = event.getMember();
ListType scamList = checkScamList(Text.standardize(member.getUsername()));
ListType toxicList = checkToxicList(Text.standardize(member.getUsername()));
String memberUsername = Text.standardize(member.getUsername().toLowerCase());
ListType scamList = checkScamList(memberUsername);
ListType toxicList = checkToxicList(memberUsername);
if (scamList != null)
{
sendWarning(Text.standardize(member.getUsername()), scamList);
if (config.highlightInClan())
sendWarning(memberUsername, scamList);
if (this.highlightInClan)
{
highlightRedInCC();
}
@@ -171,8 +201,8 @@ public class BanListPlugin extends Plugin
if (toxicList != null)
{
sendWarning(Text.standardize(member.getUsername()), toxicList);
if (config.highlightInClan())
sendWarning(memberUsername, toxicList);
if (this.highlightInClan)
{
highlightRedInCC();
}
@@ -185,54 +215,93 @@ public class BanListPlugin extends Plugin
@Subscribe
public void onWidgetLoaded(WidgetLoaded widgetLoaded)
{
if (config.highlightInTrade())
{
if (widgetLoaded.getGroupId() == 335)
{ //if trading window was loaded
clientThread.invokeLater(() ->
if (this.highlightInTrade && widgetLoaded.getGroupId() == TRADING_SCREEN)
{ //if trading window was loaded
clientThread.invokeLater(() ->
{
Widget tradingWith = client.getWidget(335, 31);
String name = tradingWith.getText().replaceAll("Trading With: ", "").toLowerCase();
if (checkScamList(name) != null)
{
Widget tradingWith = client.getWidget(335, 31);
String name = tradingWith.getText().replaceAll("Trading With: ", "");
if (checkScamList(name) != null)
{
tradingWith.setText(tradingWith.getText().replaceAll(name, "<col=ff0000>" + name + " (Scammer)" + "</col>"));
}
if (checkToxicList(name) != null)
{
tradingWith.setText(tradingWith.getText().replaceAll(name, "<col=ff6400>" + name + " (Toxic)" + "</col>"));
}
});
tradingWith.setText(tradingWith.getText().replaceAll(name, "<col=ff0000>" + name + " (Scammer)" + "</col>"));
}
if (checkToxicList(name) != null)
{
tradingWith.setText(tradingWith.getText().replaceAll(name, "<col=ff6400>" + name + " (Toxic)" + "</col>"));
}
});
}
}
@Subscribe
public void onGameTick(GameTick event)
{
if (client.getWidget(WidgetInfo.THEATRE_OF_BLOOD_RAIDING_PARTY) == null)
{
return;
}
Widget raidingParty = client.getWidget(WidgetInfo.THEATRE_OF_BLOOD_RAIDING_PARTY);
String allNames = raidingParty.getText();
if (allNames.equalsIgnoreCase(tobNames))
{
return;
}
tobNames = allNames;
String[] split = allNames.split("<br>");
for (int i = 0; i < 5; i++)
{
String name = split[i];
if (!name.equalsIgnoreCase("-"))
{
ListType scamList = checkScamList(Text.standardize(name));
if (scamList != null)
{
sendWarning(name, scamList);
}
ListType toxicList = checkToxicList(Text.standardize(name));
if (toxicList != null)
{
sendWarning(name, toxicList);
}
}
}
}
boolean inTobParty()
{
return client.getVar(Varbits.THEATRE_OF_BLOOD) == 1;
}
/**
* Compares player name to everything in the ban lists
*/
private ListType checkScamList(String nameToBeChecked)
{
if (wdrScamArrayList.size() > 0 && config.enableWDR())
if (wdrScamSet.size() > 0 && this.enableWDRScam && wdrScamSet.contains(nameToBeChecked))
{
if (wdrScamArrayList.stream().anyMatch(nameToBeChecked::equalsIgnoreCase))
{
return ListType.WEDORAIDSSCAM_LIST;
}
return ListType.WEDORAIDSSCAM_LIST;
}
if (runeWatchArrayList.size() > 0 && config.enableRuneWatch())
if (runeWatchSet.size() > 0 && this.enableRuneWatch && runeWatchSet.contains(nameToBeChecked))
{
if (runeWatchArrayList.stream().anyMatch(nameToBeChecked::equalsIgnoreCase))
{
return ListType.RUNEWATCH_LIST;
}
return ListType.RUNEWATCH_LIST;
}
if (manualBans.size() > 0)
if (manualBans.size() > 0 && manualBans.contains(nameToBeChecked))
{
if (manualBans.stream().anyMatch(nameToBeChecked::equalsIgnoreCase))
{
return ListType.MANUAL_LIST;
}
return ListType.MANUAL_LIST;
}
return null;
@@ -241,12 +310,9 @@ public class BanListPlugin extends Plugin
private ListType checkToxicList(String nameToBeChecked)
{
if (wdrToxicArrayList.size() > 0 && config.enableWDR())
if (wdrToxicSet.size() > 0 && this.enableWDRToxic && wdrToxicSet.contains(nameToBeChecked))
{
if (wdrToxicArrayList.stream().anyMatch(nameToBeChecked::equalsIgnoreCase))
{
return ListType.WEDORAIDSTOXIC_LIST;
}
return ListType.WEDORAIDSTOXIC_LIST;
}
return null;
@@ -288,7 +354,7 @@ public class BanListPlugin extends Plugin
case RUNEWATCH_LIST:
final String rw_message = new ChatMessageBuilder()
.append(ChatColorType.HIGHLIGHT)
.append("Warning! " + playerName + " is on the Runewatch\'s scammer list!")
.append("Warning! " + playerName + " is on the Runewatch\'s potential scammer list!")
.build();
chatMessageManager.queue(
@@ -338,9 +404,9 @@ public class BanListPlugin extends Plugin
ArrayList<String> wdrList = new ArrayList<>(Arrays.asList(text.split(",")));
ArrayList<String> wdrList2 = new ArrayList<>();
wdrList.forEach((name) -> wdrList2.add(Text.standardize(name)));
wdrList.forEach((name) -> wdrList2.add(Text.standardize(name).toLowerCase()));
wdrScamArrayList.addAll(wdrList2);
wdrScamSet.addAll(wdrList2);
}
});
@@ -366,9 +432,9 @@ public class BanListPlugin extends Plugin
{
if (x.contains("title"))
{
x = x.substring(x.indexOf("title"), x.indexOf(">"));
x = x.substring(x.indexOf("=") + 2, x.length() - 1);
runeWatchArrayList.add(Text.standardize(x));
x = x.substring(x.indexOf("title"), x.indexOf('>'));
x = x.substring(x.indexOf('=') + 2, x.length() - 1);
runeWatchSet.add(Text.standardize(x).toLowerCase());
}
}
}
@@ -395,9 +461,9 @@ public class BanListPlugin extends Plugin
ArrayList<String> wdrToxicList = new ArrayList<>(Arrays.asList(text.split(",")));
ArrayList<String> wdrToxicList2 = new ArrayList<>();
wdrToxicList.forEach((name) -> wdrToxicList2.add(Text.standardize(name)));
wdrToxicList.forEach((name) -> wdrToxicList2.add(Text.standardize(name).toLowerCase()));
wdrToxicArrayList.addAll(wdrToxicList2);
wdrToxicSet.addAll(wdrToxicList2);
}
});
}
@@ -412,8 +478,8 @@ public class BanListPlugin extends Plugin
Widget widget = client.getWidget(WidgetInfo.CLAN_CHAT_LIST);
for (Widget widgetChild : widget.getDynamicChildren())
{
ListType scamList = checkScamList(widgetChild.getText());
ListType toxicList = checkToxicList(widgetChild.getText());
ListType scamList = checkScamList(widgetChild.getText().toLowerCase());
ListType toxicList = checkToxicList(widgetChild.getText().toLowerCase());
if (scamList != null)
{

View File

@@ -27,6 +27,7 @@
package net.runelite.client.plugins.barbarianassault;
import com.google.common.collect.ImmutableMap;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
@@ -46,7 +47,7 @@ import java.awt.Stroke;
import java.awt.BasicStroke;
import java.util.Map;
@Singleton
class AboveSceneOverlay extends Overlay
{
private static final int HEALTH_BAR_HEIGHT = 20;
@@ -62,18 +63,16 @@ class AboveSceneOverlay extends Overlay
private final Client client;
private final BarbarianAssaultPlugin game;
private final BarbarianAssaultConfig config;
@Inject
private AboveSceneOverlay(Client client, BarbarianAssaultPlugin game, BarbarianAssaultConfig config)
private AboveSceneOverlay(final Client client, final BarbarianAssaultPlugin game)
{
super(game);
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ABOVE_SCENE);
this.client = client;
this.game = game;
this.config = config;
}
@Override
@@ -88,11 +87,11 @@ class AboveSceneOverlay extends Overlay
{
case HEALER:
if (config.showTeammateHealthbars())
if (game.isShowTeammateHealthbars())
{
renderHealthBars(graphics);
}
if (config.healerCodes())
if (game.isHealerCodes())
{
renderHealerCodes(graphics);
}
@@ -100,7 +99,7 @@ class AboveSceneOverlay extends Overlay
case COLLECTOR:
if (config.highlightCollectorEggs())
if (game.isHighlightCollectorEggs())
{
renderEggs(graphics);
}

View File

@@ -32,6 +32,7 @@ import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.Point;
import net.runelite.api.widgets.Widget;
@@ -43,7 +44,7 @@ import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayUtil;
import net.runelite.client.util.ImageUtil;
@Singleton
class AboveWidgetsOverlay extends Overlay
{
private static final int OFFSET_X_TEXT_QUANTITY = 0;
@@ -51,18 +52,15 @@ class AboveWidgetsOverlay extends Overlay
private final Client client;
private final BarbarianAssaultPlugin game;
private final BarbarianAssaultConfig config;
@Inject
private AboveWidgetsOverlay(Client client, BarbarianAssaultPlugin game, BarbarianAssaultConfig config)
private AboveWidgetsOverlay(final Client client, final BarbarianAssaultPlugin game)
{
super(game);
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ABOVE_WIDGETS);
this.client = client;
this.game = game;
this.config = config;
}
@Override
@@ -75,7 +73,7 @@ class AboveWidgetsOverlay extends Overlay
Role role = game.getRole();
if (config.showTimer())
if (game.isShowTimer())
{
renderTimer(graphics, role);
}
@@ -83,23 +81,23 @@ class AboveWidgetsOverlay extends Overlay
switch (role)
{
case ATTACKER:
if (config.highlightArrows())
if (game.isHighlightArrows())
{
renderInventoryHighlights(graphics, game.getRole().getListenItem(game.getLastListenText()), config.highlightArrowColor());
renderInventoryHighlights(graphics, game.getRole().getListenItem(game.getLastListenText()), game.getHighlightArrowColor());
}
break;
case DEFENDER:
if (config.highlightBait())
if (game.isHighlightBait())
{
renderInventoryHighlights(graphics, game.getRole().getListenItem(game.getLastListenText()), config.highlightBaitColor());
renderInventoryHighlights(graphics, game.getRole().getListenItem(game.getLastListenText()), game.getHighlightBaitColor());
}
break;
case HEALER:
if (config.highlightPoison())
if (game.isHighlightPoison())
{
renderInventoryHighlights(graphics, game.getRole().getListenItem(game.getLastListenText()), config.highlightPoisonColor());
renderInventoryHighlights(graphics, game.getRole().getListenItem(game.getLastListenText()), game.getHighlightPoisonColor());
}
}
return null;
@@ -115,11 +113,11 @@ class AboveWidgetsOverlay extends Overlay
return;
}
if (role == Role.COLLECTOR && config.showEggCountOverlay() && game.getWave() != null)
if (role == Role.COLLECTOR && game.isShowEggCountOverlay() && game.getWave() != null)
{
roleText.setText("(" + game.getWave().getCollectedEggCount() + ") " + formatClock());
}
else if (role == Role.HEALER && config.showHpCountOverlay() && game.getWave() != null)
else if (role == Role.HEALER && game.isShowHpCountOverlay() && game.getWave() != null)
{
roleText.setText("(" + game.getWave().getHpHealed() + ") " + formatClock());
}

View File

@@ -26,6 +26,8 @@
package net.runelite.client.plugins.barbarianassault;
import com.google.common.collect.Sets;
import java.util.List;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import net.runelite.client.menus.ComparableEntry;
@@ -40,24 +42,24 @@ class BarbarianAssaultMenu
{
private final MenuManager menuManager;
private final BarbarianAssaultPlugin game;
private final BarbarianAssaultConfig config;
private final ArrayList<ComparableEntry> tracker = new ArrayList<>();
@Getter @Setter
private final List<ComparableEntry> tracker = new ArrayList<>();
@Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PACKAGE)
private boolean hornUpdated = false;
@Getter @Setter
@Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PACKAGE)
private boolean rebuildForced = false;
@Inject
BarbarianAssaultMenu(MenuManager menuManager, BarbarianAssaultPlugin game, BarbarianAssaultConfig config)
BarbarianAssaultMenu(final MenuManager menuManager, final BarbarianAssaultPlugin game)
{
this.menuManager = menuManager;
this.game = game;
this.config = config;
}
private boolean isHornOptionHidden(String option)
{
if (game.isInGame() && game.getRole() != null && game.getRole().getTell(game.getLastCallText()).toLowerCase().equals(option))
if (game.isInGame() && game.getRole() != null && game.getRole().getTell(game.getLastCallText()).equalsIgnoreCase(option))
{
// This will force the menu to be rebuilt after the correct tell is found
// medic will be added to the menu if it wasn't there before
@@ -100,24 +102,24 @@ class BarbarianAssaultMenu
case TELL_BLUE_ATTACKER_HORN:
case TELL_GREEN_ATTACKER_HORN:
case TELL_RED_ATTACKER_HORN:
return ((role == Role.ATTACKER && isHornOptionHidden(entry.getOption())) || role == null) && config.removeIncorrectCalls();
return ((role == Role.ATTACKER && isHornOptionHidden(entry.getOption())) || role == null) && game.isRemoveIncorrectCalls();
case ATTACK_PENANCE_FIGHTER:
case ATTACK_PENANCE_RANGER:
case GET_SPIKES_PETRIFIED_MUSHROOM:
case TAKE_ATTACKER_ITEM_MACHINE:
return (role != Role.ATTACKER && role != null) && config.removeUnusedMenus();
return (role != Role.ATTACKER && role != null) && game.isRemoveUnusedMenus();
// Defender role Options
case TELL_MEAT_DEFENDER_HORN:
case TELL_TOFU_DEFENDER_HORN:
case TELL_WORMS_DEFENDER_HORN:
return ((role == Role.DEFENDER && isHornOptionHidden(entry.getOption())) || role == null) && config.removeIncorrectCalls();
return ((role == Role.DEFENDER && isHornOptionHidden(entry.getOption())) || role == null) && game.isRemoveIncorrectCalls();
case BLOCK_PENANCE_CAVE:
return ((role != Role.DEFENDER && role != null) && config.removeUnusedMenus())
|| (role == Role.DEFENDER && config.removePenanceCave());
return ((role != Role.DEFENDER && role != null) && game.isRemoveUnusedMenus())
|| (role == Role.DEFENDER && game.isRemovePenanceCave());
case DUNK_LAVA_CRATER:
case FIX:
@@ -125,7 +127,7 @@ class BarbarianAssaultMenu
case TAKE_DEFENDER_ITEM_MACHINE:
case TAKE_HAMMER:
case TAKE_LOGS:
return (role != Role.DEFENDER && role != null) && config.removeUnusedMenus();
return (role != Role.DEFENDER && role != null) && game.isRemoveUnusedMenus();
// Collector role options
@@ -133,7 +135,7 @@ class BarbarianAssaultMenu
case TELL_AGGRESSIVE_COLLECTOR_HORN:
case TELL_CONTROLLED_COLLECTOR_HORN:
case TELL_DEFENSIVE_COLLECTOR_HORN:
return ((role == Role.COLLECTOR && isHornOptionHidden(entry.getOption())) || role == null) && config.removeIncorrectCalls();
return ((role == Role.COLLECTOR && isHornOptionHidden(entry.getOption())) || role == null) && game.isRemoveIncorrectCalls();
case CONVERT_COLLECTOR_CONVERTER:
case LOAD_EGG_HOPPER:
@@ -141,40 +143,40 @@ class BarbarianAssaultMenu
case TAKE_GREEN_EGG:
case TAKE_RED_EGG:
case TAKE_YELLOW_EGG:
return (role != Role.COLLECTOR && role != null) && config.removeUnusedMenus();
return (role != Role.COLLECTOR && role != null) && game.isRemoveUnusedMenus();
// Healer role options
case TELL_CRACKERS_HEALER_HORN:
case TELL_TOFU_HEALER_HORN:
case TELL_WORMS_HEALER_HORN:
return ((role == Role.HEALER && isHornOptionHidden(entry.getOption())) || role == null) && config.removeIncorrectCalls();
return ((role == Role.HEALER && isHornOptionHidden(entry.getOption())) || role == null) && game.isRemoveIncorrectCalls();
case DUNK_POISON_CRATER:
case STOCK_UP_HEALER_ITEM_MACHINE:
case TAKE_HEALER_ITEM_MACHINE:
case TAKE_FROM_HEALER_SPRING:
case DRINK_FROM_HEALER_SPRING:
return (role != Role.HEALER && role != null) && config.removeUnusedMenus();
return (role != Role.HEALER && role != null) && game.isRemoveUnusedMenus();
case USE_VIAL_GROUND:
case USE_VIAL_ITEM:
case USE_VIAL_NPC:
case USE_VIAL_WIDGET:
return role == Role.HEALER && config.removeUnusedMenus();
return role == Role.HEALER && game.isRemoveUnusedMenus();
// Any role options
case DROP_HORN:
case EXAMINE_HORN:
case USE_HORN:
return config.removeIncorrectCalls();
return game.isRemoveIncorrectCalls();
case MEDIC_HORN:
return config.removeIncorrectCalls() && !hornUpdated;
return game.isRemoveIncorrectCalls() && !hornUpdated;
default:
return role != null && config.removeUnusedMenus();
return role != null && game.isRemoveUnusedMenus();
}
});
@@ -189,15 +191,15 @@ class BarbarianAssaultMenu
void enableSwaps()
{
if (config.swapLadder())
if (game.isSwapLadder())
{
menuManager.addSwap("climb-down", "ladder", "quick-start", "ladder");
}
if (config.swapCollectorBag())
if (game.isSwapCollectorBag())
{
menuManager.addSwap("look-in", "collection bag", "empty", "collection bag");
}
if (config.swapDestroyEggs())
if (game.isSwapDestroyEggs())
{
menuManager.addSwap("use", "blue egg", "destroy", "blue egg");
menuManager.addSwap("use", "green egg", "destroy", "green egg");
@@ -207,17 +209,17 @@ class BarbarianAssaultMenu
void disableSwaps(boolean force)
{
if (!config.swapLadder() || force)
if (!game.isSwapLadder() || force)
{
menuManager.removeSwap("climb-down", "ladder", "quick-start", "ladder");
}
if (!config.swapCollectorBag() || force)
if (!game.isSwapCollectorBag() || force)
{
menuManager.removeSwap("look-in", "collection bag", "empty", "collection bag");
}
if (!config.swapDestroyEggs() || force)
if (!game.isSwapDestroyEggs() || force)
{
menuManager.removeSwap("use", "blue egg", "destroy", "blue egg");
menuManager.removeSwap("use", "green egg", "destroy", "green egg");

View File

@@ -29,7 +29,7 @@ package net.runelite.client.plugins.barbarianassault;
import com.google.common.collect.ImmutableList;
import com.google.inject.Provides;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
@@ -41,10 +41,10 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
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.ChatMessageType;
import net.runelite.api.Client;
@@ -108,6 +108,7 @@ import org.apache.commons.lang3.StringUtils;
tags = {"minigame", "overlay", "timer"},
type = PluginType.PVM // don't remove this, added this because our barbarian assault plugin is big time modified
)
@Singleton
public class BarbarianAssaultPlugin extends Plugin implements KeyListener
{
private static final String ENDGAME_REWARD_NEEDLE_TEXT = "<br>5";
@@ -182,16 +183,16 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
private Font font = null;
@Getter
private final HashMap<WorldPoint, Integer> redEggs = new HashMap<>();
private final Map<WorldPoint, Integer> redEggs = new HashMap<>();
@Getter
private final HashMap<WorldPoint, Integer> greenEggs = new HashMap<>();
private final Map<WorldPoint, Integer> greenEggs = new HashMap<>();
@Getter
private final HashMap<WorldPoint, Integer> blueEggs = new HashMap<>();
private final Map<WorldPoint, Integer> blueEggs = new HashMap<>();
@Getter
private final HashMap<WorldPoint, Integer> yellowEggs = new HashMap<>();
private final Map<WorldPoint, Integer> yellowEggs = new HashMap<>();
@Getter
private final Map<Integer, Healer> healers = new HashMap<>();
@@ -202,7 +203,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
@Getter
private String lastListenText = null;
private String lastClickedTell = null;
// private String lastClickedTell = null;
private int lastCallColor = -1;
@@ -212,7 +213,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
private int tickNum = 0;
private int gameTick = -1;
// private int gameTick = -1;
private int inGameBit = 0;
@@ -233,24 +234,79 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
private BufferedImage torsoImage, fighterImage, healerImage, rangerImage, runnerImage;
private ArrayList<TimerBox> deathTimes = new ArrayList<>();
private final List<TimerBox> deathTimes = new ArrayList<>();
private HashMap<Integer, Projectile> projectiles = new HashMap<>();
private final Map<Integer, Projectile> projectiles = new HashMap<>();
private TimerBox tickCounter;
private String poisonUsed = null;
@Provides
BarbarianAssaultConfig provideConfig(ConfigManager configManager)
{
return configManager.getConfig(BarbarianAssaultConfig.class);
}
// save config values
@Getter(AccessLevel.PACKAGE)
private boolean swapLadder;
@Getter(AccessLevel.PACKAGE)
private boolean showTimer;
@Getter(AccessLevel.PACKAGE)
private boolean removeIncorrectCalls;
@Getter(AccessLevel.PACKAGE)
private boolean removeUnusedMenus;
private boolean prayerMetronome;
private int prayerMetronomeVolume;
private boolean showDeathTimes;
private DeathTimesMode showDeathTimesMode;
private boolean waveTimes;
private boolean showTotalRewards;
@Getter(AccessLevel.PACKAGE)
private boolean highlightArrows;
@Getter(AccessLevel.PACKAGE)
private Color highlightArrowColor;
private boolean removeIncorrectAttackStyles;
private boolean tagging;
@Getter(AccessLevel.PACKAGE)
private boolean highlightBait;
@Getter(AccessLevel.PACKAGE)
private Color highlightBaitColor;
private boolean showDefTimer;
private boolean deprioritizeBait;
@Getter(AccessLevel.PACKAGE)
private boolean removePenanceCave;
@Getter(AccessLevel.PACKAGE)
private boolean highlightPoison;
@Getter(AccessLevel.PACKAGE)
private Color highlightPoisonColor;
private boolean highlightNotification;
private Color highlightNotificationColor;
@Getter(AccessLevel.PACKAGE)
private boolean showHpCountOverlay;
@Getter(AccessLevel.PACKAGE)
private boolean showTeammateHealthbars;
@Getter(AccessLevel.PACKAGE)
private boolean healerCodes;
private boolean healerMenuOption;
private boolean shiftOverstock;
private boolean controlHealer;
@Getter(AccessLevel.PACKAGE)
private boolean swapCollectorBag;
@Getter(AccessLevel.PACKAGE)
private boolean swapDestroyEggs;
@Getter(AccessLevel.PACKAGE)
private boolean highlightCollectorEggs;
private boolean deprioritizeIncorrectEggs;
@Getter(AccessLevel.PACKAGE)
private boolean showEggCountOverlay;
@Override
protected void startUp() throws Exception
{
updateConfig();
font = FontManager.getRunescapeFont().deriveFont(Font.BOLD, 24);
torsoImage = itemManager.getImage(ItemID.FIGHTER_TORSO);
clockImage = ImageUtil.getResourceStreamFromClass(getClass(), "clock.png");
@@ -282,7 +338,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
controlDown = false;
resetWave();
wave = null;
gameTick = client.getTickCount();
// gameTick = client.getTickCount();
menu.disableSwaps(true);
menu.clearHiddenMenus();
}
@@ -329,10 +385,12 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
return;
}
updateConfig();
switch (configChanged.getKey())
{
case "showTimer":
if (!config.showTimer())
if (!this.showTimer)
{
showRoleSprite();
}
@@ -352,7 +410,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
break;
case "showDefTimer":
if (config.showDefTimer() && getRole() == Role.DEFENDER)
if (this.showDefTimer && getRole() == Role.DEFENDER)
{
addTickTimer();
}
@@ -364,9 +422,9 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
case "showDeathTimes":
case "showDeathTimesMode":
if (config.showDeathTimes()
&& (config.showDeathTimesMode() == DeathTimesMode.INFO_BOX
|| config.showDeathTimesMode() == DeathTimesMode.BOTH))
if (this.showDeathTimes
&& (this.showDeathTimesMode == DeathTimesMode.INFO_BOX
|| this.showDeathTimesMode == DeathTimesMode.BOTH))
{
addAllDeathTimes();
}
@@ -383,7 +441,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
break;
case "removeIncorrectAttackStyles":
if (!config.removeIncorrectAttackStyles())
if (!this.removeIncorrectAttackStyles)
{
clientThread.invoke(this::showAllStyles);
}
@@ -391,6 +449,44 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
}
}
private void updateConfig()
{
this.swapLadder = config.swapLadder();
this.showTimer = config.showTimer();
this.removeIncorrectCalls = config.removeIncorrectCalls();
this.removeUnusedMenus = config.removeUnusedMenus();
this.prayerMetronome = config.prayerMetronome();
this.prayerMetronomeVolume = config.prayerMetronomeVolume();
this.showDeathTimes = config.showDeathTimes();
this.showDeathTimesMode = config.showDeathTimesMode();
this.waveTimes = config.waveTimes();
this.showTotalRewards = config.showTotalRewards();
this.highlightArrows = config.highlightArrows();
this.highlightArrowColor = config.highlightArrowColor();
this.removeIncorrectAttackStyles = config.removeIncorrectAttackStyles();
this.tagging = config.tagging();
this.highlightBait = config.highlightBait();
this.highlightBaitColor = config.highlightBaitColor();
this.showDefTimer = config.showDefTimer();
this.deprioritizeBait = config.deprioritizeBait();
this.removePenanceCave = config.removePenanceCave();
this.highlightPoison = config.highlightPoison();
this.highlightPoisonColor = config.highlightPoisonColor();
this.highlightNotification = config.highlightNotification();
this.highlightNotificationColor = config.highlightNotificationColor();
this.showHpCountOverlay = config.showHpCountOverlay();
this.showTeammateHealthbars = config.showTeammateHealthbars();
this.healerCodes = config.healerCodes();
this.healerMenuOption = config.healerMenuOption();
this.shiftOverstock = config.shiftOverstock();
this.controlHealer = config.controlHealer();
this.swapCollectorBag = config.swapCollectorBag();
this.swapDestroyEggs = config.swapDestroyEggs();
this.highlightCollectorEggs = config.highlightCollectorEggs();
this.deprioritizeIncorrectEggs = config.deprioritizeIncorrectEggs();
this.showEggCountOverlay = config.showEggCountOverlay();
}
@Subscribe
public void onWidgetLoaded(WidgetLoaded event)
{
@@ -408,7 +504,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
Widget pointsWidget = client.getWidget(WidgetInfo.BA_REWARD_TEXT);
if (!rewardWidget.getText().contains(ENDGAME_REWARD_NEEDLE_TEXT))
{
if (config.showTotalRewards() && pointsWidget != null)
if (this.showTotalRewards && pointsWidget != null)
{
// The wave will be null if the plugin is disabled mid game, but
// the wave points will still be accurate if it is re-enabled
@@ -433,7 +529,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
{
announceGameTime();
if (config.showTotalRewards() && scorecard != null && scorecard.getNumberOfWaves() == 9)
if (this.showTotalRewards && scorecard != null && scorecard.getNumberOfWaves() == 9)
{
announce(scorecard.getGameSummary());
}
@@ -496,11 +592,11 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
wave.setHpHealed(wave.getHpHealed() + health);
}
}
else if (message.contains("the wrong type of poisoned food to use") && config.highlightNotification())
else if (message.contains("the wrong type of poisoned food to use") && this.highlightNotification)
{
final MessageNode messageNode = chatMessage.getMessageNode();
final String nodeValue = Text.removeTags(messageNode.getValue());
messageNode.setValue(ColorUtil.wrapWithColorTag(nodeValue, config.highlightNotificationColor()));
messageNode.setValue(ColorUtil.wrapWithColorTag(nodeValue, this.highlightNotificationColor));
chatMessageManager.update(messageNode);
}
else if (message.startsWith("All of the Penance"))
@@ -528,9 +624,9 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
break;
}
if (config.showDeathTimes() && wave != null
&& (config.showDeathTimesMode() == DeathTimesMode.CHAT_BOX
|| config.showDeathTimesMode() == DeathTimesMode.BOTH))
if (this.showDeathTimes && wave != null
&& (this.showDeathTimesMode == DeathTimesMode.CHAT_BOX
|| this.showDeathTimesMode == DeathTimesMode.BOTH))
{
final MessageNode node = chatMessage.getMessageNode();
final String nodeValue = Text.removeTags(node.getValue());
@@ -549,7 +645,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
return;
}
HashMap<WorldPoint, Integer> eggMap = getEggMap(itemSpawned.getItem().getId());
Map<WorldPoint, Integer> eggMap = getEggMap(itemSpawned.getItem().getId());
if (eggMap != null)
{
WorldPoint worldPoint = itemSpawned.getTile().getWorldLocation();
@@ -578,7 +674,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
// If an egg despawns due to time and the collector is standing over it,
// a point will added as if the player picked it up
HashMap<WorldPoint, Integer> eggMap = getEggMap(itemId);
Map<WorldPoint, Integer> eggMap = getEggMap(itemId);
if (eggMap != null)
{
WorldPoint worldPoint = itemDespawned.getTile().getWorldLocation();
@@ -635,9 +731,9 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
tickCounter.setCount(tickNum);
}
if (config.prayerMetronome() && isAnyPrayerActive())
if (this.prayerMetronome && isAnyPrayerActive())
{
for (int i = 0; i < config.prayerMetronomeVolume(); i++)
for (int i = 0; i < this.prayerMetronomeVolume; i++)
{
client.playSoundEffect(SoundEffectID.GE_INCREMENT_PLOP);
}
@@ -661,12 +757,9 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
String name = event.getNpc().getName();
if (name.equals("Penance Healer"))
if (name.equals("Penance Healer") && !healers.containsKey(npc.getIndex()))
{
if (!healers.containsKey(npc.getIndex()))
{
healers.put(npc.getIndex(), new Healer(npc, healers.size(), stage));
}
healers.put(npc.getIndex(), new Healer(npc, healers.size(), stage));
}
}
@@ -821,7 +914,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
// This doesn't have to be done in BeforeRender. And although it is
// inefficient, it's only being done while in the instance. Will
// likely be changed in the future
if (getRole() == Role.ATTACKER && config.removeIncorrectAttackStyles())
if (getRole() == Role.ATTACKER && this.removeIncorrectAttackStyles)
{
Widget weapon = client.getWidget(WidgetInfo.COMBAT_WEAPON);
@@ -891,7 +984,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
switch (getRole())
{
case ATTACKER:
if (config.tagging() && option.equals("attack") && (target.startsWith("penance fighter") || target.startsWith("penance ranger")))
if (this.tagging && option.equals("attack") && (target.startsWith("penance fighter") || target.startsWith("penance ranger")))
{
String tag = StringUtils.substringBefore(entry.getTarget(), ")");
@@ -932,7 +1025,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
priority.add(entry);
continue;
}
else if (config.deprioritizeIncorrectEggs()
else if (this.deprioritizeIncorrectEggs
&& option.equals("take")
&& (target.equals("blue egg") || target.equals("green egg") || target.equals("red egg")))
{
@@ -954,7 +1047,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
priority.add(entry);
continue;
}
else if (config.deprioritizeBait()
else if (this.deprioritizeBait
&& option.equals("take")
&& (target.equals("tofu") || target.equals("crackers") || target.equals("worms")))
{
@@ -963,7 +1056,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
break;
case HEALER:
if (config.healerMenuOption() && target.contains("penance healer") && healers.containsKey(identifier))
if (this.healerMenuOption && target.contains("penance healer") && healers.containsKey(identifier))
{
String tag = StringUtils.substringBefore(entry.getTarget(), " (");
int time = healers.get(identifier).timeToPoison();
@@ -978,17 +1071,17 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
if ((target.startsWith("poisoned meat ->") || target.startsWith("poisoned tofu ->") || target.startsWith("poisoned worms ->")))
{
// Poison should only be used on healers
if (config.removeUnusedMenus() && !target.contains("penance healer"))
if (this.removeUnusedMenus && !target.contains("penance healer"))
{
continue;
}
else if (config.controlHealer() && controlDown && identifier == lastHealerPoisoned && target.contains("penance healer"))
else if (this.controlHealer && controlDown && identifier == lastHealerPoisoned && target.contains("penance healer"))
{
selected.add(entry);
continue;
}
}
else if (config.shiftOverstock() && target.equals("healer item machine") && shiftDown)
else if (this.shiftOverstock && target.equals("healer item machine") && shiftDown)
{
if (option.contains(listen))
{
@@ -996,7 +1089,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
continue;
}
}
else if (config.removeUnusedMenus())
else if (this.removeUnusedMenus)
{
// Vials that are empty should only be used on spring
if (target.startsWith("healing vial ->") && !target.endsWith("healer spring"))
@@ -1061,16 +1154,12 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
String target = Text.removeTags(event.getTarget()).toLowerCase();
if (getRole() == Role.HEALER)
if (getRole() == Role.HEALER && (target.startsWith("poisoned meat -> penance healer")
|| target.startsWith("poisoned tofu -> penance healer")
|| target.startsWith("poisoned worms -> penance healer")))
{
if (target.startsWith("poisoned meat -> penance healer")
|| target.startsWith("poisoned tofu -> penance healer")
|| target.startsWith("poisoned worms -> penance healer"))
{
lastHealerPoisoned = event.getIdentifier();
poisonUsed = StringUtils.substringBefore(target.replace("oned", "."), " ->");
return;
}
lastHealerPoisoned = event.getIdentifier();
poisonUsed = StringUtils.substringBefore(target.replace("oned", "."), " ->");
}
// INW
@@ -1107,14 +1196,11 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
if (opponent == null)
{
if (lastInteracted != -1)
if (lastInteracted != -1 && StringUtils.equalsIgnoreCase(poisonUsed, getRole().getListen(client)) && healers.containsKey(lastInteracted))
{
if (StringUtils.equalsIgnoreCase(poisonUsed, getRole().getListen(client)) && healers.containsKey(lastInteracted))
{
Healer healer = healers.get(lastInteracted);
healer.setFoodRemaining(healer.getFoodRemaining() - 1);
healer.setTimeLastPoisoned(Instant.now());
}
Healer healer = healers.get(lastInteracted);
healer.setFoodRemaining(healer.getFoodRemaining() - 1);
healer.setTimeLastPoisoned(Instant.now());
}
lastInteracted = -1;
@@ -1164,7 +1250,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
lastListenText = null;
lastCallText = null;
lastCallColor = -1;
lastClickedTell = null;
// lastClickedTell = null;
}
else
{
@@ -1286,12 +1372,12 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
if (newCallColor == COLOR_CALL_CALLED)
{
lastCallColor = COLOR_CALL_CALLED;
lastClickedTell = lastCallText;
// lastClickedTell = lastCallText;
}
else if (callTimer == null)
{
lastCallColor = COLOR_CALL_UPDATED;
lastClickedTell = null;
// lastClickedTell = null;
}
if (callWidget != null)
@@ -1312,12 +1398,12 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
private void validateWidgets()
{
if (!config.showTimer())
if (!this.showTimer)
{
showRoleSprite();
}
if (config.showDefTimer() && getRole() == Role.DEFENDER)
if (this.showDefTimer && getRole() == Role.DEFENDER)
{
addTickTimer();
}
@@ -1326,9 +1412,9 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
removeTickTimer();
}
if (config.showDeathTimes()
&& (config.showDeathTimesMode() == DeathTimesMode.INFO_BOX
|| config.showDeathTimesMode() == DeathTimesMode.BOTH))
if (this.showDeathTimes
&& (this.showDeathTimesMode == DeathTimesMode.INFO_BOX
|| this.showDeathTimesMode == DeathTimesMode.BOTH))
{
addAllDeathTimes();
}
@@ -1388,7 +1474,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
deathTimes.add(box);
if (config.showDeathTimes() && (config.showDeathTimesMode() == DeathTimesMode.INFO_BOX || config.showDeathTimesMode() == DeathTimesMode.BOTH))
if (this.showDeathTimes && (this.showDeathTimesMode == DeathTimesMode.INFO_BOX || this.showDeathTimesMode == DeathTimesMode.BOTH))
{
infoBoxManager.addInfoBox(box);
}
@@ -1454,7 +1540,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
private void announceWaveTime()
{
if (config.waveTimes() && wave != null)
if (this.waveTimes && wave != null)
{
announceTime("Wave " + getStage() + " duration: ", wave.getWaveTimer().getElapsedTimeFormatted());
}
@@ -1462,7 +1548,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
private void announceGameTime()
{
if (config.waveTimes() && gameTimer != null)
if (this.waveTimes && gameTimer != null)
{
announceTime("Game finished, duration: ", gameTimer.getElapsedTimeFormatted());
}
@@ -1504,7 +1590,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
yellowEggs.clear();
}
private HashMap<WorldPoint, Integer> getEggMap(int itemID)
private Map<WorldPoint, Integer> getEggMap(int itemID)
{
switch (itemID)
{

View File

@@ -28,6 +28,7 @@ package net.runelite.client.plugins.barbarianassault;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.events.ChatMessage;
@@ -35,13 +36,13 @@ import net.runelite.client.chat.ChatMessageBuilder;
import net.runelite.client.eventbus.Subscribe;
@Getter
@Getter(AccessLevel.PACKAGE)
public class Scorecard
{
private BarbarianAssaultPlugin game;
@Getter(AccessLevel.NONE)
private ArrayList<Wave> waves = new ArrayList<>();
private List<Wave> waves = new ArrayList<>();
private String[] totalDescriptions = {
"A: ",
"; D: ",
@@ -67,13 +68,10 @@ public class Scorecard
@Subscribe
public void onChatMessage(ChatMessage chatMessage)
{
if (chatMessage.getMessage().startsWith("---- Points:"))
if (chatMessage.getMessage().startsWith("---- Points:") && game.getStage() == 1)
{
if (game.getStage() == 1)
{
totalPoints = new int[6];
totalAmounts = new int[6];
}
totalPoints = new int[6];
totalAmounts = new int[6];
}
}

View File

@@ -24,6 +24,7 @@
*/
package net.runelite.client.plugins.barbarianassault;
import lombok.AccessLevel;
import lombok.Getter;
import java.time.Duration;
@@ -33,7 +34,7 @@ import java.time.format.DateTimeFormatter;
class Timer
{
@Getter
@Getter(AccessLevel.PACKAGE)
private final Instant startTime;
Timer()

View File

@@ -26,12 +26,14 @@
package net.runelite.client.plugins.barbarianassault;
import lombok.Data;
import lombok.EqualsAndHashCode;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.ui.overlay.infobox.InfoBox;
import java.awt.Color;
import java.awt.image.BufferedImage;
@EqualsAndHashCode(callSuper = true)
@Data
public class TimerBox extends InfoBox
{

View File

@@ -37,7 +37,6 @@ import net.runelite.client.chat.ChatMessageBuilder;
import java.awt.Color;
@Data
public class Wave
{

View File

@@ -28,6 +28,7 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
import net.runelite.api.Varbits;
@@ -43,13 +44,14 @@ import net.runelite.client.ui.overlay.components.table.TableAlignment;
import net.runelite.client.ui.overlay.components.table.TableComponent;
import net.runelite.client.util.ColorUtil;
@Singleton
public class BarrowsBrotherSlainOverlay extends Overlay
{
private final Client client;
private final PanelComponent panelComponent = new PanelComponent();
@Inject
private BarrowsBrotherSlainOverlay(BarrowsPlugin plugin, Client client)
private BarrowsBrotherSlainOverlay(final BarrowsPlugin plugin, final Client client)
{
super(plugin);
setPosition(OverlayPosition.TOP_LEFT);

View File

@@ -24,6 +24,7 @@
*/
package net.runelite.client.plugins.barrows;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.runelite.api.Varbits;
@@ -39,10 +40,10 @@ public enum BarrowsBrothers
TORAG("Torag", new WorldPoint(3553, 3283, 0), Varbits.BARROWS_KILLED_TORAG),
VERAC("Verac", new WorldPoint(3557, 3298, 0), Varbits.BARROWS_KILLED_VERAC);
@Getter
@Getter(AccessLevel.PACKAGE)
private final String name;
@Getter
@Getter(AccessLevel.PACKAGE)
private final WorldPoint location;
@Getter
@Getter(AccessLevel.PACKAGE)
private final Varbits killedVarbit;
}

View File

@@ -30,6 +30,7 @@ import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.GameObject;
import net.runelite.api.NPC;
@@ -44,22 +45,21 @@ import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition;
@Singleton
class BarrowsOverlay extends Overlay
{
private static final int MAX_DISTANCE = 2350;
private final Client client;
private final BarrowsPlugin plugin;
private final BarrowsConfig config;
@Inject
private BarrowsOverlay(Client client, BarrowsPlugin plugin, BarrowsConfig config)
private BarrowsOverlay(final Client client, final BarrowsPlugin plugin)
{
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ABOVE_WIDGETS);
this.client = client;
this.plugin = plugin;
this.config = config;
}
@Override
@@ -71,7 +71,7 @@ class BarrowsOverlay extends Overlay
Widget puzzleAnswer = plugin.getPuzzleAnswer();
// tunnels are only on z=0
if (!plugin.getWalls().isEmpty() && client.getPlane() == 0 && config.showMinimap())
if (!plugin.getWalls().isEmpty() && client.getPlane() == 0 && plugin.isShowMinimap())
{
// NPC dots
graphics.setColor(npcColor);
@@ -117,12 +117,12 @@ class BarrowsOverlay extends Overlay
graphics.setColor(playerColor);
graphics.fillRect(local.getMinimapLocation().getX(), local.getMinimapLocation().getY(), 3, 3);
}
else if (config.showBrotherLoc())
else if (plugin.isShowBrotherLoc())
{
renderBarrowsBrothers(graphics);
}
if (puzzleAnswer != null && config.showPuzzleAnswer() && !puzzleAnswer.isHidden())
if (puzzleAnswer != null && plugin.isShowPuzzleAnswer() && !puzzleAnswer.isHidden())
{
Rectangle answerRect = puzzleAnswer.getBounds();
graphics.setColor(Color.GREEN);
@@ -230,11 +230,11 @@ class BarrowsOverlay extends Overlay
if (client.getVar(brother.getKilledVarbit()) > 0)
{
graphics.setColor(config.deadBrotherLocColor());
graphics.setColor(plugin.getDeadBrotherLocColor());
}
else
{
graphics.setColor(config.brotherLocColor());
graphics.setColor(plugin.getBrotherLocColor());
}
graphics.drawString(brotherLetter, minimapText.getX(), minimapText.getY());

View File

@@ -27,10 +27,12 @@ package net.runelite.client.plugins.barrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
import com.google.inject.Provides;
import java.awt.Color;
import java.time.temporal.ChronoUnit;
import java.util.HashSet;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.ChatMessageType;
@@ -77,6 +79,7 @@ import net.runelite.client.util.StackFormatter;
description = "Show helpful information for the Barrows minigame",
tags = {"combat", "minigame", "minimap", "bosses", "pve", "pvm"}
)
@Singleton
public class BarrowsPlugin extends Plugin
{
@Getter(AccessLevel.PACKAGE)
@@ -144,9 +147,23 @@ public class BarrowsPlugin extends Plugin
return configManager.getConfig(BarrowsConfig.class);
}
@Getter(AccessLevel.PACKAGE)
private boolean showMinimap;
@Getter(AccessLevel.PACKAGE)
private boolean showBrotherLoc;
private boolean showChestValue;
@Getter(AccessLevel.PACKAGE)
private Color brotherLocColor;
@Getter(AccessLevel.PACKAGE)
private Color deadBrotherLocColor;
@Getter(AccessLevel.PACKAGE)
private boolean showPuzzleAnswer;
private boolean showPrayerDrainTimer;
@Override
protected void startUp() throws Exception
{
updateConfig();
overlayManager.add(barrowsOverlay);
overlayManager.add(brotherOverlay);
}
@@ -179,12 +196,28 @@ public class BarrowsPlugin extends Plugin
@Subscribe
public void onConfigChanged(ConfigChanged event)
{
if (event.getGroup().equals("barrows") && !config.showPrayerDrainTimer())
if (event.getGroup().equals("barrows"))
{
stopPrayerDrainTimer();
updateConfig();
if (!this.showPrayerDrainTimer)
{
stopPrayerDrainTimer();
}
}
}
private void updateConfig()
{
this.showMinimap = config.showMinimap();
this.showBrotherLoc = config.showBrotherLoc();
this.showChestValue = config.showChestValue();
this.brotherLocColor = config.brotherLocColor();
this.deadBrotherLocColor = config.deadBrotherLocColor();
this.showPuzzleAnswer = config.showPuzzleAnswer();
this.showPrayerDrainTimer = config.showPrayerDrainTimer();
}
@Subscribe
public void onWallObjectSpawned(WallObjectSpawned event)
{
@@ -256,19 +289,16 @@ public class BarrowsPlugin extends Plugin
ladders.clear();
puzzleAnswer = null;
}
else if (event.getGameState() == GameState.LOGGED_IN)
else if (event.getGameState() == GameState.LOGGED_IN && client.getLocalPlayer() != null)
{
if (client.getLocalPlayer() != null)
boolean isInCrypt = isInCrypt();
if (wasInCrypt && !isInCrypt)
{
boolean isInCrypt = isInCrypt();
if (wasInCrypt && !isInCrypt)
{
stopPrayerDrainTimer();
}
else if (!wasInCrypt && isInCrypt)
{
startPrayerDrainTimer();
}
stopPrayerDrainTimer();
}
else if (!wasInCrypt && isInCrypt)
{
startPrayerDrainTimer();
}
}
}
@@ -276,10 +306,14 @@ public class BarrowsPlugin extends Plugin
@Subscribe
public void onWidgetLoaded(WidgetLoaded event)
{
if (event.getGroupId() == WidgetID.BARROWS_REWARD_GROUP_ID && config.showChestValue())
if (event.getGroupId() == WidgetID.BARROWS_REWARD_GROUP_ID && this.showChestValue)
{
ItemContainer barrowsRewardContainer = client.getItemContainer(InventoryID.BARROWS_REWARD);
Item[] items = barrowsRewardContainer.getItems();
Item[] items = new Item[0];
if (barrowsRewardContainer != null)
{
items = barrowsRewardContainer.getItems();
}
long chestPrice = 0;
for (Item item : items)
@@ -320,7 +354,7 @@ public class BarrowsPlugin extends Plugin
private void startPrayerDrainTimer()
{
if (config.showPrayerDrainTimer())
if (this.showPrayerDrainTimer)
{
final LoopTimer loopTimer = new LoopTimer(
PRAYER_DRAIN_INTERVAL_MS,

View File

@@ -35,10 +35,10 @@ import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.Varbits;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.menus.MenuManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType;
@@ -56,7 +56,6 @@ import org.apache.commons.lang3.RandomUtils;
type = PluginType.SKILLING,
enabledByDefault = false
)
@Singleton
@Slf4j
public class BlackjackPlugin extends Plugin
@@ -68,10 +67,9 @@ public class BlackjackPlugin extends Plugin
@Inject
private Client client;
@Inject
private MenuManager menuManager;
@Inject
private BlackjackConfig config;
private boolean pickpocketOnAggro;
@Provides
BlackjackConfig getConfig(ConfigManager configManager)
@@ -79,6 +77,20 @@ public class BlackjackPlugin extends Plugin
return configManager.getConfig(BlackjackConfig.class);
}
@Override
protected void startUp() throws Exception
{
this.pickpocketOnAggro = config.pickpocketOnAggro();
}
@Subscribe
public void onConfigChanged(ConfigChanged event)
{
if (event.getGroup().equals("blackjack"))
{
this.pickpocketOnAggro = config.pickpocketOnAggro();
}
}
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded event)
@@ -105,12 +117,9 @@ public class BlackjackPlugin extends Plugin
@Subscribe
public void onChatMessage(ChatMessage event)
{
if (event.getType() == ChatMessageType.SPAM)
if (event.getType() == ChatMessageType.SPAM && event.getMessage().equals(SUCCESS_BLACKJACK) ^ (event.getMessage().equals(FAILED_BLACKJACK) && this.pickpocketOnAggro))
{
if (event.getMessage().equals(SUCCESS_BLACKJACK) ^ (event.getMessage().equals(FAILED_BLACKJACK) && config.pickpocketOnAggro()))
{
nextKnockOutTick = client.getTickCount() + RandomUtils.nextInt(3, 4);
}
nextKnockOutTick = client.getTickCount() + RandomUtils.nextInt(3, 4);
}
}
}

View File

@@ -29,6 +29,7 @@ import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.geom.Area;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.EquipmentInventorySlot;
import net.runelite.api.GameObject;
@@ -42,21 +43,20 @@ import net.runelite.api.coords.LocalPoint;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
@Singleton
class BlastFurnaceClickBoxOverlay extends Overlay
{
private static final int MAX_DISTANCE = 2350;
private final Client client;
private final BlastFurnacePlugin plugin;
private final BlastFurnaceConfig config;
@Inject
private BlastFurnaceClickBoxOverlay(Client client, BlastFurnacePlugin plugin, BlastFurnaceConfig config)
private BlastFurnaceClickBoxOverlay(final Client client, final BlastFurnacePlugin plugin)
{
setPosition(OverlayPosition.DYNAMIC);
this.client = client;
this.plugin = plugin;
this.config = config;
}
@Override
@@ -64,13 +64,13 @@ class BlastFurnaceClickBoxOverlay extends Overlay
{
int dispenserState = client.getVar(Varbits.BAR_DISPENSER);
if (config.showConveyorBelt() && plugin.getConveyorBelt() != null)
if (plugin.isShowConveyorBelt() && plugin.getConveyorBelt() != null)
{
Color color = dispenserState == 1 ? Color.RED : Color.GREEN;
renderObject(plugin.getConveyorBelt(), graphics, color);
}
if (config.showBarDispenser() && plugin.getBarDispenser() != null)
if (plugin.isShowBarDispenser() && plugin.getBarDispenser() != null)
{
boolean hasIceGloves = hasIceGloves();
Color color = dispenserState == 2 && hasIceGloves ? Color.GREEN : (dispenserState == 3 ? Color.GREEN : Color.RED);

View File

@@ -27,6 +27,7 @@ package net.runelite.client.plugins.blastfurnace;
import java.awt.Dimension;
import java.awt.Graphics2D;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
import static net.runelite.api.Varbits.BLAST_FURNACE_COFFER;
@@ -41,6 +42,7 @@ import net.runelite.client.ui.overlay.components.table.TableComponent;
import net.runelite.client.ui.overlay.components.table.TableAlignment;
import net.runelite.client.util.StackFormatter;
@Singleton
class BlastFurnaceCofferOverlay extends Overlay
{
private final Client client;
@@ -48,7 +50,7 @@ class BlastFurnaceCofferOverlay extends Overlay
private final PanelComponent panelComponent = new PanelComponent();
@Inject
private BlastFurnaceCofferOverlay(Client client, BlastFurnacePlugin plugin)
private BlastFurnaceCofferOverlay(final Client client, final BlastFurnacePlugin plugin)
{
super(plugin);
setPosition(OverlayPosition.TOP_LEFT);

View File

@@ -28,6 +28,7 @@ import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
import net.runelite.client.game.ItemManager;
@@ -39,6 +40,7 @@ import net.runelite.client.ui.overlay.components.ComponentOrientation;
import net.runelite.client.ui.overlay.components.ImageComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
@Singleton
class BlastFurnaceOverlay extends Overlay
{
private final Client client;
@@ -49,7 +51,7 @@ class BlastFurnaceOverlay extends Overlay
private ItemManager itemManager;
@Inject
BlastFurnaceOverlay(Client client, BlastFurnacePlugin plugin)
BlastFurnaceOverlay(final Client client, final BlastFurnacePlugin plugin)
{
super(plugin);
this.plugin = plugin;

View File

@@ -29,6 +29,7 @@ import com.google.inject.Provides;
import java.time.Duration;
import java.time.Instant;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.Client;
@@ -37,6 +38,7 @@ import net.runelite.api.GameState;
import static net.runelite.api.NullObjectID.NULL_9092;
import static net.runelite.api.ObjectID.CONVEYOR_BELT;
import net.runelite.api.Skill;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.GameObjectDespawned;
import net.runelite.api.events.GameObjectSpawned;
import net.runelite.api.events.GameStateChanged;
@@ -57,6 +59,7 @@ import net.runelite.client.util.Text;
description = "Show helpful information for the Blast Furnace minigame",
tags = {"minigame", "overlay", "skilling", "smithing"}
)
@Singleton
public class BlastFurnacePlugin extends Plugin
{
private static final int BAR_DISPENSER = NULL_9092;
@@ -91,9 +94,19 @@ public class BlastFurnacePlugin extends Plugin
@Inject
private InfoBoxManager infoBoxManager;
@Inject
private BlastFurnaceConfig config;
@Getter(AccessLevel.PACKAGE)
private boolean showConveyorBelt;
@Getter(AccessLevel.PACKAGE)
private boolean showBarDispenser;
@Override
protected void startUp() throws Exception
{
updateConfig();
overlayManager.add(overlay);
overlayManager.add(cofferOverlay);
overlayManager.add(clickBoxOverlay);
@@ -117,6 +130,15 @@ public class BlastFurnacePlugin extends Plugin
return configManager.getConfig(BlastFurnaceConfig.class);
}
@Subscribe
public void onConfigChanged(ConfigChanged event)
{
if (event.getGroup().equals("blastfurnace"))
{
updateConfig();
}
}
@Subscribe
public void onGameObjectSpawned(GameObjectSpawned event)
{
@@ -187,4 +209,10 @@ public class BlastFurnacePlugin extends Plugin
}
}
}
private void updateConfig()
{
this.showBarDispenser = config.showBarDispenser();
this.showConveyorBelt = config.showConveyorBelt();
}
}

View File

@@ -28,6 +28,7 @@ import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.ItemID;
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
@@ -43,20 +44,21 @@ import net.runelite.client.ui.overlay.components.ComponentOrientation;
import net.runelite.client.ui.overlay.components.ImageComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
@Singleton
class BlastMineOreCountOverlay extends Overlay
{
private final Client client;
private final BlastMinePluginConfig config;
private final BlastMinePlugin plugin;
private final ItemManager itemManager;
private final PanelComponent panelComponent = new PanelComponent();
@Inject
private BlastMineOreCountOverlay(BlastMinePlugin plugin, Client client, BlastMinePluginConfig config, ItemManager itemManager)
private BlastMineOreCountOverlay(final BlastMinePlugin plugin, final Client client, final ItemManager itemManager)
{
super(plugin);
setPosition(OverlayPosition.TOP_LEFT);
this.client = client;
this.config = config;
this.plugin = plugin;
this.itemManager = itemManager;
panelComponent.setOrientation(ComponentOrientation.HORIZONTAL);
getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Blast mine overlay"));
@@ -74,7 +76,7 @@ class BlastMineOreCountOverlay extends Overlay
panelComponent.getChildren().clear();
if (config.showOreOverlay())
if (plugin.isShowOreOverlay())
{
blastMineWidget.setHidden(true);
panelComponent.getChildren().add(new ImageComponent(getImage(ItemID.COAL, client.getVar(Varbits.BLAST_MINE_COAL))));

View File

@@ -25,9 +25,12 @@
package net.runelite.client.plugins.blastmine;
import com.google.inject.Provides;
import java.awt.Color;
import java.util.HashMap;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.Client;
import net.runelite.api.GameObject;
@@ -49,9 +52,10 @@ import net.runelite.client.ui.overlay.OverlayManager;
description = "Show helpful information for the Blast Mine minigame",
tags = {"explode", "explosive", "mining", "minigame", "skilling"}
)
@Singleton
public class BlastMinePlugin extends Plugin
{
@Getter
@Getter(AccessLevel.PACKAGE)
private final Map<WorldPoint, BlastMineRock> rocks = new HashMap<>();
@Inject
@@ -66,15 +70,33 @@ public class BlastMinePlugin extends Plugin
@Inject
private BlastMineOreCountOverlay blastMineOreCountOverlay;
@Inject
private BlastMinePluginConfig config;
@Provides
BlastMinePluginConfig getConfig(ConfigManager configManager)
{
return configManager.getConfig(BlastMinePluginConfig.class);
}
@Getter(AccessLevel.PACKAGE)
private boolean showOreOverlay;
@Getter(AccessLevel.PACKAGE)
private boolean showRockIconOverlay;
@Getter(AccessLevel.PACKAGE)
private boolean showTimerOverlay;
@Getter(AccessLevel.PACKAGE)
private boolean showWarningOverlay;
@Getter(AccessLevel.PACKAGE)
private Color timerColor;
@Getter(AccessLevel.PACKAGE)
private Color warningColor;
@Override
protected void startUp() throws Exception
{
updateConfig();
overlayManager.add(blastMineRockOverlay);
overlayManager.add(blastMineOreCountOverlay);
}
@@ -132,4 +154,14 @@ public class BlastMinePlugin extends Plugin
(rock.getRemainingTimeRelative() == 1 && rock.getType() != BlastMineRockType.NORMAL) ||
(rock.getRemainingFuseTimeRelative() == 1 && rock.getType() == BlastMineRockType.LIT));
}
private void updateConfig()
{
this.showOreOverlay = config.showOreOverlay();
this.showRockIconOverlay = config.showRockIconOverlay();
this.showTimerOverlay = config.showTimerOverlay();
this.showWarningOverlay = config.showWarningOverlay();
this.timerColor = config.getTimerColor();
this.warningColor = config.getWarningColor();
}
}

View File

@@ -26,6 +26,7 @@ package net.runelite.client.plugins.blastmine;
import java.time.Duration;
import java.time.Instant;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.GameObject;
@@ -34,10 +35,10 @@ class BlastMineRock
private static final Duration PLANT_TIME = Duration.ofSeconds(30);
private static final Duration FUSE_TIME = Duration.ofMillis(4200);
@Getter
@Getter(AccessLevel.PACKAGE)
private final GameObject gameObject;
@Getter
@Getter(AccessLevel.PACKAGE)
private final BlastMineRockType type;
private final Instant creationTime = Instant.now();

View File

@@ -32,6 +32,7 @@ import java.awt.Polygon;
import java.awt.image.BufferedImage;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.GameObject;
import net.runelite.api.ItemID;
@@ -49,6 +50,7 @@ import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.ProgressPieComponent;
@Singleton
public class BlastMineRockOverlay extends Overlay
{
private static final int MAX_DISTANCE = 16;
@@ -62,20 +64,18 @@ public class BlastMineRockOverlay extends Overlay
private final Client client;
private final BlastMinePlugin plugin;
private final BlastMinePluginConfig config;
private final BufferedImage chiselIcon;
private final BufferedImage dynamiteIcon;
private final BufferedImage tinderboxIcon;
@Inject
private BlastMineRockOverlay(Client client, BlastMinePlugin plugin, BlastMinePluginConfig config, ItemManager itemManager)
private BlastMineRockOverlay(final Client client, final BlastMinePlugin plugin, final ItemManager itemManager)
{
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ABOVE_SCENE);
this.client = client;
this.plugin = plugin;
this.config = config;
chiselIcon = itemManager.getImage(ItemID.CHISEL);
dynamiteIcon = itemManager.getImage(ItemID.DYNAMITE);
tinderboxIcon = itemManager.getImage(ItemID.TINDERBOX);
@@ -114,8 +114,8 @@ public class BlastMineRockOverlay extends Overlay
drawIconOnRock(graphics, rock, tinderboxIcon);
break;
case LIT:
drawTimerOnRock(graphics, rock, config.getTimerColor());
drawAreaWarning(graphics, rock, config.getWarningColor(), tiles);
drawTimerOnRock(graphics, rock, plugin.getTimerColor());
drawAreaWarning(graphics, rock, plugin.getWarningColor(), tiles);
break;
}
}
@@ -125,7 +125,7 @@ public class BlastMineRockOverlay extends Overlay
private void drawIconOnRock(Graphics2D graphics, BlastMineRock rock, BufferedImage icon)
{
if (!config.showRockIconOverlay())
if (!plugin.isShowRockIconOverlay())
{
return;
}
@@ -140,7 +140,7 @@ public class BlastMineRockOverlay extends Overlay
private void drawTimerOnRock(Graphics2D graphics, BlastMineRock rock, Color color)
{
if (!config.showTimerOverlay())
if (!plugin.isShowTimerOverlay())
{
return;
}
@@ -161,7 +161,7 @@ public class BlastMineRockOverlay extends Overlay
private void drawAreaWarning(Graphics2D graphics, BlastMineRock rock, Color color, Tile[][][] tiles)
{
if (!config.showWarningOverlay())
if (!plugin.isShowWarningOverlay())
{
return;
}

View File

@@ -26,6 +26,7 @@ package net.runelite.client.plugins.blastmine;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.ObjectID;
@@ -54,7 +55,7 @@ public enum BlastMineRockType
rockTypes = builder.build();
}
@Getter
@Getter(AccessLevel.PACKAGE)
private final int[] objectIds;
BlastMineRockType(int... objectIds)

View File

@@ -26,6 +26,7 @@ package net.runelite.client.plugins.boosts;
import java.awt.Color;
import java.awt.image.BufferedImage;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.Client;
import net.runelite.api.Skill;
@@ -35,17 +36,15 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxPriority;
public class BoostIndicator extends InfoBox
{
private final BoostsPlugin plugin;
private final BoostsConfig config;
private final Client client;
@Getter
@Getter(AccessLevel.PACKAGE)
private final Skill skill;
BoostIndicator(Skill skill, BufferedImage image, BoostsPlugin plugin, Client client, BoostsConfig config)
BoostIndicator(final Skill skill, final BufferedImage image, final BoostsPlugin plugin, final Client client)
{
super(image, plugin);
this.plugin = plugin;
this.config = config;
this.client = client;
this.skill = skill;
setTooltip(skill.getName() + " boost");
@@ -55,7 +54,7 @@ public class BoostIndicator extends InfoBox
@Override
public String getText()
{
if (!config.useRelativeBoost())
if (!plugin.isUseRelativeBoost())
{
return String.valueOf(client.getBoostedSkillLevel(skill));
}
@@ -81,13 +80,13 @@ public class BoostIndicator extends InfoBox
return new Color(238, 51, 51);
}
return boosted - base <= config.boostThreshold() ? Color.YELLOW : Color.GREEN;
return boosted - base <= plugin.getBoostThreshold() ? Color.YELLOW : Color.GREEN;
}
@Override
public boolean render()
{
if (config.displayInfoboxes() && plugin.canShowBoosts() && plugin.getShownSkills().contains(getSkill()))
if (plugin.isDisplayInfoboxes() && plugin.canShowBoosts() && plugin.getShownSkills().contains(getSkill()))
{
return client.getBoostedSkillLevel(skill) != client.getRealSkillLevel(skill);
}

View File

@@ -28,6 +28,7 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
import net.runelite.api.Skill;
@@ -41,20 +42,19 @@ import net.runelite.client.ui.overlay.components.table.TableAlignment;
import net.runelite.client.ui.overlay.components.table.TableComponent;
import net.runelite.client.util.ColorUtil;
@Singleton
class BoostsOverlay extends Overlay
{
private final Client client;
private final BoostsConfig config;
private final PanelComponent panelComponent = new PanelComponent();
private final BoostsPlugin plugin;
@Inject
private BoostsOverlay(Client client, BoostsConfig config, BoostsPlugin plugin)
private BoostsOverlay(final Client client, final BoostsPlugin plugin)
{
super(plugin);
this.plugin = plugin;
this.client = client;
this.config = config;
setPosition(OverlayPosition.TOP_LEFT);
setPriority(OverlayPriority.MED);
getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Boosts overlay"));
@@ -63,7 +63,7 @@ class BoostsOverlay extends Overlay
@Override
public Dimension render(Graphics2D graphics)
{
if (config.displayInfoboxes() || config.displayIcons())
if (plugin.isDisplayInfoboxes() || plugin.isDisplayIcons())
{
return null;
}
@@ -103,7 +103,7 @@ class BoostsOverlay extends Overlay
final Color strColor = getTextColor(boost);
String str;
if (config.useRelativeBoost())
if (plugin.isUseRelativeBoost())
{
str = String.valueOf(boost);
if (boost > 0)
@@ -133,7 +133,7 @@ class BoostsOverlay extends Overlay
return new Color(238, 51, 51);
}
return boost <= config.boostThreshold() ? Color.YELLOW : Color.GREEN;
return boost <= plugin.getBoostThreshold() ? Color.YELLOW : Color.GREEN;
}
}

View File

@@ -33,6 +33,7 @@ import java.util.List;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.Client;
import net.runelite.api.Constants;
@@ -105,7 +106,22 @@ public class BoostsPlugin extends Plugin
private int lastChangeUp = -1;
private boolean preserveBeenActive = false;
private long lastTickMillis;
private List<String> boostedSkillsChanged = new ArrayList<>();
private final List<String> boostedSkillsChanged = new ArrayList<>();
private boolean enableSkill;
@Getter(AccessLevel.PACKAGE)
private boolean useRelativeBoost;
@Getter(AccessLevel.PACKAGE)
private boolean displayInfoboxes;
@Getter(AccessLevel.PACKAGE)
private boolean displayIcons;
@Getter(AccessLevel.PACKAGE)
private boolean boldIconFont;
private BoostsConfig.DisplayChangeMode displayNextBuffChange;
private BoostsConfig.DisplayChangeMode displayNextDebuffChange;
@Getter(AccessLevel.PACKAGE)
private int boostThreshold;
private boolean groupNotifications;
@Provides
BoostsConfig provideConfig(ConfigManager configManager)
@@ -116,6 +132,8 @@ public class BoostsPlugin extends Plugin
@Override
protected void startUp() throws Exception
{
updateConfig();
overlayManager.add(boostsOverlay);
overlayManager.add(combatIconsOverlay);
updateShownSkills();
@@ -130,7 +148,7 @@ public class BoostsPlugin extends Plugin
{
if (skill != Skill.OVERALL)
{
infoBoxManager.addInfoBox(new BoostIndicator(skill, skillIconManager.getSkillImage(skill), this, client, config));
infoBoxManager.addInfoBox(new BoostIndicator(skill, skillIconManager.getSkillImage(skill), this, client));
}
}
}
@@ -169,14 +187,15 @@ public class BoostsPlugin extends Plugin
return;
}
updateConfig();
updateShownSkills();
if (config.displayNextBuffChange() == BoostsConfig.DisplayChangeMode.NEVER)
if (this.displayNextBuffChange == BoostsConfig.DisplayChangeMode.NEVER)
{
lastChangeDown = -1;
}
if (config.displayNextDebuffChange() == BoostsConfig.DisplayChangeMode.NEVER)
if (this.displayNextDebuffChange == BoostsConfig.DisplayChangeMode.NEVER)
{
lastChangeUp = -1;
}
@@ -211,7 +230,7 @@ public class BoostsPlugin extends Plugin
lastSkillLevels[skillIdx] = cur;
updateBoostedStats();
int boostThreshold = config.boostThreshold();
int boostThreshold = this.boostThreshold;
if (boostThreshold != 0)
{
@@ -220,7 +239,7 @@ public class BoostsPlugin extends Plugin
int boost = cur - real;
if (boost <= boostThreshold && boostThreshold < lastBoost)
{
if (config.groupNotifications())
if (this.groupNotifications)
{
boostedSkillsChanged.add(skill.getName());
}
@@ -237,7 +256,7 @@ public class BoostsPlugin extends Plugin
{
lastTickMillis = System.currentTimeMillis();
if (config.groupNotifications() && !boostedSkillsChanged.isEmpty())
if (this.groupNotifications && !boostedSkillsChanged.isEmpty())
{
if (boostedSkillsChanged.size() == 1)
{
@@ -268,7 +287,7 @@ public class BoostsPlugin extends Plugin
if (getChangeUpTicks() <= 0)
{
switch (config.displayNextDebuffChange())
switch (this.displayNextDebuffChange)
{
case ALWAYS:
if (lastChangeUp != -1)
@@ -286,7 +305,7 @@ public class BoostsPlugin extends Plugin
if (getChangeDownTicks() <= 0)
{
switch (config.displayNextBuffChange())
switch (this.displayNextBuffChange)
{
case ALWAYS:
if (lastChangeDown != -1)
@@ -305,7 +324,7 @@ public class BoostsPlugin extends Plugin
private void updateShownSkills()
{
if (config.enableSkill())
if (this.enableSkill)
{
shownSkills.addAll(BOOSTABLE_NON_COMBAT_SKILLS);
}
@@ -368,8 +387,8 @@ public class BoostsPlugin extends Plugin
int getChangeDownTicks()
{
if (lastChangeDown == -1 ||
config.displayNextBuffChange() == BoostsConfig.DisplayChangeMode.NEVER ||
(config.displayNextBuffChange() == BoostsConfig.DisplayChangeMode.BOOSTED && !isChangedUp))
this.displayNextBuffChange == BoostsConfig.DisplayChangeMode.NEVER ||
(this.displayNextBuffChange == BoostsConfig.DisplayChangeMode.BOOSTED && !isChangedUp))
{
return -1;
}
@@ -396,8 +415,8 @@ public class BoostsPlugin extends Plugin
int getChangeUpTicks()
{
if (lastChangeUp == -1 ||
config.displayNextDebuffChange() == BoostsConfig.DisplayChangeMode.NEVER ||
(config.displayNextDebuffChange() == BoostsConfig.DisplayChangeMode.BOOSTED && !isChangedDown))
this.displayNextDebuffChange == BoostsConfig.DisplayChangeMode.NEVER ||
(this.displayNextDebuffChange == BoostsConfig.DisplayChangeMode.BOOSTED && !isChangedDown))
{
return -1;
}
@@ -418,4 +437,17 @@ public class BoostsPlugin extends Plugin
final long diff = System.currentTimeMillis() - lastTickMillis;
return time != -1 ? (int) ((time * Constants.GAME_TICK_LENGTH - diff) / 1000d) : time;
}
private void updateConfig()
{
this.enableSkill = config.enableSkill();
this.useRelativeBoost = config.useRelativeBoost();
this.displayInfoboxes = config.displayInfoboxes();
this.displayIcons = config.displayIcons();
this.boldIconFont = config.boldIconFont();
this.displayNextBuffChange = config.displayNextBuffChange();
this.displayNextDebuffChange = config.displayNextDebuffChange();
this.boostThreshold = config.boostThreshold();
this.groupNotifications = config.groupNotifications();
}
}

View File

@@ -6,6 +6,7 @@ import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
import net.runelite.api.Skill;
@@ -23,21 +24,20 @@ import net.runelite.client.ui.FontManager;
import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.ImageUtil;
@Singleton
class CombatIconsOverlay extends Overlay
{
private final Client client;
private final BoostsConfig config;
private final PanelComponent panelComponent = new PanelComponent();
private final SkillIconManager iconManager;
private final BoostsPlugin plugin;
@Inject
private CombatIconsOverlay(Client client, BoostsConfig config, BoostsPlugin plugin, SkillIconManager iconManager)
private CombatIconsOverlay(final Client client, final BoostsPlugin plugin, final SkillIconManager iconManager)
{
super(plugin);
this.plugin = plugin;
this.client = client;
this.config = config;
this.iconManager = iconManager;
setPosition(OverlayPosition.TOP_LEFT);
setPriority(OverlayPriority.MED);
@@ -47,12 +47,12 @@ class CombatIconsOverlay extends Overlay
@Override
public Dimension render(Graphics2D graphics)
{
if (config.displayInfoboxes() || !config.displayIcons())
if (plugin.isDisplayInfoboxes() || !plugin.isDisplayIcons())
{
return null;
}
if (config.boldIconFont())
if (plugin.isBoldIconFont())
{
graphics.setFont(FontManager.getRunescapeBoldFont());
}
@@ -79,7 +79,7 @@ class CombatIconsOverlay extends Overlay
final Color strColor = getTextColor(boost);
String str;
if (config.useRelativeBoost())
if (plugin.isUseRelativeBoost())
{
str = String.valueOf(boost);
if (boost > 0)
@@ -137,7 +137,7 @@ class CombatIconsOverlay extends Overlay
return new Color(238, 51, 51);
}
return boost <= config.boostThreshold() ? Color.YELLOW : Color.GREEN;
return boost <= plugin.getBoostThreshold() ? Color.YELLOW : Color.GREEN;
}
}

View File

@@ -29,7 +29,7 @@ import java.awt.image.BufferedImage;
import net.runelite.client.ui.overlay.infobox.InfoBox;
import net.runelite.client.ui.overlay.infobox.InfoBoxPriority;
public class StatChangeIndicator extends InfoBox
class StatChangeIndicator extends InfoBox
{
private final boolean up;
private final BoostsPlugin plugin;

View File

@@ -26,6 +26,7 @@
package net.runelite.client.plugins.bosstimer;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.NPC;
import net.runelite.api.events.NpcDespawned;
@@ -40,6 +41,7 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
description = "Show boss spawn timer overlays",
tags = {"combat", "pve", "overlay", "spawn"}
)
@Singleton
@Slf4j
public class BossTimersPlugin extends Plugin
{

View File

@@ -33,7 +33,7 @@ class RespawnTimer extends Timer
{
private final Boss boss;
public RespawnTimer(Boss boss, BufferedImage bossImage, Plugin plugin)
RespawnTimer(Boss boss, BufferedImage bossImage, Plugin plugin)
{
super(boss.getSpawnTime().toMillis(), ChronoUnit.MILLIS, bossImage, plugin);
this.boss = boss;

View File

@@ -28,7 +28,7 @@ import java.awt.Color;
import java.awt.image.BufferedImage;
import net.runelite.client.ui.overlay.infobox.InfoBox;
public class CannonCounter extends InfoBox
class CannonCounter extends InfoBox
{
private final CannonPlugin plugin;

View File

@@ -29,6 +29,7 @@ import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Polygon;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.Perspective;
import static net.runelite.api.Perspective.LOCAL_TILE_SIZE;
@@ -40,22 +41,21 @@ import net.runelite.client.ui.overlay.OverlayPriority;
import net.runelite.client.ui.overlay.OverlayUtil;
import net.runelite.client.ui.overlay.components.TextComponent;
@Singleton
class CannonOverlay extends Overlay
{
private static final int MAX_DISTANCE = 2500;
private final Client client;
private final CannonConfig config;
private final CannonPlugin plugin;
private final TextComponent textComponent = new TextComponent();
@Inject
CannonOverlay(Client client, CannonConfig config, CannonPlugin plugin)
CannonOverlay(final Client client, final CannonPlugin plugin)
{
setPosition(OverlayPosition.DYNAMIC);
setPriority(OverlayPriority.MED);
this.client = client;
this.config = config;
this.plugin = plugin;
}
@@ -91,9 +91,9 @@ class CannonOverlay extends Overlay
textComponent.render(graphics);
}
if (config.showDoubleHitSpot())
if (plugin.isShowDoubleHitSpot())
{
Color color = config.highlightDoubleHitColor();
Color color = plugin.getHighlightDoubleHitColor();
drawDoubleHitSpots(graphics, cannonPoint, color);
}
}

View File

@@ -33,6 +33,7 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.inject.Inject;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.AnimationID;
import net.runelite.api.ChatMessageType;
@@ -80,19 +81,19 @@ public class CannonPlugin extends Plugin
private CannonCounter counter;
private boolean skipProjectileCheckThisTick;
@Getter
@Getter(AccessLevel.PACKAGE)
private int cballsLeft;
@Getter
@Getter(AccessLevel.PACKAGE)
private boolean cannonPlaced;
@Getter
@Getter(AccessLevel.PACKAGE)
private WorldPoint cannonPosition;
@Getter
@Getter(AccessLevel.PACKAGE)
private GameObject cannon;
@Getter
@Getter(AccessLevel.PACKAGE)
private List<WorldPoint> spotPoints = new ArrayList<>();
@Inject
@@ -124,6 +125,17 @@ public class CannonPlugin extends Plugin
private boolean lock;
private boolean showEmptyCannonNotification;
private boolean showInfobox;
@Getter(AccessLevel.PACKAGE)
private boolean showDoubleHitSpot;
@Getter(AccessLevel.PACKAGE)
private Color highlightDoubleHitColor;
@Getter(AccessLevel.PACKAGE)
private boolean showCannonSpots;
private int ammoAmount;
private boolean notifyAmmoLeft;
@Provides
CannonConfig provideConfig(ConfigManager configManager)
{
@@ -133,6 +145,8 @@ public class CannonPlugin extends Plugin
@Override
protected void startUp() throws Exception
{
updateConfig();
overlayManager.add(cannonOverlay);
overlayManager.add(cannonSpotOverlay);
lock = false;
@@ -169,7 +183,9 @@ public class CannonPlugin extends Plugin
{
if (event.getGroup().equals("cannon"))
{
if (!config.showInfobox())
updateConfig();
if (!this.showInfobox)
{
removeCounter();
}
@@ -190,7 +206,7 @@ public class CannonPlugin extends Plugin
)
public void checkSpots()
{
if (!config.showCannonSpots())
if (!this.showCannonSpots)
{
return;
}
@@ -213,14 +229,12 @@ public class CannonPlugin extends Plugin
GameObject gameObject = event.getGameObject();
Player localPlayer = client.getLocalPlayer();
if (gameObject.getId() == CANNON_BASE && !cannonPlaced)
if (gameObject.getId() == CANNON_BASE && !cannonPlaced &&
localPlayer.getWorldLocation().distanceTo(gameObject.getWorldLocation()) <= 2 &&
localPlayer.getAnimation() == AnimationID.BURYING_BONES)
{
if (localPlayer.getWorldLocation().distanceTo(gameObject.getWorldLocation()) <= 2
&& localPlayer.getAnimation() == AnimationID.BURYING_BONES)
{
cannonPosition = gameObject.getWorldLocation();
cannon = gameObject;
}
cannonPosition = gameObject.getWorldLocation();
cannon = gameObject;
}
}
@@ -234,17 +248,15 @@ public class CannonPlugin extends Plugin
WorldPoint projectileLoc = WorldPoint.fromLocal(client, projectile.getX1(), projectile.getY1(), client.getPlane());
//Check to see if projectile x,y is 0 else it will continuously decrease while ball is flying.
if (projectileLoc.equals(cannonPosition) && projectile.getX() == 0 && projectile.getY() == 0)
{
if (projectileLoc.equals(cannonPosition) && projectile.getX() == 0 && projectile.getY() == 0 &&
// When there's a chat message about cannon reloaded/unloaded/out of ammo,
// the message event runs before the projectile event. However they run
// in the opposite order on the server. So if both fires in the same tick,
// we don't want to update the cannonball counter if it was set to a specific
// amount.
if (!skipProjectileCheckThisTick)
{
cballsLeft--;
}
!skipProjectileCheckThisTick)
{
cballsLeft--;
}
}
}
@@ -318,7 +330,7 @@ public class CannonPlugin extends Plugin
// extra check is a good idea.
cballsLeft = 0;
if (config.showEmptyCannonNotification())
if (this.showEmptyCannonNotification)
{
notifier.notify("Your cannon is out of ammo!");
}
@@ -350,13 +362,10 @@ public class CannonPlugin extends Plugin
{
return Color.orange;
}
else if (cballsLeft <= config.ammoAmount())
else if (cballsLeft <= this.ammoAmount && this.notifyAmmoLeft && !lock)
{
if (config.notifyAmmoLeft() && !lock)
{
notifier.notify("Your cannon has " + config.ammoAmount() + " balls left!");
lock = true;
}
notifier.notify("Your cannon has " + this.ammoAmount + " balls left!");
lock = true;
}
return Color.red;
@@ -364,7 +373,7 @@ public class CannonPlugin extends Plugin
private void addCounter()
{
if (!config.showInfobox() || counter != null)
if (!this.showInfobox || counter != null)
{
return;
}
@@ -385,4 +394,15 @@ public class CannonPlugin extends Plugin
infoBoxManager.removeInfoBox(counter);
counter = null;
}
private void updateConfig()
{
this.showEmptyCannonNotification = config.showEmptyCannonNotification();
this.showInfobox = config.showInfobox();
this.showDoubleHitSpot = config.showDoubleHitSpot();
this.highlightDoubleHitColor = config.highlightDoubleHitColor();
this.showCannonSpots = config.showCannonSpots();
this.ammoAmount = config.ammoAmount();
this.notifyAmmoLeft = config.notifyAmmoLeft();
}
}

View File

@@ -30,6 +30,7 @@ import java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.image.BufferedImage;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.AccessLevel;
import lombok.Setter;
import net.runelite.api.Client;
@@ -43,13 +44,13 @@ import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayUtil;
@Singleton
public class CannonSpotOverlay extends Overlay
{
private static final int MAX_DISTANCE = 2350;
private final Client client;
private final CannonPlugin plugin;
private final CannonConfig config;
@Inject
private ItemManager itemManager;
@@ -58,18 +59,17 @@ public class CannonSpotOverlay extends Overlay
private boolean hidden;
@Inject
CannonSpotOverlay(Client client, CannonPlugin plugin, CannonConfig config)
CannonSpotOverlay(final Client client, final CannonPlugin plugin)
{
setPosition(OverlayPosition.DYNAMIC);
this.client = client;
this.plugin = plugin;
this.config = config;
}
@Override
public Dimension render(Graphics2D graphics)
{
if (hidden || !config.showCannonSpots() || plugin.isCannonPlaced())
if (hidden || !plugin.isShowCannonSpots() || plugin.isCannonPlaced())
{
return null;
}

View File

@@ -27,13 +27,14 @@ package net.runelite.client.plugins.cerberus;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import java.util.Optional;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.runelite.api.NPC;
import net.runelite.api.NpcID;
import net.runelite.api.Skill;
@Getter
@Getter(AccessLevel.PACKAGE)
@RequiredArgsConstructor
public enum CerberusGhost
{

View File

@@ -25,6 +25,7 @@
package net.runelite.client.plugins.chatboxperformance;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.events.WidgetPositioned;
import net.runelite.api.widgets.Widget;
@@ -40,6 +41,7 @@ import net.runelite.client.plugins.PluginDescriptor;
name = "Chatbox performance",
hidden = true
)
@Singleton
public class ChatboxPerformancePlugin extends Plugin
{
@Inject

View File

@@ -25,6 +25,7 @@
*/
package net.runelite.client.plugins.chatcommands;
import javax.inject.Singleton;
import net.runelite.api.vars.AccountType;
import com.google.inject.Provides;
import java.io.IOException;
@@ -81,6 +82,7 @@ import org.apache.commons.text.WordUtils;
description = "Enable chat commands",
tags = {"grand", "exchange", "level", "prices"}
)
@Singleton
@Slf4j
public class ChatCommandsPlugin extends Plugin
{
@@ -816,7 +818,7 @@ public class ChatCommandsPlugin extends Plugin
}
catch (IOException e)
{
e.printStackTrace();
log.error("Error looking up prices", e);
}
int itemId = item.getId();
@@ -1164,7 +1166,7 @@ public class ChatCommandsPlugin extends Plugin
ItemPrice shortest = null;
for (ItemPrice item : items)
{
if (item.getName().toLowerCase().equals(originalInput.toLowerCase()))
if (item.getName().equalsIgnoreCase(originalInput.toLowerCase()))
{
return item;
}

View File

@@ -34,7 +34,7 @@ import net.runelite.client.callback.ClientThread;
import net.runelite.client.input.KeyListener;
@Singleton
public class ChatKeyboardListener implements KeyListener
class ChatKeyboardListener implements KeyListener
{
@Inject
private ChatCommandsConfig chatCommandsConfig;

View File

@@ -34,6 +34,9 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.AccessLevel;
import lombok.Setter;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.MessageNode;
@@ -53,6 +56,7 @@ import org.apache.commons.lang3.StringUtils;
description = "Censor user configurable words or patterns from chat",
enabledByDefault = false
)
@Singleton
public class ChatFilterPlugin extends Plugin
{
private static final Splitter NEWLINE_SPLITTER = Splitter
@@ -71,6 +75,17 @@ public class ChatFilterPlugin extends Plugin
@Inject
private ChatFilterConfig config;
@Setter(AccessLevel.PACKAGE)
private ChatFilterType filterType;
@Setter(AccessLevel.PACKAGE)
private String filteredWords;
@Setter(AccessLevel.PACKAGE)
private String filteredRegex;
@Setter(AccessLevel.PACKAGE)
private boolean filterFriends;
@Setter(AccessLevel.PACKAGE)
private boolean filterClan;
@Provides
ChatFilterConfig provideConfig(ConfigManager configManager)
{
@@ -80,13 +95,16 @@ public class ChatFilterPlugin extends Plugin
@Override
protected void startUp() throws Exception
{
updateConfig();
updateFilteredPatterns();
client.refreshChat();
}
@Override
protected void shutDown() throws Exception
{
filteredPatterns.clear();
client.refreshChat();
}
@Subscribe
@@ -122,8 +140,8 @@ public class ChatFilterPlugin extends Plugin
MessageNode messageNode = (MessageNode) client.getMessages().get(messageId);
if (client.getLocalPlayer().getName().equals(messageNode.getName()) ||
!config.filterFriends() && messageNode.isFromFriend() ||
!config.filterClan() && messageNode.isFromClanMate())
!this.filterFriends && messageNode.isFromFriend() ||
!this.filterClan && messageNode.isFromClanMate())
{
return;
}
@@ -168,8 +186,8 @@ public class ChatFilterPlugin extends Plugin
{
boolean isMessageFromSelf = playerName.equals(client.getLocalPlayer().getName());
return !isMessageFromSelf &&
(config.filterFriends() || !client.isFriended(playerName, false)) &&
(config.filterClan() || !client.isClanMember(playerName));
(this.filterFriends || !client.isFriended(playerName, false)) &&
(this.filterClan || !client.isClanMember(playerName));
}
String censorMessage(final String message)
@@ -185,7 +203,7 @@ public class ChatFilterPlugin extends Plugin
while (m.find())
{
switch (config.filterType())
switch (this.filterType)
{
case CENSOR_WORDS:
m.appendReplacement(sb, StringUtils.repeat("*", m.group(0).length()));
@@ -209,11 +227,11 @@ public class ChatFilterPlugin extends Plugin
{
filteredPatterns.clear();
Text.fromCSV(config.filteredWords()).stream()
Text.fromCSV(this.filteredWords).stream()
.map(s -> Pattern.compile(Pattern.quote(s), Pattern.CASE_INSENSITIVE))
.forEach(filteredPatterns::add);
NEWLINE_SPLITTER.splitToList(config.filteredRegex()).stream()
NEWLINE_SPLITTER.splitToList(this.filteredRegex).stream()
.map(s ->
{
try
@@ -237,6 +255,19 @@ public class ChatFilterPlugin extends Plugin
return;
}
updateConfig();
updateFilteredPatterns();
//Refresh chat after config change to reflect current rules
client.refreshChat();
}
private void updateConfig()
{
this.filterType = config.filterType();
this.filteredWords = config.filteredWords();
this.filteredRegex = config.filteredRegex();
this.filterFriends = config.filterFriends();
this.filterClan = config.filterClan();
}
}

View File

@@ -32,12 +32,14 @@ import java.util.Deque;
import java.util.Iterator;
import java.util.Queue;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.ScriptID;
import net.runelite.api.VarClientInt;
import net.runelite.api.VarClientStr;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.MenuOptionClicked;
import net.runelite.api.vars.InputType;
import net.runelite.client.callback.ClientThread;
@@ -56,6 +58,7 @@ import net.runelite.client.util.Text;
description = "Retain your chat history when logging in/out or world hopping",
tags = {"chat", "history", "retain", "cycle", "pm"}
)
@Singleton
public class ChatHistoryPlugin extends Plugin implements KeyListener
{
private static final String WELCOME_MESSAGE = "Welcome to Old School RuneScape.";
@@ -82,6 +85,9 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
@Inject
private ChatMessageManager chatMessageManager;
private boolean retainChatHistory;
private boolean pmTargetCycling;
@Provides
ChatHistoryConfig getConfig(ConfigManager configManager)
{
@@ -91,6 +97,8 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
@Override
protected void startUp()
{
updateConfig();
messageQueue = EvictingQueue.create(100);
friends = new ArrayDeque<>(FRIENDS_MAX_SIZE + 1);
keyManager.registerKeyListener(this);
@@ -113,7 +121,7 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
// of information that chat history was reset
if (chatMessage.getMessage().equals(WELCOME_MESSAGE))
{
if (!config.retainChatHistory())
if (!this.retainChatHistory)
{
return;
}
@@ -135,13 +143,11 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
case MODPRIVATECHAT:
final String name = Text.removeTags(chatMessage.getName());
// Remove to ensure uniqueness & its place in history
if (!friends.remove(name))
{
if (!friends.remove(name) &&
// If the friend didn't previously exist ensure deque capacity doesn't increase by adding them
if (friends.size() >= FRIENDS_MAX_SIZE)
{
friends.remove();
}
friends.size() >= FRIENDS_MAX_SIZE)
{
friends.remove();
}
friends.add(name);
// intentional fall-through
@@ -204,7 +210,7 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
@Override
public void keyPressed(KeyEvent e)
{
if (e.getKeyCode() != CYCLE_HOTKEY || !config.pmTargetCycling())
if (e.getKeyCode() != CYCLE_HOTKEY || !this.pmTargetCycling)
{
return;
}
@@ -260,4 +266,21 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
return friends.getLast();
}
@Subscribe
public void onConfigChanged(ConfigChanged event)
{
if (!"chathistory".equals(event.getGroup()))
{
return;
}
updateConfig();
}
private void updateConfig()
{
this.retainChatHistory = config.retainChatHistory();
this.pmTargetCycling = config.pmTargetCycling();
}
}

View File

@@ -36,6 +36,7 @@ import java.util.regex.Pattern;
import static java.util.regex.Pattern.quote;
import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.MessageNode;
import net.runelite.api.events.ChatMessage;
@@ -57,6 +58,7 @@ import net.runelite.client.util.Text;
tags = {"duel", "messages", "notifications", "trade", "username"},
enabledByDefault = false
)
@Singleton
public class ChatNotificationsPlugin extends Plugin
{
@Inject
@@ -80,7 +82,15 @@ public class ChatNotificationsPlugin extends Plugin
private Pattern highlightMatcher = null;
// Private message cache used to avoid duplicate notifications from ChatHistory.
private Set<Integer> privateMessageHashes = new HashSet<>();
private final Set<Integer> privateMessageHashes = new HashSet<>();
private boolean highlightOwnName;
private String highlightWordsString;
private boolean notifyOnOwnName;
private boolean notifyOnHighlight;
private boolean notifyOnTrade;
private boolean notifyOnDuel;
private boolean notifyOnPm;
@Provides
ChatNotificationsConfig provideConfig(ConfigManager configManager)
@@ -91,6 +101,7 @@ public class ChatNotificationsPlugin extends Plugin
@Override
public void startUp()
{
updateConfig();
updateHighlights();
}
@@ -117,6 +128,7 @@ public class ChatNotificationsPlugin extends Plugin
{
if (event.getGroup().equals("chatnotification"))
{
updateConfig();
updateHighlights();
}
}
@@ -125,9 +137,9 @@ public class ChatNotificationsPlugin extends Plugin
{
highlightMatcher = null;
if (!config.highlightWordsString().trim().equals(""))
if (!this.highlightWordsString.trim().equals(""))
{
List<String> items = Text.fromCSV(config.highlightWordsString());
List<String> items = Text.fromCSV(this.highlightWordsString);
String joined = items.stream()
.map(Text::escapeJagex) // we compare these strings to the raw Jagex ones
.map(Pattern::quote)
@@ -147,13 +159,13 @@ public class ChatNotificationsPlugin extends Plugin
switch (chatMessage.getType())
{
case TRADEREQ:
if (chatMessage.getMessage().contains("wishes to trade with you.") && config.notifyOnTrade())
if (chatMessage.getMessage().contains("wishes to trade with you.") && this.notifyOnTrade)
{
notifier.notify(chatMessage.getMessage());
}
break;
case CHALREQ_TRADE:
if (chatMessage.getMessage().contains("wishes to duel with you.") && config.notifyOnDuel())
if (chatMessage.getMessage().contains("wishes to duel with you.") && this.notifyOnDuel)
{
notifier.notify(chatMessage.getMessage());
}
@@ -167,7 +179,7 @@ public class ChatNotificationsPlugin extends Plugin
break;
case PRIVATECHAT:
case MODPRIVATECHAT:
if (config.notifyOnPm())
if (this.notifyOnPm)
{
int messageHash = this.buildMessageHash(chatMessage);
if (this.privateMessageHashes.contains(messageHash))
@@ -187,7 +199,7 @@ public class ChatNotificationsPlugin extends Plugin
usernameReplacer = "<col" + ChatColorType.HIGHLIGHT.name() + "><u>" + username + "</u><col" + ChatColorType.NORMAL.name() + ">";
}
if (config.highlightOwnName() && usernameMatcher != null)
if (this.highlightOwnName && usernameMatcher != null)
{
Matcher matcher = usernameMatcher.matcher(messageNode.getValue());
if (matcher.find())
@@ -195,7 +207,7 @@ public class ChatNotificationsPlugin extends Plugin
messageNode.setValue(matcher.replaceAll(usernameReplacer));
update = true;
if (config.notifyOnOwnName())
if (this.notifyOnOwnName)
{
sendNotification(chatMessage);
}
@@ -222,7 +234,7 @@ public class ChatNotificationsPlugin extends Plugin
matcher.appendTail(stringBuffer);
messageNode.setValue(stringBuffer.toString());
if (config.notifyOnHighlight())
if (this.notifyOnHighlight)
{
sendNotification(chatMessage);
}
@@ -261,4 +273,15 @@ public class ChatNotificationsPlugin extends Plugin
String notification = stringBuilder.toString();
notifier.notify(notification);
}
private void updateConfig()
{
this.highlightOwnName = config.highlightOwnName();
this.highlightWordsString = config.highlightWordsString();
this.notifyOnOwnName = config.notifyOnOwnName();
this.notifyOnHighlight = config.notifyOnHighlight();
this.notifyOnTrade = config.notifyOnTrade();
this.notifyOnDuel = config.notifyOnDuel();
this.notifyOnPm = config.notifyOnPm();
}
}

View File

@@ -3,7 +3,20 @@ package net.runelite.client.plugins.chattranslation;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ObjectArrays;
import com.google.inject.Provides;
import net.runelite.api.*;
import java.awt.event.KeyEvent;
import java.util.HashSet;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry;
import net.runelite.api.MessageNode;
import static net.runelite.api.ScriptID.CHATBOX_INPUT;
import net.runelite.api.VarClientStr;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.MenuEntryAdded;
@@ -23,17 +36,14 @@ import net.runelite.client.plugins.PluginType;
import net.runelite.client.util.Text;
import org.apache.commons.lang3.ArrayUtils;
import javax.inject.Inject;
import javax.inject.Provider;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
@PluginDescriptor(
name = "Chat Translator",
description = "Translates messages from one Language to another.",
tags = {"translate", "language", "english", "spanish", "dutch", "french"},
type = PluginType.UTILITY
)
@Singleton
@Slf4j
public class ChatTranslationPlugin extends Plugin implements KeyListener
{
@@ -41,7 +51,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
private static final ImmutableList<String> AFTER_OPTIONS = ImmutableList.of("Message", "Add ignore", "Remove friend", "Kick");
private ArrayList<String> playerNames = new ArrayList<>();
private final Set<String> playerNames = new HashSet<>();
@Inject
private Client client;
@@ -64,6 +74,13 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
@Inject
private ChatTranslationConfig config;
private boolean translateOptionVisable;
private boolean publicChat;
private String getPlayerNames;
private Languages publicTargetLanguage;
private boolean playerChat;
private Languages playerTargetLanguage;
@Provides
ChatTranslationConfig provideConfig(ConfigManager configManager)
{
@@ -73,12 +90,11 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
@Override
protected void startUp() throws Exception
{
if (client != null)
updateConfig();
if (client != null && this.translateOptionVisable)
{
if (config.translateOptionVisable())
{
menuManager.get().addPlayerMenuItem(TRANSLATE);
}
menuManager.get().addPlayerMenuItem(TRANSLATE);
}
keyManager.registerKeyListener(this);
@@ -88,12 +104,9 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
@Override
protected void shutDown() throws Exception
{
if (client != null)
if (client != null && this.translateOptionVisable)
{
if (config.translateOptionVisable())
{
menuManager.get().removePlayerMenuItem(TRANSLATE);
}
menuManager.get().removePlayerMenuItem(TRANSLATE);
}
keyManager.unregisterKeyListener(this);
@@ -105,9 +118,10 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
{
if (event.getGroup().equals("chattranslation"))
{
updateConfig();
if (event.getKey().equals("playerNames"))
{
for (String names : Text.fromCSV(config.getPlayerNames()))
for (String names : Text.fromCSV(this.getPlayerNames))
{
if (!playerNames.contains(Text.toJagexName(names)))
{
@@ -121,7 +135,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded event)
{
if (!config.translateOptionVisable())
if (!this.translateOptionVisable)
{
return;
}
@@ -131,8 +145,6 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
if (groupId == WidgetInfo.CHATBOX.getGroupId())
{
boolean after;
if (!AFTER_OPTIONS.contains(option))
{
return;
@@ -181,7 +193,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
case PUBLICCHAT:
case MODCHAT:
case FRIENDSCHAT:
if (!config.publicChat())
if (!this.publicChat)
{
return;
}
@@ -201,7 +213,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
try
{
//Automatically check language of message and translate to selected language.
String translation = translator.translate("auto", config.publicTargetLanguage().toString(), message);
String translation = translator.translate("auto", this.publicTargetLanguage.toString(), message);
if (translation != null)
{
final MessageNode messageNode = chatMessage.getMessageNode();
@@ -211,7 +223,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
}
catch (Exception e)
{
e.printStackTrace();
log.warn(e.toString());
}
client.refreshChat();
@@ -227,54 +239,49 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
return;
}
if (!config.playerChat())
if (!this.playerChat)
{
return;
}
Widget chatboxParent = client.getWidget(WidgetInfo.CHATBOX_PARENT);
if (chatboxParent != null && chatboxParent.getOnKeyListener() != null)
if (chatboxParent != null && chatboxParent.getOnKeyListener() != null && event.getKeyCode() == 0xA)
{
if (event.getKeyCode() == 0xA)
Translator translator = new Translator();
String message = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT);
if (message.startsWith("/"))
{
Translator translator = new Translator();
String message = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT);
if (message.startsWith("/"))
{
try
{
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, translator.translate("auto", config.playerTargetLanguage().toString(), message));
}
catch (Exception e)
{
e.printStackTrace();
}
return;
}
event.consume();
try
{
//Automatically check language of message and translate to selected language.
String translation = translator.translate("auto", config.playerTargetLanguage().toString(), message);
if (translation != null)
{
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, translation);
clientThread.invoke(() ->
{
client.runScript(96, 0, translation);
});
}
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, "");
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, translator.translate("auto", config.playerTargetLanguage().toString(), message));
}
catch (Exception e)
{
e.printStackTrace();
log.warn("Translation error", e);
}
return;
}
event.consume();
try
{
//Automatically check language of message and translate to selected language.
String translation = translator.translate("auto", this.playerTargetLanguage.toString(), message);
if (translation != null)
{
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, translation);
clientThread.invoke(() ->
client.runScript(CHATBOX_INPUT, 0, translation));
}
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, "");
}
catch (Exception e)
{
log.warn(e.toString());
}
}
}
@@ -291,4 +298,13 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
// Nothing.
}
private void updateConfig()
{
this.publicChat = config.publicChat();
this.getPlayerNames = config.getPlayerNames();
this.translateOptionVisable = config.translateOptionVisable();
this.publicTargetLanguage = config.publicTargetLanguage();
this.playerChat = config.playerChat();
this.playerTargetLanguage = config.playerTargetLanguage();
}
}

View File

@@ -1,6 +1,7 @@
package net.runelite.client.plugins.chattranslation;
import org.json.JSONArray;
import com.google.gson.JsonArray;
import com.google.gson.JsonParser;
import java.io.BufferedReader;
import java.io.InputStreamReader;
@@ -8,7 +9,7 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
public class Translator
class Translator
{
public String translate(String source, String target, String message) throws Exception
@@ -22,7 +23,7 @@ public class Translator
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null)
{
@@ -33,14 +34,15 @@ public class Translator
return parseResult(response.toString());
}
private String parseResult(String inputJson) throws Exception
private String parseResult(String inputJson)
{
//TODO: find a way to do this using google.gson
JSONArray jsonArray = new JSONArray(inputJson);
JSONArray jsonArray2 = (JSONArray) jsonArray.get(0);
JSONArray jsonArray3 = (JSONArray) jsonArray2.get(0);
String result;
JsonArray jsonArray = new JsonParser().parse(inputJson).getAsJsonArray();
JsonArray jsonArray2 = jsonArray.get(0).getAsJsonArray();
JsonArray jsonArray3 = jsonArray2.get(0).getAsJsonArray();
result = jsonArray3.get(0).toString();
return jsonArray3.get(0).toString();
return result.substring(1, result.length() - 1);
}
}

View File

@@ -26,13 +26,15 @@ package net.runelite.client.plugins.clanchat;
import java.awt.Color;
import java.awt.image.BufferedImage;
import javax.inject.Singleton;
import net.runelite.client.ui.overlay.infobox.Counter;
@Singleton
class ClanChatIndicator extends Counter
{
private final ClanChatPlugin plugin;
ClanChatIndicator(BufferedImage image, ClanChatPlugin plugin)
ClanChatIndicator(final BufferedImage image, final ClanChatPlugin plugin)
{
super(image, plugin, plugin.getClanAmount());
this.plugin = plugin;

View File

@@ -40,6 +40,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.ChatLineBuffer;
import net.runelite.api.ChatMessageType;
import net.runelite.api.ClanMember;
@@ -68,7 +69,6 @@ import net.runelite.api.widgets.WidgetInfo;
import net.runelite.api.widgets.WidgetType;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.chat.ChatMessageBuilder;
import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.game.ClanManager;
@@ -87,6 +87,7 @@ import net.runelite.client.util.Text;
description = "Add rank icons to users talking in clan chat",
tags = {"icons", "rank", "recent"}
)
@Singleton
public class ClanChatPlugin extends Plugin
{
private static final int MAX_CHATS = 20;
@@ -112,9 +113,6 @@ public class ClanChatPlugin extends Plugin
@Inject
private ClientThread clientThread;
@Inject
private ChatMessageManager chatMessageManager;
private List<String> chats = new ArrayList<>();
@@ -123,15 +121,26 @@ public class ClanChatPlugin extends Plugin
return (CopyOnWriteArrayList<Player>) clanMembers.clone();
}
private static CopyOnWriteArrayList<Player> clanMembers = new CopyOnWriteArrayList<>();
private static final CopyOnWriteArrayList<Player> clanMembers = new CopyOnWriteArrayList<>();
private ClanChatIndicator clanMemberCounter;
/**
* queue of temporary messages added to the client
*/
private final Deque<ClanJoinMessage> clanJoinMessages = new ArrayDeque<>();
private Map<String, ClanMemberActivity> activityBuffer = new HashMap<>();
private final Map<String, ClanMemberActivity> activityBuffer = new HashMap<>();
private int clanJoinedTick;
private boolean clanChatIcons;
private boolean recentChats;
private boolean showClanCounter;
private String chatsData;
private boolean showJoinLeave;
private ClanMemberRank joinLeaveRank;
private boolean privateMessageIcons;
private boolean publicChatIcons;
private boolean clanTabChat;
private String clanname;
@Provides
ClanChatConfig getConfig(ConfigManager configManager)
{
@@ -141,7 +150,8 @@ public class ClanChatPlugin extends Plugin
@Override
public void startUp()
{
chats = new ArrayList<>(Text.fromCSV(config.chatsData()));
updateConfig();
chats = new ArrayList<>(Text.fromCSV(this.chatsData));
}
@Override
@@ -157,12 +167,14 @@ public class ClanChatPlugin extends Plugin
{
if (configChanged.getGroup().equals("clanchat"))
{
if (!config.recentChats())
updateConfig();
if (!this.recentChats)
{
resetClanChats();
}
if (config.showClanCounter())
if (this.showClanCounter)
{
clientThread.invoke(this::addClanCounter);
}
@@ -200,8 +212,8 @@ public class ClanChatPlugin extends Plugin
return;
}
if (!config.showJoinLeave() ||
member.getRank().getValue() < config.joinLeaveRank().getValue())
if (!this.showJoinLeave ||
member.getRank().getValue() < this.joinLeaveRank.getValue())
{
return;
}
@@ -245,8 +257,8 @@ public class ClanChatPlugin extends Plugin
}
}
if (!config.showJoinLeave() ||
member.getRank().getValue() < config.joinLeaveRank().getValue())
if (!this.showJoinLeave ||
member.getRank().getValue() < this.joinLeaveRank.getValue())
{
return;
}
@@ -271,7 +283,7 @@ public class ClanChatPlugin extends Plugin
return;
}
client.setVar(VarClientStr.RECENT_CLAN_CHAT, config.clanname());
client.setVar(VarClientStr.RECENT_CLAN_CHAT, this.clanname);
Widget clanChatTitleWidget = client.getWidget(WidgetInfo.CLAN_CHAT_TITLE);
if (clanChatTitleWidget != null)
@@ -282,7 +294,7 @@ public class ClanChatPlugin extends Plugin
{
clanChatTitleWidget.setText(CLAN_CHAT_TITLE + " (" + client.getClanChatCount() + "/100)");
}
else if (config.recentChats() && clanChatList.getChildren() == null && !Strings.isNullOrEmpty(owner.getText()))
else if (this.recentChats && clanChatList.getChildren() == null && !Strings.isNullOrEmpty(owner.getText()))
{
clanChatTitleWidget.setText(RECENT_TITLE);
@@ -290,7 +302,7 @@ public class ClanChatPlugin extends Plugin
}
}
if (!config.showJoinLeave())
if (!this.showJoinLeave)
{
return;
}
@@ -373,7 +385,7 @@ public class ClanChatPlugin extends Plugin
channelColor = CHAT_CLAN_NAME_TRANSPARENT_BACKGROUND;
}
if (config.clanChatIcons() && rank != null && rank != ClanMemberRank.UNRANKED)
if (this.clanChatIcons && rank != null && rank != ClanMemberRank.UNRANKED)
{
rankIcon = clanManager.getIconNumber(rank);
}
@@ -405,7 +417,7 @@ public class ClanChatPlugin extends Plugin
@Subscribe
public void onVarClientStrChanged(VarClientStrChanged strChanged)
{
if (strChanged.getIndex() == VarClientStr.RECENT_CLAN_CHAT.getIndex() && config.recentChats())
if (strChanged.getIndex() == VarClientStr.RECENT_CLAN_CHAT.getIndex() && this.recentChats)
{
updateRecentChat(client.getVar(VarClientStr.RECENT_CLAN_CHAT));
}
@@ -428,20 +440,20 @@ public class ClanChatPlugin extends Plugin
{
case PRIVATECHAT:
case MODPRIVATECHAT:
if (!config.privateMessageIcons())
if (!this.privateMessageIcons)
{
return;
}
break;
case PUBLICCHAT:
case MODCHAT:
if (!config.publicChatIcons())
if (!this.publicChatIcons)
{
return;
}
break;
case FRIENDSCHAT:
if (!config.clanChatIcons())
if (!this.clanChatIcons)
{
return;
}
@@ -473,7 +485,7 @@ public class ClanChatPlugin extends Plugin
final Player local = client.getLocalPlayer();
final Player player = event.getPlayer();
if (player != local && player.isClanMember())
if (player != null && !player.equals(local) && player.isClanMember())
{
clanMembers.add(player);
addClanCounter();
@@ -515,7 +527,7 @@ public class ClanChatPlugin extends Plugin
final int[] intStack = client.getIntStack();
final int size = client.getIntStackSize();
intStack[size - 1] = config.clanTabChat() ? 1 : 0;
intStack[size - 1] = this.clanTabChat ? 1 : 0;
}
int getClanAmount()
@@ -617,7 +629,10 @@ public class ClanChatPlugin extends Plugin
chats.remove(0);
}
config.chatsData(Text.toCSV(chats));
String csvText = Text.toCSV(chats);
config.chatsData(csvText);
this.chatsData = csvText;
}
private void removeClanCounter()
@@ -628,7 +643,7 @@ public class ClanChatPlugin extends Plugin
private void addClanCounter()
{
if (!config.showClanCounter() || clanMemberCounter != null || clanMembers.isEmpty())
if (!this.showClanCounter || clanMemberCounter != null || clanMembers.isEmpty())
{
return;
}
@@ -637,4 +652,18 @@ public class ClanChatPlugin extends Plugin
clanMemberCounter = new ClanChatIndicator(image, this);
infoBoxManager.addInfoBox(clanMemberCounter);
}
private void updateConfig()
{
this.clanChatIcons = config.clanChatIcons();
this.recentChats = config.recentChats();
this.showClanCounter = config.showClanCounter();
this.chatsData = config.chatsData();
this.showJoinLeave = config.showJoinLeave();
this.joinLeaveRank = config.joinLeaveRank();
this.privateMessageIcons = config.privateMessageIcons();
this.publicChatIcons = config.publicChatIcons();
this.clanTabChat = config.clanTabChat();
this.clanname = config.clanname();
}
}

View File

@@ -151,17 +151,6 @@ public interface ClanManModeConfig extends Config
return false;
}
@ConfigItem(
position = 13,
keyName = "hideatkopt",
name = "Hide attack option for clan members",
description = "Disables attack option for clan members"
)
default boolean hideAtkOpt()
{
return false;
}
@ConfigItem(
position = 14,
keyName = "showclanmembers",

View File

@@ -16,12 +16,12 @@ import net.runelite.client.ui.overlay.OverlayUtil;
public class ClanManModeMinimapOverlay extends Overlay
{
private final ClanManModeService ClanManModeService;
private final ClanManModeConfig config;
private final ClanManModePlugin plugin;
@Inject
private ClanManModeMinimapOverlay(ClanManModeConfig config, ClanManModeService ClanManModeService)
private ClanManModeMinimapOverlay(final ClanManModePlugin plugin, final ClanManModeService ClanManModeService)
{
this.config = config;
this.plugin = plugin;
this.ClanManModeService = ClanManModeService;
setLayer(OverlayLayer.ABOVE_WIDGETS);
setPosition(OverlayPosition.DYNAMIC);
@@ -39,7 +39,7 @@ public class ClanManModeMinimapOverlay extends Overlay
{
final String name = actor.getName().replace('\u00A0', ' ');
if (config.drawMinimapNames())
if (plugin.isDrawMinimapNames())
{
final net.runelite.api.Point minimapLocation = actor.getMinimapLocation();

Some files were not shown because too many files have changed in this diff Show More