Merge remote-tracking branch 'runelite/master' into 1710-merge

This commit is contained in:
Owain van Brakel
2019-10-17 19:12:46 +02:00
75 changed files with 10716 additions and 639 deletions

View File

@@ -223,7 +223,7 @@ public enum AgilityShortcut
BRIMHAVEN_DUNGEON_VINE_EAST(87, "Vine", new WorldPoint(2672, 9582, 0), VINE_26880, VINE_26882),
BRIMHAVEN_DUNGEON_VINE_WEST(87, "Vine", new WorldPoint(2606, 9584, 0), VINE_26880, VINE_26882),
MOUNT_KARUULM_PIPE_SOUTH(88, "Pipe", new WorldPoint(1316, 10214, 0), MYSTERIOUS_PIPE),
MOUNT_KARUULM_PIPE_NORTH(88, "Pipe", new WorldPoint(1346, 10231, 0), MYSTERIOUS_PIPE),
MOUNT_KARUULM_PIPE_NORTH(88, "Pipe", new WorldPoint(1345, 10230, 0), MYSTERIOUS_PIPE),
REVENANT_CAVES_CHAMBER_JUMP(89, "Jump", new WorldPoint(3240, 10144, 0), PILLAR_31561);
/**

View File

@@ -216,6 +216,8 @@ public enum ItemMapping
ITEM_HYDRA_TAIL(HYDRA_TAIL, BONECRUSHER_NECKLACE),
ITEM_DRAGONBONE_NECKLACE(DRAGONBONE_NECKLACE, BONECRUSHER_NECKLACE),
ITEM_BOTTOMLESS_COMPOST_BUCKET(BOTTOMLESS_COMPOST_BUCKET, BOTTOMLESS_COMPOST_BUCKET_22997),
ITEM_BASILISK_JAW(BASILISK_JAW, NEITIZNOT_FACEGUARD),
ITEM_HELM_OF_NEITIZNOT(HELM_OF_NEITIZNOT, NEITIZNOT_FACEGUARD),
// Crystal items
ITEM_CRYSTAL_TOOL_SEED(CRYSTAL_TOOL_SEED, CRYSTAL_AXE, CRYSTAL_AXE_INACTIVE, CRYSTAL_HARPOON, CRYSTAL_HARPOON_INACTIVE, CRYSTAL_PICKAXE, CRYSTAL_PICKAXE_INACTIVE),

View File

@@ -54,7 +54,7 @@ public class ItemVariationMapping
static void load() throws IOException
{
try (JsonReader reader = new JsonReader(new InputStreamReader(ItemVariationMapping.class.getResourceAsStream("/item_variations.json"), StandardCharsets.UTF_8)))
try (JsonReader reader = new JsonReader(new InputStreamReader(ItemVariationMapping.class.getResourceAsStream("/item_variations.min.json"), StandardCharsets.UTF_8)))
{
ImmutableMap.Builder<Integer, Integer> builder = ImmutableMap.builderWithExpectedSize(5039);
reader.beginObject();

View File

@@ -129,6 +129,12 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
this.clientThread = clientThread;
}
public ChatboxTextInput addCharValidator(IntPredicate validator)
{
this.charValidator = this.charValidator.and(validator);
return this;
}
public ChatboxTextInput lines(int lines)
{
this.lines = lines;
@@ -151,7 +157,15 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
public ChatboxTextInput value(String value)
{
this.value = new StringBuffer(value);
StringBuffer sb = new StringBuffer();
for (char c : value.toCharArray())
{
if (charValidator.test(c))
{
sb.append(c);
}
}
this.value = sb;
cursorAt(this.value.length());
return this;
}

View File

@@ -33,7 +33,7 @@ import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.ui.overlay.infobox.Counter;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
class AmmoCounter extends Counter
{
@@ -56,7 +56,7 @@ class AmmoCounter extends Counter
@Override
public String getText()
{
return StackFormatter.quantityToRSDecimalStack(getCount());
return QuantityFormatter.quantityToRSDecimalStack(getCount());
}
@Override

View File

@@ -66,7 +66,7 @@ import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.banktags.tabs.BankSearch;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
@PluginDescriptor(
name = "Bank",
@@ -297,11 +297,11 @@ public class BankPlugin extends Plugin
if (this.showExact)
{
strCurrentTab += StackFormatter.formatNumber(gePrice) + ")";
strCurrentTab += QuantityFormatter.formatNumber(gePrice) + ")";
}
else
{
strCurrentTab += StackFormatter.quantityToStackSize(gePrice) + ")";
strCurrentTab += QuantityFormatter.quantityToStackSize(gePrice) + ")";
}
}
@@ -316,11 +316,11 @@ public class BankPlugin extends Plugin
if (this.showExact)
{
strCurrentTab += StackFormatter.formatNumber(haPrice) + ")";
strCurrentTab += QuantityFormatter.formatNumber(haPrice) + ")";
}
else
{
strCurrentTab += StackFormatter.quantityToStackSize(haPrice) + ")";
strCurrentTab += QuantityFormatter.quantityToStackSize(haPrice) + ")";
}
}
@@ -479,7 +479,7 @@ public class BankPlugin extends Plugin
long compare;
try
{
compare = StackFormatter.stackSizeToQuantity(matcher.group("num"));
compare = QuantityFormatter.parseQuantity(matcher.group("num"));
}
catch (ParseException e)
{
@@ -508,8 +508,8 @@ public class BankPlugin extends Plugin
long compare1, compare2;
try
{
compare1 = StackFormatter.stackSizeToQuantity(num1);
compare2 = StackFormatter.stackSizeToQuantity(num2);
compare1 = QuantityFormatter.parseQuantity(num1);
compare2 = QuantityFormatter.parseQuantity(num2);
}
catch (ParseException e)
{

View File

@@ -37,6 +37,7 @@ import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.regex.Matcher;
import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.inject.Inject;
@@ -79,10 +80,11 @@ import net.runelite.client.plugins.PluginDependency;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.banktags.tabs.BankSearch;
import net.runelite.client.plugins.banktags.tabs.TabInterface;
import static net.runelite.client.plugins.banktags.tabs.TabInterface.FILTERED_CHARS;
import net.runelite.client.plugins.banktags.tabs.TabSprites;
import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
import net.runelite.client.util.StackFormatter;
import net.runelite.api.util.Text;
import net.runelite.client.util.QuantityFormatter;
@PluginDescriptor(
name = "Bank Tags",
@@ -147,6 +149,9 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
@Inject
private EventBus eventBus;
@Inject
private ConfigManager configManager;
private boolean shiftPressed = false;
private int nextRowIndex = 0;
@VisibleForTesting
@@ -163,12 +168,66 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
{
addSubscriptions();
cleanConfig();
keyManager.registerKeyListener(this);
mouseManager.registerMouseWheelListener(this);
clientThread.invokeLater(tabInterface::init);
spriteManager.addSpriteOverrides(TabSprites.values());
}
@Deprecated
private void cleanConfig()
{
removeInvalidTags("tagtabs");
List<String> tags = configManager.getConfigurationKeys(CONFIG_GROUP + ".item_");
tags.forEach(s ->
{
String[] split = s.split("\\.", 2);
removeInvalidTags(split[1]);
});
List<String> icons = configManager.getConfigurationKeys(CONFIG_GROUP + ".icon_");
icons.forEach(s ->
{
String[] split = s.split("\\.", 2);
String replaced = split[1].replaceAll("[<>/]", "");
if (!split[1].equals(replaced))
{
String value = configManager.getConfiguration(CONFIG_GROUP, split[1]);
configManager.unsetConfiguration(CONFIG_GROUP, split[1]);
if (replaced.length() > "icon_".length())
{
configManager.setConfiguration(CONFIG_GROUP, replaced, value);
}
}
});
}
@Deprecated
private void removeInvalidTags(final String key)
{
final String value = configManager.getConfiguration(CONFIG_GROUP, key);
if (value == null)
{
return;
}
String replaced = value.replaceAll("[<>/]", "");
if (!value.equals(replaced))
{
replaced = Text.toCSV(Text.fromCSV(replaced));
if (replaced.isEmpty())
{
configManager.unsetConfiguration(CONFIG_GROUP, key);
}
else
{
configManager.setConfiguration(CONFIG_GROUP, key, replaced);
}
}
}
@Override
public void shutDown()
{
@@ -381,6 +440,7 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
String initialValue = Text.toCSV(tags);
chatboxPanelManager.openTextInput(name + " tags:<br>(append " + VAR_TAG_SUFFIX + " for variation tag)")
.addCharValidator(FILTERED_CHARS)
.value(initialValue)
.onDone((newValue) ->
clientThread.invoke(() ->
@@ -529,7 +589,7 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
long compare;
try
{
compare = StackFormatter.stackSizeToQuantity(matcher.group("num"));
compare = QuantityFormatter.parseQuantity(matcher.group("num"));
}
catch (ParseException e)
{
@@ -558,8 +618,8 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
long compare1, compare2;
try
{
compare1 = StackFormatter.stackSizeToQuantity(num1);
compare2 = StackFormatter.stackSizeToQuantity(num2);
compare1 = QuantityFormatter.parseQuantity(num1);
compare2 = QuantityFormatter.parseQuantity(num2);
}
catch (ParseException e)
{

View File

@@ -45,6 +45,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.function.IntPredicate;
import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -94,6 +95,8 @@ import net.runelite.api.util.Text;
@Singleton
public class TabInterface
{
public static final IntPredicate FILTERED_CHARS = c -> "</>".indexOf(c) == -1;
private static final Color HILIGHT_COLOR = JagexColors.MENU_TARGET;
private static final String SCROLL_UP = "Scroll up";
private static final String SCROLL_DOWN = "Scroll down";
@@ -253,6 +256,7 @@ public class TabInterface
}
chatboxPanelManager.openTextInput((inventory ? "Inventory " : "Equipment ") + " tags:")
.addCharValidator(FILTERED_CHARS)
.onDone((newTags) ->
clientThread.invoke(() ->
{
@@ -274,6 +278,7 @@ public class TabInterface
{
case NewTab.NEW_TAB:
chatboxPanelManager.openTextInput("Tag name")
.addCharValidator(FILTERED_CHARS)
.onDone((tagName) -> clientThread.invoke(() ->
{
if (!Strings.isNullOrEmpty(tagName))
@@ -286,7 +291,6 @@ public class TabInterface
.build();
break;
case NewTab.IMPORT_TAB:
try
{
final String dataString = Toolkit
@@ -297,7 +301,24 @@ public class TabInterface
.trim();
final Iterator<String> dataIter = Text.fromCSV(dataString).iterator();
final String name = dataIter.next();
String name = dataIter.next();
StringBuffer sb = new StringBuffer();
for (char c : name.toCharArray())
{
if (FILTERED_CHARS.test(c))
{
sb.append(c);
}
}
if (sb.length() == 0)
{
notifier.notify("Failed to import tag tab from clipboard, invalid format.");
return;
}
name = sb.toString();
final String icon = dataIter.next();
tabManager.setIcon(name, icon);
@@ -785,6 +806,7 @@ public class TabInterface
private void renameTab(String oldTag)
{
chatboxPanelManager.openTextInput("Enter new tag name for tag \"" + oldTag + "\":")
.addCharValidator(FILTERED_CHARS)
.onDone((newTag) -> clientThread.invoke(() ->
{
if (!Strings.isNullOrEmpty(newTag) && !newTag.equalsIgnoreCase(oldTag))

View File

@@ -40,7 +40,7 @@ import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.PanelComponent;
import net.runelite.client.ui.overlay.components.table.TableComponent;
import net.runelite.client.ui.overlay.components.table.TableAlignment;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
@Singleton
class BlastFurnaceCofferOverlay extends Overlay
@@ -78,7 +78,7 @@ class BlastFurnaceCofferOverlay extends Overlay
{
sack.setHidden(true);
tableComponent.addRow("Coffer:", StackFormatter.quantityToStackSize(client.getVar(BLAST_FURNACE_COFFER)) + " gp");
tableComponent.addRow("Coffer:", QuantityFormatter.quantityToStackSize(client.getVar(BLAST_FURNACE_COFFER)) + " gp");
}
if (!tableComponent.isEmpty())

View File

@@ -64,7 +64,7 @@ import net.runelite.client.game.ItemManager;
import net.runelite.client.input.KeyManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
import static net.runelite.api.util.Text.sanitize;
import net.runelite.http.api.chat.ChatClient;
import net.runelite.http.api.chat.Duels;
@@ -861,11 +861,11 @@ public class ChatCommandsPlugin extends Plugin
builder.append(ChatColorType.NORMAL);
builder.append(": GE ");
builder.append(ChatColorType.HIGHLIGHT);
builder.append(StackFormatter.formatNumber(itemPrice));
builder.append(QuantityFormatter.formatNumber(itemPrice));
builder.append(ChatColorType.NORMAL);
builder.append(": OSB ");
builder.append(ChatColorType.HIGHLIGHT);
builder.append(StackFormatter.formatNumber(osbresult.getOverall_average()));
builder.append(QuantityFormatter.formatNumber(osbresult.getOverall_average()));
ItemDefinition itemComposition = itemManager.getItemDefinition(itemId);
if (itemComposition != null)
@@ -875,7 +875,7 @@ public class ChatCommandsPlugin extends Plugin
.append(ChatColorType.NORMAL)
.append(" HA value ")
.append(ChatColorType.HIGHLIGHT)
.append(StackFormatter.formatNumber(alchPrice));
.append(QuantityFormatter.formatNumber(alchPrice));
}
String response = builder.build();

View File

@@ -216,7 +216,7 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc
new CrypticClue("Search the drawers in the house next to the Port Sarim mage shop.", DRAWERS, new WorldPoint(3024, 3259, 0), "House east of Betty's. Contains a cooking sink."),
new CrypticClue("With a name like that, you'd expect a little more than just a few scimitars.", "Daga", new WorldPoint(2759, 2775, 0), "Speak to Daga on Ape Atoll."),
new CrypticClue("Strength potions with red spiders' eggs? He is quite a herbalist.", "Apothecary", new WorldPoint(3194, 3403, 0), "Talk to Apothecary in the South-western Varrock. (the) apothecary is just north-west of the Varrock Swordshop."),
new CrypticClue("Robin wishes to see your finest ranged equipment.", "Robin", new WorldPoint(3673, 3492, 0), "Robin at the inn in Port Phasmatys. Speak to him with +182 in ranged attack bonus."),
new CrypticClue("Robin wishes to see your finest ranged equipment.", "Robin", new WorldPoint(3673, 3492, 0), "Robin at the inn in Port Phasmatys. Speak to him with +182 in ranged attack bonus. Bonus granted by the toxic blowpipe is ignored."),
new CrypticClue("You will need to under-cook to solve this one.", CRATE_357, new WorldPoint(3219, 9617, 0), "Search the crate in the Lumbridge basement."),
new CrypticClue("Search through some drawers found in Taverley's houses.", DRAWERS_350, new WorldPoint(2894, 3418, 0), "The south-eastern most house, south of Jatix's Herblore Shop."),
new CrypticClue("Anger Abbot Langley.", "Abbot Langley", new WorldPoint(3058, 3487, 0), "Speak to Abbot Langley in the Edgeville Monastery while you have a negative prayer bonus (currently only possible with an Ancient staff)."),

View File

@@ -58,7 +58,7 @@ import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
import net.runelite.http.api.examine.ExamineClient;
import net.runelite.http.api.osbuddy.OSBGrandExchangeClient;
@@ -388,7 +388,7 @@ public class ExaminePlugin extends Plugin
if (quantity > 1)
{
message
.append(StackFormatter.formatNumber(quantity))
.append(QuantityFormatter.formatNumber(quantity))
.append(" x ");
}
@@ -410,7 +410,7 @@ public class ExaminePlugin extends Plugin
.append(ChatColorType.NORMAL)
.append(" GE ")
.append(ChatColorType.HIGHLIGHT)
.append(StackFormatter.formatNumber(gePrice * finalQuantity));
.append(QuantityFormatter.formatNumber(gePrice * finalQuantity));
if (osbresult != null)
{
@@ -418,7 +418,7 @@ public class ExaminePlugin extends Plugin
.append(ChatColorType.NORMAL)
.append(" OSB ")
.append(ChatColorType.HIGHLIGHT)
.append(StackFormatter.formatNumber(osbresult.getOverall_average() * finalQuantity));
.append(QuantityFormatter.formatNumber(osbresult.getOverall_average() * finalQuantity));
}
if (finalQuantity > 1)
@@ -427,7 +427,7 @@ public class ExaminePlugin extends Plugin
.append(ChatColorType.NORMAL)
.append(" (")
.append(ChatColorType.HIGHLIGHT)
.append(StackFormatter.formatNumber(gePrice))
.append(QuantityFormatter.formatNumber(gePrice))
.append(ChatColorType.NORMAL)
.append("ea)");
}
@@ -436,7 +436,7 @@ public class ExaminePlugin extends Plugin
.append(ChatColorType.NORMAL)
.append(" HA value ")
.append(ChatColorType.HIGHLIGHT)
.append(StackFormatter.formatNumber(alchPrice * finalQuantity));
.append(QuantityFormatter.formatNumber(alchPrice * finalQuantity));
if (finalQuantity > 1)
{
@@ -444,7 +444,7 @@ public class ExaminePlugin extends Plugin
.append(ChatColorType.NORMAL)
.append(" (")
.append(ChatColorType.HIGHLIGHT)
.append(StackFormatter.formatNumber(alchPrice))
.append(QuantityFormatter.formatNumber(alchPrice))
.append(ChatColorType.NORMAL)
.append("ea)");
}
@@ -463,7 +463,7 @@ public class ExaminePlugin extends Plugin
.append(ChatColorType.NORMAL)
.append(" HA value ")
.append(ChatColorType.HIGHLIGHT)
.append(StackFormatter.formatNumber(alchPrice * quantity));
.append(QuantityFormatter.formatNumber(alchPrice * quantity));
if (quantity > 1)
{
@@ -471,7 +471,7 @@ public class ExaminePlugin extends Plugin
.append(ChatColorType.NORMAL)
.append(" (")
.append(ChatColorType.HIGHLIGHT)
.append(StackFormatter.formatNumber(alchPrice))
.append(QuantityFormatter.formatNumber(alchPrice))
.append(ChatColorType.NORMAL)
.append("ea)");
}

View File

@@ -43,7 +43,7 @@ import javax.swing.border.EmptyBorder;
import net.runelite.client.util.AsyncBufferedImage;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.util.LinkBrowser;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
/**
* This panel displays an individual item result in the
@@ -126,7 +126,7 @@ class GrandExchangeItemPanel extends JPanel
JLabel gePriceLabel = new JLabel();
if (gePrice > 0)
{
gePriceLabel.setText(StackFormatter.formatNumber(gePrice) + " gp");
gePriceLabel.setText(QuantityFormatter.formatNumber(gePrice) + " gp");
}
else
{
@@ -141,13 +141,13 @@ class GrandExchangeItemPanel extends JPanel
// Alch price
JLabel haPriceLabel = new JLabel();
haPriceLabel.setText(StackFormatter.formatNumber(haPrice) + " alch");
haPriceLabel.setText(QuantityFormatter.formatNumber(haPrice) + " alch");
haPriceLabel.setForeground(ColorScheme.GRAND_EXCHANGE_ALCH);
alchAndLimitPanel.add(haPriceLabel, BorderLayout.WEST);
// GE Limit
JLabel geLimitLabel = new JLabel();
String limitLabelText = geItemLimit == 0 ? "" : "Limit " + StackFormatter.formatNumber(geItemLimit);
String limitLabelText = geItemLimit == 0 ? "" : "Limit " + QuantityFormatter.formatNumber(geItemLimit);
geLimitLabel.setText(limitLabelText);
geLimitLabel.setForeground(ColorScheme.GRAND_EXCHANGE_LIMIT);
geLimitLabel.setBorder(new CompoundBorder(geLimitLabel.getBorder(), new EmptyBorder(0, 0, 0, 7)));

View File

@@ -57,7 +57,7 @@ import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.components.ThinProgressBar;
import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
@Singleton
class GrandExchangeOfferSlot extends JPanel
@@ -228,17 +228,17 @@ class GrandExchangeOfferSlot extends JPanel
|| newOffer.getState() == GrandExchangeOfferState.CANCELLED_BUY;
String offerState = (buying ? "Bought " : "Sold ")
+ StackFormatter.quantityToRSDecimalStack(newOffer.getQuantitySold()) + " / "
+ StackFormatter.quantityToRSDecimalStack(newOffer.getTotalQuantity());
+ QuantityFormatter.quantityToRSDecimalStack(newOffer.getQuantitySold()) + " / "
+ QuantityFormatter.quantityToRSDecimalStack(newOffer.getTotalQuantity());
offerInfo.setText(offerState);
itemPrice.setText(htmlLabel("Price each: ", StackFormatter.formatNumber(newOffer.getPrice())));
itemPrice.setText(htmlLabel("Price each: ", QuantityFormatter.formatNumber(newOffer.getPrice())));
String action = buying ? "Spent: " : "Received: ";
offerSpent.setText(htmlLabel(action, StackFormatter.formatNumber(newOffer.getSpent()) + " / "
+ StackFormatter.formatNumber(newOffer.getPrice() * newOffer.getTotalQuantity())));
offerSpent.setText(htmlLabel(action, QuantityFormatter.formatNumber(newOffer.getSpent()) + " / "
+ QuantityFormatter.formatNumber(newOffer.getPrice() * newOffer.getTotalQuantity())));
progressBar.setForeground(getProgressColor(newOffer));
progressBar.setMaximumValue(newOffer.getTotalQuantity());

View File

@@ -83,7 +83,7 @@ import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.NavigationButton;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
import net.runelite.api.util.Text;
import net.runelite.http.api.RuneLiteAPI;
import net.runelite.http.api.ge.GrandExchangeClient;
@@ -504,11 +504,11 @@ public class GrandExchangePlugin extends Plugin
if (config.showExact())
{
titleBuilder.append(StackFormatter.formatNumber(total));
titleBuilder.append(QuantityFormatter.formatNumber(total));
}
else
{
titleBuilder.append(StackFormatter.quantityToStackSize(total));
titleBuilder.append(QuantityFormatter.quantityToStackSize(total));
}
titleBuilder.append(')');
@@ -573,7 +573,7 @@ public class GrandExchangePlugin extends Plugin
// If we have item buy limit, append it
if (itemLimit != null)
{
final String text = geText.getText() + BUY_LIMIT_GE_TEXT + StackFormatter.formatNumber(itemLimit);
final String text = geText.getText() + BUY_LIMIT_GE_TEXT + QuantityFormatter.formatNumber(itemLimit);
geText.setText(text);
}
}
@@ -600,7 +600,7 @@ public class GrandExchangePlugin extends Plugin
.subscribe(
(osbresult) ->
{
final String text = geText.getText() + OSB_GE_TEXT + StackFormatter.formatNumber(osbresult.getOverall_average());
final String text = geText.getText() + OSB_GE_TEXT + QuantityFormatter.formatNumber(osbresult.getOverall_average());
if (geText.getText().contains(OSB_GE_TEXT))
{
// If there are multiple tasks queued and one of them have already added the price

View File

@@ -59,7 +59,7 @@ import net.runelite.client.ui.overlay.OverlayUtil;
import net.runelite.client.ui.overlay.components.BackgroundComponent;
import net.runelite.client.ui.overlay.components.ProgressPieComponent;
import net.runelite.client.ui.overlay.components.TextComponent;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
@Singleton
public class GroundItemsOverlay extends Overlay
@@ -270,7 +270,7 @@ public class GroundItemsOverlay extends Overlay
else
{
itemStringBuilder.append(" (")
.append(StackFormatter.quantityToStackSize(item.getQuantity()))
.append(QuantityFormatter.quantityToStackSize(item.getQuantity()))
.append(")");
}
}
@@ -280,14 +280,14 @@ public class GroundItemsOverlay extends Overlay
if (item.getGePrice() > 0)
{
itemStringBuilder.append(" (EX: ")
.append(StackFormatter.quantityToStackSize(item.getGePrice()))
.append(QuantityFormatter.quantityToStackSize(item.getGePrice()))
.append(" gp)");
}
if (item.getHaPrice() > 0)
{
itemStringBuilder.append(" (HA: ")
.append(StackFormatter.quantityToStackSize(item.getHaPrice()))
.append(QuantityFormatter.quantityToStackSize(item.getHaPrice()))
.append(" gp)");
}
}
@@ -301,7 +301,7 @@ public class GroundItemsOverlay extends Overlay
{
itemStringBuilder
.append(" (")
.append(StackFormatter.quantityToStackSize(price))
.append(QuantityFormatter.quantityToStackSize(price))
.append(" gp)");
}
}

View File

@@ -100,7 +100,7 @@ import net.runelite.client.plugins.grounditems.config.TimerDisplayMode;
import net.runelite.client.plugins.grounditems.config.ValueCalculationMode;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
@PluginDescriptor(
name = "Ground Items",
@@ -1213,7 +1213,7 @@ public class GroundItemsPlugin extends Plugin
else
{
notificationStringBuilder.append(" (")
.append(StackFormatter.quantityToStackSize(item.getQuantity()))
.append(QuantityFormatter.quantityToStackSize(item.getQuantity()))
.append(")");
}
}

View File

@@ -60,7 +60,7 @@ import net.runelite.client.ui.components.IconTextField;
import net.runelite.client.ui.components.materialtabs.MaterialTab;
import net.runelite.client.ui.components.materialtabs.MaterialTabGroup;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
import net.runelite.http.api.hiscore.HiscoreClient;
import net.runelite.http.api.hiscore.HiscoreEndpoint;
import net.runelite.http.api.hiscore.HiscoreResult;
@@ -512,8 +512,8 @@ public class HiscorePanel extends PluginPanel
+ result.getRanged().getExperience() + result.getPrayer().getExperience();
content += "<p><span style = 'color:white'>Skill:</span> Combat</p>";
content += "<p><span style = 'color:white'>Exact Combat Level:</span> " + StackFormatter.formatNumber(combatLevel) + "</p>";
content += "<p><span style = 'color:white'>Experience:</span> " + StackFormatter.formatNumber(combatExperience) + "</p>";
content += "<p><span style = 'color:white'>Exact Combat Level:</span> " + QuantityFormatter.formatNumber(combatLevel) + "</p>";
content += "<p><span style = 'color:white'>Experience:</span> " + QuantityFormatter.formatNumber(combatExperience) + "</p>";
}
else
{
@@ -521,20 +521,20 @@ public class HiscorePanel extends PluginPanel
{
case CLUE_SCROLL_ALL:
{
String allRank = (result.getClueScrollAll().getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(result.getClueScrollAll().getRank());
String beginnerRank = (result.getClueScrollBeginner().getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(result.getClueScrollBeginner().getRank());
String easyRank = (result.getClueScrollEasy().getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(result.getClueScrollEasy().getRank());
String mediumRank = (result.getClueScrollMedium().getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(result.getClueScrollMedium().getRank());
String hardRank = (result.getClueScrollHard().getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(result.getClueScrollHard().getRank());
String eliteRank = (result.getClueScrollElite().getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(result.getClueScrollElite().getRank());
String masterRank = (result.getClueScrollMaster().getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(result.getClueScrollMaster().getRank());
String all = (result.getClueScrollAll().getLevel() == -1 ? "0" : StackFormatter.formatNumber(result.getClueScrollAll().getLevel()));
String beginner = (result.getClueScrollBeginner().getLevel() == -1 ? "0" : StackFormatter.formatNumber(result.getClueScrollBeginner().getLevel()));
String easy = (result.getClueScrollEasy().getLevel() == -1 ? "0" : StackFormatter.formatNumber(result.getClueScrollEasy().getLevel()));
String medium = (result.getClueScrollMedium().getLevel() == -1 ? "0" : StackFormatter.formatNumber(result.getClueScrollMedium().getLevel()));
String hard = (result.getClueScrollHard().getLevel() == -1 ? "0" : StackFormatter.formatNumber(result.getClueScrollHard().getLevel()));
String elite = (result.getClueScrollElite().getLevel() == -1 ? "0" : StackFormatter.formatNumber(result.getClueScrollElite().getLevel()));
String master = (result.getClueScrollMaster().getLevel() == -1 ? "0" : StackFormatter.formatNumber(result.getClueScrollMaster().getLevel()));
String allRank = (result.getClueScrollAll().getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(result.getClueScrollAll().getRank());
String beginnerRank = (result.getClueScrollBeginner().getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(result.getClueScrollBeginner().getRank());
String easyRank = (result.getClueScrollEasy().getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(result.getClueScrollEasy().getRank());
String mediumRank = (result.getClueScrollMedium().getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(result.getClueScrollMedium().getRank());
String hardRank = (result.getClueScrollHard().getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(result.getClueScrollHard().getRank());
String eliteRank = (result.getClueScrollElite().getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(result.getClueScrollElite().getRank());
String masterRank = (result.getClueScrollMaster().getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(result.getClueScrollMaster().getRank());
String all = (result.getClueScrollAll().getLevel() == -1 ? "0" : QuantityFormatter.formatNumber(result.getClueScrollAll().getLevel()));
String beginner = (result.getClueScrollBeginner().getLevel() == -1 ? "0" : QuantityFormatter.formatNumber(result.getClueScrollBeginner().getLevel()));
String easy = (result.getClueScrollEasy().getLevel() == -1 ? "0" : QuantityFormatter.formatNumber(result.getClueScrollEasy().getLevel()));
String medium = (result.getClueScrollMedium().getLevel() == -1 ? "0" : QuantityFormatter.formatNumber(result.getClueScrollMedium().getLevel()));
String hard = (result.getClueScrollHard().getLevel() == -1 ? "0" : QuantityFormatter.formatNumber(result.getClueScrollHard().getLevel()));
String elite = (result.getClueScrollElite().getLevel() == -1 ? "0" : QuantityFormatter.formatNumber(result.getClueScrollElite().getLevel()));
String master = (result.getClueScrollMaster().getLevel() == -1 ? "0" : QuantityFormatter.formatNumber(result.getClueScrollMaster().getLevel()));
content += "<p><span style = 'color:white'>All:</span> " + all + " <span style = 'color:white'>Rank:</span> " + allRank + "</p>";
content += "<p><span style = 'color:white'>Beginner:</span> " + beginner + " <span style = 'color:white'>Rank:</span> " + beginnerRank + "</p>";
content += "<p><span style = 'color:white'>Easy:</span> " + easy + " <span style = 'color:white'>Rank:</span> " + easyRank + "</p>";
@@ -546,27 +546,27 @@ public class HiscorePanel extends PluginPanel
}
case BOUNTY_HUNTER_ROGUE:
{
String rank = (result.getBountyHunterRogue().getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(result.getBountyHunterRogue().getRank());
String rank = (result.getBountyHunterRogue().getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(result.getBountyHunterRogue().getRank());
content += "<p><span style = 'color:white'>Rank:</span> " + rank + "</p>";
break;
}
case BOUNTY_HUNTER_HUNTER:
{
String rank = (result.getBountyHunterHunter().getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(result.getBountyHunterHunter().getRank());
String rank = (result.getBountyHunterHunter().getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(result.getBountyHunterHunter().getRank());
content += "<p><span style = 'color:white'>Rank:</span> " + rank + "</p>";
break;
}
case LAST_MAN_STANDING:
{
String rank = (result.getLastManStanding().getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(result.getLastManStanding().getRank());
String rank = (result.getLastManStanding().getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(result.getLastManStanding().getRank());
content += "<p><span style = 'color:white'>Rank:</span> " + rank + "</p>";
break;
}
case OVERALL:
{
Skill requestedSkill = result.getSkill(skill);
String rank = (requestedSkill.getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(requestedSkill.getRank());
String exp = (requestedSkill.getExperience() == -1L) ? "Unranked" : StackFormatter.formatNumber(requestedSkill.getExperience());
String rank = (requestedSkill.getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(requestedSkill.getRank());
String exp = (requestedSkill.getExperience() == -1L) ? "Unranked" : QuantityFormatter.formatNumber(requestedSkill.getExperience());
content += "<p><span style = 'color:white'>Skill:</span> " + skill.getName() + "</p>";
content += "<p><span style = 'color:white'>Rank:</span> " + rank + "</p>";
content += "<p><span style = 'color:white'>Experience:</span> " + exp + "</p>";
@@ -577,8 +577,8 @@ public class HiscorePanel extends PluginPanel
Skill requestedSkill = result.getSkill(skill);
final long experience = requestedSkill.getExperience();
String rank = (requestedSkill.getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(requestedSkill.getRank());
String exp = (experience == -1L) ? "Unranked" : StackFormatter.formatNumber(experience);
String rank = (requestedSkill.getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(requestedSkill.getRank());
String exp = (experience == -1L) ? "Unranked" : QuantityFormatter.formatNumber(experience);
String remainingXp;
if (experience == -1L)
{
@@ -587,7 +587,7 @@ public class HiscorePanel extends PluginPanel
else
{
int currentLevel = Experience.getLevelForXp((int) experience);
remainingXp = (currentLevel + 1 <= Experience.MAX_VIRT_LEVEL) ? StackFormatter.formatNumber(Experience.getXpForLevel(currentLevel + 1) - experience) : "0";
remainingXp = (currentLevel + 1 <= Experience.MAX_VIRT_LEVEL) ? QuantityFormatter.formatNumber(Experience.getXpForLevel(currentLevel + 1) - experience) : "0";
}
content += "<p><span style = 'color:white'>Skill:</span> " + skill.getName() + "</p>";

View File

@@ -46,7 +46,7 @@ import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.tooltip.Tooltip;
import net.runelite.client.ui.overlay.tooltip.TooltipManager;
import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
@Singleton
class ItemPricesOverlay extends Overlay
@@ -185,11 +185,11 @@ class ItemPricesOverlay extends Overlay
// Special case for coins and platinum tokens
if (id == ItemID.COINS_995)
{
return StackFormatter.formatNumber(qty) + " gp";
return QuantityFormatter.formatNumber(qty) + " gp";
}
else if (id == ItemID.PLATINUM_TOKEN)
{
return StackFormatter.formatNumber(qty * 1000) + " gp";
return QuantityFormatter.formatNumber(qty * 1000) + " gp";
}
ItemDefinition itemDef = itemManager.getItemDefinition(id);
@@ -236,12 +236,12 @@ class ItemPricesOverlay extends Overlay
if (gePrice > 0)
{
itemStringBuilder.append("EX: ")
.append(StackFormatter.quantityToStackSize(gePrice * qty))
.append(QuantityFormatter.quantityToStackSize(gePrice * qty))
.append(" gp");
if (plugin.isShowEA() && qty > 1)
{
itemStringBuilder.append(" (")
.append(StackFormatter.quantityToStackSize(gePrice))
.append(QuantityFormatter.quantityToStackSize(gePrice))
.append(" ea)");
}
}
@@ -253,12 +253,12 @@ class ItemPricesOverlay extends Overlay
}
itemStringBuilder.append("HA: ")
.append(StackFormatter.quantityToStackSize(haValue * qty))
.append(QuantityFormatter.quantityToStackSize(haValue * qty))
.append(" gp");
if (plugin.isShowEA() && qty > 1)
{
itemStringBuilder.append(" (")
.append(StackFormatter.quantityToStackSize(haValue))
.append(QuantityFormatter.quantityToStackSize(haValue))
.append(" ea)");
}
}

View File

@@ -62,7 +62,7 @@ import net.runelite.client.game.ItemManager;
import net.runelite.client.game.ItemMapping;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
@PluginDescriptor(
name = "Items Kept on Death",
@@ -586,7 +586,7 @@ public class ItemsKeptOnDeathPlugin extends Plugin
total += (long) price * w.getItemQuantity();
}
final Widget lostValue = client.getWidget(WidgetInfo.ITEMS_LOST_VALUE);
lostValue.setText(StackFormatter.quantityToStackSize(total) + " gp");
lostValue.setText(QuantityFormatter.quantityToStackSize(total) + " gp");
// Update Max items kept
final Widget max = client.getWidget(WidgetInfo.ITEMS_KEPT_MAX);

View File

@@ -65,7 +65,7 @@ import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.JagexColors;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
import net.runelite.http.api.item.ItemEquipmentStats;
import net.runelite.http.api.item.ItemStats;
@@ -376,7 +376,7 @@ public class ItemStatPlugin extends Plugin
createSeparator(invContainer, invContainer.getHeight() - 40);
final String coinText = "You have " + StackFormatter.quantityToRSStackSize(getCurrentGP())
final String coinText = "You have " + QuantityFormatter.quantityToStackSize(getCurrentGP())
+ (getCurrentGP() == 1 ? " coin." : " coins.");
final Widget coinWidget = createText(invContainer, coinText, FontID.PLAIN_12, ORANGE_TEXT,

View File

@@ -28,7 +28,7 @@ package net.runelite.client.plugins.kingdomofmiscellania;
import java.awt.image.BufferedImage;
import javax.inject.Singleton;
import net.runelite.client.ui.overlay.infobox.Counter;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
@Singleton
class KingdomCounter extends Counter
@@ -55,7 +55,7 @@ class KingdomCounter extends Counter
.append("/127")
.append("</br>")
.append("Coffer: ")
.append(StackFormatter.quantityToRSStackSize(plugin.getCoffer()))
.append(QuantityFormatter.quantityToStackSize(plugin.getCoffer()))
.toString();
}
}

View File

@@ -55,8 +55,8 @@ import net.runelite.client.game.ItemManager;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.FontManager;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.StackFormatter;
import net.runelite.api.util.Text;
import net.runelite.client.util.QuantityFormatter;
class LootTrackerBox extends JPanel
{
@@ -200,8 +200,8 @@ class LootTrackerBox extends JPanel
{
buildItems();
priceLabel.setText(StackFormatter.quantityToStackSize(totalPrice) + " gp");
priceLabel.setToolTipText(StackFormatter.formatNumber(totalPrice) + " gp");
priceLabel.setText(QuantityFormatter.quantityToStackSize(totalPrice) + " gp");
priceLabel.setToolTipText(QuantityFormatter.formatNumber(totalPrice) + " gp");
final long kills = getTotalKills();
if (kills > 1)
@@ -373,6 +373,6 @@ class LootTrackerBox extends JPanel
final int quantity = item.getQuantity();
final long price = item.getPrice();
final String ignoredLabel = item.isIgnored() ? " - Ignored" : "";
return name + " x " + quantity + " (" + StackFormatter.quantityToStackSize(price) + ") " + ignoredLabel;
return name + " x " + quantity + " (" + QuantityFormatter.quantityToStackSize(price) + ") " + ignoredLabel;
}
}

View File

@@ -60,7 +60,7 @@ import net.runelite.client.ui.PluginPanel;
import net.runelite.client.ui.components.PluginErrorPanel;
import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
import net.runelite.http.api.loottracker.LootTrackerClient;
@Slf4j
@@ -825,7 +825,7 @@ class LootTrackerPanel extends PluginPanel
private static String htmlLabel(String key, long value)
{
final String valueStr = StackFormatter.quantityToStackSize(value);
final String valueStr = QuantityFormatter.quantityToStackSize(value);
return String.format(HTML_LABEL_TEMPLATE, ColorUtil.toHexColor(ColorScheme.LIGHT_GRAY_COLOR), key, valueStr);
}
}

View File

@@ -118,8 +118,8 @@ import net.runelite.client.task.Schedule;
import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.NavigationButton;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.StackFormatter;
import net.runelite.api.util.Text;
import net.runelite.client.util.QuantityFormatter;
import net.runelite.http.api.RuneLiteAPI;
import net.runelite.http.api.loottracker.GameItem;
import net.runelite.http.api.loottracker.LootRecord;
@@ -627,7 +627,7 @@ public class LootTrackerPlugin extends Plugin
if (WorldType.isDeadmanWorld(client.getWorldType()) || WorldType.isHighRiskWorld(client.getWorldType()) ||
WorldType.isPvpWorld(client.getWorldType()) || client.getVar(Varbits.IN_WILDERNESS) == 1)
{
final String totalValue = StackFormatter.quantityToRSStackSize(playerLootReceived.getItems().stream()
final String totalValue = QuantityFormatter.quantityToStackSize(playerLootReceived.getItems().stream()
.mapToInt(itemStack -> itemManager.getItemPrice(itemStack.getId()) * itemStack.getQuantity()).sum());
chatMessageManager.queue(QueuedMessage.builder().type(ChatMessageType.CONSOLE).runeLiteFormattedMessage(
@@ -725,7 +725,7 @@ public class LootTrackerPlugin extends Plugin
final ChatMessageBuilder message = new ChatMessageBuilder()
.append(ChatColorType.HIGHLIGHT)
.append("Your loot is worth around ")
.append(StackFormatter.formatNumber(chestPrice))
.append(QuantityFormatter.formatNumber(chestPrice))
.append(" coins.")
.append(ChatColorType.NORMAL);

View File

@@ -45,7 +45,7 @@ import net.runelite.client.ui.overlay.components.PanelComponent;
import net.runelite.client.ui.overlay.components.table.TableAlignment;
import net.runelite.client.ui.overlay.components.table.TableComponent;
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
@Singleton
class NightmareZoneOverlay extends Overlay
@@ -109,12 +109,12 @@ class NightmareZoneOverlay extends Overlay
TableComponent tableComponent = new TableComponent();
tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT);
tableComponent.addRow("Points:", StackFormatter.formatNumber(currentPoints));
tableComponent.addRow("Points/Hour:", StackFormatter.formatNumber(plugin.getPointsPerHour()));
tableComponent.addRow("Points:", QuantityFormatter.formatNumber(currentPoints));
tableComponent.addRow("Points/Hour:", QuantityFormatter.formatNumber(plugin.getPointsPerHour()));
if (plugin.isShowtotalpoints())
{
tableComponent.addRow("Total:", StackFormatter.formatNumber(totalPoints));
tableComponent.addRow("Total:", QuantityFormatter.formatNumber(totalPoints));
}
panelComponent.getChildren().add(tableComponent);

View File

@@ -69,7 +69,7 @@ import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType;
import net.runelite.client.util.PvPUtil;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
import net.runelite.http.api.discord.DiscordClient;
import net.runelite.http.api.discord.DiscordEmbed;
import net.runelite.http.api.discord.DiscordMessage;
@@ -495,7 +495,7 @@ public class PlayerScouter extends Plugin
fieldList.add(FieldEmbed.builder()
.name("Risk")
.value(StackFormatter.quantityToRSDecimalStack(player.getRisk()))
.value(QuantityFormatter.quantityToRSDecimalStack(player.getRisk()))
.inline(true)
.build());
@@ -561,7 +561,7 @@ public class PlayerScouter extends Plugin
fieldList.add(FieldEmbed.builder()
.name(name)
.value("Value: " + StackFormatter.quantityToRSDecimalStack(value))
.value("Value: " + QuantityFormatter.quantityToRSDecimalStack(value))
.inline(true)
.build());
}

View File

@@ -63,8 +63,8 @@ import net.runelite.client.util.AsyncBufferedImage;
import net.runelite.client.util.HotkeyListener;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.PvPUtil;
import static net.runelite.client.util.StackFormatter.quantityToRSDecimalStack;
import net.runelite.api.util.Text;
import net.runelite.client.util.QuantityFormatter;
import org.apache.commons.lang3.ArrayUtils;
@PluginDescriptor(
@@ -536,7 +536,7 @@ public class PvpToolsPlugin extends Plugin
}
wealth += value;
}
panel.totalRiskLabel.setText(htmlLabel("Total risk: ", quantityToRSDecimalStack(wealth)));
panel.totalRiskLabel.setText(htmlLabel("Total risk: ", QuantityFormatter.quantityToRSDecimalStack(wealth)));
panel.totalRiskLabel.repaint();
int itemLimit = 0;
@@ -572,7 +572,7 @@ public class PvpToolsPlugin extends Plugin
}
}
panel.riskProtectingItem.setText(htmlLabel("Risk Protecting Item: ",
quantityToRSDecimalStack(descendingMap.keySet().stream().mapToInt(Integer::intValue).sum())));
QuantityFormatter.quantityToRSDecimalStack(descendingMap.keySet().stream().mapToInt(Integer::intValue).sum())));
panel.riskProtectingItem.repaint();
panel.biggestItemLabel.setText("Most Valuable Item: ");

View File

@@ -0,0 +1,156 @@
/*
* Copyright (c) 2018, trimbe <github.com/trimbe>
* 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.randomevents;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@ConfigGroup("randomevents")
public interface RandomEventConfig extends Config
{
@ConfigItem(
keyName = "removeMenuOptions",
name = "Remove others' menu options",
description = "Remove menu options from random events for other players.",
position = 0
)
default boolean removeMenuOptions()
{
return true;
}
@ConfigItem(
keyName = "notifyDunce",
name = "Notify on Surprise Exam",
description = "",
position = 1
)
default boolean notifyDunce()
{
return false;
}
@ConfigItem(
keyName = "notifyGenie",
name = "Notify on Genie",
description = "",
position = 2
)
default boolean notifyGenie()
{
return false;
}
@ConfigItem(
keyName = "notifyDemon",
name = "Notify on Drill Demon",
description = "",
position = 3
)
default boolean notifyDemon()
{
return false;
}
@ConfigItem(
keyName = "notifyForester",
name = "Notify on Freaky Forester",
description = "",
position = 4
)
default boolean notifyForester()
{
return false;
}
@ConfigItem(
keyName = "notifyFrog",
name = "Notify on Kiss the Frog",
description = "",
position = 5
)
default boolean notifyFrog()
{
return false;
}
@ConfigItem(
keyName = "notifyGravedigger",
name = "Notify on Gravedigger",
description = "",
position = 6
)
default boolean notifyGravedigger()
{
return false;
}
@ConfigItem(
keyName = "notifyMoM",
name = "Notify on Mysterious Old Man",
description = "",
position = 7
)
default boolean notifyMoM()
{
return false;
}
@ConfigItem(
keyName = "notifyBob",
name = "Notify on Evil Bob",
description = "",
position = 8
)
default boolean notifyBob()
{
return false;
}
@ConfigItem(
keyName = "notifyQuiz",
name = "Notify on Quiz Master",
description = "",
position = 9
)
default boolean notifyQuiz()
{
return false;
}
@ConfigItem(
keyName = "notifyAll",
name = "Notify for all events",
description = "",
position = 10
)
default boolean notifyAllEvents()
{
return false;
}
}

View File

@@ -0,0 +1,281 @@
/*
* Copyright (c) 2018, trimbe <github.com/trimbe>
* 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.randomevents;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Provides;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import net.runelite.api.Actor;
import net.runelite.api.Client;
import net.runelite.api.MenuOpcode;
import net.runelite.api.NPC;
import net.runelite.api.NpcID;
import net.runelite.api.Player;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.InteractingChanged;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.NpcSpawned;
import net.runelite.client.Notifier;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
@PluginDescriptor(
name = "Random Events",
description = "Notify when random events appear and remove talk/dismiss options on events that aren't yours.",
enabledByDefault = false
)
public class RandomEventPlugin extends Plugin
{
private static final Set<Integer> EVENT_NPCS = ImmutableSet.of(
NpcID.DR_JEKYLL, NpcID.DR_JEKYLL_314,
NpcID.BEE_KEEPER_6747,
NpcID.CAPT_ARNAV,
NpcID.SERGEANT_DAMIEN_6743,
NpcID.DRUNKEN_DWARF,
NpcID.FREAKY_FORESTER_6748,
NpcID.GENIE, NpcID.GENIE_327,
NpcID.EVIL_BOB, NpcID.EVIL_BOB_6754,
NpcID.POSTIE_PETE_6738,
NpcID.LEO_6746,
NpcID.MYSTERIOUS_OLD_MAN_6750, NpcID.MYSTERIOUS_OLD_MAN_6751,
NpcID.MYSTERIOUS_OLD_MAN_6752, NpcID.MYSTERIOUS_OLD_MAN_6753,
NpcID.PILLORY_GUARD,
NpcID.FLIPPA_6744,
NpcID.QUIZ_MASTER_6755,
NpcID.RICK_TURPENTINE, NpcID.RICK_TURPENTINE_376,
NpcID.SANDWICH_LADY,
NpcID.DUNCE_6749,
NpcID.NILES, NpcID.NILES_5439,
NpcID.MILES, NpcID.MILES_5440,
NpcID.GILES, NpcID.GILES_5441,
NpcID.FROG_5429
);
private static final Set<String> EVENT_OPTIONS = ImmutableSet.of(
"Talk-to",
"Dismiss"
);
private static final int RANDOM_EVENT_TIMEOUT = 150;
private Map<NPC, Integer> spawnedNpcs = new HashMap<>();
private NPC currentRandomEvent;
// event npcs teleport to you to stay in range, we need to throttle spawns
private int lastEventTick = -RANDOM_EVENT_TIMEOUT;
@Inject
private Client client;
@Inject
private Notifier notifier;
@Inject
private RandomEventConfig config;
@Inject
private EventBus eventBus;
private boolean notifyAllEvents;
private boolean notifyDemon;
private boolean notifyForester;
private boolean notifyFrog;
private boolean notifyGenie;
private boolean notifyBob;
private boolean notifyGravedigger;
private boolean notifyMoM;
private boolean notifyQuiz;
private boolean notifyDunce;
@Provides
RandomEventConfig getConfig(ConfigManager configManager)
{
return configManager.getConfig(RandomEventConfig.class);
}
@Override
protected void startUp() throws Exception
{
updateConfig();
addSubscriptions();
}
@Override
protected void shutDown() throws Exception
{
eventBus.unregister(this);
lastEventTick = 0;
currentRandomEvent = null;
spawnedNpcs.clear();
}
private void addSubscriptions()
{
eventBus.subscribe(NpcSpawned.class, this, this::onNpcSpawned);
eventBus.subscribe(InteractingChanged.class, this, this::onInteractingChanged);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
eventBus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded);
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
}
private void onNpcSpawned(NpcSpawned event)
{
NPC npc = event.getNpc();
if (!EVENT_NPCS.contains(npc.getId()))
{
return;
}
// only occasionally do event npcs spawn with non-null interacting
if (npc.getInteracting() == client.getLocalPlayer())
{
if (client.getTickCount() - lastEventTick > RANDOM_EVENT_TIMEOUT)
{
currentRandomEvent = npc;
lastEventTick = client.getTickCount();
}
}
else
{
spawnedNpcs.put(npc, client.getTickCount());
}
}
private void onInteractingChanged(InteractingChanged event)
{
Actor source = event.getSource();
Actor target = event.getTarget();
if (spawnedNpcs.containsKey(source))
{
Player player = client.getLocalPlayer();
if (player == target && client.getTickCount() - lastEventTick > RANDOM_EVENT_TIMEOUT)
{
currentRandomEvent = (NPC) source;
if (shouldNotify(currentRandomEvent.getId()))
{
notifier.notify("Random event spawned: " + currentRandomEvent.getName());
}
}
}
}
private void onGameTick(GameTick event)
{
if (!spawnedNpcs.isEmpty())
{
// allow 2 ticks for interacting to get set
spawnedNpcs.entrySet().removeIf(entry -> client.getTickCount() - entry.getValue() >= 2);
}
if (client.getTickCount() - lastEventTick > RANDOM_EVENT_TIMEOUT)
{
currentRandomEvent = null;
}
}
private void onMenuEntryAdded(MenuEntryAdded event)
{
if (event.getOpcode() >= MenuOpcode.NPC_FIRST_OPTION.getId()
&& event.getOpcode() <= MenuOpcode.NPC_FIFTH_OPTION.getId()
&& EVENT_OPTIONS.contains(event.getOption()))
{
NPC npc = client.getCachedNPCs()[event.getIdentifier()];
if (npc != null && EVENT_NPCS.contains(npc.getId()) && npc != currentRandomEvent && config.removeMenuOptions())
{
client.setMenuEntries(Arrays.copyOf(client.getMenuEntries(), client.getMenuEntries().length - 1));
}
}
}
private boolean shouldNotify(int id)
{
if (this.notifyAllEvents)
{
return true;
}
switch (id)
{
case NpcID.SERGEANT_DAMIEN_6743:
return this.notifyDemon;
case NpcID.FREAKY_FORESTER_6748:
return this.notifyForester;
case NpcID.FROG_5429:
return this.notifyFrog;
case NpcID.GENIE:
case NpcID.GENIE_327:
return this.notifyGenie;
case NpcID.EVIL_BOB:
case NpcID.EVIL_BOB_6754:
return this.notifyBob;
case NpcID.LEO_6746:
return this.notifyGravedigger;
case NpcID.MYSTERIOUS_OLD_MAN_6750:
case NpcID.MYSTERIOUS_OLD_MAN_6751:
case NpcID.MYSTERIOUS_OLD_MAN_6752:
case NpcID.MYSTERIOUS_OLD_MAN_6753:
return this.notifyMoM;
case NpcID.QUIZ_MASTER_6755:
return this.notifyQuiz;
case NpcID.DUNCE_6749:
return this.notifyDunce;
default:
return false;
}
}
private void onConfigChanged(ConfigChanged event)
{
if (!"randomevents".equals(event.getGroup()))
{
return;
}
updateConfig();
}
private void updateConfig()
{
this.notifyAllEvents = config.notifyAllEvents();
this.notifyDemon = config.notifyDemon();
this.notifyForester = config.notifyForester();
this.notifyFrog = config.notifyFrog();
this.notifyGenie = config.notifyGenie();
this.notifyBob = config.notifyBob();
this.notifyGravedigger = config.notifyGravedigger();
this.notifyMoM = config.notifyMoM();
this.notifyQuiz = config.notifyQuiz();
this.notifyDunce = config.notifyDunce();
}
}

View File

@@ -633,7 +633,7 @@ public class SlayerPlugin extends Plugin
forcedWait--;
}
if (infoTimer != null)
if (infoTimer != null && config.statTimeout() != 0)
{
Duration timeSinceInfobox = Duration.between(infoTimer, Instant.now());
Duration statTimeout = Duration.ofMinutes(this.statTimeout);

View File

@@ -22,7 +22,7 @@ import net.runelite.client.ui.PluginPanel;
import net.runelite.client.ui.components.PluginErrorPanel;
import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
@Singleton
public class SlayerTaskPanel extends PluginPanel
@@ -367,7 +367,7 @@ public class SlayerTaskPanel extends PluginPanel
private static String htmlLabel(String key, int value)
{
String valueStr = StackFormatter.quantityToRSDecimalStack(value);
String valueStr = QuantityFormatter.quantityToRSDecimalStack(value);
return String.format(HTML_LABEL_TEMPLATE, ColorUtil.toHexColor(ColorScheme.LIGHT_GRAY_COLOR),
key, valueStr);
}

View File

@@ -19,7 +19,7 @@ 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.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
@Singleton
class TaskBox extends JPanel
@@ -301,7 +301,7 @@ class TaskBox extends JPanel
private static String htmlLabel(int value)
{
String valueStr = StackFormatter.quantityToRSDecimalStack(value);
String valueStr = QuantityFormatter.quantityToRSDecimalStack(value);
return String.format(HTML_LABEL_TEMPLATE, valueStr);
}
}

View File

@@ -42,7 +42,7 @@ import net.runelite.client.plugins.loottracker.localstorage.LTItemEntry;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.components.shadowlabel.JShadowedLabel;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
@Getter
class ItemPanel extends JPanel
@@ -84,7 +84,7 @@ class ItemPanel extends JPanel
labelName.setForeground(getRSValueColor(this.record.getPrice()));
labelName.setVerticalAlignment(SwingUtilities.BOTTOM);
final JShadowedLabel labelValue = new JShadowedLabel(StackFormatter.quantityToStackSize(total) + " gp");
final JShadowedLabel labelValue = new JShadowedLabel(QuantityFormatter.quantityToStackSize(total) + " gp");
labelValue.setFont(FontManager.getRunescapeSmallFont());
labelValue.setForeground(getRSValueColor(total));
labelValue.setVerticalAlignment(SwingUtilities.TOP);
@@ -113,9 +113,9 @@ class ItemPanel extends JPanel
final int quantity = record.getQuantity();
final long price = record.getPrice();
return "<html>" + name + " x " + StackFormatter.formatNumber(quantity)
+ "<br/>Price: " + StackFormatter.quantityToStackSize(price)
+ "<br/>Total: " + StackFormatter.quantityToStackSize(quantity * price) + "</html>";
return "<html>" + name + " x " + QuantityFormatter.formatNumber(quantity)
+ "<br/>Price: " + QuantityFormatter.quantityToStackSize(price)
+ "<br/>Total: " + QuantityFormatter.quantityToStackSize(quantity * price) + "</html>";
}
private static Color getRSValueColor(long val)

View File

@@ -33,7 +33,7 @@ import javax.swing.border.EmptyBorder;
import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.loottracker.localstorage.LTItemEntry;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
class LootGrid extends JPanel
{
@@ -81,8 +81,8 @@ class LootGrid extends JPanel
final int quantity = item.getQuantity();
final long price = item.getPrice();
return "<html>" + name + " x " + StackFormatter.formatNumber(quantity)
+ "<br/>Price: " + StackFormatter.quantityToStackSize(price)
+ "<br/>Total: " + StackFormatter.quantityToStackSize(quantity * price) + "</html>";
return "<html>" + name + " x " + QuantityFormatter.formatNumber(quantity)
+ "<br/>Price: " + QuantityFormatter.quantityToStackSize(price)
+ "<br/>Total: " + QuantityFormatter.quantityToStackSize(quantity * price) + "</html>";
}
}

View File

@@ -35,7 +35,7 @@ import javax.swing.SwingConstants;
import javax.swing.border.Border;
import lombok.Getter;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
@Getter
class TextPanel extends JPanel
@@ -58,7 +58,7 @@ class TextPanel extends JPanel
totalText.setForeground(Color.WHITE);
// Item Values (Colored off Total Value of item)
final JLabel total = new JLabel(StackFormatter.quantityToStackSize(totalValue) + " gp", SwingConstants.LEFT);
final JLabel total = new JLabel(QuantityFormatter.quantityToStackSize(totalValue) + " gp", SwingConstants.LEFT);
total.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
total.setForeground(getRSValueColor(totalValue));
@@ -74,7 +74,7 @@ class TextPanel extends JPanel
c.gridy = 0;
c.ipady = 20;
panel.setToolTipText(StackFormatter.formatNumber(totalValue));
panel.setToolTipText(QuantityFormatter.formatNumber(totalValue));
this.add(panel, c);
}

View File

@@ -43,7 +43,7 @@ import net.runelite.client.plugins.stonedtracker.data.UniqueItem;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.util.AsyncBufferedImage;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
@Getter
class UniqueItemPanel extends JPanel
@@ -108,15 +108,15 @@ class UniqueItemPanel extends JPanel
String s = "<html>" + item.getName();
if (qty > 0)
{
s += " x " + StackFormatter.formatNumber(qty);
s += " x " + QuantityFormatter.formatNumber(qty);
}
if (item.getPrice() > 0)
{
s += "<br/>Price: " + StackFormatter.quantityToStackSize(item.getPrice());
s += "<br/>Price: " + QuantityFormatter.quantityToStackSize(item.getPrice());
// Check for qty here as well as we should only show Total if the item has a value as well
if (qty > 0)
{
s += "<br/>Total: " + StackFormatter.quantityToStackSize(qty * item.getPrice()) + "</html";
s += "<br/>Total: " + QuantityFormatter.quantityToStackSize(qty * item.getPrice()) + "</html";
}
}
s += "</html>";

View File

@@ -46,7 +46,7 @@ import net.runelite.client.game.ItemManager;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.FontManager;
import net.runelite.client.util.AsyncBufferedImage;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
@Singleton
class SuppliesBox extends JPanel
@@ -166,8 +166,8 @@ class SuppliesBox extends JPanel
{
buildItems();
priceLabel.setText(StackFormatter.quantityToStackSize(totalPrice) + " gp");
priceLabel.setToolTipText(StackFormatter.formatNumber(totalPrice) + " gp");
priceLabel.setText(QuantityFormatter.quantityToStackSize(totalPrice) + " gp");
priceLabel.setToolTipText(QuantityFormatter.formatNumber(totalPrice) + " gp");
final long supplies = getTotalSupplies();
if (supplies > 0)
@@ -341,7 +341,7 @@ class SuppliesBox extends JPanel
ItemDefinition item = this.itemManager.getItemDefinition(itemId);
final String name = item.getName();
final long price = item.getPrice();
return name + " x " + qty + " (" + StackFormatter.quantityToStackSize(price * qty) + ") ";
return name + " x " + qty + " (" + QuantityFormatter.quantityToStackSize(price * qty) + ") ";
}
}

View File

@@ -45,7 +45,7 @@ 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;
import net.runelite.client.util.QuantityFormatter;
@Singleton
class SuppliesTrackerPanel extends PluginPanel
@@ -154,7 +154,7 @@ class SuppliesTrackerPanel extends PluginPanel
*/
private static String htmlLabel(String key, long value)
{
final String valueStr = StackFormatter.quantityToStackSize(value);
final String valueStr = QuantityFormatter.quantityToStackSize(value);
return String.format(HTML_LABEL_TEMPLATE, ColorUtil.toHexColor(ColorScheme.LIGHT_GRAY_COLOR), key, valueStr);
}

