From 3d88a00839c347b082832def5cbda78079edd761 Mon Sep 17 00:00:00 2001 From: Lucwousin Date: Tue, 21 May 2019 02:24:25 +0200 Subject: [PATCH] Remove Musicmodifier + quest & a lot of findbugs catches (#335) * Remove Musicmodifier + quest & a lot of findbugs catches * fix imports --- .../java/net/runelite/client/flexo/Flexo.java | 11 +- .../client/plugins/ammo/AmmoCounter.java | 11 +- .../BarbarianAssaultOverlay.java | 2 +- .../client/plugins/batools/BAToolsPlugin.java | 4 +- .../blastfurnace/BlastFurnaceOverlay.java | 3 +- .../devtools/WorldMapRegionOverlay.java | 2 +- .../plugins/fightcave/TimersOverlay.java | 44 +-- .../groundmarkers/GroundMarkerPlugin.java | 4 +- .../client/plugins/minimap/MinimapDot.java | 4 +- .../plugins/mta/alchemy/AlchemyRoom.java | 6 +- .../plugins/mta/graveyard/GraveyardRoom.java | 3 +- .../musicmodifier/MidiFileAdjuster.java | 202 ---------- .../musicmodifier/MusicCustomizerPlugin.java | 363 ------------------ .../musicmodifier/RealTimeMIDIPlayer.java | 282 -------------- .../plugins/pestcontrol/HintArrowOverlay.java | 1 - .../pestcontrol/PestControlPlugin.java | 17 +- .../pestcontrol/PortalWeaknessOverlay.java | 5 +- .../plugins/questhelper/ItemRequirement.java | 87 ----- .../plugins/questhelper/QuestDescriptor.java | 38 -- .../plugins/questhelper/QuestHelper.java | 143 ------- .../questhelper/QuestHelperOverlay.java | 70 ---- .../questhelper/QuestHelperPlugin.java | 265 ------------- .../questhelper/QuestHelperWorldMapPoint.java | 74 ---- .../questhelper/QuestHelperWorldOverlay.java | 66 ---- .../QuestInstantiationException.java | 34 -- .../quests/cooksassistant/CooksAssistant.java | 58 --- .../quests/impcatcher/ImpCatcher.java | 58 --- .../quests/xmarksthespot/XMarksTheSpot.java | 80 ---- .../plugins/questhelper/steps/DigStep.java | 124 ------ .../questhelper/steps/NpcTalkStep.java | 158 -------- .../plugins/questhelper/steps/QuestStep.java | 85 ---- .../plugins/runedoku/RunedokuOverlay.java | 12 +- .../client/plugins/slayer/SlayerPlugin.java | 63 ++- .../tearsofguthix/TearsOfGuthixPlugin.java | 4 +- .../tickcounter/TickCounterPlugin.java | 7 +- .../plugins/vanguards/VanguardOverlay.java | 60 +-- .../whalewatchers/WhaleWatchersOverlay.java | 9 +- .../client/plugins/wiki/WikiPlugin.java | 6 +- .../client/plugins/worldhopper/ping/Ping.java | 8 +- .../client/plugins/ztob/TheatrePlugin.java | 2 +- .../net/runelite/client/util/PvPUtil.java | 1 - .../net/runelite/client/util/ping/Ping.java | 8 +- 42 files changed, 123 insertions(+), 2361 deletions(-) delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/musicmodifier/MidiFileAdjuster.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/musicmodifier/MusicCustomizerPlugin.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/musicmodifier/RealTimeMIDIPlayer.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/questhelper/ItemRequirement.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestDescriptor.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelper.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelperOverlay.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelperPlugin.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelperWorldMapPoint.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelperWorldOverlay.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestInstantiationException.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/questhelper/quests/cooksassistant/CooksAssistant.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/questhelper/quests/impcatcher/ImpCatcher.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/questhelper/quests/xmarksthespot/XMarksTheSpot.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/questhelper/steps/DigStep.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/questhelper/steps/NpcTalkStep.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/questhelper/steps/QuestStep.java diff --git a/runelite-client/src/main/java/net/runelite/client/flexo/Flexo.java b/runelite-client/src/main/java/net/runelite/client/flexo/Flexo.java index bb810d69a8..0f7a02d3dc 100644 --- a/runelite-client/src/main/java/net/runelite/client/flexo/Flexo.java +++ b/runelite-client/src/main/java/net/runelite/client/flexo/Flexo.java @@ -59,13 +59,12 @@ public class Flexo extends Robot public static double scale; public static Client client; public static ClientUI clientUI; - public static int fixedWidth = Constants.GAME_FIXED_WIDTH; - public static int fixedHeight = Constants.GAME_FIXED_HEIGHT; + public static final int fixedWidth = Constants.GAME_FIXED_WIDTH; + public static final int fixedHeight = Constants.GAME_FIXED_HEIGHT; public static boolean isStretched; public static int minDelay = 45; public static MouseMotionFactory currentMouseMotionFactory; public boolean pausedIndefinitely = false; - private Thread holdKeyThread; private RobotPeer peer; public Flexo() throws AWTException @@ -143,7 +142,6 @@ public class Flexo extends Robot public synchronized void mouseMove(Point p) { - Point p2 = p; mouseMove((int) p.getX(), (int) p.getY()); try { @@ -293,7 +291,7 @@ public class Flexo extends Robot public synchronized void holdKeyIndefinitely(int keycode) { - holdKeyThread = new Thread(() -> + Thread holdKeyThread = new Thread(() -> { pausedIndefinitely = true; peer.keyPress(keycode); @@ -318,8 +316,7 @@ public class Flexo extends Robot @Override public Color getPixelColor(int x, int y) { - Color color = new Color(peer.getRGBPixel(x, y)); - return color; + return new Color(peer.getRGBPixel(x, y)); } @Override diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoCounter.java b/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoCounter.java index 1856b24e2c..a9a25512a4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoCounter.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoCounter.java @@ -42,9 +42,6 @@ class AmmoCounter extends Counter private int total; private Instant time; private BigDecimal ammoPerHour; - private BigDecimal timeSinceStartInHours; - private BigDecimal timeSinceStart; - private BigDecimal diff; AmmoCounter(Plugin plugin, int itemID, int count, String name, BufferedImage image) { @@ -74,14 +71,14 @@ class AmmoCounter extends Counter } } - int lossRate() + private int lossRate() { - diff = BigDecimal.valueOf(total).subtract(BigDecimal.valueOf(getCount())); - timeSinceStart = BigDecimal.valueOf(Duration.between(time, Instant.now()).getSeconds()) + BigDecimal diff = BigDecimal.valueOf(total).subtract(BigDecimal.valueOf(getCount())); + BigDecimal timeSinceStart = BigDecimal.valueOf(Duration.between(time, Instant.now()).getSeconds()) .setScale(6, RoundingMode.UP); if (timeSinceStart.compareTo(BigDecimal.ZERO) != 0) { - timeSinceStartInHours = timeSinceStart.divide(BigDecimal.valueOf(3600), RoundingMode.UP); + BigDecimal timeSinceStartInHours = timeSinceStart.divide(BigDecimal.valueOf(3600), RoundingMode.UP); ammoPerHour = diff.divide(timeSinceStartInHours, RoundingMode.HALF_UP); } if (ammoPerHour != null) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultOverlay.java index 6e4ab20dcf..98ab9da951 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultOverlay.java @@ -60,7 +60,7 @@ import net.runelite.client.util.ImageUtil; class BarbarianAssaultOverlay extends Overlay { private static final int MAX_EGG_DISTANCE = 2500; - private final int HEALTH_BAR_HEIGHT = 20; + private static final int HEALTH_BAR_HEIGHT = 20; private final Color HEALTH_BAR_COLOR = new Color(225, 35, 0, 125); private static final Color BACKGROUND = new Color(0, 0, 0, 150); private static final int OFFSET_Z = 20; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsPlugin.java index 59c968c53e..391834c0ef 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/batools/BAToolsPlugin.java @@ -758,8 +758,8 @@ public class BAToolsPlugin extends Plugin implements KeyListener private static WorldPoint rotate(WorldPoint point, int rotation) { - int chunkX = point.getX() & ~(CHUNK_SIZE - 1); - int chunkY = point.getY() & ~(CHUNK_SIZE - 1); + int chunkX = point.getX() & -CHUNK_SIZE; + int chunkY = point.getY() & -CHUNK_SIZE; int x = point.getX() & (CHUNK_SIZE - 1); int y = point.getY() & (CHUNK_SIZE - 1); switch (rotation) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceOverlay.java index 48253cdfe3..0d17c94bb7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceOverlay.java @@ -86,7 +86,6 @@ class BlastFurnaceOverlay extends Overlay private BufferedImage getImage(int itemID, int amount) { - BufferedImage image = itemManager.getImage(itemID, amount, true); - return image; + return itemManager.getImage(itemID, amount, true); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WorldMapRegionOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WorldMapRegionOverlay.java index 1e136267b8..009a448092 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WorldMapRegionOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WorldMapRegionOverlay.java @@ -47,7 +47,7 @@ class WorldMapRegionOverlay extends Overlay private static final int LABEL_PADDING = 4; private static final int REGION_SIZE = 1 << 6; // Bitmask to return first coordinate in region - private static final int REGION_TRUNCATE = ~((1 << 6) - 1); + private static final int REGION_TRUNCATE = -(1 << 6); private final Client client; private final DevToolsPlugin plugin; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/TimersOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/TimersOverlay.java index f609cacab1..e077d5ce54 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/TimersOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/TimersOverlay.java @@ -48,7 +48,6 @@ public class TimersOverlay extends Overlay { private FightCavePlugin plugin; private Client client; - private Color tickcolor = new Color(255, 255, 255, 255); @Inject TimersOverlay(FightCavePlugin plugin, Client client) @@ -65,87 +64,88 @@ public class TimersOverlay extends Overlay { for (NPCContainer npc : plugin.getDrainers().values()) { - renderNpcOverlay(graphics, npc.getNpc(), new Color(255, 0, 0, 255), 2, 255, 20); + renderNpcOverlay(graphics, npc.getNpc(), Color.RED, 255, 20); String str = "drainer"; Point canvasPoint = npc.getNpc().getCanvasTextLocation(graphics, str, 0); - renderTextLocation(graphics, str, 12, Font.BOLD, new Color(255, 255, 255, 255), canvasPoint); + renderTextLocation(graphics, str, 12, Color.WHITE, canvasPoint); } for (NPCContainer npc : plugin.getIgnore().values()) { - renderNpcOverlay(graphics, npc.getNpc(), new Color(0, 0, 0, 255), 2, 50, 5); + renderNpcOverlay(graphics, npc.getNpc(), Color.BLACK, 50, 5); String str = "ignore"; Point canvasPoint = npc.getNpc().getCanvasTextLocation(graphics, str, 0); - renderTextLocation(graphics, str, 10, Font.BOLD, new Color(255, 255, 255, 255), canvasPoint); + renderTextLocation(graphics, str, 10, Color.WHITE, canvasPoint); } + Color tickcolor; + for (NPCContainer npc : plugin.getRangers().values()) { - renderNpcOverlay(graphics, npc.getNpc(), new Color(0, 255, 0, 255), 2, 100, 10); + renderNpcOverlay(graphics, npc.getNpc(), Color.GREEN, 100, 10); final int ticksLeft = npc.getTicksUntilAttack(); if (ticksLeft > 0) { if (ticksLeft == 1) { - tickcolor = new Color(0, 255, 0, 255); + tickcolor = Color.GREEN; } else { - - tickcolor = new Color(255, 255, 255, 255); + tickcolor = Color.WHITE; } final String ticksLeftStr = String.valueOf(ticksLeft); Point canvasPoint = npc.getNpc().getCanvasTextLocation(graphics, ticksLeftStr, 0); - renderTextLocation(graphics, ticksLeftStr, 32, Font.BOLD, tickcolor, canvasPoint); + renderTextLocation(graphics, ticksLeftStr, 32, tickcolor, canvasPoint); } } for (NPCContainer npc : plugin.getMagers().values()) { - renderNpcOverlay(graphics, npc.getNpc(), new Color(0, 255, 255, 255), 2, 100, 10); + renderNpcOverlay(graphics, npc.getNpc(), Color.CYAN, 100, 10); final int ticksLeft = npc.getTicksUntilAttack(); if (ticksLeft > 0) { if (ticksLeft == 1) { - tickcolor = new Color(0, 255, 255, 255); + tickcolor = Color.CYAN; } else { - tickcolor = new Color(255, 255, 255, 255); + tickcolor = Color.WHITE; } final String ticksLeftStr = String.valueOf(ticksLeft); Point canvasPoint = npc.getNpc().getCanvasTextLocation(graphics, ticksLeftStr, 0); - renderTextLocation(graphics, ticksLeftStr, 32, Font.BOLD, tickcolor, canvasPoint); + renderTextLocation(graphics, ticksLeftStr, 32, tickcolor, canvasPoint); } } for (NPCContainer npc : plugin.getMeleers().values()) { - renderNpcOverlay(graphics, npc.getNpc(), new Color(255, 0, 0, 255), 2, 100, 10); + renderNpcOverlay(graphics, npc.getNpc(), Color.RED, 100, 10); final int ticksLeft = npc.getTicksUntilAttack(); if (ticksLeft > 0) { if (ticksLeft == 1) { - tickcolor = new Color(255, 0, 0, 255); + tickcolor = Color.RED; } else { - tickcolor = new Color(255, 255, 255, 255); + tickcolor = Color.WHITE; } final String ticksLeftStr = String.valueOf(ticksLeft); Point canvasPoint = npc.getNpc().getCanvasTextLocation(graphics, ticksLeftStr, 0); - renderTextLocation(graphics, ticksLeftStr, 32, Font.BOLD, tickcolor, canvasPoint); + renderTextLocation(graphics, ticksLeftStr, 32, tickcolor, canvasPoint); } } return null; } - private void renderNpcOverlay(Graphics2D graphics, NPC actor, Color color, int outlineWidth, int outlineAlpha, int fillAlpha) + private void renderNpcOverlay(Graphics2D graphics, NPC actor, Color color, int outlineAlpha, int fillAlpha) { int size = 1; NPCComposition composition = actor.getTransformedComposition(); @@ -159,16 +159,16 @@ public class TimersOverlay extends Overlay if (tilePoly != null) { graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), outlineAlpha)); - graphics.setStroke(new BasicStroke(outlineWidth)); + graphics.setStroke(new BasicStroke(2)); graphics.draw(tilePoly); graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), fillAlpha)); graphics.fill(tilePoly); } } - private void renderTextLocation(Graphics2D graphics, String txtString, int fontSize, int fontStyle, Color fontColor, Point canvasPoint) + private void renderTextLocation(Graphics2D graphics, String txtString, int fontSize, Color fontColor, Point canvasPoint) { - graphics.setFont(new Font("Arial", fontStyle, fontSize)); + graphics.setFont(new Font("Arial", Font.BOLD, fontSize)); if (canvasPoint != null) { final Point canvasCenterPoint = new Point( diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerPlugin.java index e1282fd160..73818c8154 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerPlugin.java @@ -234,8 +234,8 @@ public class GroundMarkerPlugin extends Plugin */ private static WorldPoint rotate(WorldPoint point, int rotation) { - int chunkX = point.getX() & ~(CHUNK_SIZE - 1); - int chunkY = point.getY() & ~(CHUNK_SIZE - 1); + int chunkX = point.getX() & -CHUNK_SIZE; + int chunkY = point.getY() & -CHUNK_SIZE; int x = point.getX() & (CHUNK_SIZE - 1); int y = point.getY() & (CHUNK_SIZE - 1); switch (rotation) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/minimap/MinimapDot.java b/runelite-client/src/main/java/net/runelite/client/plugins/minimap/MinimapDot.java index 01d95312d9..ddcd2a8248 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/minimap/MinimapDot.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/minimap/MinimapDot.java @@ -71,8 +71,6 @@ public class MinimapDot { int[] pixels = createPixels(color); - SpritePixels dotSprite = client.createSpritePixels(pixels, MAP_DOT_WIDTH, MAP_DOT_HEIGHT); - - return dotSprite; + return client.createSpritePixels(pixels, MAP_DOT_WIDTH, MAP_DOT_HEIGHT); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mta/alchemy/AlchemyRoom.java b/runelite-client/src/main/java/net/runelite/client/plugins/mta/alchemy/AlchemyRoom.java index d76c24a838..e68e4797d3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mta/alchemy/AlchemyRoom.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mta/alchemy/AlchemyRoom.java @@ -460,14 +460,14 @@ public class AlchemyRoom extends MTARoom continue; } - drawItem(graphics, item, Color.GREEN); + drawItem(graphics, item); } } - private void drawItem(Graphics2D graphics, WidgetItem item, Color border) + private void drawItem(Graphics2D graphics, WidgetItem item) { Rectangle bounds = item.getCanvasBounds(); - graphics.setColor(border); + graphics.setColor(Color.GREEN); graphics.draw(bounds); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mta/graveyard/GraveyardRoom.java b/runelite-client/src/main/java/net/runelite/client/plugins/mta/graveyard/GraveyardRoom.java index 89956cf89c..c54773fd6b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mta/graveyard/GraveyardRoom.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mta/graveyard/GraveyardRoom.java @@ -54,7 +54,6 @@ public class GraveyardRoom extends MTARoom private final MTAPlugin plugin; private final ItemManager itemManager; private final InfoBoxManager infoBoxManager; - private int score; private GraveyardCounter counter; @@ -102,7 +101,7 @@ public class GraveyardRoom extends MTARoom if (container == client.getItemContainer(InventoryID.INVENTORY)) { - this.score = score(container.getItems()); + int score = score(container.getItems()); if (counter == null) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/musicmodifier/MidiFileAdjuster.java b/runelite-client/src/main/java/net/runelite/client/plugins/musicmodifier/MidiFileAdjuster.java deleted file mode 100644 index ea2b61252d..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/musicmodifier/MidiFileAdjuster.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (c) 2019, Rodolfo Ruiz-Velasco - * 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.musicmodifier; - -import java.io.IOException; -import javax.sound.midi.InvalidMidiDataException; -import javax.sound.midi.MidiEvent; -import javax.sound.midi.MidiMessage; -import javax.sound.midi.Sequence; -import javax.sound.midi.ShortMessage; -import javax.sound.midi.Track; - -public class MidiFileAdjuster -{ - - private int bankLSBValue; - private int chPosition = -1; - - private boolean customBank = false; - - public Sequence reorderTracks(Sequence sequence) throws InvalidMidiDataException, IOException - { - for (Track track : sequence.getTracks()) - { - for (int i = 0; i < track.size(); i++) - { - MidiEvent midiEvent = track.get(i); - MidiMessage midiMessage = midiEvent.getMessage(); - - if (midiMessage instanceof ShortMessage) - { - ShortMessage sm = (ShortMessage) midiMessage; - - if (sm.getChannel() < 16) - { - getBankLSB(sm); - - if (i == 0 & bankLSBValue != 1) - { - chPosition++; - if (chPosition == 9) - { - chPosition = 10; - } - } - - if (!customBank) - { - - if (sm.getChannel() == 9) - { - bankLSBValue = 1; - } - - if (sm.getChannel() != 9) - { - bankLSBValue = 0; - } - } - } - - if (bankLSBValue == 1) - { - - int drumChannel = 9; - if (sm.getCommand() == ShortMessage.PROGRAM_CHANGE) - { - sm.setMessage(ShortMessage.PROGRAM_CHANGE, drumChannel, sm.getData1(), sm.getData2()); - } - - if (sm.getCommand() == ShortMessage.CONTROL_CHANGE) - { - sm.setMessage(ShortMessage.CONTROL_CHANGE, drumChannel, sm.getData1(), sm.getData2()); - } - - if (sm.getCommand() == ShortMessage.NOTE_OFF) - { - sm.setMessage(ShortMessage.NOTE_OFF, drumChannel, sm.getData1(), sm.getData2()); - } - - if (sm.getCommand() == ShortMessage.NOTE_ON) - { - sm.setMessage(ShortMessage.NOTE_ON, drumChannel, sm.getData1(), sm.getData2()); - } - - if (sm.getCommand() == ShortMessage.PROGRAM_CHANGE) - { - sm.setMessage(ShortMessage.PROGRAM_CHANGE, drumChannel, sm.getData1(), sm.getData2()); - } - - if (sm.getCommand() == ShortMessage.CONTROL_CHANGE) - { - sm.setMessage(ShortMessage.CONTROL_CHANGE, drumChannel, sm.getData1(), sm.getData2()); - } - - if (sm.getCommand() == ShortMessage.PITCH_BEND) - { - sm.setMessage(ShortMessage.PITCH_BEND, drumChannel, sm.getData1(), sm.getData2()); - } - - if (sm.getCommand() == ShortMessage.CHANNEL_PRESSURE) - { - sm.setMessage(ShortMessage.CHANNEL_PRESSURE, drumChannel, sm.getData1(), sm.getData2()); - } - - if (sm.getCommand() == ShortMessage.POLY_PRESSURE) - { - sm.setMessage(ShortMessage.POLY_PRESSURE, drumChannel, sm.getData1(), sm.getData2()); - } - } - else - { - - if (sm.getCommand() == ShortMessage.PROGRAM_CHANGE) - { - sm.setMessage(ShortMessage.PROGRAM_CHANGE, chPosition, sm.getData1(), sm.getData2()); - } - - if (sm.getCommand() == ShortMessage.CONTROL_CHANGE) - { - sm.setMessage(ShortMessage.CONTROL_CHANGE, chPosition, sm.getData1(), sm.getData2()); - } - - if (sm.getCommand() == ShortMessage.NOTE_OFF) - { - sm.setMessage(ShortMessage.NOTE_OFF, chPosition, sm.getData1(), sm.getData2()); - } - - if (sm.getCommand() == ShortMessage.NOTE_ON) - { - sm.setMessage(ShortMessage.NOTE_ON, chPosition, sm.getData1(), sm.getData2()); - } - - if (sm.getCommand() == ShortMessage.PROGRAM_CHANGE) - { - sm.setMessage(ShortMessage.PROGRAM_CHANGE, chPosition, sm.getData1(), sm.getData2()); - } - - if (sm.getCommand() == ShortMessage.CONTROL_CHANGE) - { - sm.setMessage(ShortMessage.CONTROL_CHANGE, chPosition, sm.getData1(), sm.getData2()); - } - - if (sm.getCommand() == ShortMessage.PITCH_BEND) - { - sm.setMessage(ShortMessage.PITCH_BEND, chPosition, sm.getData1(), sm.getData2()); - } - - if (sm.getCommand() == ShortMessage.CHANNEL_PRESSURE) - { - sm.setMessage(ShortMessage.CHANNEL_PRESSURE, chPosition, sm.getData1(), sm.getData2()); - } - - if (sm.getCommand() == ShortMessage.POLY_PRESSURE) - { - sm.setMessage(ShortMessage.POLY_PRESSURE, chPosition, sm.getData1(), sm.getData2()); - } - } - } - } - } - return sequence; - } - - private void getBankLSB(ShortMessage sm) throws InvalidMidiDataException - { - if (sm.getCommand() == ShortMessage.CONTROL_CHANGE) - { - if (sm.getData1() == 32) - { - bankLSBValue = sm.getData2(); - customBank = true; - } - if (sm.getData1() == 0) - { - sm.setMessage(sm.getCommand(), sm.getChannel(), sm.getData1(), bankLSBValue); - } - } - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/musicmodifier/MusicCustomizerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/musicmodifier/MusicCustomizerPlugin.java deleted file mode 100644 index 91d877d303..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/musicmodifier/MusicCustomizerPlugin.java +++ /dev/null @@ -1,363 +0,0 @@ -/* - * Copyright (c) 2019, Rodolfo Ruiz-Velasco - * 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.musicmodifier; - -import java.io.File; -import javax.inject.Inject; -import net.runelite.api.Client; -import net.runelite.api.SpriteID; -import net.runelite.api.events.GameTick; -import net.runelite.api.events.WidgetLoaded; -import net.runelite.api.widgets.JavaScriptCallback; -import net.runelite.api.widgets.Widget; -import net.runelite.api.widgets.WidgetID; -import net.runelite.api.widgets.WidgetInfo; -import net.runelite.api.widgets.WidgetPositionMode; -import net.runelite.api.widgets.WidgetType; -import net.runelite.client.callback.ClientThread; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.game.chatbox.ChatboxPanelManager; -import net.runelite.client.game.chatbox.ChatboxTextInput; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.plugins.PluginType; - -@PluginDescriptor( - name = "Music Track Customizer", - description = "Customize what track plays and how it sounds, with local files", - tags = {"music", "sound"}, - type = PluginType.UTILITY, - enabledByDefault = false -) - -public class MusicCustomizerPlugin extends Plugin -{ - - @Inject - private Client client; - - @Inject - private ChatboxPanelManager chatboxPanelManager; - - @Inject - private ClientThread clientThread; - - private RealTimeMIDIPlayer realTimeMIDIPlayer = new RealTimeMIDIPlayer(); - - private String songName = "Scape Main"; - - private ChatboxTextInput songInput; - - private Widget playlistModeButton; - - private Widget playlistBox; - - private Widget hidePlaylistButton; - - private Widget addPlaylistSongButton; - - private Widget playlistText; - - private Widget playlistSong; - - private String defaultUnlockedSongs; - - private boolean isLooping = true; - - private boolean playlistMode = false; - - private int newSongY = 34; - - private int playlistCount = 0; - - @Override - public void startUp() - { - playSong(songName); - } - - @Override - public void shutDown() - { - if (realTimeMIDIPlayer != null) - { - realTimeMIDIPlayer.stopSong(); - } - } - - @Subscribe - public void onGameTick(GameTick event) - { - try - { - if (!playlistMode) - { - String newSong = client.getWidget(WidgetInfo.MUSICTAB_CURRENT_SONG_NAME).getText(); - - if (!newSong.equals(songName)) - { - songName = newSong; - playSongFromList(songName); - } - } - } - catch (NullPointerException ignored) - { - - } - - } - - private void playSong(String song) - { - File midiMusicFile = new File(System.getProperty("user.home") + "/RuneLiteAudio/MIDI Files/" + - "Music/" + song + ".mid/"); - if (realTimeMIDIPlayer.midi == null) - { - realTimeMIDIPlayer.midi = midiMusicFile; - realTimeMIDIPlayer.run(); - } - - else - { - if (realTimeMIDIPlayer.isPlaying()) - { - realTimeMIDIPlayer.stopSong(); - } - realTimeMIDIPlayer.midi = midiMusicFile; - realTimeMIDIPlayer.run(); - } - } - - @Subscribe - private void onWidgetLoaded(WidgetLoaded widgetLoaded) - { - if (widgetLoaded.getGroupId() == WidgetID.MUSICTAB_GROUP_ID) - { - Widget musicPlayerSongs = client.getWidget(WidgetInfo.MUSICTAB_ALL_SONGS); - if (musicPlayerSongs != null) - { - playlistModeButton = musicPlayerSongs.createChild(-1, WidgetType.GRAPHIC); - playlistModeButton.setSpriteId(SpriteID.RS2_TAB_MUSIC); - playlistModeButton.setOriginalWidth(32); - playlistModeButton.setOriginalHeight(32); - playlistModeButton.setXPositionMode(WidgetPositionMode.ABSOLUTE_RIGHT); - playlistModeButton.setOriginalX(0); - playlistModeButton.setOriginalY(0); - playlistModeButton.setHasListener(true); - playlistModeButton.setAction(1, "Open"); - playlistModeButton.setOnOpListener((JavaScriptCallback) e -> openPlaylist()); - playlistModeButton.setName("Playlist"); - playlistModeButton.setHidden(true); //Playlist is not enabled for this release (Unfinished). - playlistModeButton.revalidate(); - } - } - } - - private void openPlaylist() - { - playlistMode = true; - - Widget currentPlayingSong = client.getWidget(WidgetInfo.MUSICTAB_CURRENT_SONG_NAME); - Widget allInGameSongs = client.getWidget(WidgetInfo.MUSICTAB_ALL_SONGS); - Widget musicScrollbar = client.getWidget(WidgetInfo.MUSICTAB_SCROLLBAR); - allInGameSongs.setHidden(true); - musicScrollbar.setHidden(true); - - defaultUnlockedSongs = client.getWidget(WidgetInfo.MUSICTAB_UNLOCKED_SONGS).getText(); - - client.getWidget(WidgetInfo.MUSICTAB_UNLOCKED_SONGS).setText(playlistCount + " / 10"); - - playlistBox = client.getWidget(WidgetInfo.MUSICTAB_INTERFACE); - - playlistText = playlistBox.createChild(-1, WidgetType.TEXT); - playlistText.setText("Music Playlist"); - playlistText.setFontId(497); - playlistText.setXPositionMode(WidgetPositionMode.ABSOLUTE_TOP); - playlistText.setOriginalX(40); - playlistText.setOriginalY(14); - playlistText.setOriginalHeight(1); - playlistText.setOriginalWidth(1); - playlistText.setTextColor(currentPlayingSong.getTextColor()); - playlistText.revalidate(); - - hidePlaylistButton = playlistBox.createChild(-1, WidgetType.GRAPHIC); - hidePlaylistButton.setSpriteId(SpriteID.RS2_TAB_MUSIC); - hidePlaylistButton.setOriginalWidth(32); - hidePlaylistButton.setOriginalHeight(32); - hidePlaylistButton.setXPositionMode(WidgetPositionMode.ABSOLUTE_RIGHT); - hidePlaylistButton.setOriginalX(0); - hidePlaylistButton.setOriginalY(6); - hidePlaylistButton.setHasListener(true); - hidePlaylistButton.setAction(1, "Close"); - hidePlaylistButton.setOnOpListener((JavaScriptCallback) e -> closePlaylist()); - hidePlaylistButton.setName("Playlist"); - hidePlaylistButton.revalidate(); - - addPlaylistSongButton = playlistBox.createChild(-1, WidgetType.GRAPHIC); - addPlaylistSongButton.setSpriteId(SpriteID.BANK_ADD_TAB_ICON); - addPlaylistSongButton.setOriginalWidth(36); - addPlaylistSongButton.setOriginalHeight(32); - addPlaylistSongButton.setXPositionMode(WidgetPositionMode.ABSOLUTE_LEFT); - addPlaylistSongButton.setOriginalX(0); - addPlaylistSongButton.setOriginalY(6); - addPlaylistSongButton.setHasListener(true); - addPlaylistSongButton.setAction(1, "Add to"); - addPlaylistSongButton.setOnOpListener((JavaScriptCallback) e -> addSongFromInput()); - addPlaylistSongButton.setName("Playlist"); - addPlaylistSongButton.revalidate(); - - if (playlistSong != null) - { - playlistSong.setHidden(false); - } - } - - private void closePlaylist() - { - playlistMode = false; - - Widget allInGameSongs = client.getWidget(WidgetInfo.MUSICTAB_ALL_SONGS); - Widget musicScrollbar = client.getWidget(WidgetInfo.MUSICTAB_SCROLLBAR); - allInGameSongs.setHidden(false); - musicScrollbar.setHidden(false); - - client.getWidget(WidgetInfo.MUSICTAB_UNLOCKED_SONGS).setText(defaultUnlockedSongs); - playlistText.setHidden(true); - addPlaylistSongButton.setHidden(true); - hidePlaylistButton.setHidden(true); - - if (playlistSong != null) - { - playlistSong.setHidden(true); - } - } - - private void addSongFromInput() - { - addPlaylistSongButton.setAction(1, "Close search"); - addPlaylistSongButton.setOnOpListener((JavaScriptCallback) e -> closeInput()); - songInput = chatboxPanelManager.openTextInput("Please type a valid song name") - .onChanged(s -> clientThread.invokeLater(() -> updateSongs(s))) - .onClose(() -> - { - clientThread.invokeLater(() -> updateSongs(songInput.getValue())); - addPlaylistSongButton.setOnOpListener((JavaScriptCallback) e -> addSongFromInput()); - addPlaylistSongButton.setAction(1, "Add to"); - }) - .build(); - } - - private void updateSongs() - { - String song = ""; - if (chatboxIsOpen()) - { - song = songInput.getValue(); - } - updateSongs(song); - } - - private void updateSongs(String song) - { - if (playlistBox == null) - { - return; - } - - if (new File(System.getProperty("user.home") + "/RuneLiteAudio/MIDI Files/" + - "Music/" + song + ".mid/").exists()) - { - playListSongPlayer(song); - } - } - - private void playListSongPlayer(String song) - { - if (!song.equals(songName) && !chatboxIsOpen() && playlistCount < 10) - { - Widget playlistWidget = client.getWidget(WidgetInfo.MUSICTAB_INTERFACE); - playlistSong = playlistWidget.createChild(-1, WidgetType.TEXT); - playlistSong.setText(song); - playlistSong.setFontId(495); - playlistSong.setOriginalX(12); - playlistSong.setOriginalY(newSongY); - playlistSong.setOriginalWidth(120); - playlistSong.setOriginalHeight(16); - playlistSong.setTextColor(client.getWidget(WidgetInfo.MUSICTAB_CURRENT_SONG_NAME).getTextColor()); - playlistSong.setHasListener(true); - playlistSong.setAction(1, "Play"); - playlistSong.setOnOpListener((JavaScriptCallback) e -> playSongFromList(song)); - playlistSong.setName(song); - playlistSong.revalidate(); - - newSongY = newSongY + 15; - - songName = song; - - playlistCount++; - client.getWidget(WidgetInfo.MUSICTAB_UNLOCKED_SONGS).setText(playlistCount + " / 10"); - - if (playlistCount == 10) - { - addPlaylistSongButton.setHidden(true); - } - } - } - - private boolean chatboxIsOpen() - { - return songInput != null && chatboxPanelManager.getCurrentInput() == songInput; - } - - private void closeInput() - { - updateSongs(); - chatboxPanelManager.close(); - } - - private void playSongFromList(String song) - { - client.getWidget(WidgetInfo.MUSICTAB_CURRENT_SONG_NAME).setName(song); - File midiMusicFile = new File(System.getProperty("user.home") + "/RuneLiteAudio/MIDI Files/" + - "Music/" + song + ".mid/"); - - if (realTimeMIDIPlayer.midi == null) - { - realTimeMIDIPlayer.midi = midiMusicFile; - realTimeMIDIPlayer.run(); - } - - else - { - if (realTimeMIDIPlayer.isPlaying()) - { - realTimeMIDIPlayer.stopSong(); - } - realTimeMIDIPlayer.midi = midiMusicFile; - realTimeMIDIPlayer.run(); - } - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/musicmodifier/RealTimeMIDIPlayer.java b/runelite-client/src/main/java/net/runelite/client/plugins/musicmodifier/RealTimeMIDIPlayer.java deleted file mode 100644 index 6990c5cfbc..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/musicmodifier/RealTimeMIDIPlayer.java +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright (c) 2019, Rodolfo Ruiz-Velasco - * 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.musicmodifier; - -import com.sun.media.sound.AudioSynthesizer; -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import javax.sound.midi.InvalidMidiDataException; -import javax.sound.midi.MetaMessage; -import javax.sound.midi.MidiChannel; -import javax.sound.midi.MidiDevice; -import javax.sound.midi.MidiEvent; -import javax.sound.midi.MidiMessage; -import javax.sound.midi.MidiSystem; -import javax.sound.midi.MidiUnavailableException; -import javax.sound.midi.Receiver; -import javax.sound.midi.Sequence; -import javax.sound.midi.Soundbank; -import javax.sound.midi.Synthesizer; -import javax.sound.midi.Track; -import javax.sound.sampled.AudioFormat; -import javax.sound.sampled.AudioInputStream; -import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.Clip; -import javax.sound.sampled.LineUnavailableException; -import javax.sound.sampled.SourceDataLine; - -public class RealTimeMIDIPlayer implements Runnable -{ - private AudioFormat format; - - private Sequence midiSequence; - - private Soundbank soundbank; - - private SourceDataLine sdl; - - private MusicCustomizerPlugin customMusicPlugin; - - private MidiFileAdjuster adjuster; - - private Clip clip; - - public boolean looping = true; - - public File soundFont = new File(System.getProperty("user.home") + "/RuneLiteAudio/SoundFonts/" + - "RuneScape 2.sf2/"); - - public File midi; - - @Override - public void run() - { - - try - { - - adjuster = new MidiFileAdjuster(); //Unfinished class - - midiSequence = MidiSystem.getSequence(midi); - soundbank = MidiSystem.getSoundbank(soundFont); - init(); - } - catch (IOException | InvalidMidiDataException e) - { - e.printStackTrace(); - } - } - - public void stopSong() - { - if (sdl.isRunning()) - { - sdl.stop(); - } - } - - public static AudioSynthesizer findAudioSynthesizer() throws MidiUnavailableException - { - Synthesizer synth = MidiSystem.getSynthesizer(); - if (synth instanceof AudioSynthesizer) - { - return (AudioSynthesizer) synth; - } - - double gain = 0.8D; - - MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo(); - MidiChannel[] channels = synth.getChannels(); - - for (int i = 0; i < channels.length; i++) - { - channels[i].controlChange(7, ((int) (channels[i].getController(7) * gain))); - } - - for (int i = 0; i < infos.length; i++) - { - MidiDevice device = MidiSystem.getMidiDevice(infos[i]); - - if (device instanceof AudioSynthesizer) - { - return (AudioSynthesizer) device; - } - } - return null; - } - - public boolean isPlaying() - { - return sdl.isActive(); - } - - public static double send(Sequence sequence, Receiver receiver) - { - float divtype = sequence.getDivisionType(); - assert (sequence.getDivisionType() == Sequence.PPQ); - Track[] tracks = sequence.getTracks(); - int[] trackspos = new int[tracks.length]; - int mpq = 500000; - int seqres = sequence.getResolution(); - long lasttick = 0; - long curtime = 0; - while (true) - { - MidiEvent selevent = null; - int seltrack = -1; - for (int i = 0; i < tracks.length; i++) - { - int trackpos = trackspos[i]; - Track track = tracks[i]; - if (trackpos < track.size()) - { - MidiEvent event = track.get(trackpos); - if (selevent == null - || event.getTick() < selevent.getTick()) - { - selevent = event; - seltrack = i; - } - } - } - if (seltrack == -1) - { - break; - } - trackspos[seltrack]++; - long tick = selevent.getTick(); - if (divtype == Sequence.PPQ) - { - curtime += ((tick - lasttick) * mpq) / seqres; - } - else - { - curtime = (long) ((tick * 1000000.0 * divtype) / seqres); - } - lasttick = tick; - MidiMessage msg = selevent.getMessage(); - if (msg instanceof MetaMessage) - { - if (divtype == Sequence.PPQ) - { - if (((MetaMessage) msg).getType() == 0x51) - { - byte[] data = ((MetaMessage) msg).getData(); - mpq = ((data[0] & 0xff) << 16) - | ((data[1] & 0xff) << 8) | (data[2] & 0xff); - } - } - } - else - { - if (receiver != null) - { - receiver.send(msg, curtime); - } - } - } - return curtime / 1000000.0; - } - - public void init() - { - new Thread(new Runnable() - { - @Override - public void run() - { - - AudioSynthesizer synth = null; - try - { - synth = findAudioSynthesizer(); - format = new AudioFormat(44100, 16, 2, true, false); - - Map info = new HashMap(); - info.put("resamplerType", "sinc"); - info.put("maxPolyphony", "8192"); - AudioInputStream ais = synth.openStream(format, info); - synth.unloadAllInstruments(synth.getDefaultSoundbank()); - synth.loadAllInstruments(soundbank); - double total = send(midiSequence, synth.getReceiver()); - long length = (long) (ais.getFormat().getFrameRate() * (total + 4)); - AudioInputStream stream = new AudioInputStream(ais, format, length); - sdl = AudioSystem.getSourceDataLine(format); - sdl.open(format); - sdl.start(); - writeAudio(sdl, stream); - } - catch (LineUnavailableException | MidiUnavailableException e) - { - e.printStackTrace(); - } - } - }).start(); - } - - public void writeAudio(SourceDataLine sdl, AudioInputStream stream) - { - new Thread(new Runnable() - { - @Override - public void run() - { - - byte[] sampledAudio = new byte[1024]; - - int numBytesRead = 0; - - while (numBytesRead != -1) - { - try - { - numBytesRead = stream.read(sampledAudio, 0, sampledAudio.length); - - if (numBytesRead >= 0) - { - sdl.write(sampledAudio, 0, numBytesRead); - } - } - - catch (IOException e) - { - e.printStackTrace(); - } - - finally - { - - if (!isPlaying() && looping) - { - this.run(); - } - } - } - } - }).start(); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/HintArrowOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/HintArrowOverlay.java index 0d9660ed37..90c81228a1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/HintArrowOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/HintArrowOverlay.java @@ -63,7 +63,6 @@ public class HintArrowOverlay extends Overlay } List visibleActivePortals = new ArrayList<>(); - List visibleShieldedPortals = new ArrayList<>(); for (NPC npc : client.getNpcs()) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlPlugin.java index 090874604a..b9ce9922a9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlPlugin.java @@ -130,10 +130,10 @@ public class PestControlPlugin extends Plugin private Game game; @Getter - private HashMap highlightedNpcList = new HashMap(); + private HashMap highlightedNpcList = new HashMap<>(); @Getter - private List highlightedRepairList = new ArrayList(); + private List highlightedRepairList = new ArrayList<>(); @Getter private Tile noviceGangplankTile; @@ -151,8 +151,6 @@ public class PestControlPlugin extends Plugin private boolean checkForPointWidgets; - private boolean pointsRewarded = false; - private PointsInfoboxCounter pointsInfoboxCounter; @@ -330,7 +328,7 @@ public class PestControlPlugin extends Plugin } } - public void handlePointsInfoboxCounter() + private void handlePointsInfoboxCounter() { if (!config.showPoints()) { @@ -370,7 +368,7 @@ public class PestControlPlugin extends Plugin } - public void getPointsFromWidgets() + private void getPointsFromWidgets() { // Get points from dialog after the game @@ -444,7 +442,7 @@ public class PestControlPlugin extends Plugin } } - public void setCommendationPoints(int newPoints) + private void setCommendationPoints(int newPoints) { if (userConfigKey == null) { @@ -507,7 +505,6 @@ public class PestControlPlugin extends Plugin { log.debug("Pest control game has started"); game = new Game(client, this); - pointsRewarded = false; } // Check if we are in a game @@ -658,12 +655,12 @@ public class PestControlPlugin extends Plugin unlistTileObject(event.getGroundObject()); } - public boolean isInPestControlInstance() + private boolean isInPestControlInstance() { return client.getWidget(WidgetInfo.PEST_CONTROL_BLUE_SHIELD) != null; } - public boolean isOnPestControlMainIsland() + boolean isOnPestControlMainIsland() { return client.getLocalPlayer().getWorldLocation().getRegionID() == 10537; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalWeaknessOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalWeaknessOverlay.java index ed83ff2b2e..da6428368a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalWeaknessOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalWeaknessOverlay.java @@ -95,9 +95,8 @@ public class PortalWeaknessOverlay extends Overlay } // We can use any image here as it's only needed to calculate the position - Point imageLocation = Perspective.getCanvasImageLocation(client, localLocation, magicImage, zOffset); - return imageLocation; + return Perspective.getCanvasImageLocation(client, localLocation, magicImage, zOffset); } @@ -143,7 +142,7 @@ public class PortalWeaknessOverlay extends Overlay graphics.setComposite(translucentComposite); OverlayUtil.renderImageLocation(graphics, portalLeft, imageLeft); - OverlayUtil.renderImageLocation(graphics, portalPoint, imageRight); + OverlayUtil.renderImageLocation(graphics, portalRight, imageRight); graphics.setComposite(originalComposite); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/ItemRequirement.java b/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/ItemRequirement.java deleted file mode 100644 index 0d68251ce1..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/ItemRequirement.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2019, Trevor - * 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.questhelper; - -import lombok.Getter; -import net.runelite.api.Client; -import net.runelite.api.InventoryID; -import net.runelite.api.Item; - -public class ItemRequirement -{ - @Getter - private int id; - @Getter - private int quantity; - private boolean equip; - - public ItemRequirement(int id) - { - this(id, 1); - } - - public ItemRequirement(int id, int quantity) - { - this.id = id; - this.quantity = quantity; - equip = false; - } - - public ItemRequirement(int id, int quantity, boolean equip) - { - this(id, quantity); - this.equip = equip; - } - - public boolean check(Client client) - { - Item[] items; - if (equip) - { - items = client.getItemContainer(InventoryID.EQUIPMENT).getItems(); - } - else - { - items = client.getItemContainer(InventoryID.INVENTORY).getItems(); - } - - int tempQuantity = quantity; - for (Item item : items) - { - if (item.getId() == id) - { - if (item.getQuantity() >= tempQuantity) - { - return true; - } - else - { - tempQuantity -= item.getQuantity(); - } - } - } - return false; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestDescriptor.java b/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestDescriptor.java deleted file mode 100644 index f952fbce88..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestDescriptor.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2019, Trevor - * 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.questhelper; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import net.runelite.api.Quest; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface QuestDescriptor -{ - Quest quest(); -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelper.java b/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelper.java deleted file mode 100644 index b3f3d5096c..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelper.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2019, Trevor - * 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.questhelper; - -import com.google.inject.Binder; -import com.google.inject.CreationException; -import com.google.inject.Injector; -import com.google.inject.Module; -import java.util.Map; -import javax.inject.Inject; -import lombok.Getter; -import lombok.Setter; -import net.runelite.api.Client; -import net.runelite.api.Quest; -import net.runelite.api.QuestState; -import net.runelite.client.eventbus.EventBus; -import net.runelite.client.plugins.questhelper.steps.QuestStep; - -public abstract class QuestHelper implements Module -{ - @Inject - private Client client; - - @Inject - private EventBus eventBus; - - @Getter - protected QuestStep currentStep; - - protected Map steps; - protected Injector injector; - @Getter - @Setter - private Quest quest; - protected int var; - - @Override - public void configure(Binder binder) - { - } - - protected void startUp() throws Exception - { - steps = loadSteps(); - instantiateSteps(); - var = getVar(); - startUpStep(var); - } - - protected void shutDown() throws Exception - { - steps = null; - shutDownStep(); - } - - protected void startUpStep(int i) throws Exception - { - if (steps.containsKey(i)) - { - QuestStep step = steps.get(i); - currentStep = step; - eventBus.register(currentStep); - currentStep.startUp(); - } - else - { - currentStep = null; - } - } - - protected void shutDownStep() throws Exception - { - if (currentStep != null) - { - eventBus.unregister(currentStep); - currentStep.shutDown(); - currentStep = null; - } - } - - protected void updateQuest() throws Exception - { - shutDownStep(); - if (!isCompleted()) - { - currentStep = steps.get(getVar()); - currentStep.startUp(); - } - else - { - currentStep = null; - } - } - - protected void instantiateSteps() - { - for (QuestStep step : steps.values()) - { - try - { - injector.injectMembers(step); - } - catch (CreationException ex) - { - ex.printStackTrace(); - } - } - } - - protected boolean isCompleted() - { - return (quest.getState(client) == QuestState.FINISHED); - } - - protected int getVar() - { - return quest.getVar(client); - } - - protected abstract Map loadSteps(); -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelperOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelperOverlay.java deleted file mode 100644 index 0796f8a27c..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelperOverlay.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2016-2017, Seth - * Copyright (c) 2018, Lotto - * Copyright (c) 2019, Trevor - * 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.questhelper; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import javax.inject.Inject; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayPriority; -import net.runelite.client.ui.overlay.components.ComponentConstants; -import net.runelite.client.ui.overlay.components.PanelComponent; - -public class QuestHelperOverlay extends Overlay -{ - public static final Color TITLED_CONTENT_COLOR = new Color(190, 190, 190); - - private final QuestHelperPlugin plugin; - private final PanelComponent panelComponent = new PanelComponent(); - - @Inject - public QuestHelperOverlay(QuestHelperPlugin plugin) - { - this.plugin = plugin; - setPriority(OverlayPriority.LOW); - } - - @Override - public Dimension render(Graphics2D graphics) - { - QuestHelper questHelper = plugin.getSelectedQuest(); - - if (questHelper == null || questHelper.getCurrentStep() == null) - { - return null; - } - - panelComponent.getChildren().clear(); - panelComponent.setPreferredSize(new Dimension(ComponentConstants.STANDARD_WIDTH, 0)); - - questHelper.getCurrentStep().makeOverlayHint(panelComponent, plugin); - - return panelComponent.render(graphics); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelperPlugin.java deleted file mode 100644 index a8a59b4634..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelperPlugin.java +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Copyright (c) 2019, Trevor - * 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.questhelper; - -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.ClassPath; -import com.google.inject.Binder; -import com.google.inject.CreationException; -import com.google.inject.Injector; -import com.google.inject.Module; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import javax.inject.Inject; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import net.runelite.api.Client; -import net.runelite.api.GameState; -import net.runelite.api.Quest; -import net.runelite.api.events.GameStateChanged; -import net.runelite.api.events.VarbitChanged; -import net.runelite.api.events.WidgetLoaded; -import net.runelite.api.widgets.Widget; -import net.runelite.api.widgets.WidgetID; -import net.runelite.api.widgets.WidgetInfo; -import net.runelite.client.RuneLite; -import net.runelite.client.eventbus.EventBus; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.plugins.PluginType; -import net.runelite.client.ui.overlay.OverlayManager; -import net.runelite.client.util.Text; - -@PluginDescriptor( - name = "Quest Helper", - type = PluginType.UTILITY, - description = "Helps you with your quests" -) -@Slf4j -public class QuestHelperPlugin extends Plugin -{ - @Inject - private Client client; - - @Inject - private EventBus eventBus; - - @Inject - private OverlayManager overlayManager; - - @Inject - private QuestHelperOverlay questHelperOverlay; - - @Inject - private QuestHelperWorldOverlay questHelperWorldOverlay; - - private static final String QUEST_PACKAGE = "net.runelite.client.plugins.questhelper.quests"; - private Map quests; - - @Getter - private QuestHelper selectedQuest = null; - - @Override - protected void startUp() throws IOException - { - if (client.getGameState() == GameState.LOGGED_IN) - { - if (quests == null) - { - quests = scanAndInstantiate(getClass().getClassLoader(), QUEST_PACKAGE); - } - } - overlayManager.add(questHelperOverlay); - overlayManager.add(questHelperWorldOverlay); - } - - @Override - protected void shutDown() throws Exception - { - overlayManager.remove(questHelperOverlay); - overlayManager.remove(questHelperWorldOverlay); - quests = null; - shutDownQuest(); - } - - @Subscribe - public void onWidgetLoaded(WidgetLoaded event) throws Exception - { - int groupId = event.getGroupId(); - if (groupId == WidgetID.DIARY_QUEST_GROUP_ID) - { - Widget widget = client.getWidget(WidgetInfo.DIARY_QUEST_WIDGET_TITLE); - String questname = Text.removeTags(widget.getText()); - if (quests.containsKey(questname)) - { - QuestHelper widgetQuest = quests.get(questname); - if (selectedQuest == null || !selectedQuest.equals(widgetQuest)) - { - shutDownQuest(); - startUpQuest(widgetQuest); - } - } - } - } - - @Subscribe - public void onGameStateChanged(GameStateChanged event) throws IOException - { - if (event.getGameState() == GameState.LOGGED_IN) - { - if (quests == null) - { - quests = scanAndInstantiate(getClass().getClassLoader(), QUEST_PACKAGE); - } - } - } - - @Subscribe - public void onVarbitChanged(VarbitChanged event) throws Exception - { - if (selectedQuest != null && selectedQuest.var != selectedQuest.getVar()) - { - selectedQuest.var = selectedQuest.getVar(); - selectedQuest.updateQuest(); - if (selectedQuest.getCurrentStep() == null) - { - shutDownQuest(); - } - } - } - - private void startUpQuest(QuestHelper questHelper) throws Exception - { - if (!questHelper.isCompleted()) - { - selectedQuest = questHelper; - eventBus.register(selectedQuest); - selectedQuest.startUp(); - } - else - { - selectedQuest = null; - } - } - - private void shutDownQuest() throws Exception - { - if (selectedQuest != null) - { - selectedQuest.shutDown(); - eventBus.unregister(selectedQuest); - selectedQuest = null; - } - } - - Map scanAndInstantiate(ClassLoader classLoader, String packageName) throws IOException - { - Map> quests = new HashMap<>(); - - Map scannedQuests = new HashMap<>(); - ClassPath classPath = ClassPath.from(classLoader); - - ImmutableSet classes = packageName == null ? classPath.getAllClasses() - : classPath.getTopLevelClassesRecursive(packageName); - for (ClassPath.ClassInfo classInfo : classes) - { - Class clazz = classInfo.load(); - QuestDescriptor questDescriptor = clazz.getAnnotation(QuestDescriptor.class); - - if (questDescriptor == null) - { - if (clazz.getSuperclass() == QuestHelper.class) - { - log.warn("Class {} is a quest helper, but has no quest descriptor", - clazz); - } - continue; - } - - if (clazz.getSuperclass() != QuestHelper.class) - { - log.warn("Class {} has quest descriptor, but is not a quest helper", - clazz); - continue; - } - - Class questClass = (Class) clazz; - quests.put(questDescriptor.quest(), questClass); - } - - for (Map.Entry> questClazz : quests.entrySet()) - { - QuestHelper questHelper; - try - { - questHelper = instantiate((Class) questClazz.getValue(), questClazz.getKey()); - } - catch (QuestInstantiationException ex) - { - log.warn("Error instantiating quest helper!", ex); - continue; - } - - scannedQuests.put(questClazz.getKey().getName(), questHelper); - } - - return scannedQuests; - } - - private QuestHelper instantiate(Class clazz, Quest quest) throws QuestInstantiationException - { - QuestHelper questHelper; - try - { - questHelper = clazz.newInstance(); - questHelper.setQuest(quest); - } - catch (InstantiationException | IllegalAccessException ex) - { - throw new QuestInstantiationException(ex); - } - - try - { - Module questModule = (Binder binder) -> - { - binder.bind(clazz).toInstance(questHelper); - binder.install(questHelper); - }; - Injector questInjector = RuneLite.getInjector().createChildInjector(questModule); - questInjector.injectMembers(questHelper); - questHelper.injector = questInjector; - } - catch (CreationException ex) - { - throw new QuestInstantiationException(ex); - } - - log.debug("Loaded quest helper {}", clazz.getSimpleName()); - return questHelper; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelperWorldMapPoint.java b/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelperWorldMapPoint.java deleted file mode 100644 index be6e3c122e..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelperWorldMapPoint.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2018, Morgan Lewis - * Copyright (c) 2019, Trevor - * 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.questhelper; - -import java.awt.Graphics; -import java.awt.image.BufferedImage; -import net.runelite.api.Point; -import net.runelite.api.coords.WorldPoint; -import net.runelite.client.ui.overlay.worldmap.WorldMapPoint; -import net.runelite.client.util.ImageUtil; - -public class QuestHelperWorldMapPoint extends WorldMapPoint -{ - private final BufferedImage questWorldImage; - private final Point questWorldImagePoint; - private final BufferedImage questImage; - - public QuestHelperWorldMapPoint(final WorldPoint worldPoint, BufferedImage image) - { - super(worldPoint, null); - - BufferedImage mapArrow = ImageUtil.getResourceStreamFromClass(getClass(), "/util/clue_arrow.png"); - questWorldImage = new BufferedImage(mapArrow.getWidth(), mapArrow.getHeight(), BufferedImage.TYPE_INT_ARGB); - Graphics graphics = questWorldImage.getGraphics(); - graphics.drawImage(mapArrow, 0, 0, null); - int buffer = mapArrow.getWidth() / 2 - image.getWidth() / 2; - buffer = buffer < 0 ? 0 : buffer; - graphics.drawImage(image, buffer, buffer, null); - questWorldImagePoint = new Point(questWorldImage.getWidth() / 2, questWorldImage.getHeight()); - - this.questImage = image; - this.setSnapToEdge(true); - this.setJumpOnClick(true); - this.setImage(questWorldImage); - this.setImagePoint(questWorldImagePoint); - } - - @Override - public void onEdgeSnap() - { - this.setImage(questImage); - this.setImagePoint(null); - } - - @Override - public void onEdgeUnsnap() - { - this.setImage(questWorldImage); - this.setImagePoint(questWorldImagePoint); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelperWorldOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelperWorldOverlay.java deleted file mode 100644 index 9aafbfb7a5..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestHelperWorldOverlay.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2018, Lotto - * Copyright (c) 2019, Trevor - * 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.questhelper; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import javax.inject.Inject; -import net.runelite.client.ui.overlay.Overlay; -import net.runelite.client.ui.overlay.OverlayLayer; -import net.runelite.client.ui.overlay.OverlayPosition; - -public class QuestHelperWorldOverlay extends Overlay -{ - public static final int IMAGE_Z_OFFSET = 30; - - public static final Color CLICKBOX_BORDER_COLOR = Color.CYAN; - public static final Color CLICKBOX_HOVER_BORDER_COLOR = CLICKBOX_BORDER_COLOR.darker(); - public static final Color CLICKBOX_FILL_COLOR = new Color(0, 255, 0, 20); - - private final QuestHelperPlugin plugin; - - @Inject - public QuestHelperWorldOverlay(QuestHelperPlugin plugin) - { - setPosition(OverlayPosition.DYNAMIC); - setLayer(OverlayLayer.ABOVE_SCENE); - this.plugin = plugin; - } - - @Override - public Dimension render(Graphics2D graphics) - { - QuestHelper quest = plugin.getSelectedQuest(); - - if (quest != null && quest.getCurrentStep() != null) - { - quest.getCurrentStep().makeWorldOverlayHint(graphics, plugin); - } - - return null; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestInstantiationException.java b/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestInstantiationException.java deleted file mode 100644 index 1f43af8218..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/QuestInstantiationException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2016-2017, Adam - * Copyright (c) 2019, Trevor - * 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.questhelper; - -public class QuestInstantiationException extends Exception -{ - public QuestInstantiationException(Throwable cause) - { - super(cause); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/quests/cooksassistant/CooksAssistant.java b/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/quests/cooksassistant/CooksAssistant.java deleted file mode 100644 index 4905524600..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/quests/cooksassistant/CooksAssistant.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2019, Trevor - * 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.questhelper.quests.cooksassistant; - -import java.util.HashMap; -import java.util.Map; -import net.runelite.api.ItemID; -import net.runelite.api.NpcID; -import net.runelite.api.Quest; -import net.runelite.api.coords.WorldPoint; -import net.runelite.client.plugins.questhelper.ItemRequirement; -import net.runelite.client.plugins.questhelper.QuestDescriptor; -import net.runelite.client.plugins.questhelper.QuestHelper; -import net.runelite.client.plugins.questhelper.steps.NpcTalkStep; -import net.runelite.client.plugins.questhelper.steps.QuestStep; - -@QuestDescriptor( - quest = Quest.COOKS_ASSISTANT -) -public class CooksAssistant extends QuestHelper -{ - @Override - protected Map loadSteps() - { - Map steps = new HashMap<>(); - - steps.put(0, new NpcTalkStep(this, NpcID.COOK_4626, new WorldPoint(3206, 3214, 0), - "Give the Cook in Lumbridge Castle's kitchen the required items to finish the quest.", - new ItemRequirement(ItemID.BUCKET_OF_MILK), new ItemRequirement(ItemID.POT_OF_FLOUR), - new ItemRequirement(ItemID.EGG))); - - steps.put(1, steps.get(0)); - - return steps; - } -} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/quests/impcatcher/ImpCatcher.java b/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/quests/impcatcher/ImpCatcher.java deleted file mode 100644 index 8083582671..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/quests/impcatcher/ImpCatcher.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2019, Trevor - * 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.questhelper.quests.impcatcher; - -import java.util.HashMap; -import java.util.Map; -import net.runelite.api.ItemID; -import net.runelite.api.NpcID; -import net.runelite.api.Quest; -import net.runelite.api.coords.WorldPoint; -import net.runelite.client.plugins.questhelper.ItemRequirement; -import net.runelite.client.plugins.questhelper.QuestDescriptor; -import net.runelite.client.plugins.questhelper.QuestHelper; -import net.runelite.client.plugins.questhelper.steps.NpcTalkStep; -import net.runelite.client.plugins.questhelper.steps.QuestStep; - -@QuestDescriptor( - quest = Quest.IMP_CATCHER -) -public class ImpCatcher extends QuestHelper -{ - @Override - protected Map loadSteps() - { - Map steps = new HashMap<>(); - - steps.put(0, new NpcTalkStep(this, NpcID.WIZARD_MIZGOG, new WorldPoint(3103, 3163, 2), - "Talk to Wizard Mizgog on the top floor of the Wizards' Tower with the required items to finish the quest.", - new ItemRequirement(ItemID.BLACK_BEAD), new ItemRequirement(ItemID.WHITE_BEAD), - new ItemRequirement(ItemID.RED_BEAD), new ItemRequirement(ItemID.YELLOW_BEAD))); - - steps.put(1, steps.get(0)); - - return steps; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/quests/xmarksthespot/XMarksTheSpot.java b/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/quests/xmarksthespot/XMarksTheSpot.java deleted file mode 100644 index f6b98a2e0d..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/quests/xmarksthespot/XMarksTheSpot.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2019, Trevor - * 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.questhelper.quests.xmarksthespot; - -import java.util.HashMap; -import java.util.Map; -import net.runelite.api.ItemID; -import net.runelite.api.NpcID; -import net.runelite.api.Quest; -import net.runelite.api.coords.WorldPoint; -import net.runelite.client.plugins.questhelper.ItemRequirement; -import net.runelite.client.plugins.questhelper.QuestDescriptor; -import net.runelite.client.plugins.questhelper.QuestHelper; -import net.runelite.client.plugins.questhelper.steps.DigStep; -import net.runelite.client.plugins.questhelper.steps.NpcTalkStep; -import net.runelite.client.plugins.questhelper.steps.QuestStep; - -@QuestDescriptor( - quest = Quest.X_MARKS_THE_SPOT -) -public class XMarksTheSpot extends QuestHelper -{ - @Override - protected Map loadSteps() - { - Map steps = new HashMap<>(); - - steps.put(0, new NpcTalkStep(this, NpcID.VEOS_8484, new WorldPoint(3228, 3242, 0), - "Talk to Veos in The Sheared Ram pub in Lumbridge to start the quest.")); - - steps.put(1, steps.get(0)); - - steps.put(2, new DigStep(this, new WorldPoint(3230, 3209, 0), - "Dig north of Bob's Brilliant Axes, on the west side of the plant against the wall of his house.", - new ItemRequirement(ItemID.TREASURE_SCROLL))); - - steps.put(3, new DigStep(this, new WorldPoint(3203, 3212, 0), - "Dig behind Lumbridge Castle, just outside the kitchen door.", - new ItemRequirement(ItemID.TREASURE_SCROLL_23068))); - - steps.put(4, new DigStep(this, new WorldPoint(3109, 3264, 0), - "Dig north-west of the Draynor Village jail, just by the wheat farm.", - new ItemRequirement(ItemID.MYSTERIOUS_ORB_23069))); - - steps.put(5, new DigStep(this, new WorldPoint(3078, 3259, 0), - "Dig in the pig pen just west where Martin the Master Gardener is.", - new ItemRequirement(ItemID.TREASURE_SCROLL_23070))); - - steps.put(6, new NpcTalkStep(this, NpcID.VEOS_8484, new WorldPoint(3054, 3245, 0), - "Talk to Veos directly south of the Rusty Anchor Inn in Port Sarim to finish the quest.", - new ItemRequirement(ItemID.ANCIENT_CASKET))); - - steps.put(7, new NpcTalkStep(this, NpcID.VEOS_8484, new WorldPoint(3054, 3245, 0), - "Talk to Veos directly south of the Rusty Anchor Inn in Port Sarim to finish the quest.")); - - return steps; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/steps/DigStep.java b/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/steps/DigStep.java deleted file mode 100644 index 2fd845b939..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/steps/DigStep.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2019, Trevor - * 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.questhelper.steps; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import javax.inject.Inject; -import net.runelite.api.Client; -import net.runelite.api.ItemID; -import net.runelite.api.coords.LocalPoint; -import net.runelite.api.coords.WorldPoint; -import net.runelite.client.game.ItemManager; -import net.runelite.client.plugins.questhelper.ItemRequirement; -import net.runelite.client.plugins.questhelper.QuestHelper; -import net.runelite.client.plugins.questhelper.QuestHelperPlugin; -import net.runelite.client.plugins.questhelper.QuestHelperWorldMapPoint; -import net.runelite.client.ui.overlay.OverlayUtil; -import net.runelite.client.ui.overlay.components.LineComponent; -import net.runelite.client.ui.overlay.components.PanelComponent; -import net.runelite.client.ui.overlay.worldmap.WorldMapPointManager; - -public class DigStep extends QuestStep -{ - @Inject - Client client; - - @Inject - ItemManager itemManager; - - @Inject - WorldMapPointManager worldMapPointManager; - - private final WorldPoint worldPoint; - private final List itemRequirements = new ArrayList<>(); - - public DigStep(QuestHelper questHelper, WorldPoint worldPoint, String text, ItemRequirement... itemRequirements) - { - super(questHelper, text); - this.worldPoint = worldPoint; - this.itemRequirements.add(0, new ItemRequirement(ItemID.SPADE)); - Collections.addAll(this.itemRequirements, itemRequirements); - } - - @Override - public void startUp() throws Exception - { - worldMapPointManager.add(new QuestHelperWorldMapPoint(worldPoint, getQuestImage())); - } - - @Override - public void shutDown() throws Exception - { - worldMapPointManager.removeIf(QuestHelperWorldMapPoint.class::isInstance); - } - - @Override - public void makeOverlayHint(PanelComponent panelComponent, QuestHelperPlugin plugin) - { - super.makeOverlayHint(panelComponent, plugin); - - panelComponent.getChildren().add(LineComponent.builder().left("Required Items:").build()); - for (ItemRequirement itemRequirement : itemRequirements) - { - String text = itemRequirement.getQuantity() + " x " + itemManager.getItemComposition(itemRequirement.getId()).getName(); - Color color; - if (itemRequirement.check(client)) - { - color = Color.GREEN; - } - else - { - color = Color.RED; - } - panelComponent.getChildren().add(LineComponent.builder() - .left(text) - .leftColor(color) - .build()); - } - } - - @Override - public void makeWorldOverlayHint(Graphics2D graphics, QuestHelperPlugin plugin) - { - LocalPoint localLocation = LocalPoint.fromWorld(client, worldPoint); - - if (localLocation == null) - { - return; - } - - OverlayUtil.renderTileOverlay(client, graphics, localLocation, getSpadeImage(), Color.ORANGE); - } - - private BufferedImage getSpadeImage() - { - return itemManager.getImage(ItemID.SPADE); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/steps/NpcTalkStep.java b/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/steps/NpcTalkStep.java deleted file mode 100644 index c5e87854c2..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/steps/NpcTalkStep.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2019, Trevor - * 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.questhelper.steps; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import javax.inject.Inject; -import net.runelite.api.Client; -import net.runelite.api.NPC; -import net.runelite.api.coords.WorldPoint; -import net.runelite.api.events.NpcDespawned; -import net.runelite.api.events.NpcSpawned; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.game.ItemManager; -import net.runelite.client.plugins.questhelper.ItemRequirement; -import net.runelite.client.plugins.questhelper.QuestHelper; -import net.runelite.client.plugins.questhelper.QuestHelperPlugin; -import net.runelite.client.plugins.questhelper.QuestHelperWorldMapPoint; -import static net.runelite.client.plugins.questhelper.QuestHelperWorldOverlay.IMAGE_Z_OFFSET; -import net.runelite.client.ui.overlay.OverlayUtil; -import net.runelite.client.ui.overlay.components.LineComponent; -import net.runelite.client.ui.overlay.components.PanelComponent; -import net.runelite.client.ui.overlay.worldmap.WorldMapPointManager; - -public class NpcTalkStep extends QuestStep -{ - @Inject - protected Client client; - - @Inject - protected ItemManager itemManager; - - @Inject - protected WorldMapPointManager worldMapPointManager; - - private int npcID; - private WorldPoint worldPoint; - private List npcsToHighlight = new ArrayList<>(); - List itemRequirements; - - public NpcTalkStep(QuestHelper questHelper, int npcID, WorldPoint worldPoint, String text, ItemRequirement... itemRequirements) - { - super(questHelper, text); - this.npcID = npcID; - this.worldPoint = worldPoint; - this.itemRequirements = Arrays.asList(itemRequirements); - } - - @Override - public void startUp() throws Exception - { - for (NPC npc : client.getNpcs()) - { - if (npcID == npc.getId()) - { - npcsToHighlight.add(npc); - } - } - worldMapPointManager.add(new QuestHelperWorldMapPoint(worldPoint, getQuestImage())); - } - - @Override - public void shutDown() throws Exception - { - npcsToHighlight.clear(); - worldMapPointManager.removeIf(QuestHelperWorldMapPoint.class::isInstance); - } - - @Subscribe - public void onNpcSpawned(NpcSpawned event) - { - if (event.getNpc().getId() == npcID) - { - npcsToHighlight.add(event.getNpc()); - } - } - - @Subscribe - public void onNpcDespawned(NpcDespawned event) - { - npcsToHighlight.remove(event.getNpc()); - } - - @Override - public void makeOverlayHint(PanelComponent panelComponent, QuestHelperPlugin plugin) - { - super.makeOverlayHint(panelComponent, plugin); - - if (itemRequirements.isEmpty()) - { - return; - } - - panelComponent.getChildren().add(LineComponent.builder().left("Required Items:").build()); - for (ItemRequirement itemRequirement : itemRequirements) - { - String text = itemRequirement.getQuantity() + " x " + itemManager.getItemComposition(itemRequirement.getId()).getName(); - Color color; - if (itemRequirement.check(client)) - { - color = Color.GREEN; - } - else - { - color = Color.RED; - } - panelComponent.getChildren().add(LineComponent.builder() - .left(text) - .leftColor(color) - .build()); - } - } - - @Override - public void makeWorldOverlayHint(Graphics2D graphics, QuestHelperPlugin plugin) - { - if (!worldPoint.isInScene(client)) - { - return; - } - - if (npcsToHighlight.isEmpty()) - { - return; - } - - for (NPC npc : npcsToHighlight) - { - OverlayUtil.renderActorOverlayImage(graphics, npc, getQuestImage(), Color.CYAN, IMAGE_Z_OFFSET); - } - - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/steps/QuestStep.java b/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/steps/QuestStep.java deleted file mode 100644 index 36bd00a28e..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/questhelper/steps/QuestStep.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2019, Trevor - * 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.questhelper.steps; - -import com.google.inject.Binder; -import com.google.inject.Inject; -import com.google.inject.Module; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import net.runelite.api.SpriteID; -import net.runelite.client.game.SpriteManager; -import net.runelite.client.plugins.questhelper.QuestHelper; -import static net.runelite.client.plugins.questhelper.QuestHelperOverlay.TITLED_CONTENT_COLOR; -import net.runelite.client.plugins.questhelper.QuestHelperPlugin; -import net.runelite.client.ui.overlay.components.LineComponent; -import net.runelite.client.ui.overlay.components.PanelComponent; -import net.runelite.client.ui.overlay.components.TitleComponent; - -public abstract class QuestStep implements Module -{ - @Inject - SpriteManager spriteManager; - - private final String text; - private final QuestHelper questHelper; - - public QuestStep(QuestHelper questHelper, String text) - { - this.text = text; - this.questHelper = questHelper; - } - - @Override - public void configure(Binder binder) - { - } - - public void startUp() throws Exception - { - } - - public void shutDown() throws Exception - { - } - - public void makeOverlayHint(PanelComponent panelComponent, QuestHelperPlugin plugin) - { - panelComponent.getChildren().add(TitleComponent.builder().text(questHelper.getQuest().getName()).build()); - - panelComponent.getChildren().add(LineComponent.builder().left("Step:").build()); - panelComponent.getChildren().add(LineComponent.builder() - .left(text) - .leftColor(TITLED_CONTENT_COLOR) - .build()); - } - - public abstract void makeWorldOverlayHint(Graphics2D graphics, QuestHelperPlugin plugin); - - public BufferedImage getQuestImage() - { - return spriteManager.getSprite(SpriteID.TAB_QUESTS, 0); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuOverlay.java index 6bcfe8a388..2394c66166 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuOverlay.java @@ -100,16 +100,16 @@ class RunedokuOverlay extends Overlay { if (!util.makeSimple(util.createTable(client)).contains(0)) { - OverlayUtil.renderPolygon(graphics, util.rectangleToPolygon(widget.getBounds()), Color.GREEN); + OverlayUtil.renderPolygon(graphics, RunedokuUtil.rectangleToPolygon(widget.getBounds()), Color.GREEN); } else { - OverlayUtil.renderPolygon(graphics, util.rectangleToPolygon(widget.getBounds()), util.referenceColors(i)); + OverlayUtil.renderPolygon(graphics, RunedokuUtil.rectangleToPolygon(widget.getBounds()), util.referenceColors(i)); } } else { - OverlayUtil.renderPolygon(graphics, util.rectangleToPolygon(widget.getBounds()), RED); + OverlayUtil.renderPolygon(graphics, RunedokuUtil.rectangleToPolygon(widget.getBounds()), RED); } } @@ -134,17 +134,17 @@ class RunedokuOverlay extends Overlay { if (!util.makeSimple(util.createTable(client)).contains(0)) { - OverlayUtil.renderPolygon(graphics, util.rectangleToPolygon(squareToHighlight.getBounds()), Color.GREEN); + OverlayUtil.renderPolygon(graphics, RunedokuUtil.rectangleToPolygon(squareToHighlight.getBounds()), Color.GREEN); } else { - OverlayUtil.renderPolygon(graphics, util.rectangleToPolygon(squareToHighlight.getBounds()), util.sudokuPieceToColor(simpleArr.get(iteration))); + OverlayUtil.renderPolygon(graphics, RunedokuUtil.rectangleToPolygon(squareToHighlight.getBounds()), util.sudokuPieceToColor(simpleArr.get(iteration))); } iteration++; } else { - OverlayUtil.renderPolygon(graphics, util.rectangleToPolygon(squareToHighlight.getBounds()), RED); + OverlayUtil.renderPolygon(graphics, RunedokuUtil.rectangleToPolygon(squareToHighlight.getBounds()), RED); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java index 3f44d26d0e..6743a807de 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java @@ -347,7 +347,7 @@ public class SlayerPlugin extends Plugin { highlightedTargets.add(npc); NPCPresence newPresence = NPCPresence.buildPresence(npc); - log.debug("New presence of " + newPresence.toString()); + // log.debug("New presence of " + newPresence.toString()); } } @@ -360,7 +360,7 @@ public class SlayerPlugin extends Plugin { NPCPresence lingeringPresence = NPCPresence.buildPresence(npc); lingeringPresences.add(lingeringPresence); - log.debug("Presence of " + lingeringPresence.toString() + " now lingering"); + // log.debug("Presence of " + lingeringPresence.toString() + " now lingering"); } } @@ -401,14 +401,13 @@ public class SlayerPlugin extends Plugin return 0; } - StringBuilder debugString = new StringBuilder(); - for (NPCPresence presence : potentialKills) - { - debugString.append(presence.toString()); - debugString.append(", "); - } - log.debug("Estimating kc of xp drop " + gains + " for presences {" + - debugString.toString() + "}"); + //StringBuilder debugString = new StringBuilder(); + //for (NPCPresence presence : potentialKills) + //{ + // debugString.append(presence.toString()); + // debugString.append(", "); + //} + // log.debug("Estimating kc of xp drop " + gains + " for presences {" + debugString.toString() + "}"); // first determine potential xp drops given by all npcs that died this tick by grabbing the slayer xp // info from the map made out of the data in slayer_xp.json @@ -422,14 +421,13 @@ public class SlayerPlugin extends Plugin } } - debugString = new StringBuilder(); - for (Double drop : potentialXpDrops) - { - debugString.append(drop); - debugString.append(", "); - } - log.debug("Determined xp drop " + gains + " can be made of {" + debugString.toString() - + "}"); + //debugString = new StringBuilder(); + //for (Double drop : potentialXpDrops) + //{ + // debugString.append(drop); + // debugString.append(", "); + //} + // log.debug("Determined xp drop " + gains + " can be made of {" + debugString.toString() + "}"); // we can attempt to determine exactly how many npcs died to give this amount of xp // by using a solver for the knapsack problem @@ -485,7 +483,7 @@ public class SlayerPlugin extends Plugin presence.tickExistence(); if (!presence.shouldExist()) { - log.debug("Lingering presence of " + presence.toString() + " expired"); + // log.debug("Lingering presence of " + presence.toString() + " expired"); presenceIterator.remove(); } } @@ -662,29 +660,29 @@ public class SlayerPlugin extends Plugin // this is not the initial xp sent on login so these are new xp gains int gains = slayerExp - cachedXp; - log.debug("Slayer xp drop received"); + //log.debug("Slayer xp drop received"); - StringBuilder debugString = new StringBuilder(); + //StringBuilder debugString = new StringBuilder(); // potential npcs to give xp drop are current highlighted npcs and the lingering presences List potentialNPCs = new ArrayList<>(); - debugString.append("Lingering presences {"); + //debugString.append("Lingering presences {"); for (NPCPresence presence : lingeringPresences) { potentialNPCs.add(presence); - debugString.append(presence.toString()); - debugString.append(", "); + // debugString.append(presence.toString()); + // debugString.append(", "); } - debugString.append("}\nCurrent presences {"); + //debugString.append("}\nCurrent presences {"); for (NPC npc : highlightedTargets) { NPCPresence currentPresence = NPCPresence.buildPresence(npc); potentialNPCs.add(currentPresence); - debugString.append(currentPresence.toString()); - debugString.append(", "); + // debugString.append(currentPresence.toString()); + // debugString.append(", "); } - debugString.append("}"); - log.debug(debugString.toString()); + //debugString.append("}"); + //log.debug(debugString.toString()); int killCount = estimateKillCount(potentialNPCs, gains); for (int i = 0; i < killCount; i++) @@ -707,7 +705,7 @@ public class SlayerPlugin extends Plugin final Actor interacting = client.getLocalPlayer().getInteracting(); weaknessTask = null; - if (interacting == null || !(interacting instanceof NPC)) + if (!(interacting instanceof NPC)) { return; } @@ -791,11 +789,12 @@ public class SlayerPlugin extends Plugin { for (int j = i; j < seq0.length; j++) { - String sub0 = ""; + StringBuilder sub0Builder = new StringBuilder(); for (int k = i; k <= j; k++) { - sub0 += seq0[k] + " "; + sub0Builder.append(seq0[k]).append(" "); } + String sub0 = sub0Builder.toString(); sub0 = sub0.substring(0, sub0.length() - 1); // remove extra space if (sub0.equals(toMatch)) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tearsofguthix/TearsOfGuthixPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/tearsofguthix/TearsOfGuthixPlugin.java index 0af69e7863..d75eb0bb6a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tearsofguthix/TearsOfGuthixPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tearsofguthix/TearsOfGuthixPlugin.java @@ -91,8 +91,8 @@ public class TearsOfGuthixPlugin extends Plugin { DecorativeObject object = event.getDecorativeObject(); - if (event.getDecorativeObject().getId() == ObjectID.BLUE_TEARS || - event.getDecorativeObject().getId() == ObjectID.BLUE_TEARS_6665) + if (object.getId() == ObjectID.BLUE_TEARS || + object.getId() == ObjectID.BLUE_TEARS_6665) { if (client.getLocalPlayer().getWorldLocation().getRegionID() == TOG_REGION) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterPlugin.java index 11c9d349d6..9a4e142315 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tickcounter/TickCounterPlugin.java @@ -31,7 +31,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import javax.inject.Inject; -import net.runelite.api.Actor; import net.runelite.api.Client; import net.runelite.api.Player; import net.runelite.api.events.AnimationChanged; @@ -75,7 +74,6 @@ public class TickCounterPlugin extends Plugin private List blowpiping = new ArrayList<>(); private boolean instanced = false; - private boolean prevInstance = false; @Override protected void startUp() throws Exception @@ -223,8 +221,7 @@ public class TickCounterPlugin extends Plugin */ for (Player p : blowpiping) { - Actor rsp = p; - if (rsp.getActionFrame() == 0 && rsp.getActionFrameCycle() == 1) + if (p.getActionFrame() == 0 && p.getActionFrameCycle() == 1) { String name = p.getName(); int activity = this.activity.getOrDefault(name, 0); @@ -240,7 +237,7 @@ public class TickCounterPlugin extends Plugin { return; } - prevInstance = instanced; + boolean prevInstance = instanced; instanced = client.isInInstancedRegion(); if (!prevInstance && instanced) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/vanguards/VanguardOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/vanguards/VanguardOverlay.java index e81b96b6df..53a4deb7a7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/vanguards/VanguardOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/vanguards/VanguardOverlay.java @@ -37,30 +37,19 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.components.LineComponent; import net.runelite.client.ui.overlay.components.PanelComponent; import net.runelite.client.ui.overlay.components.TitleComponent; +import net.runelite.client.util.Text; -//import net.runelite.client.plugins.opponentinfo.OpponentInfoOverlay; public class VanguardOverlay extends Overlay { - private VanguardPlugin plugin; private final PanelComponent panelComponent = new PanelComponent(); private static final int MAGE_VANGUARD_ID = 7529; private static final int RANGE_VANGUARD_ID = 7528; private static final int MELEE_VANGUARD_ID = 7527; - //private final NPCManager npcManager; - private int mageHp = -1; - private float magePercent = 0; - - private int rangeHp = -1; - private float rangePercent = 0; - - private int meleeHp = -1; - private float meleePercent = 0; - - public String right_mage_str, right_range_str, right_melee_str = ""; + String right_mage_str, right_range_str, right_melee_str = ""; @Inject private Client client; @@ -70,63 +59,50 @@ public class VanguardOverlay extends Overlay public VanguardOverlay(VanguardPlugin plugin) { super(plugin);//? - this.plugin = plugin; setPosition(OverlayPosition.ABOVE_CHATBOX_RIGHT); - //this.opponentInfoPlugin = opponentInfoPlugin; } @Override public Dimension render(Graphics2D graphics) { - Player p = client.getLocalPlayer(); //local player aka me - Actor opponent = p.getInteracting(); //get entity i am interacting with - //how to find its Id since it's an Actor not NPC specifically - //if(opponent.getName().equals("Vanguard") && opponent.getHealth() > 0)//might wana double check the name - //{ + Player p = client.getLocalPlayer(); + Actor opponent = p.getInteracting(); + if (opponent instanceof NPC) { int id = ((NPC) opponent).getId(); - String name = opponent.getName(); - if (id == MAGE_VANGUARD_ID) //maybe check name.equals("Vanguard") + if (!Text.standardize(opponent.getName()).contains("vanguard")) { - magePercent = (float) opponent.getHealthRatio() / opponent.getHealth() * 100; - mageHp = (int) magePercent; + return null; + } + + if (id == MAGE_VANGUARD_ID) + { + float magePercent = (float) opponent.getHealthRatio() / opponent.getHealth() * 100; + int mageHp = (int) magePercent; right_mage_str = Integer.toString(mageHp); - System.out.println("mager"); } else if (id == RANGE_VANGUARD_ID) { - rangePercent = (float) opponent.getHealthRatio() / opponent.getHealth() * 100; - rangeHp = (int) rangePercent; + float rangePercent = (float) opponent.getHealthRatio() / opponent.getHealth() * 100; + int rangeHp = (int) rangePercent; right_range_str = Integer.toString(rangeHp); - - System.out.println("ranger"); } else if (id == MELEE_VANGUARD_ID) { - meleePercent = (float) opponent.getHealthRatio() / opponent.getHealth() * 100; - meleeHp = (int) meleePercent; + float meleePercent = (float) opponent.getHealthRatio() / opponent.getHealth() * 100; + int meleeHp = (int) meleePercent; right_melee_str = Integer.toString(meleeHp); - - - System.out.println("meleer"); } } - //} - - - //if (opponent == null) { - //} - panelComponent.getChildren().clear(); String overlayTitle = "Vanguard HP"; - //title + panelComponent.getChildren().add(TitleComponent.builder().text(overlayTitle).color(Color.RED).build()); - //size (width) panelComponent.setPreferredSize(new Dimension(graphics.getFontMetrics().stringWidth(overlayTitle) + 30, 0)); panelComponent.getChildren().add(LineComponent.builder().left("Mage:").right(right_mage_str).build()); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersOverlay.java index 1354054295..6158d791b6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersOverlay.java @@ -63,10 +63,9 @@ public class WhaleWatchersOverlay extends Overlay panelComponent.setWrapping(5); String opp = client.getLocalPlayer().getInteracting() != null ? client.getLocalPlayer().getInteracting().getName() : lastOpponent; - if (client.getLocalPlayer().getInteracting() != null) - { - lastOpponent = client.getLocalPlayer().getInteracting().getName(); - } + + lastOpponent = opp; + String damageTaken = "Damage Taken: " + plugin.damageTaken; String damageDealt = "Damage Dealt: " + plugin.damageDone; @@ -85,8 +84,8 @@ public class WhaleWatchersOverlay extends Overlay else { panelComponent.getChildren().clear(); - } + return panelComponent.render(graphics); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiPlugin.java index afbc30b766..fb87b1a793 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiPlugin.java @@ -174,11 +174,9 @@ public class WikiPlugin extends Plugin icon.setAction(5, "Search"); // Start at option 5 so the target op is ontop icon.setOnOpListener((JavaScriptCallback) ev -> { - switch (ev.getOp()) + if (ev.getOp() == 6) { - case 6: - openSearchInput(); - break; + openSearchInput(); } }); // This doesn't always run because we cancel the menuop diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/ping/Ping.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/ping/Ping.java index fd9a84fa57..95c4aa51c7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/ping/Ping.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/ping/Ping.java @@ -47,13 +47,11 @@ public class Ping { try { - switch (OSType.getOSType()) + if (OSType.getOSType() == OSType.Windows) { - case Windows: - return windowsPing(world); - default: - return tcpPing(world); + return windowsPing(world); } + return tcpPing(world); } catch (IOException ex) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ztob/TheatrePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/ztob/TheatrePlugin.java index ccc43cae1e..9b99327f11 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/ztob/TheatrePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ztob/TheatrePlugin.java @@ -659,7 +659,7 @@ public class TheatrePlugin extends Plugin WorldPoint p = WorldPoint.fromLocal(client, obj.getLocation()); if (temp.size() == 0) { - +// TODO: ??? } else { diff --git a/runelite-client/src/main/java/net/runelite/client/util/PvPUtil.java b/runelite-client/src/main/java/net/runelite/client/util/PvPUtil.java index 3150816a9d..ef7ed230f4 100644 --- a/runelite-client/src/main/java/net/runelite/client/util/PvPUtil.java +++ b/runelite-client/src/main/java/net/runelite/client/util/PvPUtil.java @@ -38,7 +38,6 @@ public class PvPUtil */ public static int getWildernessLevelFrom(WorldPoint point) { - int x = point.getX(); int y = point.getY(); int underLevel = ((y - 9920) / 8) + 1; diff --git a/runelite-client/src/main/java/net/runelite/client/util/ping/Ping.java b/runelite-client/src/main/java/net/runelite/client/util/ping/Ping.java index 9d189a6592..873a1b0f7b 100644 --- a/runelite-client/src/main/java/net/runelite/client/util/ping/Ping.java +++ b/runelite-client/src/main/java/net/runelite/client/util/ping/Ping.java @@ -52,13 +52,11 @@ public class Ping { try { - switch (OSType.getOSType()) + if (OSType.getOSType() == OSType.Windows) { - case Windows: - return windowsPing(address); - default: - return tcpPing(address); + return windowsPing(address); } + return tcpPing(address); } catch (IOException ex) {