From 9524f6fb1b0d8e7dc49e19cbd8fd35a9b361c8d1 Mon Sep 17 00:00:00 2001 From: rune3132 Date: Mon, 9 Apr 2018 22:00:04 +0200 Subject: [PATCH] jewellery count plugin: add ring of recoil breaking notification --- .../jewellerycount/JewelleryCountConfig.java | 59 +++++++++++++++++++ .../jewellerycount/JewelleryCountOverlay.java | 9 ++- .../jewellerycount/JewelleryCountPlugin.java | 35 ++++++++++- 3 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/jewellerycount/JewelleryCountConfig.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/jewellerycount/JewelleryCountConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/jewellerycount/JewelleryCountConfig.java new file mode 100644 index 0000000000..bb9b4186ab --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/jewellerycount/JewelleryCountConfig.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2017, Devin French + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.jewellerycount; + +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup( + keyName = "jewelleryCount", + name = "Jewellery Count", + description = "Configuration for the Jewellery count plugin" +) +public interface JewelleryCountConfig extends Config +{ + @ConfigItem( + keyName = "showJewelleryCount", + name = "Show Jewellery Count Configuration", + description = "Configures if jewellery count is shown", + position = 1 + ) + default boolean showJewelleryCount() + { + return true; + } + + @ConfigItem( + keyName = "recoilNotification", + name = "Ring of Recoil Notification", + description = "Configures if the ring of recoil breaking notification is shown", + position = 2 + ) + default boolean recoilNotification() + { + return false; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/jewellerycount/JewelleryCountOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/jewellerycount/JewelleryCountOverlay.java index 22e9a4f055..e0818303e3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/jewellerycount/JewelleryCountOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/jewellerycount/JewelleryCountOverlay.java @@ -47,18 +47,25 @@ import net.runelite.client.util.QueryRunner; class JewelleryCountOverlay extends Overlay { private final QueryRunner queryRunner; + private final JewelleryCountConfig config; @Inject - JewelleryCountOverlay(QueryRunner queryRunner) + JewelleryCountOverlay(QueryRunner queryRunner, JewelleryCountConfig config) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); this.queryRunner = queryRunner; + this.config = config; } @Override public Dimension render(Graphics2D graphics) { + if (!config.showJewelleryCount()) + { + return null; + } + graphics.setFont(FontManager.getRunescapeSmallFont()); for (WidgetItem item : getJewelleryWidgetItems()) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/jewellerycount/JewelleryCountPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/jewellerycount/JewelleryCountPlugin.java index e144b9229b..5827090926 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/jewellerycount/JewelleryCountPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/jewellerycount/JewelleryCountPlugin.java @@ -25,9 +25,16 @@ package net.runelite.client.plugins.jewellerycount; import javax.inject.Inject; +import net.runelite.api.ChatMessageType; import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.overlay.Overlay; +import com.google.common.eventbus.Subscribe; +import com.google.inject.Provides; +import javax.inject.Inject; +import net.runelite.api.events.ChatMessage; +import net.runelite.client.Notifier; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.plugins.PluginDescriptor; @PluginDescriptor( name = "Jewellery Count" @@ -37,9 +44,33 @@ public class JewelleryCountPlugin extends Plugin @Inject private JewelleryCountOverlay overlay; + @Inject + private Notifier notifier; + + @Inject + private JewelleryCountConfig config; + @Override public Overlay getOverlay() { return overlay; } -} + + @Provides + JewelleryCountConfig getConfig(ConfigManager configManager) + { + return configManager.getConfig(JewelleryCountConfig.class); + } + + @Subscribe + public void onChatMessage(ChatMessage event) + { + if (event.getType() == ChatMessageType.SERVER) + { + if (config.recoilNotification() && event.getMessage().contains("Your Ring of Recoil has shattered.")) + { + notifier.notify("Your Ring of Recoil has shattered"); + } + } + } +} \ No newline at end of file