View File

@@ -115,6 +115,7 @@ public class TimersPlugin extends Plugin
private static final int POISON_TICK_LENGTH = 30;
private static final String SUPER_ANTIVENOM_DRINK_MESSAGE = "You drink some of your super antivenom potion";
private static final String KILLED_TELEBLOCK_OPPONENT_TEXT = "<col=4f006f>Your Tele Block has been removed because you killed ";
private static final String PRAYER_ENHANCE_EXPIRED = "<col=ff0000>Your prayer enhance effect has worn off.</col>";
private static final Pattern DEADMAN_HALF_TELEBLOCK_PATTERN = Pattern.compile("<col=4f006f>A Tele Block spell has been cast on you by (.+)\\. It will expire in 1 minute, 15 seconds\\.</col>");
private static final Pattern FULL_TELEBLOCK_PATTERN = Pattern.compile("<col=4f006f>A Tele Block spell has been cast on you by (.+)\\. It will expire in 5 minutes, 0 seconds\\.</col>");
private static final Pattern HALF_TELEBLOCK_PATTERN = Pattern.compile("<col=4f006f>A Tele Block spell has been cast on you by (.+)\\. It will expire in 2 minutes, 30 seconds\\.</col>");
@@ -628,6 +629,11 @@ public class TimersPlugin extends Plugin
createGameTimer(PRAYER_ENHANCE);
}
if (this.showPrayerEnhance && event.getMessage().equals(PRAYER_ENHANCE_EXPIRED))
{
removeGameTimer(PRAYER_ENHANCE);
}
if (this.showCharge && event.getMessage().equals(CHARGE_MESSAGE))
{
createGameTimer(CHARGE);

View File

@@ -30,7 +30,7 @@ import java.time.format.TextStyle;
import java.time.temporal.ChronoUnit;
import java.util.Locale;
import javax.swing.JPanel;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
public abstract class TabContentPanel extends JPanel
{
@@ -82,7 +82,7 @@ public abstract class TabContentPanel extends JPanel
sb.append(endTime.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.getDefault())).append(" ");
}
sb.append("at ").append(StackFormatter.getPlatformTimeStringFromLocalDateTime(endTime));
sb.append("at ").append(QuantityFormatter.getPlatformTimeStringFromLocalDateTime(endTime));
return sb.toString();
}
}

