Add ui for tracking slayer tasks
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
package net.runelite.client.events;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
public class SlayerAmountChanged
|
||||
{
|
||||
private int oldAmount, newAmount;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package net.runelite.client.events;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
public class SlayerTaskChanged
|
||||
{
|
||||
private final String oldTask, newTask;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ class SlayerOverlay extends Overlay
|
||||
return null;
|
||||
}
|
||||
|
||||
int amount = plugin.getAmount();
|
||||
int amount = plugin.getCurrentTask().getAmount();
|
||||
if (amount <= 0)
|
||||
{
|
||||
return null;
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -52,6 +53,7 @@ import net.runelite.api.MessageNode;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.NPCComposition;
|
||||
import static net.runelite.api.Skill.SLAYER;
|
||||
import net.runelite.api.SpriteID;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
@@ -73,14 +75,17 @@ import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.EventBus;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.events.ChatInput;
|
||||
import net.runelite.client.events.SlayerAmountChanged;
|
||||
import net.runelite.client.events.SlayerTaskChanged;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.game.SpriteManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.task.Schedule;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
import net.runelite.client.util.ColorUtil;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
import net.runelite.client.util.Text;
|
||||
import net.runelite.http.api.chat.ChatClient;
|
||||
|
||||
@@ -128,6 +133,12 @@ public class SlayerPlugin extends Plugin
|
||||
private static final Pattern TASK_STRING_VALIDATION = Pattern.compile("[^a-zA-Z0-9' -]");
|
||||
private static final int TASK_STRING_MAX_LENGTH = 50;
|
||||
|
||||
@Inject
|
||||
private ClientToolbar clientToolbar;
|
||||
|
||||
@Inject
|
||||
private SpriteManager spriteManager;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@@ -181,15 +192,7 @@ public class SlayerPlugin extends Plugin
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private int amount;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private int initialAmount;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private String taskLocation;
|
||||
private TaskData currentTask;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
@@ -199,10 +202,6 @@ public class SlayerPlugin extends Plugin
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private int slaughterChargeCount;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private String taskName;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private int streak;
|
||||
|
||||
@@ -215,6 +214,10 @@ public class SlayerPlugin extends Plugin
|
||||
private boolean loginFlag;
|
||||
private List<String> targetNames = new ArrayList<>();
|
||||
|
||||
private SlayerTaskPanel panel;
|
||||
private NavigationButton navButton;
|
||||
private long lastTickMillis = 0;
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
@@ -223,6 +226,22 @@ public class SlayerPlugin extends Plugin
|
||||
overlayManager.add(targetWeaknessOverlay);
|
||||
overlayManager.add(targetMinimapOverlay);
|
||||
|
||||
panel = new SlayerTaskPanel(this);
|
||||
spriteManager.getSpriteAsync(SpriteID.SKILL_SLAYER, 0, panel::loadHeaderIcon);
|
||||
|
||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "panel_icon.png");
|
||||
|
||||
navButton = NavigationButton.builder()
|
||||
.tooltip("Slayer Tracker")
|
||||
.icon(icon)
|
||||
.priority(6)
|
||||
.panel(panel)
|
||||
.build();
|
||||
|
||||
clientToolbar.addNavigation(navButton);
|
||||
System.out.println("=================================");
|
||||
System.out.println("added slayer nav button");
|
||||
|
||||
if (client.getGameState() == GameState.LOGGED_IN
|
||||
&& config.amount() != -1
|
||||
&& !config.taskName().isEmpty())
|
||||
@@ -231,7 +250,7 @@ public class SlayerPlugin extends Plugin
|
||||
streak = config.streak();
|
||||
setExpeditiousChargeCount(config.expeditious());
|
||||
setSlaughterChargeCount(config.slaughter());
|
||||
clientThread.invoke(() -> setTask(config.taskName(), config.amount(), config.initialAmount(), config.taskLocation()));
|
||||
clientThread.invoke(() -> setTask(config.taskName(), config.amount(), config.initialAmount(), true, config.taskLocation()));
|
||||
}
|
||||
|
||||
chatCommandManager.registerCommandAsync(TASK_COMMAND_STRING, this::taskLookup, this::taskSubmit);
|
||||
@@ -248,6 +267,7 @@ public class SlayerPlugin extends Plugin
|
||||
highlightedTargets.clear();
|
||||
|
||||
chatCommandManager.unregisterCommand(TASK_COMMAND_STRING);
|
||||
clientToolbar.removeNavigation(navButton);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@@ -264,8 +284,7 @@ public class SlayerPlugin extends Plugin
|
||||
case HOPPING:
|
||||
case LOGGING_IN:
|
||||
cachedXp = 0;
|
||||
taskName = "";
|
||||
amount = 0;
|
||||
currentTask = new TaskData(0, 0,0, 0, "", "", true);
|
||||
loginFlag = true;
|
||||
highlightedTargets.clear();
|
||||
break;
|
||||
@@ -278,7 +297,7 @@ public class SlayerPlugin extends Plugin
|
||||
streak = config.streak();
|
||||
setExpeditiousChargeCount(config.expeditious());
|
||||
setSlaughterChargeCount(config.slaughter());
|
||||
setTask(config.taskName(), config.amount(), config.initialAmount(), config.taskLocation());
|
||||
setTask(config.taskName(), config.amount(), config.initialAmount(), true, config.taskLocation());
|
||||
loginFlag = false;
|
||||
}
|
||||
break;
|
||||
@@ -287,10 +306,10 @@ public class SlayerPlugin extends Plugin
|
||||
|
||||
private void save()
|
||||
{
|
||||
config.amount(amount);
|
||||
config.initialAmount(initialAmount);
|
||||
config.taskName(taskName);
|
||||
config.taskLocation(taskLocation);
|
||||
config.amount(currentTask.getAmount());
|
||||
config.initialAmount(currentTask.getInitialAmount());
|
||||
config.taskName(currentTask.getTaskName());
|
||||
config.taskLocation(currentTask.getTaskLocation());
|
||||
config.points(points);
|
||||
config.streak(streak);
|
||||
config.expeditious(expeditiousChargeCount);
|
||||
@@ -331,17 +350,17 @@ public class SlayerPlugin extends Plugin
|
||||
String name = mAssign.group("name");
|
||||
int amount = Integer.parseInt(mAssign.group("amount"));
|
||||
String location = mAssign.group("location");
|
||||
setTask(name, amount, amount, location);
|
||||
setTask(name, amount, amount, true, location);
|
||||
}
|
||||
else if (mAssignFirst.find())
|
||||
{
|
||||
int amount = Integer.parseInt(mAssignFirst.group(2));
|
||||
setTask(mAssignFirst.group(1), amount, amount);
|
||||
setTask(mAssignFirst.group(1), amount, amount, true);
|
||||
}
|
||||
else if (mAssignBoss.find())
|
||||
{
|
||||
int amount = Integer.parseInt(mAssignBoss.group(2));
|
||||
setTask(mAssignBoss.group(1), amount, amount);
|
||||
setTask(mAssignBoss.group(1), amount, amount, true);
|
||||
points = Integer.parseInt(mAssignBoss.group(3).replaceAll(",", ""));
|
||||
}
|
||||
else if (mCurrent.find())
|
||||
@@ -349,7 +368,7 @@ public class SlayerPlugin extends Plugin
|
||||
String name = mCurrent.group("name");
|
||||
int amount = Integer.parseInt(mCurrent.group("amount"));
|
||||
String location = mCurrent.group("location");
|
||||
setTask(name, amount, initialAmount, location);
|
||||
setTask(name, amount, currentTask.getInitialAmount(), false, location);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,7 +436,7 @@ public class SlayerPlugin extends Plugin
|
||||
{
|
||||
Matcher mSlaughter = CHAT_BRACELET_SLAUGHTER_REGEX.matcher(chatMsg);
|
||||
|
||||
amount++;
|
||||
currentTask.setAmount(currentTask.getAmount() + 1);
|
||||
slaughterChargeCount = mSlaughter.find() ? Integer.parseInt(mSlaughter.group(1)) : SLAUGHTER_CHARGE;
|
||||
config.slaughter(slaughterChargeCount);
|
||||
}
|
||||
@@ -426,7 +445,7 @@ public class SlayerPlugin extends Plugin
|
||||
{
|
||||
Matcher mExpeditious = CHAT_BRACELET_EXPEDITIOUS_REGEX.matcher(chatMsg);
|
||||
|
||||
amount--;
|
||||
currentTask.setAmount(currentTask.getAmount() - 1);
|
||||
expeditiousChargeCount = mExpeditious.find() ? Integer.parseInt(mExpeditious.group(1)) : EXPEDITIOUS_CHARGE;
|
||||
config.expeditious(expeditiousChargeCount);
|
||||
}
|
||||
@@ -480,13 +499,13 @@ public class SlayerPlugin extends Plugin
|
||||
default:
|
||||
log.warn("Unreachable default case for message ending in '; return to Slayer master'");
|
||||
}
|
||||
setTask("", 0, 0);
|
||||
setTask("", 0, 0, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (chatMsg.equals(CHAT_GEM_COMPLETE_MESSAGE) || chatMsg.equals(CHAT_CANCEL_MESSAGE) || chatMsg.equals(CHAT_CANCEL_MESSAGE_JAD))
|
||||
{
|
||||
setTask("", 0, 0);
|
||||
setTask("", 0, 0, true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -503,7 +522,7 @@ public class SlayerPlugin extends Plugin
|
||||
String name = mProgress.group("name");
|
||||
int gemAmount = Integer.parseInt(mProgress.group("amount"));
|
||||
String location = mProgress.group("location");
|
||||
setTask(name, gemAmount, initialAmount, location);
|
||||
setTask(name, gemAmount, currentTask.getInitialAmount(), false, location);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -512,10 +531,10 @@ public class SlayerPlugin extends Plugin
|
||||
if (bracerProgress.find())
|
||||
{
|
||||
final int taskAmount = Integer.parseInt(bracerProgress.group(1));
|
||||
setTask(taskName, taskAmount, initialAmount);
|
||||
setTask(currentTask.getTaskName(), taskAmount, currentTask.getInitialAmount(), false);
|
||||
|
||||
// Avoid race condition (combat brace message goes through first before XP drop)
|
||||
amount++;
|
||||
currentTask.setAmount(currentTask.getAmount() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,21 +585,22 @@ public class SlayerPlugin extends Plugin
|
||||
@VisibleForTesting
|
||||
void killedOne()
|
||||
{
|
||||
int oldAmount = amount;
|
||||
|
||||
if (amount == 0)
|
||||
if (currentTask.getAmount() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
amount--;
|
||||
currentTask.setAmount(currentTask.getAmount() - 1);
|
||||
currentTask.setElapsedKills(currentTask.getElapsedKills() + 1);
|
||||
if (doubleTroubleExtraKill())
|
||||
{
|
||||
amount--;
|
||||
currentTask.setAmount(currentTask.getAmount() - 1);
|
||||
currentTask.setElapsedKills(currentTask.getElapsedKills() + 1);
|
||||
}
|
||||
|
||||
config.amount(amount); // save changed value
|
||||
eventBus.post(new SlayerAmountChanged(oldAmount, amount));
|
||||
config.amount(currentTask.getAmount()); // save changed value
|
||||
currentTask.setPaused(false); // no longer paused since xp is gained
|
||||
panel.updateCurrentTask(true, currentTask.isPaused(), currentTask, false);
|
||||
|
||||
if (!config.showInfobox())
|
||||
{
|
||||
@@ -589,7 +609,7 @@ public class SlayerPlugin extends Plugin
|
||||
|
||||
// add and update counter, set timer
|
||||
addCounter();
|
||||
counter.setText(String.valueOf(amount));
|
||||
counter.setText(String.valueOf(currentTask.getAmount()));
|
||||
infoTimer = Instant.now();
|
||||
}
|
||||
|
||||
@@ -643,7 +663,7 @@ public class SlayerPlugin extends Plugin
|
||||
.map(String::toLowerCase)
|
||||
.forEach(targetNames::add);
|
||||
|
||||
targetNames.add(taskName.toLowerCase().replaceAll("s$", ""));
|
||||
targetNames.add(currentTask.getTaskName().toLowerCase().replaceAll("s$", ""));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -660,38 +680,30 @@ public class SlayerPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
private void setTask(String name, int amt, int initAmt)
|
||||
private void setTask(String name, int amt, int initAmt, boolean isNewAssignment)
|
||||
{
|
||||
setTask(name, amt, initAmt, null);
|
||||
setTask(name, amt, initAmt, isNewAssignment,null);
|
||||
}
|
||||
|
||||
private void setTask(String name, int amt, int initAmt, String location)
|
||||
private void setTask(String name, int amt, int initAmt, boolean isNewAssignment, String location)
|
||||
{
|
||||
String oldName = taskName;
|
||||
|
||||
taskName = name;
|
||||
amount = amt;
|
||||
initialAmount = initAmt;
|
||||
taskLocation = location;
|
||||
currentTask = new TaskData(isNewAssignment ? 0 : currentTask.getElapsedTime(),
|
||||
isNewAssignment ? 0 : currentTask.getElapsedKills(),
|
||||
amt, initAmt, location, name,
|
||||
isNewAssignment ? true : currentTask.isPaused());
|
||||
panel.updateCurrentTask(true, currentTask.isPaused(), currentTask, isNewAssignment);
|
||||
save();
|
||||
removeCounter();
|
||||
addCounter();
|
||||
infoTimer = Instant.now();
|
||||
eventBus.post(new SlayerTaskChanged(oldName, taskName));
|
||||
|
||||
Task task = Task.getTask(name);
|
||||
rebuildTargetNames(task);
|
||||
rebuildTargetList();
|
||||
}
|
||||
|
||||
private void addCounter()
|
||||
public BufferedImage getImageForTask(Task task)
|
||||
{
|
||||
if (!config.showInfobox() || counter != null || Strings.isNullOrEmpty(taskName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Task task = Task.getTask(taskName);
|
||||
int itemSpriteId = ItemID.ENCHANTED_GEM;
|
||||
if (task != null)
|
||||
{
|
||||
@@ -699,11 +711,23 @@ public class SlayerPlugin extends Plugin
|
||||
}
|
||||
|
||||
BufferedImage taskImg = itemManager.getImage(itemSpriteId);
|
||||
return taskImg;
|
||||
}
|
||||
|
||||
private void addCounter()
|
||||
{
|
||||
if (!config.showInfobox() || counter != null || Strings.isNullOrEmpty(currentTask.getTaskName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Task task = Task.getTask(currentTask.getTaskName());
|
||||
BufferedImage taskImg = getImageForTask(task);
|
||||
String taskTooltip = ColorUtil.wrapWithColorTag("%s", new Color(255, 119, 0)) + "</br>";
|
||||
|
||||
if (taskLocation != null && !taskLocation.isEmpty())
|
||||
if (currentTask.getTaskLocation() != null && !currentTask.getTaskLocation().isEmpty())
|
||||
{
|
||||
taskTooltip += taskLocation + "</br>";
|
||||
taskTooltip += currentTask.getTaskLocation() + "</br>";
|
||||
}
|
||||
|
||||
taskTooltip += ColorUtil.wrapWithColorTag("Pts:", Color.YELLOW)
|
||||
@@ -711,15 +735,15 @@ public class SlayerPlugin extends Plugin
|
||||
+ ColorUtil.wrapWithColorTag("Streak:", Color.YELLOW)
|
||||
+ " %s";
|
||||
|
||||
if (initialAmount > 0)
|
||||
if (currentTask.getInitialAmount() > 0)
|
||||
{
|
||||
taskTooltip += "</br>"
|
||||
+ ColorUtil.wrapWithColorTag("Start:", Color.YELLOW)
|
||||
+ " " + initialAmount;
|
||||
+ " " + currentTask.getInitialAmount();
|
||||
}
|
||||
|
||||
counter = new TaskCounter(taskImg, this, amount);
|
||||
counter.setTooltip(String.format(taskTooltip, capsString(taskName), points, streak));
|
||||
counter = new TaskCounter(taskImg, this, currentTask.getAmount());
|
||||
counter.setTooltip(String.format(taskTooltip, capsString(currentTask.getTaskName()), points, streak));
|
||||
|
||||
infoBoxManager.addInfoBox(counter);
|
||||
}
|
||||
@@ -806,7 +830,7 @@ public class SlayerPlugin extends Plugin
|
||||
|
||||
private boolean taskSubmit(ChatInput chatInput, String value)
|
||||
{
|
||||
if (Strings.isNullOrEmpty(taskName))
|
||||
if (Strings.isNullOrEmpty(currentTask.getTaskName()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -817,7 +841,8 @@ public class SlayerPlugin extends Plugin
|
||||
{
|
||||
try
|
||||
{
|
||||
chatClient.submitTask(playerName, capsString(taskName), amount, initialAmount, taskLocation);
|
||||
chatClient.submitTask(playerName, capsString(currentTask.getTaskName()), currentTask.getAmount(),
|
||||
currentTask.getInitialAmount(), currentTask.getTaskLocation());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -832,6 +857,39 @@ public class SlayerPlugin extends Plugin
|
||||
return true;
|
||||
}
|
||||
|
||||
/* package access method for changing the pause state of the time tracker for the current task */
|
||||
void setPaused(boolean paused)
|
||||
{
|
||||
currentTask.setPaused(paused);
|
||||
panel.updateCurrentTask(false, currentTask.isPaused(), currentTask, false);
|
||||
}
|
||||
|
||||
@Schedule(
|
||||
period = 1,
|
||||
unit = ChronoUnit.SECONDS
|
||||
)
|
||||
public void tickTaskTimes()
|
||||
{
|
||||
if (lastTickMillis == 0)
|
||||
{
|
||||
lastTickMillis = System.currentTimeMillis();
|
||||
return;
|
||||
}
|
||||
|
||||
final long nowMillis = System.currentTimeMillis();
|
||||
final long tickDelta = nowMillis - lastTickMillis;
|
||||
lastTickMillis = nowMillis;
|
||||
|
||||
|
||||
if (currentTask == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
currentTask.tick(tickDelta);
|
||||
|
||||
panel.updateCurrentTask(false, currentTask.isPaused(), currentTask, false);
|
||||
}
|
||||
|
||||
//Utils
|
||||
private String capsString(String str)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,271 @@
|
||||
package net.runelite.client.plugins.slayer;
|
||||
|
||||
public class SlayerTaskPanel
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.PluginPanel;
|
||||
import net.runelite.client.ui.components.PluginErrorPanel;
|
||||
import net.runelite.client.util.ColorUtil;
|
||||
import net.runelite.client.util.StackFormatter;
|
||||
|
||||
public class SlayerTaskPanel extends PluginPanel
|
||||
{
|
||||
private static final long MILLIS_PER_SECOND = 1000;
|
||||
private static final long SECONDS_PER_MINUTE = 60;
|
||||
private static final long MINUTES_PER_HOUR = 60;
|
||||
|
||||
// Templates
|
||||
private static final String HTML_LABEL_TEMPLATE =
|
||||
"<html><body style='color:%s'>%s<span style='color:white'>%s</span></body></html>";
|
||||
private static final String HTML_TIME_LABEL_TEMPLATE =
|
||||
"<html><body style='color:%s'>%s<span style='color:white'>%02d:%02d:%02d</span></body></html>";
|
||||
|
||||
|
||||
// TODO: set some kind of maximum for the amount of tasks to be tracked in a session
|
||||
private static final int MAX_TASK_BOXES = 50;
|
||||
|
||||
// When there are no tasks, display this
|
||||
private final PluginErrorPanel errorPanel = new PluginErrorPanel();
|
||||
|
||||
// Handle task boxes
|
||||
private final JPanel tasksContainer = new JPanel();
|
||||
|
||||
// Handle overall slayer session data
|
||||
private final JPanel overallPanel = new JPanel();
|
||||
private final JLabel overallKillsLabel = new JLabel();
|
||||
private final JLabel overallTimeLabel = new JLabel();
|
||||
private final JLabel overallIcon = new JLabel();
|
||||
|
||||
// Actions
|
||||
private final JPanel actionsContainer = new JPanel();
|
||||
private final JLabel playBtn = new JLabel();
|
||||
private final JLabel pauseBtn = new JLabel();
|
||||
|
||||
// Log tasks
|
||||
private final List<TaskBox> tasks = new ArrayList<>();
|
||||
|
||||
private SlayerPlugin slayerPlugin;
|
||||
|
||||
public SlayerTaskPanel(SlayerPlugin slayerPlugin)
|
||||
{
|
||||
this.slayerPlugin = slayerPlugin;
|
||||
|
||||
setBorder(new EmptyBorder(6, 6, 6, 6));
|
||||
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
// Create layout panel for wrapping
|
||||
final JPanel layoutPanel = new JPanel();
|
||||
layoutPanel.setLayout(new BoxLayout(layoutPanel, BoxLayout.Y_AXIS));
|
||||
add(layoutPanel, BorderLayout.NORTH);
|
||||
|
||||
actionsContainer.setLayout(new GridLayout(1, 2, 10, 0));
|
||||
actionsContainer.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||
actionsContainer.setPreferredSize(new Dimension(0, 30));
|
||||
actionsContainer.setBorder(new EmptyBorder(5, 5, 5, 10));
|
||||
actionsContainer.setVisible(false);
|
||||
|
||||
playBtn.setText("->");
|
||||
playBtn.setToolTipText("Resume the current slayer task");
|
||||
playBtn.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent mouseEvent)
|
||||
{
|
||||
slayerPlugin.setPaused(false);
|
||||
}
|
||||
});
|
||||
|
||||
pauseBtn.setText("||");
|
||||
pauseBtn.setToolTipText("Pause the current slayer task");
|
||||
pauseBtn.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent mouseEvent)
|
||||
{
|
||||
slayerPlugin.setPaused(true);
|
||||
}
|
||||
});
|
||||
|
||||
actionsContainer.add(playBtn);
|
||||
actionsContainer.add(pauseBtn);
|
||||
|
||||
// Create panel that will contain overall data
|
||||
overallPanel.setBorder(new EmptyBorder(8, 10, 8, 10));
|
||||
overallPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||
overallPanel.setLayout(new BorderLayout());
|
||||
overallPanel.setVisible(false);
|
||||
|
||||
// Add contents
|
||||
final JPanel overallInfo = new JPanel();
|
||||
overallInfo.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||
overallInfo.setLayout(new GridLayout(2, 1));
|
||||
overallInfo.setBorder(new EmptyBorder(2, 10, 2, 0));
|
||||
overallKillsLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
overallTimeLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
overallInfo.add(overallKillsLabel);
|
||||
overallInfo.add(overallTimeLabel);
|
||||
overallPanel.add(overallIcon, BorderLayout.WEST);
|
||||
overallPanel.add(overallInfo, BorderLayout.CENTER);
|
||||
|
||||
tasksContainer.setLayout(new BoxLayout(tasksContainer, BoxLayout.Y_AXIS));
|
||||
layoutPanel.add(actionsContainer);
|
||||
layoutPanel.add(Box.createRigidArea(new Dimension(0, 5)));
|
||||
layoutPanel.add(overallPanel);
|
||||
layoutPanel.add(tasksContainer);
|
||||
|
||||
// Add error pane
|
||||
errorPanel.setContent("Task trackers", "You have not received any slayer tasks yet.");
|
||||
add(errorPanel);
|
||||
}
|
||||
|
||||
void loadHeaderIcon(BufferedImage img)
|
||||
{
|
||||
overallIcon.setIcon(new ImageIcon(img));
|
||||
}
|
||||
|
||||
private void updateOverall()
|
||||
{
|
||||
int overallKills = 0;
|
||||
long overallTime = 0;
|
||||
for (TaskBox box : tasks)
|
||||
{
|
||||
overallKills += box.getTaskData().getElapsedKills();
|
||||
overallTime += box.getTaskData().getElapsedTime();
|
||||
}
|
||||
|
||||
overallKillsLabel.setText(htmlLabel("Total kills: ", overallKills));
|
||||
overallTimeLabel.setText(htmlLabel("Total time: ", overallTime));
|
||||
}
|
||||
|
||||
private static boolean isEmptyTask(TaskData taskData)
|
||||
{
|
||||
return taskData.getTaskName().equals("") && taskData.getAmount() == 0 && taskData.getInitialAmount() == 0;
|
||||
}
|
||||
|
||||
private void showMainView()
|
||||
{
|
||||
remove(errorPanel);
|
||||
actionsContainer.setVisible(true);
|
||||
overallPanel.setVisible(true);
|
||||
}
|
||||
|
||||
private TaskBox buildBox(SlayerPlugin plugin, JPanel container, TaskData data)
|
||||
{
|
||||
TaskBox newBox = new TaskBox(plugin, container, data.toBuilder().build());
|
||||
tasks.add(0, newBox);
|
||||
showMainView();
|
||||
return newBox;
|
||||
}
|
||||
|
||||
void updateCurrentTask(boolean updated, boolean paused, TaskData newData, boolean isNewAssignment)
|
||||
{
|
||||
// important case for if the current task is completed so the update will show the empty task
|
||||
if (isEmptyTask(newData))
|
||||
{
|
||||
if (tasks.isEmpty()) // if there is no current task an empty task doesn't do anything
|
||||
{
|
||||
return;
|
||||
}
|
||||
System.out.println("empty task sent so ending current task");
|
||||
TaskBox current = tasks.get(0);
|
||||
// current task has ended so it should be paused
|
||||
current.update(true, true, current.getTaskData());
|
||||
return;
|
||||
}
|
||||
|
||||
if (tasks.isEmpty() || isNewAssignment)
|
||||
{
|
||||
System.out.println("new task is set");
|
||||
|
||||
// new task so append it to the front of the list
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
TaskBox newBox = buildBox(slayerPlugin, tasksContainer, newData);
|
||||
newBox.update(true, newData.isPaused(), newData);
|
||||
});
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if here there is a current task so check if the current task matches
|
||||
// the update being sent
|
||||
TaskBox current = tasks.get(0);
|
||||
System.out.println("current task: " + current.getTaskData().getTaskName() + " " +
|
||||
current.getTaskData().getTaskLocation() + " " + current.getTaskData().getInitialAmount());
|
||||
System.out.println("new task: " + newData.getTaskName() + " " + newData.getTaskLocation() +
|
||||
" " + newData.getInitialAmount());
|
||||
if (!current.getTaskData().getTaskName().equals(newData.getTaskName()) ||
|
||||
!current.getTaskData().getTaskLocation().equals(newData.getTaskLocation()) ||
|
||||
current.getTaskData().getInitialAmount() != newData.getInitialAmount())
|
||||
{
|
||||
// current task does not match the update being sent so the current task
|
||||
// must have been outdated - this is necessarily true because if a true
|
||||
// new task was sent it would have set the isNewAssignment flag
|
||||
System.out.println("task does not match must create new match");
|
||||
|
||||
// so this previous task is invalid so delete it then add in the new actually
|
||||
// correct task
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
tasksContainer.remove(tasks.get(0));
|
||||
tasks.remove(0);
|
||||
TaskBox newBox = buildBox(slayerPlugin, tasksContainer, newData);
|
||||
newBox.update(true, newData.isPaused(), newData);
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("simply updating task");
|
||||
System.out.println("task panel size = " + tasks.size());
|
||||
System.out.println("task elapsed time " + tasks.get(0).getTaskData().getElapsedTime());
|
||||
System.out.println("task elapsed kills " + tasks.get(0).getTaskData().getElapsedKills());
|
||||
// not an empty assignment or a new assignment so just update the current assignment
|
||||
TaskBox current = tasks.get(0);
|
||||
current.update(updated, paused, newData);
|
||||
|
||||
// update the overall stats once this task stats are updated
|
||||
updateOverall();
|
||||
}
|
||||
|
||||
static String htmlLabel(String key, long timeMillis)
|
||||
{
|
||||
if (timeMillis == Long.MAX_VALUE)
|
||||
{
|
||||
String valueStr = "N/A";
|
||||
return String.format(HTML_LABEL_TEMPLATE, ColorUtil.toHexColor(ColorScheme.LIGHT_GRAY_COLOR),
|
||||
key, valueStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
long seconds = timeMillis / MILLIS_PER_SECOND;
|
||||
long minutes = seconds / SECONDS_PER_MINUTE;
|
||||
seconds %= 60;
|
||||
long hours = minutes / MINUTES_PER_HOUR;
|
||||
minutes %= 60;
|
||||
return String.format(HTML_TIME_LABEL_TEMPLATE, ColorUtil.toHexColor(ColorScheme.LIGHT_GRAY_COLOR),
|
||||
key, (int) hours, (int) minutes, (int) seconds);
|
||||
}
|
||||
}
|
||||
|
||||
static String htmlLabel(String key, int value)
|
||||
{
|
||||
String valueStr = StackFormatter.quantityToRSDecimalStack(value);
|
||||
return String.format(HTML_LABEL_TEMPLATE, ColorUtil.toHexColor(ColorScheme.LIGHT_GRAY_COLOR),
|
||||
key, valueStr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class TargetWeaknessOverlay extends Overlay
|
||||
return null;
|
||||
}
|
||||
|
||||
final Task curTask = Task.getTask(plugin.getTaskName());
|
||||
final Task curTask = Task.getTask(plugin.getCurrentTask().getTaskName());
|
||||
if (curTask == null || curTask.getWeaknessThreshold() < 0 || curTask.getWeaknessItem() < 0)
|
||||
{
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,273 @@
|
||||
package net.runelite.client.plugins.slayer;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Collections;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
import net.runelite.client.ui.DynamicGridLayout;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.components.ProgressBar;
|
||||
import net.runelite.client.util.ColorUtil;
|
||||
import net.runelite.client.util.StackFormatter;
|
||||
|
||||
public class TaskBox extends JPanel
|
||||
{
|
||||
private static final long MILLIS_PER_SECOND = 1000;
|
||||
private static final long SECONDS_PER_MINUTE = 60;
|
||||
private static final long MINUTES_PER_HOUR = 60;
|
||||
private static final long MILLIS_PER_HOUR = MILLIS_PER_SECOND * SECONDS_PER_MINUTE * MINUTES_PER_HOUR;
|
||||
|
||||
private static final DecimalFormat TWO_DECIMAL_FORMAT = new DecimalFormat("0.00");
|
||||
|
||||
|
||||
// Templates
|
||||
private static final String HTML_TOOL_TIP_TEMPLATE =
|
||||
"<html>%.1f Kills/hr<br/>" +
|
||||
"%02d:%02d:%02d per kill</html>";
|
||||
private static final String HTML_LABEL_TEMPLATE =
|
||||
"<html><body style='color:%s'>%s<span style='color:white'>%s</span></body></html>";
|
||||
private static final String HTML_TIME_LABEL_TEMPLATE =
|
||||
"<html><body style='color:%s'>%s<span style='color:white'>%02d:%02d:%02d</span></body></html>";
|
||||
|
||||
// Instance members
|
||||
private final JPanel panel;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final TaskData taskData;
|
||||
|
||||
/* This task's wrapping container */
|
||||
private final JPanel container = new JPanel();
|
||||
|
||||
/* Contains the task icon and the stats panel */
|
||||
private final JPanel headerPanel = new JPanel();
|
||||
|
||||
/* Contains the overall stats of the slayer task */
|
||||
private final JPanel statsPanel = new JPanel();
|
||||
|
||||
private final ProgressBar progressBar = new ProgressBar();
|
||||
|
||||
private final JLabel currentDuration = new JLabel();
|
||||
private final JLabel remainingDuration = new JLabel();
|
||||
private final JLabel currentKills = new JLabel();
|
||||
private final JLabel remainingKills = new JLabel();
|
||||
|
||||
private boolean paused = false;
|
||||
|
||||
public TaskBox(SlayerPlugin slayerPlugin, JPanel panel, TaskData taskData)
|
||||
{
|
||||
this.panel = panel;
|
||||
this.taskData = taskData;
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
setBorder(new EmptyBorder(5, 0, 0, 0));
|
||||
|
||||
container.setLayout(new BorderLayout());
|
||||
container.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||
|
||||
BufferedImage taskImg = slayerPlugin.getImageForTask(Task.getTask(taskData.getTaskName()));
|
||||
JLabel taskIcon = new JLabel(new ImageIcon(taskImg));
|
||||
taskIcon.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
taskIcon.setVerticalAlignment(SwingConstants.CENTER);
|
||||
taskIcon.setPreferredSize(new Dimension(35, 35));
|
||||
|
||||
headerPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||
headerPanel.setLayout(new BorderLayout());
|
||||
|
||||
statsPanel.setLayout(new DynamicGridLayout(2, 2));
|
||||
statsPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||
statsPanel.setBorder(new EmptyBorder(9, 2, 9, 2));
|
||||
|
||||
currentDuration.setFont(FontManager.getRunescapeSmallFont());
|
||||
remainingDuration.setFont(FontManager.getRunescapeSmallFont());
|
||||
currentKills.setFont(FontManager.getRunescapeSmallFont());
|
||||
remainingKills.setFont(FontManager.getRunescapeSmallFont());
|
||||
|
||||
statsPanel.add(currentDuration);
|
||||
statsPanel.add(currentKills);
|
||||
statsPanel.add(remainingDuration);
|
||||
statsPanel.add(remainingKills);
|
||||
|
||||
headerPanel.add(taskIcon, BorderLayout.WEST);
|
||||
headerPanel.add(statsPanel, BorderLayout.CENTER);
|
||||
|
||||
JPanel progressWrapper = new JPanel();
|
||||
progressWrapper.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||
progressWrapper.setLayout(new BorderLayout());
|
||||
progressWrapper.setBorder(new EmptyBorder(0, 7, 7, 7));
|
||||
|
||||
|
||||
progressBar.setMaximumValue(100);
|
||||
progressBar.setBackground(new Color(61, 56, 49));
|
||||
progressBar.setForeground(new Color(98, 70, 70));
|
||||
progressBar.setDimmedText("Paused");
|
||||
|
||||
progressWrapper.add(progressBar, BorderLayout.NORTH);
|
||||
|
||||
final JPanel logTitle = new JPanel(new BorderLayout(5, 0));
|
||||
logTitle.setBorder(new EmptyBorder(7, 7, 7, 7));
|
||||
logTitle.setBackground(ColorScheme.DARKER_GRAY_COLOR.darker());
|
||||
|
||||
String taskName = taskData.getTaskName();
|
||||
taskName = taskName.substring(0, 1).toUpperCase() + taskName.substring(1);
|
||||
final JLabel titleLabel = new JLabel(taskName);
|
||||
titleLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
titleLabel.setForeground(Color.WHITE);
|
||||
|
||||
logTitle.add(titleLabel, BorderLayout.WEST);
|
||||
|
||||
final JLabel subTitleLabel = new JLabel("x " + taskData.getInitialAmount());
|
||||
subTitleLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
subTitleLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
|
||||
|
||||
logTitle.add(subTitleLabel, BorderLayout.CENTER);
|
||||
|
||||
if (taskData.getTaskLocation() != null && !taskData.getTaskLocation().equals(""))
|
||||
{
|
||||
final JLabel locationLabel = new JLabel(taskData.getTaskLocation());
|
||||
locationLabel.setFont(FontManager.getRunescapeSmallFont());
|
||||
locationLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
|
||||
|
||||
logTitle.add(locationLabel, BorderLayout.EAST);
|
||||
}
|
||||
|
||||
container.add(logTitle, BorderLayout.NORTH);
|
||||
container.add(headerPanel, BorderLayout.CENTER);
|
||||
container.add(progressWrapper, BorderLayout.SOUTH);
|
||||
|
||||
add(container, BorderLayout.NORTH);
|
||||
}
|
||||
|
||||
void update(boolean updated, boolean paused, TaskData newData)
|
||||
{
|
||||
SwingUtilities.invokeLater(() -> rebuildAsync(updated, paused, newData));
|
||||
}
|
||||
|
||||
private void rebuildAsync(boolean updated, boolean taskPaused, TaskData newData)
|
||||
{
|
||||
if (updated)
|
||||
{
|
||||
if (getParent() != panel)
|
||||
{
|
||||
panel.add(this);
|
||||
panel.revalidate();
|
||||
}
|
||||
|
||||
// Update data
|
||||
taskData.setElapsedKills(newData.getElapsedKills());
|
||||
taskData.setAmount(newData.getAmount());
|
||||
|
||||
// Update information labels
|
||||
int kills = taskData.getInitialAmount() - taskData.getAmount();
|
||||
currentKills.setText(htmlLabel("Elapsed Kills: ", taskData.getElapsedKills()));
|
||||
remainingKills.setText(htmlLabel("Remaining Kills: ", taskData.getAmount()));
|
||||
|
||||
// Update progress bar
|
||||
double percentComplete = ((double) kills) / ((double) taskData.getInitialAmount());
|
||||
progressBar.setValue((int) (percentComplete * 100));
|
||||
progressBar.setCenterLabel(TWO_DECIMAL_FORMAT.format(percentComplete * 100) + "%");
|
||||
progressBar.setLeftLabel("0 Kc");
|
||||
progressBar.setRightLabel(taskData.getInitialAmount() + " Kc");
|
||||
progressBar.setPositions(Collections.emptyList());
|
||||
|
||||
double killsPerMillis = ((double) taskData.getElapsedKills() - 1) / ((double) taskData.getElapsedTime());
|
||||
if (killsPerMillis <= 0)
|
||||
{
|
||||
progressBar.setToolTipText(String.format(
|
||||
HTML_TOOL_TIP_TEMPLATE,
|
||||
0,
|
||||
99,
|
||||
99,
|
||||
99
|
||||
));
|
||||
}
|
||||
double killsPerHour = killsPerMillis * MILLIS_PER_HOUR;
|
||||
double millisPerKill = 1.0 / killsPerMillis;
|
||||
long seconds = ((long) millisPerKill) / MILLIS_PER_SECOND;
|
||||
long minutes = seconds / SECONDS_PER_MINUTE;
|
||||
seconds %= 60;
|
||||
long hours = minutes / MINUTES_PER_HOUR;
|
||||
minutes %= 60;
|
||||
progressBar.setToolTipText(String.format(
|
||||
HTML_TOOL_TIP_TEMPLATE,
|
||||
killsPerHour,
|
||||
hours,
|
||||
minutes,
|
||||
seconds
|
||||
));
|
||||
|
||||
progressBar.setDimmed(taskPaused);
|
||||
|
||||
progressBar.repaint();
|
||||
}
|
||||
else if (!paused && taskPaused)
|
||||
{
|
||||
progressBar.setDimmed(true);
|
||||
progressBar.repaint();
|
||||
paused = true;
|
||||
}
|
||||
else if (paused && !taskPaused)
|
||||
{
|
||||
progressBar.setDimmed(false);
|
||||
progressBar.repaint();
|
||||
paused = false;
|
||||
}
|
||||
|
||||
// Update duration separately, every time (not only when there's an update)
|
||||
taskData.setElapsedTime(newData.getElapsedTime());
|
||||
currentDuration.setText(htmlLabel("Elapsed Time: ", taskData.getElapsedTime()));
|
||||
remainingDuration.setText(htmlLabel("Remaining Time: ", estimateRemainingTime(taskData)));
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
static long estimateRemainingTime(TaskData taskData)
|
||||
{
|
||||
int kills = taskData.getElapsedKills();
|
||||
int killsInElapsedTime = kills - 1; // b/c time only elapses after 1st slayer drop
|
||||
if (killsInElapsedTime < 1)
|
||||
{
|
||||
return Long.MAX_VALUE;
|
||||
}
|
||||
double timePerKill = ((double) taskData.getElapsedTime()) / ((double) killsInElapsedTime);
|
||||
double remainingTime = timePerKill * taskData.getAmount();
|
||||
return (long) remainingTime;
|
||||
}
|
||||
|
||||
static String htmlLabel(String key, long timeMillis)
|
||||
{
|
||||
if (timeMillis == Long.MAX_VALUE)
|
||||
{
|
||||
String valueStr = "N/A";
|
||||
return String.format(HTML_LABEL_TEMPLATE, ColorUtil.toHexColor(ColorScheme.LIGHT_GRAY_COLOR),
|
||||
key, valueStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
long seconds = timeMillis / MILLIS_PER_SECOND;
|
||||
long minutes = seconds / SECONDS_PER_MINUTE;
|
||||
seconds %= 60;
|
||||
long hours = minutes / MINUTES_PER_HOUR;
|
||||
minutes %= 60;
|
||||
return String.format(HTML_TIME_LABEL_TEMPLATE, ColorUtil.toHexColor(ColorScheme.LIGHT_GRAY_COLOR),
|
||||
key, (int) hours, (int) minutes, (int) seconds);
|
||||
}
|
||||
}
|
||||
|
||||
static String htmlLabel(String key, int value)
|
||||
{
|
||||
String valueStr = StackFormatter.quantityToRSDecimalStack(value);
|
||||
return String.format(HTML_LABEL_TEMPLATE, ColorUtil.toHexColor(ColorScheme.LIGHT_GRAY_COLOR),
|
||||
key, valueStr);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package net.runelite.client.plugins.slayer;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Builder(toBuilder=true)
|
||||
public class TaskData
|
||||
{
|
||||
private long elapsedTime;
|
||||
private int elapsedKills;
|
||||
private int amount, initialAmount;
|
||||
private String taskLocation;
|
||||
private String taskName;
|
||||
private boolean paused;
|
||||
|
||||
public void tick(long delta)
|
||||
{
|
||||
if (!paused)
|
||||
{
|
||||
elapsedTime += delta;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 559 B |
@@ -171,8 +171,8 @@ public class SlayerPluginTest
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Suqahs", slayerPlugin.getTaskName());
|
||||
assertEquals(231, slayerPlugin.getAmount());
|
||||
assertEquals("Suqahs", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(231, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -183,9 +183,9 @@ public class SlayerPluginTest
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Wyrms", slayerPlugin.getTaskName());
|
||||
assertEquals(147, slayerPlugin.getAmount());
|
||||
assertEquals("Karuulm Slayer Dungeon", slayerPlugin.getTaskLocation());
|
||||
assertEquals("Wyrms", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(147, slayerPlugin.getCurrentTask().getAmount());
|
||||
assertEquals("Karuulm Slayer Dungeon", slayerPlugin.getCurrentTask().getTaskLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -196,9 +196,9 @@ public class SlayerPluginTest
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Hellhounds", slayerPlugin.getTaskName());
|
||||
assertEquals(142, slayerPlugin.getAmount());
|
||||
assertEquals("Witchhaven Dungeon", slayerPlugin.getTaskLocation());
|
||||
assertEquals("Hellhounds", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(142, slayerPlugin.getCurrentTask().getAmount());
|
||||
assertEquals("Witchhaven Dungeon", slayerPlugin.getCurrentTask().getTaskLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -209,8 +209,8 @@ public class SlayerPluginTest
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("goblins", slayerPlugin.getTaskName());
|
||||
assertEquals(17, slayerPlugin.getAmount());
|
||||
assertEquals("goblins", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(17, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -221,8 +221,8 @@ public class SlayerPluginTest
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Suqahs", slayerPlugin.getTaskName());
|
||||
assertEquals(211, slayerPlugin.getAmount());
|
||||
assertEquals("Suqahs", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(211, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -233,8 +233,8 @@ public class SlayerPluginTest
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Vet'ion", slayerPlugin.getTaskName());
|
||||
assertEquals(3, slayerPlugin.getAmount());
|
||||
assertEquals("Vet'ion", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(3, slayerPlugin.getCurrentTask().getAmount());
|
||||
assertEquals(914, slayerPlugin.getPoints());
|
||||
}
|
||||
|
||||
@@ -246,8 +246,8 @@ public class SlayerPluginTest
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Chaos Elemental", slayerPlugin.getTaskName());
|
||||
assertEquals(3, slayerPlugin.getAmount());
|
||||
assertEquals("Chaos Elemental", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(3, slayerPlugin.getCurrentTask().getAmount());
|
||||
assertEquals(914, slayerPlugin.getPoints());
|
||||
}
|
||||
|
||||
@@ -257,8 +257,8 @@ public class SlayerPluginTest
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, SERVER, "", TASK_NEW_FROM_PARTNER, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals("Dust Devils", slayerPlugin.getTaskName());
|
||||
assertEquals(377, slayerPlugin.getAmount());
|
||||
assertEquals("Dust Devils", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(377, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -266,8 +266,8 @@ public class SlayerPluginTest
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, SERVER, "", TASK_CHECKSLAYERGEM, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
assertEquals("Suqahs", slayerPlugin.getTaskName());
|
||||
assertEquals(211, slayerPlugin.getAmount());
|
||||
assertEquals("Suqahs", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(211, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -275,9 +275,9 @@ public class SlayerPluginTest
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, SERVER, "", TASK_CHECKSLAYERGEM_WILDERNESS, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
assertEquals("Suqahs", slayerPlugin.getTaskName());
|
||||
assertEquals(211, slayerPlugin.getAmount());
|
||||
assertEquals("Wilderness", slayerPlugin.getTaskLocation());
|
||||
assertEquals("Suqahs", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(211, slayerPlugin.getCurrentTask().getAmount());
|
||||
assertEquals("Wilderness", slayerPlugin.getCurrentTask().getTaskLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -286,9 +286,9 @@ public class SlayerPluginTest
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, SERVER, "", TASK_CHECKSLAYERGEM_KONAR, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals("Blue dragons", slayerPlugin.getTaskName());
|
||||
assertEquals(122, slayerPlugin.getAmount());
|
||||
assertEquals("Ogre Enclave", slayerPlugin.getTaskLocation());
|
||||
assertEquals("Blue dragons", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(122, slayerPlugin.getCurrentTask().getAmount());
|
||||
assertEquals("Ogre Enclave", slayerPlugin.getCurrentTask().getTaskLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -299,8 +299,8 @@ public class SlayerPluginTest
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("suqahs", slayerPlugin.getTaskName());
|
||||
assertEquals(222, slayerPlugin.getAmount());
|
||||
assertEquals("suqahs", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(222, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -325,8 +325,8 @@ public class SlayerPluginTest
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(1, slayerPlugin.getStreak());
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
assertEquals("", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(0, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -336,8 +336,8 @@ public class SlayerPluginTest
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(3, slayerPlugin.getStreak());
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
assertEquals("", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(0, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -347,8 +347,8 @@ public class SlayerPluginTest
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(9, slayerPlugin.getStreak());
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
assertEquals("", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(0, slayerPlugin.getCurrentTask().getAmount());
|
||||
assertEquals(18_000, slayerPlugin.getPoints());
|
||||
}
|
||||
|
||||
@@ -359,35 +359,35 @@ public class SlayerPluginTest
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(2465, slayerPlugin.getStreak());
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
assertEquals("", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(0, slayerPlugin.getCurrentTask().getAmount());
|
||||
assertEquals(17_566_000, slayerPlugin.getPoints());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplete()
|
||||
{
|
||||
slayerPlugin.setTaskName("cows");
|
||||
slayerPlugin.setAmount(42);
|
||||
slayerPlugin.getCurrentTask().setTaskName("cows");
|
||||
slayerPlugin.getCurrentTask().setAmount(42);
|
||||
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, SERVER, "Perterter", TASK_COMPLETE, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
assertEquals("", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(0, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCancelled()
|
||||
{
|
||||
slayerPlugin.setTaskName("cows");
|
||||
slayerPlugin.setAmount(42);
|
||||
slayerPlugin.getCurrentTask().setTaskName("cows");
|
||||
slayerPlugin.getCurrentTask().setAmount(42);
|
||||
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, SERVER, "Perterter", TASK_CANCELED, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
assertEquals("", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(0, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -409,13 +409,13 @@ public class SlayerPluginTest
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, SERVER, "", BRACLET_SLAUGHTER, null, 0);
|
||||
|
||||
slayerPlugin.setAmount(42);
|
||||
slayerPlugin.getCurrentTask().setAmount(42);
|
||||
slayerPlugin.setSlaughterChargeCount(10);
|
||||
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(9, slayerPlugin.getSlaughterChargeCount());
|
||||
assertEquals(43, slayerPlugin.getAmount());
|
||||
assertEquals(43, slayerPlugin.getCurrentTask().getAmount());
|
||||
|
||||
chatMessageEvent = new ChatMessage(null, SERVER, "", CHAT_BRACELET_SLAUGHTER_CHARGE, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
@@ -443,13 +443,13 @@ public class SlayerPluginTest
|
||||
|
||||
chatMessageEvent = new ChatMessage(null, SERVER, "", BRACLET_SLAUGHTER_V2, null, 0);
|
||||
|
||||
slayerPlugin.setAmount(42);
|
||||
slayerPlugin.getCurrentTask().setAmount(42);
|
||||
slayerPlugin.setSlaughterChargeCount(2);
|
||||
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(1, slayerPlugin.getSlaughterChargeCount());
|
||||
assertEquals(43, slayerPlugin.getAmount());
|
||||
assertEquals(43, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -457,12 +457,12 @@ public class SlayerPluginTest
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, SERVER, "", BRACLET_EXPEDITIOUS, null, 0);
|
||||
|
||||
slayerPlugin.setAmount(42);
|
||||
slayerPlugin.getCurrentTask().setAmount(42);
|
||||
slayerPlugin.setExpeditiousChargeCount(10);
|
||||
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(41, slayerPlugin.getAmount());
|
||||
assertEquals(41, slayerPlugin.getCurrentTask().getAmount());
|
||||
assertEquals(9, slayerPlugin.getExpeditiousChargeCount());
|
||||
|
||||
chatMessageEvent = new ChatMessage(null, SERVER, "", CHAT_BRACELET_EXPEDITIOUS_CHARGE, null, 0);
|
||||
@@ -491,12 +491,12 @@ public class SlayerPluginTest
|
||||
|
||||
chatMessageEvent = new ChatMessage(null, SERVER, "", BRACLET_EXPEDITIOUS_V2, null, 0);
|
||||
|
||||
slayerPlugin.setAmount(42);
|
||||
slayerPlugin.getCurrentTask().setAmount(42);
|
||||
slayerPlugin.setExpeditiousChargeCount(2);
|
||||
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(41, slayerPlugin.getAmount());
|
||||
assertEquals(41, slayerPlugin.getCurrentTask().getAmount());
|
||||
assertEquals(1, slayerPlugin.getExpeditiousChargeCount());
|
||||
}
|
||||
|
||||
@@ -507,15 +507,15 @@ public class SlayerPluginTest
|
||||
when(player.getLocalLocation()).thenReturn(new LocalPoint(0, 0));
|
||||
when(client.getLocalPlayer()).thenReturn(player);
|
||||
|
||||
slayerPlugin.setTaskName("Suqahs");
|
||||
slayerPlugin.setAmount(231);
|
||||
slayerPlugin.getCurrentTask().setTaskName("Suqahs");
|
||||
slayerPlugin.getCurrentTask().setAmount(231);
|
||||
|
||||
ChatMessage chatMessage = new ChatMessage(null, SERVER, "", TASK_UPDATE_COMBAT_BRACELET, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessage);
|
||||
|
||||
assertEquals("Suqahs", slayerPlugin.getTaskName());
|
||||
assertEquals("Suqahs", slayerPlugin.getCurrentTask().getTaskName());
|
||||
slayerPlugin.killedOne();
|
||||
assertEquals(30, slayerPlugin.getAmount());
|
||||
assertEquals(30, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user