jewellery count plugin: add ring of recoil breaking notification
This commit is contained in:
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,18 +47,25 @@ import net.runelite.client.util.QueryRunner;
|
|||||||
class JewelleryCountOverlay extends Overlay
|
class JewelleryCountOverlay extends Overlay
|
||||||
{
|
{
|
||||||
private final QueryRunner queryRunner;
|
private final QueryRunner queryRunner;
|
||||||
|
private final JewelleryCountConfig config;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
JewelleryCountOverlay(QueryRunner queryRunner)
|
JewelleryCountOverlay(QueryRunner queryRunner, JewelleryCountConfig config)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
||||||
this.queryRunner = queryRunner;
|
this.queryRunner = queryRunner;
|
||||||
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension render(Graphics2D graphics)
|
public Dimension render(Graphics2D graphics)
|
||||||
{
|
{
|
||||||
|
if (!config.showJewelleryCount())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
graphics.setFont(FontManager.getRunescapeSmallFont());
|
graphics.setFont(FontManager.getRunescapeSmallFont());
|
||||||
|
|
||||||
for (WidgetItem item : getJewelleryWidgetItems())
|
for (WidgetItem item : getJewelleryWidgetItems())
|
||||||
|
|||||||
@@ -25,9 +25,16 @@
|
|||||||
package net.runelite.client.plugins.jewellerycount;
|
package net.runelite.client.plugins.jewellerycount;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import net.runelite.api.ChatMessageType;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
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(
|
@PluginDescriptor(
|
||||||
name = "Jewellery Count"
|
name = "Jewellery Count"
|
||||||
@@ -37,9 +44,33 @@ public class JewelleryCountPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private JewelleryCountOverlay overlay;
|
private JewelleryCountOverlay overlay;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Notifier notifier;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private JewelleryCountConfig config;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Overlay getOverlay()
|
public Overlay getOverlay()
|
||||||
{
|
{
|
||||||
return overlay;
|
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("<col=7f007f>Your Ring of Recoil has shattered.</col>"))
|
||||||
|
{
|
||||||
|
notifier.notify("Your Ring of Recoil has shattered");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user