View File

@@ -131,7 +131,8 @@ enum TeleportLocationData
NEITIZNOT_LYRE(TeleportType.OTHER, "Enchanted Lyre", "Neitiznot", new WorldPoint(2336, 3801, 0), "enchanted_lyre_teleport_icon.png"),
JATIZSO_LYRE(TeleportType.OTHER, "Enchanted Lyre", "Jatizso", new WorldPoint(2409, 3809, 0), "enchanted_lyre_teleport_icon.png"),
WEISS_ICY_BASALT(TeleportType.OTHER, "Icy Basalt", "Weiss", new WorldPoint(2846, 3940, 0), "icy_basalt_teleport_icon.png"),
TROLL_STRONGHOLD_STONY_BASALT(TeleportType.OTHER, "Stony Basalt", "Troll Stronghold", new WorldPoint(2838, 3693, 0), "stony_basalt_teleport_icon.png"),
TROLL_STRONGHOLD_STONY_BASALT(TeleportType.OTHER, "Stony Basalt", "Troll Stronghold (with 73 Agility)", new WorldPoint(2838, 3693, 0), "stony_basalt_teleport_icon.png"),
TROLL_STRONGHOLD_STONY_BASALT_OUTSIDE(TeleportType.OTHER, "Stony Basalt", "Troll Stronghold", new WorldPoint(2844, 3693, 0), "stony_basalt_teleport_icon.png"),
KHAREDSTS_MEMOIRS_HOSIDIUS(TeleportType.OTHER, "Kharedst's Memoirs", "Lunch by the Lancalliums (Hosidius)", new WorldPoint(1713, 3612, 0), "kharedsts_memoirs_teleport_icon.png"),
KHAREDSTS_MEMOIRS_PISCARILIUS(TeleportType.OTHER, "Kharedst's Memoirs", "The Fisher's Flute (Piscarilius)", new WorldPoint(1802, 3748, 0), "kharedsts_memoirs_teleport_icon.png"),
KHAREDSTS_MEMOIRS_SHAYZIEN(TeleportType.OTHER, "Kharedst's Memoirs", "History and Hearsay (Shayzien)", new WorldPoint(1476, 3580, 0), "kharedsts_memoirs_teleport_icon.png"),

