Add initial kill counter to slayer task (#6654)

Closes #3350
This commit is contained in:
Davis Cook
2018-11-30 04:22:28 -05:00
committed by Tomas Slusny
parent 3000b5d287
commit 4104c04d37
2 changed files with 62 additions and 27 deletions

View File

@@ -136,6 +136,24 @@ public interface SlayerConfig extends Config
)
void amount(int amt);
@ConfigItem(
keyName = "initialAmount",
name = "",
description = "",
hidden = true
)
default int initialAmount()
{
return -1;
}
@ConfigItem(
keyName = "initialAmount",
name = "",
description = ""
)
void initialAmount(int initAmt);
@ConfigItem(
keyName = "streak",
name = "",

View File

@@ -148,6 +148,10 @@ public class SlayerPlugin extends Plugin
@Setter(AccessLevel.PACKAGE)
private int amount;
@Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PACKAGE)
private int initialAmount;
@Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PACKAGE)
private int expeditiousChargeCount;
@@ -187,7 +191,7 @@ public class SlayerPlugin extends Plugin
streak = config.streak();
setExpeditiousChargeCount(config.expeditious());
setSlaughterChargeCount(config.slaughter());
clientThread.invoke(() -> setTask(config.taskName(), config.amount()));
clientThread.invoke(() -> setTask(config.taskName(), config.amount(), config.initialAmount()));
}
}
@@ -217,6 +221,7 @@ public class SlayerPlugin extends Plugin
cachedXp = 0;
taskName = "";
amount = 0;
initialAmount = 0;
loginFlag = true;
highlightedTargets.clear();
break;
@@ -229,7 +234,7 @@ public class SlayerPlugin extends Plugin
streak = config.streak();
setExpeditiousChargeCount(config.expeditious());
setSlaughterChargeCount(config.slaughter());
setTask(config.taskName(), config.amount());
setTask(config.taskName(), config.amount(), config.initialAmount());
loginFlag = false;
}
break;
@@ -239,6 +244,7 @@ public class SlayerPlugin extends Plugin
private void save()
{
config.amount(amount);
config.initialAmount(initialAmount);
config.taskName(taskName);
config.points(points);
config.streak(streak);
@@ -277,7 +283,7 @@ public class SlayerPlugin extends Plugin
if (mAssign.find())
{
setTask(mAssign.group(2), Integer.parseInt(mAssign.group(1)));
setTask(mAssign.group(2), Integer.parseInt(mAssign.group(1)), Integer.parseInt(mAssign.group(1)));
}
else if (mAssignFirst.find())
{
@@ -285,12 +291,12 @@ public class SlayerPlugin extends Plugin
}
else if (mAssignBoss.find())
{
setTask(mAssignBoss.group(1), Integer.parseInt(mAssignBoss.group(2)));
setTask(mAssignBoss.group(1), Integer.parseInt(mAssignBoss.group(2)), Integer.parseInt(mAssignBoss.group(2)));
points = Integer.parseInt(mAssignBoss.group(3).replaceAll(",", ""));
}
else if (mCurrent.find())
{
setTask(mCurrent.group(1), Integer.parseInt(mCurrent.group(2)));
setTask(mCurrent.group(1), Integer.parseInt(mCurrent.group(2)), Integer.parseInt(mCurrent.group(2)));
}
}
@@ -413,13 +419,13 @@ public class SlayerPlugin extends Plugin
default:
log.warn("Unreachable default case for message ending in '; return to Slayer master'");
}
setTask("", 0);
setTask("", 0, initialAmount);
return;
}
if (chatMsg.equals(CHAT_GEM_COMPLETE_MESSAGE) || chatMsg.equals(CHAT_CANCEL_MESSAGE) || chatMsg.equals(CHAT_CANCEL_MESSAGE_JAD))
{
setTask("", 0);
setTask("", 0, initialAmount);
return;
}
@@ -435,7 +441,7 @@ public class SlayerPlugin extends Plugin
{
String gemTaskName = mProgress.group(1);
int gemAmount = Integer.parseInt(mProgress.group(2));
setTask(gemTaskName, gemAmount);
setTask(gemTaskName, gemAmount, initialAmount);
return;
}
@@ -444,7 +450,7 @@ public class SlayerPlugin extends Plugin
if (bracerProgress.find())
{
final int taskAmount = Integer.parseInt(bracerProgress.group(1));
setTask(taskName, taskAmount);
setTask(taskName, taskAmount, initialAmount);
// Avoid race condition (combat brace message goes through first before XP drop)
amount++;
@@ -584,10 +590,11 @@ public class SlayerPlugin extends Plugin
}
}
private void setTask(String name, int amt)
private void setTask(String name, int amt, int initAmt)
{
taskName = name;
amount = amt;
initialAmount = initAmt;
save();
removeCounter();
addCounter();
@@ -600,28 +607,38 @@ public class SlayerPlugin extends Plugin
private void addCounter()
{
if (!config.showInfobox() || counter != null || Strings.isNullOrEmpty(taskName))
if (config.showInfobox() && counter == null && !Strings.isNullOrEmpty(taskName))
{
return;
Task task = Task.getTask(taskName);
int itemSpriteId = ItemID.ENCHANTED_GEM;
if (task != null)
{
itemSpriteId = task.getItemSpriteId();
}
BufferedImage taskImg = itemManager.getImage(itemSpriteId);
counter = new TaskCounter(taskImg, this, amount);
infoBoxManager.addInfoBox(counter);
}
Task task = Task.getTask(taskName);
int itemSpriteId = ItemID.ENCHANTED_GEM;
if (task != null)
if (counter != null && !Strings.isNullOrEmpty(taskName))
{
itemSpriteId = task.getItemSpriteId();
String taskTooltip = ColorUtil.prependColorTag("%s</br>", new Color(255, 119, 0))
+ ColorUtil.wrapWithColorTag("Pts:", Color.YELLOW)
+ " %s</br>"
+ ColorUtil.wrapWithColorTag("Streak:", Color.YELLOW)
+ " %s";
// makes it so upon updating to track initialAmount people's previously active task won't show X/-1
if (initialAmount != -1)
{
taskTooltip += "</br>"
+ ColorUtil.wrapWithColorTag("Start:", Color.YELLOW)
+ " " + initialAmount;
}
counter.setTooltip(String.format(taskTooltip, capsString(taskName), points, streak));
}
BufferedImage taskImg = itemManager.getImage(itemSpriteId);
final String taskTooltip = ColorUtil.prependColorTag("%s</br>", new Color(255, 119, 0))
+ ColorUtil.wrapWithColorTag("Pts:", Color.YELLOW)
+ " %s</br>"
+ ColorUtil.wrapWithColorTag("Streak:", Color.YELLOW)
+ " %s";
counter = new TaskCounter(taskImg, this, amount);
counter.setTooltip(String.format(taskTooltip, capsString(taskName), points, streak));
infoBoxManager.addInfoBox(counter);
}
private void removeCounter()