Remove Musicmodifier + quest & a lot of findbugs catches (#335)
* Remove Musicmodifier + quest & a lot of findbugs catches * fix imports
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -1,202 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Rodolfo Ruiz-Velasco <https://github.com/lequietriot/>
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,363 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Rodolfo Ruiz-Velasco <https://github.com/lequietriot/>
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,282 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Rodolfo Ruiz-Velasco <https://github.com/lequietriot/>
|
||||
* 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<String, Object> info = new HashMap<String, Object>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,6 @@ public class HintArrowOverlay extends Overlay
|
||||
}
|
||||
|
||||
List<NPC> visibleActivePortals = new ArrayList<>();
|
||||
List<NPC> visibleShieldedPortals = new ArrayList<>();
|
||||
|
||||
for (NPC npc : client.getNpcs())
|
||||
{
|
||||
|
||||
@@ -130,10 +130,10 @@ public class PestControlPlugin extends Plugin
|
||||
private Game game;
|
||||
|
||||
@Getter
|
||||
private HashMap<Integer, NpcHighlightContext> highlightedNpcList = new HashMap<Integer, NpcHighlightContext>();
|
||||
private HashMap<Integer, NpcHighlightContext> highlightedNpcList = new HashMap<>();
|
||||
|
||||
@Getter
|
||||
private List<TileObject> highlightedRepairList = new ArrayList<TileObject>();
|
||||
private List<TileObject> 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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Trevor <https://github.com/Trevor159>
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Trevor <https://github.com/Trevor159>
|
||||
* 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();
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Trevor <https://github.com/Trevor159>
|
||||
* 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<Integer, QuestStep> 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<Integer, QuestStep> loadSteps();
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Seth <Sethtroll3@gmail.com>
|
||||
* Copyright (c) 2018, Lotto <https://github.com/devLotto>
|
||||
* Copyright (c) 2019, Trevor <https://github.com/Trevor159>
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
@@ -1,265 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Trevor <https://github.com/Trevor159>
|
||||
* 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<String, QuestHelper> 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<String, QuestHelper> scanAndInstantiate(ClassLoader classLoader, String packageName) throws IOException
|
||||
{
|
||||
Map<Quest, Class<? extends QuestHelper>> quests = new HashMap<>();
|
||||
|
||||
Map<String, QuestHelper> scannedQuests = new HashMap<>();
|
||||
ClassPath classPath = ClassPath.from(classLoader);
|
||||
|
||||
ImmutableSet<ClassPath.ClassInfo> 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<QuestHelper> questClass = (Class<QuestHelper>) clazz;
|
||||
quests.put(questDescriptor.quest(), questClass);
|
||||
}
|
||||
|
||||
for (Map.Entry<Quest, Class<? extends QuestHelper>> questClazz : quests.entrySet())
|
||||
{
|
||||
QuestHelper questHelper;
|
||||
try
|
||||
{
|
||||
questHelper = instantiate((Class<QuestHelper>) 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<QuestHelper> 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;
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Morgan Lewis <https://github.com/MESLewis>
|
||||
* Copyright (c) 2019, Trevor <https://github.com/Trevor159>
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Lotto <https://github.com/devLotto>
|
||||
* Copyright (c) 2019, Trevor <https://github.com/Trevor159>
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
|
||||
* Copyright (c) 2019, Trevor <https://github.com/Trevor159>
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Trevor <https://github.com/Trevor159>
|
||||
* 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<Integer, QuestStep> loadSteps()
|
||||
{
|
||||
Map<Integer, QuestStep> 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;
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Trevor <https://github.com/Trevor159>
|
||||
* 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<Integer, QuestStep> loadSteps()
|
||||
{
|
||||
Map<Integer, QuestStep> 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;
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Trevor <https://github.com/Trevor159>
|
||||
* 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<Integer, QuestStep> loadSteps()
|
||||
{
|
||||
Map<Integer, QuestStep> 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;
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Trevor <https://github.com/Trevor159>
|
||||
* 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<ItemRequirement> 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);
|
||||
}
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Trevor <https://github.com/Trevor159>
|
||||
* 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<NPC> npcsToHighlight = new ArrayList<>();
|
||||
List<ItemRequirement> 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Trevor <https://github.com/Trevor159>
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<NPCPresence> 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))
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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<Player> 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)
|
||||
{
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -659,7 +659,7 @@ public class TheatrePlugin extends Plugin
|
||||
WorldPoint p = WorldPoint.fromLocal(client, obj.getLocation());
|
||||
if (temp.size() == 0)
|
||||
{
|
||||
|
||||
// TODO: ???
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user