Remove binding necklace from Runecraft plugin

This commit is contained in:
TheStonedTurtle
2019-02-21 10:03:13 -08:00
committed by TheStonedTurtle
parent 4b91ae53df
commit c0563ac3e3
3 changed files with 0 additions and 186 deletions

View File

@@ -1,107 +0,0 @@
/*
* Copyright (c) 2017, Seth <Sethtroll3@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.runecraft;
import static net.runelite.api.ItemID.BINDING_NECKLACE;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import javax.inject.Inject;
import net.runelite.api.Query;
import net.runelite.api.queries.EquipmentItemQuery;
import net.runelite.api.queries.InventoryWidgetItemQuery;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.api.widgets.WidgetItem;
import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.TextComponent;
import net.runelite.client.util.QueryRunner;
public class BindNeckOverlay extends Overlay
{
private final QueryRunner queryRunner;
private final RunecraftConfig config;
int bindingCharges;
@Inject
BindNeckOverlay(QueryRunner queryRunner, RunecraftConfig config)
{
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ABOVE_WIDGETS);
this.queryRunner = queryRunner;
this.config = config;
}
@Override
public Dimension render(Graphics2D graphics)
{
if (!config.showBindNeck())
{
return null;
}
graphics.setFont(FontManager.getRunescapeSmallFont());
for (WidgetItem necklace : getNecklaceWidgetItems())
{
final Color color = bindingCharges == 1 ? Color.RED : Color.WHITE;
final Rectangle bounds = necklace.getCanvasBounds();
final String text = bindingCharges <= 0 ? "?" : bindingCharges + "";
final TextComponent textComponent = new TextComponent();
textComponent.setPosition(new Point(bounds.x, bounds.y + 16));
textComponent.setText(text);
textComponent.setColor(color);
textComponent.render(graphics);
}
return null;
}
private Collection<WidgetItem> getNecklaceWidgetItems()
{
Query inventoryQuery = new InventoryWidgetItemQuery()
.idEquals(BINDING_NECKLACE);
WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
Query equipmentQuery = new EquipmentItemQuery()
.slotEquals(WidgetInfo.EQUIPMENT_AMULET)
.idEquals(BINDING_NECKLACE);
WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
Collection<WidgetItem> necklaces = new ArrayList<>();
necklaces.addAll(Arrays.asList(inventoryWidgetItems));
necklaces.addAll(Arrays.asList(equipmentWidgetItems));
return necklaces;
}
}

View File

@@ -32,17 +32,6 @@ import net.runelite.client.config.ConfigItem;
@ConfigGroup("runecraft")
public interface RunecraftConfig extends Config
{
@ConfigItem(
keyName = "showBindNeck",
name = "Show Binding Neck charges",
description = "Configures whether the binding neck charge is displayed",
position = 2
)
default boolean showBindNeck()
{
return true;
}
@ConfigItem(
keyName = "showRifts",
name = "Show Rifts in Abyss",

View File

@@ -29,8 +29,6 @@ import com.google.inject.Provides;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import javax.inject.Inject;
import lombok.AccessLevel;
@@ -50,11 +48,8 @@ import net.runelite.api.events.DecorativeObjectDespawned;
import net.runelite.api.events.DecorativeObjectSpawned;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.ItemContainerChanged;
import net.runelite.api.events.MenuOptionClicked;
import net.runelite.api.events.NpcDespawned;
import net.runelite.api.events.NpcSpawned;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.Notifier;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
@@ -69,10 +64,8 @@ import net.runelite.client.ui.overlay.OverlayManager;
)
public class RunecraftPlugin extends Plugin
{
private static Pattern bindNeckString = Pattern.compile("You have ([0-9]+|one) charges? left before your Binding necklace disintegrates.");
private static final String POUCH_DECAYED_NOTIFICATION_MESSAGE = "Your rune pouch has decayed.";
private static final String POUCH_DECAYED_MESSAGE = "Your pouch has decayed through use.";
private static final int DESTROY_ITEM_WIDGET_ID = WidgetInfo.DESTROY_ITEM_YES.getId();
private static final List<Integer> DEGRADED_POUCHES = ImmutableList.of(
ItemID.MEDIUM_POUCH_5511,
ItemID.LARGE_POUCH_5513,
@@ -94,9 +87,6 @@ public class RunecraftPlugin extends Plugin
@Inject
private OverlayManager overlayManager;
@Inject
private BindNeckOverlay bindNeckOverlay;
@Inject
private AbyssOverlay abyssOverlay;
@@ -115,7 +105,6 @@ public class RunecraftPlugin extends Plugin
@Override
protected void startUp() throws Exception
{
overlayManager.add(bindNeckOverlay);
overlayManager.add(abyssOverlay);
abyssOverlay.updateConfig();
}
@@ -123,7 +112,6 @@ public class RunecraftPlugin extends Plugin
@Override
protected void shutDown() throws Exception
{
overlayManager.remove(bindNeckOverlay);
overlayManager.remove(abyssOverlay);
abyssObjects.clear();
darkMage = null;
@@ -144,71 +132,15 @@ public class RunecraftPlugin extends Plugin
return;
}
if (config.showBindNeck())
{
Matcher match = bindNeckString.matcher(event.getMessage());
if (match.find())
{
if (match.group(1).equals("one"))
{
bindNeckOverlay.bindingCharges = 1;
}
else
{
bindNeckOverlay.bindingCharges = Integer.parseInt(match.group(1));
}
return;
}
if (event.getMessage().contains("You bind the temple's power"))
{
if (event.getMessage().contains("mud")
|| event.getMessage().contains("lava")
|| event.getMessage().contains("steam")
|| event.getMessage().contains("dust")
|| event.getMessage().contains("smoke")
|| event.getMessage().contains("mist"))
{
bindNeckOverlay.bindingCharges -= 1;
return;
}
}
if (event.getMessage().contains("Your Binding necklace has disintegrated."))
{
//set it to 17 because this message is triggered first before the above chat event
bindNeckOverlay.bindingCharges = 17;
return;
}
}
if (config.degradingNotification())
{
if (event.getMessage().contains(POUCH_DECAYED_MESSAGE))
{
notifier.notify(POUCH_DECAYED_NOTIFICATION_MESSAGE);
return;
}
}
}
@Subscribe
public void onMenuOptionClicked(MenuOptionClicked event)
{
if (event.getWidgetId() != DESTROY_ITEM_WIDGET_ID)
{
return;
}
Widget widgetDestroyItemName = client.getWidget(WidgetInfo.DESTROY_ITEM_NAME);
if (widgetDestroyItemName == null || !widgetDestroyItemName.getText().equals("Binding necklace"))
{
return;
}
bindNeckOverlay.bindingCharges = 16;
}
@Subscribe
public void onDecorativeObjectSpawned(DecorativeObjectSpawned event)
{