View File

@@ -37,9 +37,10 @@ import javax.annotation.Nullable;
enum TransportationPointLocation
{
//Ships
ARDOUGNE_TO_BRIMHAVEN("Ship to Brimhaven", new WorldPoint(2675, 3275, 0), new WorldPoint(2772, 3234, 0)),
ARDOUGNE_TO_BRIMHAVEN("Ship to Brimhaven / Rimmington", new WorldPoint(2675, 3275, 0)),
ARDOUGNE_TO_FISHINGPLAT("Ship to Fishing Platform", new WorldPoint(2722, 3304, 0), new WorldPoint(2779, 3271, 0)),
BRIMHAVEN_TO_ARDOUGNE("Ship to Ardougne", new WorldPoint(2772, 3234, 0), new WorldPoint(2675, 3275, 0)),
BRIMHAVEN_TO_ARDOUGNE("Ship to Ardougne / Rimmington", new WorldPoint(2772, 3234, 0)),
RIMMINGTON_TO_ARDOUGNE("Ship to Ardougne / Brimhaven", new WorldPoint(2915, 3224, 0)),
CATHERBY_TO_KEEP_LE_FAYE("Ship to Keep Le Faye", new WorldPoint(2804, 3421, 0), new WorldPoint(2769, 3402, 0)),
CORSAIR_TO_RIMMINGTON("Ship to Rimmington", new WorldPoint(2577, 2839, 0), new WorldPoint(2909, 3227, 0 )),
DRAGONTOOTH_TO_PHASMATYS("Ship to Port Phasmatys", new WorldPoint(3791, 3561, 0), new WorldPoint(3703, 3487, 0)),
@@ -50,7 +51,7 @@ enum TransportationPointLocation
ICEBERG_TO_RELLEKKA("Ship to Rellekka", new WorldPoint(2657, 3988, 0), new WorldPoint(2707, 3735, 0)),
ISLAND_TO_APE_ATOLL("Ship to Ape Atoll", new WorldPoint(2891, 2726, 0), new WorldPoint(2802, 2706, 0)),
JATIZSO_TO_RELLEKKA("Ship to Rellekka", new WorldPoint(2420, 3780, 0), new WorldPoint(2639, 3710, 0)),
KARAMJA_TO_PORT_SARIM("Ship to Port Sarim", new WorldPoint(2955, 3144, 0), new WorldPoint(3029, 3218, 0)),
KARAMJA_TO_PORT_SARIM("Ship to Port Sarim", new WorldPoint(2955, 3145, 0), new WorldPoint(3029, 3218, 0)),
KARAMJA_TO_PORT_KHAZARD("Ship to Port Khazard", new WorldPoint(2763, 2957, 0), new WorldPoint(2653, 3166, 0)),
LANDSEND_TO_PORTSARIM_PORTPISCARILIUS("Ship to Port Sarim/Port Piscarilius", new WorldPoint(1503, 3398, 0)),
LUNAR_ISLE_TO_PIRATES_COVE("Ship to Pirates' Cove", new WorldPoint(2137, 3899, 0), new WorldPoint(2223, 3796, 0)),
@@ -108,7 +109,7 @@ enum TransportationPointLocation
CHARTER_BRIMHAVEN("Charter Ship", new WorldPoint(2760, 3238, 0)),
CHARTER_CATHERBY("Charter Ship", new WorldPoint(2791, 3415, 0)),
CHARTER_CORSAIR_("Charter Ship", new WorldPoint(2589, 2851, 0)),
CHARTER_KARAMJA_NORTH("Charter Ship", new WorldPoint(2954, 3159, 0)),
CHARTER_KARAMJA_NORTH("Charter Ship", new WorldPoint(2954, 3158, 0)),
CHARTER_KARAMJA_EAST("Charter Ship", new WorldPoint(2999, 3032, 0)),
CHARTER_KHAZARD("Charter Ship", new WorldPoint(2673, 3143, 0)),
CHARTER_MOSLE_HARMLESS("Charter Ship", new WorldPoint(3669, 2931, 0)),

View File

@@ -59,7 +59,7 @@ import net.runelite.client.ui.SkillColor;
import net.runelite.client.ui.components.ProgressBar;
import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.LinkBrowser;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
class XpInfoBox extends JPanel
{
@@ -364,7 +364,7 @@ class XpInfoBox extends JPanel
static String htmlLabel(String key, int value)
{
String valueStr = StackFormatter.quantityToRSDecimalStack(value, true);
String valueStr = QuantityFormatter.quantityToRSDecimalStack(value, true);
return String.format(HTML_LABEL_TEMPLATE, ColorUtil.toHexColor(ColorScheme.LIGHT_GRAY_COLOR), key, valueStr);
}
}

View File

@@ -46,7 +46,7 @@ import net.runelite.client.ui.overlay.components.LineComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
import net.runelite.client.ui.overlay.components.ProgressBarComponent;
import net.runelite.client.ui.overlay.components.SplitComponent;
import net.runelite.client.util.StackFormatter;
import net.runelite.client.util.QuantityFormatter;
class XpInfoBoxOverlay extends Overlay
{
@@ -119,7 +119,7 @@ class XpInfoBoxOverlay extends Overlay
final LineComponent xpLine = LineComponent.builder()
.left(leftStr + ":")
.right(StackFormatter.quantityToRSDecimalStack(rightNum, true))
.right(QuantityFormatter.quantityToRSDecimalStack(rightNum, true))
.build();
final String bottemLeftStr;
@@ -140,7 +140,7 @@ class XpInfoBoxOverlay extends Overlay
final LineComponent xpLineBottom = LineComponent.builder()
.left(bottemLeftStr + ":")
.right(StackFormatter.quantityToRSDecimalStack(bottomRightNum, true))
.right(QuantityFormatter.quantityToRSDecimalStack(bottomRightNum, true))
.build();
final SplitComponent xpSplit = SplitComponent.builder()

View File

@@ -51,7 +51,6 @@ public class WidgetOverlay extends Overlay
.put(WidgetInfo.PEST_CONTROL_INFO, OverlayPosition.TOP_LEFT)
.put(WidgetInfo.ZEAH_MESS_HALL_COOKING_DISPLAY, OverlayPosition.TOP_LEFT)
.put(WidgetInfo.PVP_BOUNTY_HUNTER_INFO, OverlayPosition.TOP_RIGHT)
.put(WidgetInfo.PVP_KILLDEATH_COUNTER, OverlayPosition.TOP_LEFT)
.put(WidgetInfo.SKOTIZO_CONTAINER, OverlayPosition.TOP_LEFT)
.put(WidgetInfo.KOUREND_FAVOUR_OVERLAY, OverlayPosition.TOP_CENTER)
.put(WidgetInfo.MULTICOMBAT_FIXED, OverlayPosition.BOTTOM_RIGHT)

View File

@@ -21,7 +21,6 @@ import net.runelite.api.Varbits;
import net.runelite.api.WorldType;
import net.runelite.api.coords.WorldPoint;
import net.runelite.client.game.ItemManager;
import static net.runelite.client.util.StackFormatter.quantityToRSDecimalStack;
import org.apache.commons.lang3.ArrayUtils;
/**
@@ -106,7 +105,7 @@ public class PvPUtil
}
wealth += value;
}
return Integer.parseInt(quantityToRSDecimalStack(priceMap.keySet().stream().mapToInt(Integer::intValue).sum()));
return Integer.parseInt(QuantityFormatter.quantityToRSDecimalStack(priceMap.keySet().stream().mapToInt(Integer::intValue).sum()));
}
}

View File

@@ -37,10 +37,9 @@ import java.util.regex.Pattern;
import net.runelite.client.RuneLite;
/**
* A set of utility functions to use when
* formatting numbers for to stack sizes.
* A set of utility functions to use when formatting quantities
*/
public class StackFormatter
public class QuantityFormatter
{
/**
* A list of suffixes to use when formatting stack sizes.
@@ -52,44 +51,18 @@ public class StackFormatter
*/
private static final Pattern SUFFIX_PATTERN = Pattern.compile("^-?[0-9,.]+([a-zA-Z]?)$");
/**
* A number formatter
*/
private static final NumberFormat NUMBER_FORMATTER = NumberFormat.getInstance(Locale.ENGLISH);
/**
* A decimal number formatter
*/
private static final NumberFormat DECIMAL_FORMATTER = new DecimalFormat(
"#,###.#",
DecimalFormatSymbols.getInstance(Locale.ENGLISH)
);
/**
* A more precise decimal number formatter, outputting thousandths
*/
private static final NumberFormat PRECISE_DECIMAL_FORMATTER = new DecimalFormat(
"#,###.###",
DecimalFormatSymbols.getInstance(Locale.ENGLISH)
);
/**
* Attempts to call the platform to get a localized time string based on
* the users preferences. Falls back on using locale default if it is on a
* platform that has no consistent way of obtaining this information.
*
* @param localDateTime The LocalDateTime object to format as a string
* @return The formatted string.
*/
public static String getPlatformTimeStringFromLocalDateTime(LocalDateTime localDateTime)
{
if (OSType.getOSType() == OSType.Windows)
{
return WinApi.getTimeFormatString(localDateTime);
}
return StackFormatter.getLocalizedDateTimeFormatter(FormatStyle.SHORT).format(localDateTime.toLocalTime());
}
/**
* Get a localized DateTimeFormatter for use.
*
@@ -101,15 +74,17 @@ public class StackFormatter
return DateTimeFormatter.ofLocalizedTime(formatStyle).withLocale(RuneLite.SYSTEM_LOCALE);
}
/**
* Convert a quantity to a nicely formatted stack size.
* See the StackFormatterTest to see expected output.
* Convert a quantity to a short, comma separated, SI-prefix style string
*
* example: {@code 9,450}, {@code 2.14B}, {@code 100K}
*
* @param quantity The quantity to convert.
* @return A condensed version, with commas, K, M or B
* as needed to 3 significant figures.
* @return a 6 or less character string, possibly with a decimal point, commas or K/M/B suffix
*/
public static String quantityToStackSize(long quantity)
public static synchronized String quantityToStackSize(long quantity)
{
if (quantity < 0)
{
@@ -147,49 +122,12 @@ public class StackFormatter
}
/**
* Convert a quantity to stack size as it would
* appear in RuneScape.
*
* @param quantity The quantity to convert.
* @return The stack size as it would appear in RS,
* with K after 100,000 and M after 10,000,000
*/
public static String quantityToRSStackSize(int quantity)
{
if (quantity == Integer.MIN_VALUE)
{
// Integer.MIN_VALUE = Integer.MIN_VALUE * -1 so we need to correct for it.
return "-" + quantityToRSStackSize(Integer.MAX_VALUE);
}
else if (quantity < 0)
{
return "-" + quantityToRSStackSize(-quantity);
}
else if (quantity < 100_000)
{
return Integer.toString(quantity);
}
else if (quantity < 10_000_000)
{
return quantity / 1_000 + "K";
}
else
{
return quantity / 1_000_000 + "M";
}
}
/**
* Convert a quantity to stack size as it would
* appear in RuneScape. (with decimals)
* <p>
* This differs from quantityToRSStack in that it displays
* decimals. Ex: 27100 is 27.1k (not 27k)
* <p>
*
* @param quantity The quantity to convert.
* @return The stack size as it would appear in RS, with decimals,
* Convert a quantity to a short SI-prefix style string, possibly with a decimal,
* with K after 100,000 and M after 10,000,000
*
* example: {@code 9,450}, {@code 2.1B}, {@code 100K}
*
* @see #quantityToRSDecimalStack(int, boolean)
*/
public static String quantityToRSDecimalStack(int quantity)
{
@@ -197,19 +135,16 @@ public class StackFormatter
}
/**
* Convert a quantity to stack size as it would
* appear in RuneScape. (with decimals)
* <p>
* This differs from quantityToRSStack in that it displays
* decimals. Ex: 27100 is 27.1k (not 27k)
* <p>
*
* @param quantity The quantity to convert.
* @param precise If true, the returned string will have thousandths precision if quantity is larger than 1 million.
* @return The stack size as it would appear in RS, with decimals,
* Convert a quantity to a short SI-prefix style string, possibly with decimals,
* with K after 100,000 and M after 10,000,000
*
* example without {@code precise}: {@code 9,450}, {@code 2.1B}, {@code 8.4M}
* example with {@code precise}: {@code 9,450}, {@code 2.147B}, {@code 8.32M}
*
* @param precise If true, allow thousandths precision if {@code quantity} is larger than 1 million.
* Otherwise have at most a single decimal
*/
public static String quantityToRSDecimalStack(int quantity, boolean precise)
public static synchronized String quantityToRSDecimalStack(int quantity, boolean precise)
{
String quantityStr = String.valueOf(quantity);
if (quantityStr.length() <= 4)
@@ -234,7 +169,7 @@ public class StackFormatter
* @param string The string to convert.
* @return A long representation of it.
*/
public static long stackSizeToQuantity(String string) throws ParseException
public static synchronized long parseQuantity(String string) throws ParseException
{
int multiplier = getMultiplier(string);
float parsedValue = NUMBER_FORMATTER.parse(string).floatValue();
@@ -242,29 +177,23 @@ public class StackFormatter
}
/**
* Specialization of format.
* Formats a number to be comma delimited. No suffixes are given
*
* @param number the long number to format
* @return the formatted String
* @throws ArithmeticException if rounding is needed with rounding
* mode being set to RoundingMode.UNNECESSARY
* @see java.text.Format#format
* example: {@code 10,123,351}, {@code 5}
*/
public static String formatNumber(final long number)
public static synchronized String formatNumber(final long number)
{
return NUMBER_FORMATTER.format(number);
}
/**
* Specialization of format.
* Formats a number to be comma delimited. No suffixes are given. Has at
* most 3 decimal places
*
* @param number the double number to format
* @return the formatted String
* @throws ArithmeticException if rounding is needed with rounding
* mode being set to RoundingMode.UNNECESSARY
* @see java.text.Format#format
* example: {@code 10,123,351}, {@code 5.612}
*/
public static String formatNumber(double number)
public static synchronized String formatNumber(double number)
{
return NUMBER_FORMATTER.format(number);
}
@@ -307,4 +236,21 @@ public class StackFormatter
return 1;
}
}
/**
* Attempts to call the platform to get a localized time string based on
* the users preferences. Falls back on using locale default if it is on a
* platform that has no consistent way of obtaining this information.
*
* @param localDateTime The LocalDateTime object to format as a string
* @return The formatted string.
*/
public static String getPlatformTimeStringFromLocalDateTime(LocalDateTime localDateTime)
{
if (OSType.getOSType() == OSType.Windows)
{
return WinApi.getTimeFormatString(localDateTime);
}
return QuantityFormatter.getLocalizedDateTimeFormatter(FormatStyle.SHORT).format(localDateTime.toLocalTime());
}
}