Merge pull request #10027 from abextm/quantity-formatter
Fix documentation/naming/safety of StackFormatter
This commit is contained in:
@@ -28,7 +28,7 @@ import java.awt.image.BufferedImage;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.ui.overlay.infobox.Counter;
|
import net.runelite.client.ui.overlay.infobox.Counter;
|
||||||
import net.runelite.client.util.StackFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
|
|
||||||
class AmmoCounter extends Counter
|
class AmmoCounter extends Counter
|
||||||
{
|
{
|
||||||
@@ -46,7 +46,7 @@ class AmmoCounter extends Counter
|
|||||||
@Override
|
@Override
|
||||||
public String getText()
|
public String getText()
|
||||||
{
|
{
|
||||||
return StackFormatter.quantityToRSDecimalStack(getCount());
|
return QuantityFormatter.quantityToRSDecimalStack(getCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ import net.runelite.client.game.ItemManager;
|
|||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.plugins.banktags.tabs.BankSearch;
|
import net.runelite.client.plugins.banktags.tabs.BankSearch;
|
||||||
import net.runelite.client.util.StackFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Bank",
|
name = "Bank",
|
||||||
@@ -241,11 +241,11 @@ public class BankPlugin extends Plugin
|
|||||||
|
|
||||||
if (config.showExact())
|
if (config.showExact())
|
||||||
{
|
{
|
||||||
strCurrentTab += StackFormatter.formatNumber(gePrice) + ")";
|
strCurrentTab += QuantityFormatter.formatNumber(gePrice) + ")";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strCurrentTab += StackFormatter.quantityToStackSize(gePrice) + ")";
|
strCurrentTab += QuantityFormatter.quantityToStackSize(gePrice) + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,11 +260,11 @@ public class BankPlugin extends Plugin
|
|||||||
|
|
||||||
if (config.showExact())
|
if (config.showExact())
|
||||||
{
|
{
|
||||||
strCurrentTab += StackFormatter.formatNumber(haPrice) + ")";
|
strCurrentTab += QuantityFormatter.formatNumber(haPrice) + ")";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strCurrentTab += StackFormatter.quantityToStackSize(haPrice) + ")";
|
strCurrentTab += QuantityFormatter.quantityToStackSize(haPrice) + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,7 +369,7 @@ public class BankPlugin extends Plugin
|
|||||||
long compare;
|
long compare;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
compare = StackFormatter.stackSizeToQuantity(matcher.group("num"));
|
compare = QuantityFormatter.parseQuantity(matcher.group("num"));
|
||||||
}
|
}
|
||||||
catch (ParseException e)
|
catch (ParseException e)
|
||||||
{
|
{
|
||||||
@@ -398,8 +398,8 @@ public class BankPlugin extends Plugin
|
|||||||
long compare1, compare2;
|
long compare1, compare2;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
compare1 = StackFormatter.stackSizeToQuantity(num1);
|
compare1 = QuantityFormatter.parseQuantity(num1);
|
||||||
compare2 = StackFormatter.stackSizeToQuantity(num2);
|
compare2 = QuantityFormatter.parseQuantity(num2);
|
||||||
}
|
}
|
||||||
catch (ParseException e)
|
catch (ParseException e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ import net.runelite.client.ui.overlay.OverlayManager;
|
|||||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||||
import net.runelite.client.ui.overlay.infobox.InfoBoxPriority;
|
import net.runelite.client.ui.overlay.infobox.InfoBoxPriority;
|
||||||
import net.runelite.client.ui.overlay.infobox.LoopTimer;
|
import net.runelite.client.ui.overlay.infobox.LoopTimer;
|
||||||
import net.runelite.client.util.StackFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Barrows Brothers",
|
name = "Barrows Brothers",
|
||||||
@@ -288,7 +288,7 @@ public class BarrowsPlugin extends Plugin
|
|||||||
final ChatMessageBuilder message = new ChatMessageBuilder()
|
final ChatMessageBuilder message = new ChatMessageBuilder()
|
||||||
.append(ChatColorType.HIGHLIGHT)
|
.append(ChatColorType.HIGHLIGHT)
|
||||||
.append("Your chest is worth around ")
|
.append("Your chest is worth around ")
|
||||||
.append(StackFormatter.formatNumber(chestPrice))
|
.append(QuantityFormatter.formatNumber(chestPrice))
|
||||||
.append(" coins.")
|
.append(" coins.")
|
||||||
.append(ChatColorType.NORMAL);
|
.append(ChatColorType.NORMAL);
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import net.runelite.client.ui.overlay.OverlayMenuEntry;
|
|||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
import net.runelite.client.ui.overlay.components.LineComponent;
|
import net.runelite.client.ui.overlay.components.LineComponent;
|
||||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||||
import net.runelite.client.util.StackFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
|
|
||||||
class BlastFurnaceCofferOverlay extends Overlay
|
class BlastFurnaceCofferOverlay extends Overlay
|
||||||
{
|
{
|
||||||
@@ -74,7 +74,7 @@ class BlastFurnaceCofferOverlay extends Overlay
|
|||||||
|
|
||||||
panelComponent.getChildren().add(LineComponent.builder()
|
panelComponent.getChildren().add(LineComponent.builder()
|
||||||
.left("Coffer:")
|
.left("Coffer:")
|
||||||
.right(StackFormatter.quantityToStackSize(client.getVar(BLAST_FURNACE_COFFER)) + " gp")
|
.right(QuantityFormatter.quantityToStackSize(client.getVar(BLAST_FURNACE_COFFER)) + " gp")
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ import net.runelite.client.game.ItemManager;
|
|||||||
import net.runelite.client.input.KeyManager;
|
import net.runelite.client.input.KeyManager;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.util.StackFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
import static net.runelite.client.util.Text.sanitize;
|
import static net.runelite.client.util.Text.sanitize;
|
||||||
import net.runelite.http.api.chat.ChatClient;
|
import net.runelite.http.api.chat.ChatClient;
|
||||||
import net.runelite.http.api.chat.Duels;
|
import net.runelite.http.api.chat.Duels;
|
||||||
@@ -836,7 +836,7 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
.append(ChatColorType.NORMAL)
|
.append(ChatColorType.NORMAL)
|
||||||
.append(": GE average ")
|
.append(": GE average ")
|
||||||
.append(ChatColorType.HIGHLIGHT)
|
.append(ChatColorType.HIGHLIGHT)
|
||||||
.append(StackFormatter.formatNumber(itemPrice));
|
.append(QuantityFormatter.formatNumber(itemPrice));
|
||||||
|
|
||||||
ItemComposition itemComposition = itemManager.getItemComposition(itemId);
|
ItemComposition itemComposition = itemManager.getItemComposition(itemId);
|
||||||
if (itemComposition != null)
|
if (itemComposition != null)
|
||||||
@@ -846,7 +846,7 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
.append(ChatColorType.NORMAL)
|
.append(ChatColorType.NORMAL)
|
||||||
.append(" HA value ")
|
.append(" HA value ")
|
||||||
.append(ChatColorType.HIGHLIGHT)
|
.append(ChatColorType.HIGHLIGHT)
|
||||||
.append(StackFormatter.formatNumber(alchPrice));
|
.append(QuantityFormatter.formatNumber(alchPrice));
|
||||||
}
|
}
|
||||||
|
|
||||||
String response = builder.build();
|
String response = builder.build();
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ import net.runelite.client.eventbus.Subscribe;
|
|||||||
import net.runelite.client.game.ItemManager;
|
import net.runelite.client.game.ItemManager;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.util.StackFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
import net.runelite.http.api.examine.ExamineClient;
|
import net.runelite.http.api.examine.ExamineClient;
|
||||||
|
|
||||||
@@ -336,7 +336,7 @@ public class ExaminePlugin extends Plugin
|
|||||||
if (quantity > 1)
|
if (quantity > 1)
|
||||||
{
|
{
|
||||||
message
|
message
|
||||||
.append(StackFormatter.formatNumber(quantity))
|
.append(QuantityFormatter.formatNumber(quantity))
|
||||||
.append(" x ");
|
.append(" x ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,7 +351,7 @@ public class ExaminePlugin extends Plugin
|
|||||||
.append(ChatColorType.NORMAL)
|
.append(ChatColorType.NORMAL)
|
||||||
.append(" GE average ")
|
.append(" GE average ")
|
||||||
.append(ChatColorType.HIGHLIGHT)
|
.append(ChatColorType.HIGHLIGHT)
|
||||||
.append(StackFormatter.formatNumber(gePrice * quantity));
|
.append(QuantityFormatter.formatNumber(gePrice * quantity));
|
||||||
|
|
||||||
if (quantity > 1)
|
if (quantity > 1)
|
||||||
{
|
{
|
||||||
@@ -359,7 +359,7 @@ public class ExaminePlugin extends Plugin
|
|||||||
.append(ChatColorType.NORMAL)
|
.append(ChatColorType.NORMAL)
|
||||||
.append(" (")
|
.append(" (")
|
||||||
.append(ChatColorType.HIGHLIGHT)
|
.append(ChatColorType.HIGHLIGHT)
|
||||||
.append(StackFormatter.formatNumber(gePrice))
|
.append(QuantityFormatter.formatNumber(gePrice))
|
||||||
.append(ChatColorType.NORMAL)
|
.append(ChatColorType.NORMAL)
|
||||||
.append("ea)");
|
.append("ea)");
|
||||||
}
|
}
|
||||||
@@ -371,7 +371,7 @@ public class ExaminePlugin extends Plugin
|
|||||||
.append(ChatColorType.NORMAL)
|
.append(ChatColorType.NORMAL)
|
||||||
.append(" HA value ")
|
.append(" HA value ")
|
||||||
.append(ChatColorType.HIGHLIGHT)
|
.append(ChatColorType.HIGHLIGHT)
|
||||||
.append(StackFormatter.formatNumber(alchPrice * quantity));
|
.append(QuantityFormatter.formatNumber(alchPrice * quantity));
|
||||||
|
|
||||||
if (quantity > 1)
|
if (quantity > 1)
|
||||||
{
|
{
|
||||||
@@ -379,7 +379,7 @@ public class ExaminePlugin extends Plugin
|
|||||||
.append(ChatColorType.NORMAL)
|
.append(ChatColorType.NORMAL)
|
||||||
.append(" (")
|
.append(" (")
|
||||||
.append(ChatColorType.HIGHLIGHT)
|
.append(ChatColorType.HIGHLIGHT)
|
||||||
.append(StackFormatter.formatNumber(alchPrice))
|
.append(QuantityFormatter.formatNumber(alchPrice))
|
||||||
.append(ChatColorType.NORMAL)
|
.append(ChatColorType.NORMAL)
|
||||||
.append("ea)");
|
.append("ea)");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import javax.swing.border.EmptyBorder;
|
|||||||
import net.runelite.client.util.AsyncBufferedImage;
|
import net.runelite.client.util.AsyncBufferedImage;
|
||||||
import net.runelite.client.ui.ColorScheme;
|
import net.runelite.client.ui.ColorScheme;
|
||||||
import net.runelite.client.util.LinkBrowser;
|
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
|
* This panel displays an individual item result in the
|
||||||
@@ -124,7 +124,7 @@ class GrandExchangeItemPanel extends JPanel
|
|||||||
JLabel gePriceLabel = new JLabel();
|
JLabel gePriceLabel = new JLabel();
|
||||||
if (gePrice > 0)
|
if (gePrice > 0)
|
||||||
{
|
{
|
||||||
gePriceLabel.setText(StackFormatter.formatNumber(gePrice) + " gp");
|
gePriceLabel.setText(QuantityFormatter.formatNumber(gePrice) + " gp");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -139,13 +139,13 @@ class GrandExchangeItemPanel extends JPanel
|
|||||||
|
|
||||||
// Alch price
|
// Alch price
|
||||||
JLabel haPriceLabel = new JLabel();
|
JLabel haPriceLabel = new JLabel();
|
||||||
haPriceLabel.setText(StackFormatter.formatNumber(haPrice.intValue()) + " alch");
|
haPriceLabel.setText(QuantityFormatter.formatNumber(haPrice.intValue()) + " alch");
|
||||||
haPriceLabel.setForeground(ColorScheme.GRAND_EXCHANGE_ALCH);
|
haPriceLabel.setForeground(ColorScheme.GRAND_EXCHANGE_ALCH);
|
||||||
alchAndLimitPanel.add(haPriceLabel, BorderLayout.WEST);
|
alchAndLimitPanel.add(haPriceLabel, BorderLayout.WEST);
|
||||||
|
|
||||||
// GE Limit
|
// GE Limit
|
||||||
JLabel geLimitLabel = new JLabel();
|
JLabel geLimitLabel = new JLabel();
|
||||||
String limitLabelText = geItemLimit == 0 ? "" : "Limit " + StackFormatter.formatNumber(geItemLimit);
|
String limitLabelText = geItemLimit == 0 ? "" : "Limit " + QuantityFormatter.formatNumber(geItemLimit);
|
||||||
geLimitLabel.setText(limitLabelText);
|
geLimitLabel.setText(limitLabelText);
|
||||||
geLimitLabel.setForeground(ColorScheme.GRAND_EXCHANGE_LIMIT);
|
geLimitLabel.setForeground(ColorScheme.GRAND_EXCHANGE_LIMIT);
|
||||||
geLimitLabel.setBorder(new CompoundBorder(geLimitLabel.getBorder(), new EmptyBorder(0, 0, 0, 7)));
|
geLimitLabel.setBorder(new CompoundBorder(geLimitLabel.getBorder(), new EmptyBorder(0, 0, 0, 7)));
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ import net.runelite.client.ui.FontManager;
|
|||||||
import net.runelite.client.ui.components.ThinProgressBar;
|
import net.runelite.client.ui.components.ThinProgressBar;
|
||||||
import net.runelite.client.util.ColorUtil;
|
import net.runelite.client.util.ColorUtil;
|
||||||
import net.runelite.client.util.ImageUtil;
|
import net.runelite.client.util.ImageUtil;
|
||||||
import net.runelite.client.util.StackFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
|
|
||||||
public class GrandExchangeOfferSlot extends JPanel
|
public class GrandExchangeOfferSlot extends JPanel
|
||||||
{
|
{
|
||||||
@@ -211,17 +211,17 @@ public class GrandExchangeOfferSlot extends JPanel
|
|||||||
|| newOffer.getState() == GrandExchangeOfferState.CANCELLED_BUY;
|
|| newOffer.getState() == GrandExchangeOfferState.CANCELLED_BUY;
|
||||||
|
|
||||||
String offerState = (buying ? "Bought " : "Sold ")
|
String offerState = (buying ? "Bought " : "Sold ")
|
||||||
+ StackFormatter.quantityToRSDecimalStack(newOffer.getQuantitySold()) + " / "
|
+ QuantityFormatter.quantityToRSDecimalStack(newOffer.getQuantitySold()) + " / "
|
||||||
+ StackFormatter.quantityToRSDecimalStack(newOffer.getTotalQuantity());
|
+ QuantityFormatter.quantityToRSDecimalStack(newOffer.getTotalQuantity());
|
||||||
|
|
||||||
offerInfo.setText(offerState);
|
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: ";
|
String action = buying ? "Spent: " : "Received: ";
|
||||||
|
|
||||||
offerSpent.setText(htmlLabel(action, StackFormatter.formatNumber(newOffer.getSpent()) + " / "
|
offerSpent.setText(htmlLabel(action, QuantityFormatter.formatNumber(newOffer.getSpent()) + " / "
|
||||||
+ StackFormatter.formatNumber(newOffer.getPrice() * newOffer.getTotalQuantity())));
|
+ QuantityFormatter.formatNumber(newOffer.getPrice() * newOffer.getTotalQuantity())));
|
||||||
|
|
||||||
progressBar.setForeground(getProgressColor(newOffer));
|
progressBar.setForeground(getProgressColor(newOffer));
|
||||||
progressBar.setMaximumValue(newOffer.getTotalQuantity());
|
progressBar.setMaximumValue(newOffer.getTotalQuantity());
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ import net.runelite.client.plugins.PluginDescriptor;
|
|||||||
import net.runelite.client.ui.ClientToolbar;
|
import net.runelite.client.ui.ClientToolbar;
|
||||||
import net.runelite.client.ui.NavigationButton;
|
import net.runelite.client.ui.NavigationButton;
|
||||||
import net.runelite.client.util.ImageUtil;
|
import net.runelite.client.util.ImageUtil;
|
||||||
import net.runelite.client.util.StackFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
import net.runelite.http.api.ge.GrandExchangeClient;
|
import net.runelite.http.api.ge.GrandExchangeClient;
|
||||||
import net.runelite.http.api.ge.GrandExchangeTrade;
|
import net.runelite.http.api.ge.GrandExchangeTrade;
|
||||||
@@ -456,11 +456,11 @@ public class GrandExchangePlugin extends Plugin
|
|||||||
|
|
||||||
if (config.showExact())
|
if (config.showExact())
|
||||||
{
|
{
|
||||||
titleBuilder.append(StackFormatter.formatNumber(total));
|
titleBuilder.append(QuantityFormatter.formatNumber(total));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
titleBuilder.append(StackFormatter.quantityToStackSize(total));
|
titleBuilder.append(QuantityFormatter.quantityToStackSize(total));
|
||||||
}
|
}
|
||||||
|
|
||||||
titleBuilder.append(')');
|
titleBuilder.append(')');
|
||||||
@@ -497,7 +497,7 @@ public class GrandExchangePlugin extends Plugin
|
|||||||
// If we have item buy limit, append it
|
// If we have item buy limit, append it
|
||||||
if (itemLimit != null)
|
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);
|
geText.setText(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -521,7 +521,7 @@ public class GrandExchangePlugin extends Plugin
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final OSBGrandExchangeResult result = CLIENT.lookupItem(itemId);
|
final OSBGrandExchangeResult result = CLIENT.lookupItem(itemId);
|
||||||
final String text = geText.getText() + OSB_GE_TEXT + StackFormatter.formatNumber(result.getOverall_average());
|
final String text = geText.getText() + OSB_GE_TEXT + QuantityFormatter.formatNumber(result.getOverall_average());
|
||||||
geText.setText(text);
|
geText.setText(text);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ import net.runelite.client.ui.overlay.OverlayUtil;
|
|||||||
import net.runelite.client.ui.overlay.components.BackgroundComponent;
|
import net.runelite.client.ui.overlay.components.BackgroundComponent;
|
||||||
import net.runelite.client.ui.overlay.components.ProgressPieComponent;
|
import net.runelite.client.ui.overlay.components.ProgressPieComponent;
|
||||||
import net.runelite.client.ui.overlay.components.TextComponent;
|
import net.runelite.client.ui.overlay.components.TextComponent;
|
||||||
import net.runelite.client.util.StackFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
public class GroundItemsOverlay extends Overlay
|
public class GroundItemsOverlay extends Overlay
|
||||||
@@ -234,7 +234,7 @@ public class GroundItemsOverlay extends Overlay
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
itemStringBuilder.append(" (")
|
itemStringBuilder.append(" (")
|
||||||
.append(StackFormatter.quantityToStackSize(item.getQuantity()))
|
.append(QuantityFormatter.quantityToStackSize(item.getQuantity()))
|
||||||
.append(")");
|
.append(")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -244,14 +244,14 @@ public class GroundItemsOverlay extends Overlay
|
|||||||
if (item.getGePrice() > 0)
|
if (item.getGePrice() > 0)
|
||||||
{
|
{
|
||||||
itemStringBuilder.append(" (EX: ")
|
itemStringBuilder.append(" (EX: ")
|
||||||
.append(StackFormatter.quantityToStackSize(item.getGePrice()))
|
.append(QuantityFormatter.quantityToStackSize(item.getGePrice()))
|
||||||
.append(" gp)");
|
.append(" gp)");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getHaPrice() > 0)
|
if (item.getHaPrice() > 0)
|
||||||
{
|
{
|
||||||
itemStringBuilder.append(" (HA: ")
|
itemStringBuilder.append(" (HA: ")
|
||||||
.append(StackFormatter.quantityToStackSize(item.getHaPrice()))
|
.append(QuantityFormatter.quantityToStackSize(item.getHaPrice()))
|
||||||
.append(" gp)");
|
.append(" gp)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -265,7 +265,7 @@ public class GroundItemsOverlay extends Overlay
|
|||||||
{
|
{
|
||||||
itemStringBuilder
|
itemStringBuilder
|
||||||
.append(" (")
|
.append(" (")
|
||||||
.append(StackFormatter.quantityToStackSize(price))
|
.append(QuantityFormatter.quantityToStackSize(price))
|
||||||
.append(" gp)");
|
.append(" gp)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ import static net.runelite.client.plugins.grounditems.config.MenuHighlightMode.O
|
|||||||
import net.runelite.client.plugins.grounditems.config.ValueCalculationMode;
|
import net.runelite.client.plugins.grounditems.config.ValueCalculationMode;
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
import net.runelite.client.ui.overlay.OverlayManager;
|
||||||
import net.runelite.client.util.ColorUtil;
|
import net.runelite.client.util.ColorUtil;
|
||||||
import net.runelite.client.util.StackFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
@@ -673,7 +673,7 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
notificationStringBuilder.append(" (")
|
notificationStringBuilder.append(" (")
|
||||||
.append(StackFormatter.quantityToStackSize(item.getQuantity()))
|
.append(QuantityFormatter.quantityToStackSize(item.getQuantity()))
|
||||||
.append(")");
|
.append(")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ import net.runelite.client.ui.components.IconTextField;
|
|||||||
import net.runelite.client.ui.components.materialtabs.MaterialTab;
|
import net.runelite.client.ui.components.materialtabs.MaterialTab;
|
||||||
import net.runelite.client.ui.components.materialtabs.MaterialTabGroup;
|
import net.runelite.client.ui.components.materialtabs.MaterialTabGroup;
|
||||||
import net.runelite.client.util.ImageUtil;
|
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.HiscoreClient;
|
||||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
||||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
import net.runelite.http.api.hiscore.HiscoreResult;
|
||||||
@@ -512,8 +512,8 @@ public class HiscorePanel extends PluginPanel
|
|||||||
+ result.getRanged().getExperience() + result.getPrayer().getExperience();
|
+ result.getRanged().getExperience() + result.getPrayer().getExperience();
|
||||||
|
|
||||||
content += "<p><span style = 'color:white'>Skill:</span> Combat</p>";
|
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'>Exact Combat Level:</span> " + QuantityFormatter.formatNumber(combatLevel) + "</p>";
|
||||||
content += "<p><span style = 'color:white'>Experience:</span> " + StackFormatter.formatNumber(combatExperience) + "</p>";
|
content += "<p><span style = 'color:white'>Experience:</span> " + QuantityFormatter.formatNumber(combatExperience) + "</p>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -521,20 +521,20 @@ public class HiscorePanel extends PluginPanel
|
|||||||
{
|
{
|
||||||
case CLUE_SCROLL_ALL:
|
case CLUE_SCROLL_ALL:
|
||||||
{
|
{
|
||||||
String allRank = (result.getClueScrollAll().getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(result.getClueScrollAll().getRank());
|
String allRank = (result.getClueScrollAll().getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(result.getClueScrollAll().getRank());
|
||||||
String beginnerRank = (result.getClueScrollBeginner().getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(result.getClueScrollBeginner().getRank());
|
String beginnerRank = (result.getClueScrollBeginner().getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(result.getClueScrollBeginner().getRank());
|
||||||
String easyRank = (result.getClueScrollEasy().getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(result.getClueScrollEasy().getRank());
|
String easyRank = (result.getClueScrollEasy().getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(result.getClueScrollEasy().getRank());
|
||||||
String mediumRank = (result.getClueScrollMedium().getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(result.getClueScrollMedium().getRank());
|
String mediumRank = (result.getClueScrollMedium().getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(result.getClueScrollMedium().getRank());
|
||||||
String hardRank = (result.getClueScrollHard().getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(result.getClueScrollHard().getRank());
|
String hardRank = (result.getClueScrollHard().getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(result.getClueScrollHard().getRank());
|
||||||
String eliteRank = (result.getClueScrollElite().getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(result.getClueScrollElite().getRank());
|
String eliteRank = (result.getClueScrollElite().getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(result.getClueScrollElite().getRank());
|
||||||
String masterRank = (result.getClueScrollMaster().getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(result.getClueScrollMaster().getRank());
|
String masterRank = (result.getClueScrollMaster().getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(result.getClueScrollMaster().getRank());
|
||||||
String all = (result.getClueScrollAll().getLevel() == -1 ? "0" : StackFormatter.formatNumber(result.getClueScrollAll().getLevel()));
|
String all = (result.getClueScrollAll().getLevel() == -1 ? "0" : QuantityFormatter.formatNumber(result.getClueScrollAll().getLevel()));
|
||||||
String beginner = (result.getClueScrollBeginner().getLevel() == -1 ? "0" : StackFormatter.formatNumber(result.getClueScrollBeginner().getLevel()));
|
String beginner = (result.getClueScrollBeginner().getLevel() == -1 ? "0" : QuantityFormatter.formatNumber(result.getClueScrollBeginner().getLevel()));
|
||||||
String easy = (result.getClueScrollEasy().getLevel() == -1 ? "0" : StackFormatter.formatNumber(result.getClueScrollEasy().getLevel()));
|
String easy = (result.getClueScrollEasy().getLevel() == -1 ? "0" : QuantityFormatter.formatNumber(result.getClueScrollEasy().getLevel()));
|
||||||
String medium = (result.getClueScrollMedium().getLevel() == -1 ? "0" : StackFormatter.formatNumber(result.getClueScrollMedium().getLevel()));
|
String medium = (result.getClueScrollMedium().getLevel() == -1 ? "0" : QuantityFormatter.formatNumber(result.getClueScrollMedium().getLevel()));
|
||||||
String hard = (result.getClueScrollHard().getLevel() == -1 ? "0" : StackFormatter.formatNumber(result.getClueScrollHard().getLevel()));
|
String hard = (result.getClueScrollHard().getLevel() == -1 ? "0" : QuantityFormatter.formatNumber(result.getClueScrollHard().getLevel()));
|
||||||
String elite = (result.getClueScrollElite().getLevel() == -1 ? "0" : StackFormatter.formatNumber(result.getClueScrollElite().getLevel()));
|
String elite = (result.getClueScrollElite().getLevel() == -1 ? "0" : QuantityFormatter.formatNumber(result.getClueScrollElite().getLevel()));
|
||||||
String master = (result.getClueScrollMaster().getLevel() == -1 ? "0" : StackFormatter.formatNumber(result.getClueScrollMaster().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'>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'>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>";
|
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:
|
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>";
|
content += "<p><span style = 'color:white'>Rank:</span> " + rank + "</p>";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BOUNTY_HUNTER_HUNTER:
|
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>";
|
content += "<p><span style = 'color:white'>Rank:</span> " + rank + "</p>";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LAST_MAN_STANDING:
|
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>";
|
content += "<p><span style = 'color:white'>Rank:</span> " + rank + "</p>";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OVERALL:
|
case OVERALL:
|
||||||
{
|
{
|
||||||
Skill requestedSkill = result.getSkill(skill);
|
Skill requestedSkill = result.getSkill(skill);
|
||||||
String rank = (requestedSkill.getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(requestedSkill.getRank());
|
String rank = (requestedSkill.getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(requestedSkill.getRank());
|
||||||
String exp = (requestedSkill.getExperience() == -1L) ? "Unranked" : StackFormatter.formatNumber(requestedSkill.getExperience());
|
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'>Skill:</span> " + skill.getName() + "</p>";
|
||||||
content += "<p><span style = 'color:white'>Rank:</span> " + rank + "</p>";
|
content += "<p><span style = 'color:white'>Rank:</span> " + rank + "</p>";
|
||||||
content += "<p><span style = 'color:white'>Experience:</span> " + exp + "</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);
|
Skill requestedSkill = result.getSkill(skill);
|
||||||
final long experience = requestedSkill.getExperience();
|
final long experience = requestedSkill.getExperience();
|
||||||
|
|
||||||
String rank = (requestedSkill.getRank() == -1) ? "Unranked" : StackFormatter.formatNumber(requestedSkill.getRank());
|
String rank = (requestedSkill.getRank() == -1) ? "Unranked" : QuantityFormatter.formatNumber(requestedSkill.getRank());
|
||||||
String exp = (experience == -1L) ? "Unranked" : StackFormatter.formatNumber(experience);
|
String exp = (experience == -1L) ? "Unranked" : QuantityFormatter.formatNumber(experience);
|
||||||
String remainingXp;
|
String remainingXp;
|
||||||
if (experience == -1L)
|
if (experience == -1L)
|
||||||
{
|
{
|
||||||
@@ -587,7 +587,7 @@ public class HiscorePanel extends PluginPanel
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
int currentLevel = Experience.getLevelForXp((int) experience);
|
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>";
|
content += "<p><span style = 'color:white'>Skill:</span> " + skill.getName() + "</p>";
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ import net.runelite.client.ui.overlay.OverlayPosition;
|
|||||||
import net.runelite.client.ui.overlay.tooltip.Tooltip;
|
import net.runelite.client.ui.overlay.tooltip.Tooltip;
|
||||||
import net.runelite.client.ui.overlay.tooltip.TooltipManager;
|
import net.runelite.client.ui.overlay.tooltip.TooltipManager;
|
||||||
import net.runelite.client.util.ColorUtil;
|
import net.runelite.client.util.ColorUtil;
|
||||||
import net.runelite.client.util.StackFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
|
|
||||||
class ItemPricesOverlay extends Overlay
|
class ItemPricesOverlay extends Overlay
|
||||||
{
|
{
|
||||||
@@ -183,11 +183,11 @@ class ItemPricesOverlay extends Overlay
|
|||||||
// Special case for coins and platinum tokens
|
// Special case for coins and platinum tokens
|
||||||
if (id == ItemID.COINS_995)
|
if (id == ItemID.COINS_995)
|
||||||
{
|
{
|
||||||
return StackFormatter.formatNumber(qty) + " gp";
|
return QuantityFormatter.formatNumber(qty) + " gp";
|
||||||
}
|
}
|
||||||
else if (id == ItemID.PLATINUM_TOKEN)
|
else if (id == ItemID.PLATINUM_TOKEN)
|
||||||
{
|
{
|
||||||
return StackFormatter.formatNumber(qty * 1000) + " gp";
|
return QuantityFormatter.formatNumber(qty * 1000) + " gp";
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemComposition itemDef = itemManager.getItemComposition(id);
|
ItemComposition itemDef = itemManager.getItemComposition(id);
|
||||||
@@ -234,12 +234,12 @@ class ItemPricesOverlay extends Overlay
|
|||||||
if (gePrice > 0)
|
if (gePrice > 0)
|
||||||
{
|
{
|
||||||
itemStringBuilder.append("EX: ")
|
itemStringBuilder.append("EX: ")
|
||||||
.append(StackFormatter.quantityToStackSize(gePrice * qty))
|
.append(QuantityFormatter.quantityToStackSize(gePrice * qty))
|
||||||
.append(" gp");
|
.append(" gp");
|
||||||
if (config.showEA() && qty > 1)
|
if (config.showEA() && qty > 1)
|
||||||
{
|
{
|
||||||
itemStringBuilder.append(" (")
|
itemStringBuilder.append(" (")
|
||||||
.append(StackFormatter.quantityToStackSize(gePrice))
|
.append(QuantityFormatter.quantityToStackSize(gePrice))
|
||||||
.append(" ea)");
|
.append(" ea)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,12 +251,12 @@ class ItemPricesOverlay extends Overlay
|
|||||||
}
|
}
|
||||||
|
|
||||||
itemStringBuilder.append("HA: ")
|
itemStringBuilder.append("HA: ")
|
||||||
.append(StackFormatter.quantityToStackSize(haValue * qty))
|
.append(QuantityFormatter.quantityToStackSize(haValue * qty))
|
||||||
.append(" gp");
|
.append(" gp");
|
||||||
if (config.showEA() && qty > 1)
|
if (config.showEA() && qty > 1)
|
||||||
{
|
{
|
||||||
itemStringBuilder.append(" (")
|
itemStringBuilder.append(" (")
|
||||||
.append(StackFormatter.quantityToStackSize(haValue))
|
.append(QuantityFormatter.quantityToStackSize(haValue))
|
||||||
.append(" ea)");
|
.append(" ea)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ import net.runelite.client.game.ItemManager;
|
|||||||
import net.runelite.client.game.ItemMapping;
|
import net.runelite.client.game.ItemMapping;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.util.StackFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Items Kept on Death",
|
name = "Items Kept on Death",
|
||||||
@@ -570,7 +570,7 @@ public class ItemsKeptOnDeathPlugin extends Plugin
|
|||||||
total += (long) price * w.getItemQuantity();
|
total += (long) price * w.getItemQuantity();
|
||||||
}
|
}
|
||||||
final Widget lostValue = client.getWidget(WidgetInfo.ITEMS_LOST_VALUE);
|
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
|
// Update Max items kept
|
||||||
final Widget max = client.getWidget(WidgetInfo.ITEMS_KEPT_MAX);
|
final Widget max = client.getWidget(WidgetInfo.ITEMS_KEPT_MAX);
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ import net.runelite.client.plugins.PluginDescriptor;
|
|||||||
import net.runelite.client.ui.FontManager;
|
import net.runelite.client.ui.FontManager;
|
||||||
import net.runelite.client.ui.JagexColors;
|
import net.runelite.client.ui.JagexColors;
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
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.ItemEquipmentStats;
|
||||||
import net.runelite.http.api.item.ItemStats;
|
import net.runelite.http.api.item.ItemStats;
|
||||||
|
|
||||||
@@ -340,7 +340,7 @@ public class ItemStatPlugin extends Plugin
|
|||||||
|
|
||||||
createSeparator(invContainer, invContainer.getHeight() - 40);
|
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.");
|
+ (getCurrentGP() == 1 ? " coin." : " coins.");
|
||||||
|
|
||||||
final Widget coinWidget = createText(invContainer, coinText, FontID.PLAIN_12, ORANGE_TEXT,
|
final Widget coinWidget = createText(invContainer, coinText, FontID.PLAIN_12, ORANGE_TEXT,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ package net.runelite.client.plugins.kingdomofmiscellania;
|
|||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import net.runelite.client.ui.overlay.infobox.Counter;
|
import net.runelite.client.ui.overlay.infobox.Counter;
|
||||||
import net.runelite.client.util.StackFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
|
|
||||||
public class KingdomCounter extends Counter
|
public class KingdomCounter extends Counter
|
||||||
{
|
{
|
||||||
@@ -48,6 +48,6 @@ public class KingdomCounter extends Counter
|
|||||||
public String getTooltip()
|
public String getTooltip()
|
||||||
{
|
{
|
||||||
return "Favor: " + plugin.getFavor() + "/127" + "</br>"
|
return "Favor: " + plugin.getFavor() + "/127" + "</br>"
|
||||||
+ "Coffer: " + StackFormatter.quantityToRSStackSize(plugin.getCoffer());
|
+ "Coffer: " + QuantityFormatter.quantityToStackSize(plugin.getCoffer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ import net.runelite.client.game.ItemManager;
|
|||||||
import net.runelite.client.ui.ColorScheme;
|
import net.runelite.client.ui.ColorScheme;
|
||||||
import net.runelite.client.ui.FontManager;
|
import net.runelite.client.ui.FontManager;
|
||||||
import net.runelite.client.util.ImageUtil;
|
import net.runelite.client.util.ImageUtil;
|
||||||
import net.runelite.client.util.StackFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
|
|
||||||
class LootTrackerBox extends JPanel
|
class LootTrackerBox extends JPanel
|
||||||
@@ -181,8 +181,8 @@ class LootTrackerBox extends JPanel
|
|||||||
{
|
{
|
||||||
buildItems();
|
buildItems();
|
||||||
|
|
||||||
priceLabel.setText(StackFormatter.quantityToStackSize(totalPrice) + " gp");
|
priceLabel.setText(QuantityFormatter.quantityToStackSize(totalPrice) + " gp");
|
||||||
priceLabel.setToolTipText(StackFormatter.formatNumber(totalPrice) + " gp");
|
priceLabel.setToolTipText(QuantityFormatter.formatNumber(totalPrice) + " gp");
|
||||||
|
|
||||||
final long kills = getTotalKills();
|
final long kills = getTotalKills();
|
||||||
if (kills > 1)
|
if (kills > 1)
|
||||||
@@ -354,6 +354,6 @@ class LootTrackerBox extends JPanel
|
|||||||
final int quantity = item.getQuantity();
|
final int quantity = item.getQuantity();
|
||||||
final long price = item.getPrice();
|
final long price = item.getPrice();
|
||||||
final String ignoredLabel = item.isIgnored() ? " - Ignored" : "";
|
final String ignoredLabel = item.isIgnored() ? " - Ignored" : "";
|
||||||
return name + " x " + quantity + " (" + StackFormatter.quantityToStackSize(price) + ") " + ignoredLabel;
|
return name + " x " + quantity + " (" + QuantityFormatter.quantityToStackSize(price) + ") " + ignoredLabel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ import net.runelite.client.ui.PluginPanel;
|
|||||||
import net.runelite.client.ui.components.PluginErrorPanel;
|
import net.runelite.client.ui.components.PluginErrorPanel;
|
||||||
import net.runelite.client.util.ColorUtil;
|
import net.runelite.client.util.ColorUtil;
|
||||||
import net.runelite.client.util.ImageUtil;
|
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;
|
import net.runelite.http.api.loottracker.LootTrackerClient;
|
||||||
|
|
||||||
class LootTrackerPanel extends PluginPanel
|
class LootTrackerPanel extends PluginPanel
|
||||||
@@ -629,7 +629,7 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
|
|
||||||
private static String htmlLabel(String key, long value)
|
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);
|
return String.format(HTML_LABEL_TEMPLATE, ColorUtil.toHexColor(ColorScheme.LIGHT_GRAY_COLOR), key, valueStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ import net.runelite.client.ui.overlay.OverlayPriority;
|
|||||||
import net.runelite.client.ui.overlay.components.LineComponent;
|
import net.runelite.client.ui.overlay.components.LineComponent;
|
||||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||||
import net.runelite.client.util.StackFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
|
|
||||||
class NightmareZoneOverlay extends Overlay
|
class NightmareZoneOverlay extends Overlay
|
||||||
{
|
{
|
||||||
@@ -108,15 +108,15 @@ class NightmareZoneOverlay extends Overlay
|
|||||||
panelComponent.getChildren().clear();
|
panelComponent.getChildren().clear();
|
||||||
panelComponent.getChildren().add(LineComponent.builder()
|
panelComponent.getChildren().add(LineComponent.builder()
|
||||||
.left("Points: ")
|
.left("Points: ")
|
||||||
.right(StackFormatter.formatNumber(currentPoints))
|
.right(QuantityFormatter.formatNumber(currentPoints))
|
||||||
.build());
|
.build());
|
||||||
panelComponent.getChildren().add(LineComponent.builder()
|
panelComponent.getChildren().add(LineComponent.builder()
|
||||||
.left("Points/Hour: ")
|
.left("Points/Hour: ")
|
||||||
.right(StackFormatter.formatNumber(plugin.getPointsPerHour()))
|
.right(QuantityFormatter.formatNumber(plugin.getPointsPerHour()))
|
||||||
.build());
|
.build());
|
||||||
panelComponent.getChildren().add(LineComponent.builder()
|
panelComponent.getChildren().add(LineComponent.builder()
|
||||||
.left("Total: ")
|
.left("Total: ")
|
||||||
.right(StackFormatter.formatNumber(totalPoints))
|
.right(QuantityFormatter.formatNumber(totalPoints))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
return panelComponent.render(graphics);
|
return panelComponent.render(graphics);
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ import net.runelite.client.ui.SkillColor;
|
|||||||
import net.runelite.client.ui.components.ProgressBar;
|
import net.runelite.client.ui.components.ProgressBar;
|
||||||
import net.runelite.client.util.ColorUtil;
|
import net.runelite.client.util.ColorUtil;
|
||||||
import net.runelite.client.util.LinkBrowser;
|
import net.runelite.client.util.LinkBrowser;
|
||||||
import net.runelite.client.util.StackFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
|
|
||||||
class XpInfoBox extends JPanel
|
class XpInfoBox extends JPanel
|
||||||
{
|
{
|
||||||
@@ -310,7 +310,7 @@ class XpInfoBox extends JPanel
|
|||||||
|
|
||||||
static String htmlLabel(String key, int value)
|
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);
|
return String.format(HTML_LABEL_TEMPLATE, ColorUtil.toHexColor(ColorScheme.LIGHT_GRAY_COLOR), key, valueStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ import net.runelite.client.ui.overlay.components.LineComponent;
|
|||||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||||
import net.runelite.client.ui.overlay.components.ProgressBarComponent;
|
import net.runelite.client.ui.overlay.components.ProgressBarComponent;
|
||||||
import net.runelite.client.ui.overlay.components.SplitComponent;
|
import net.runelite.client.ui.overlay.components.SplitComponent;
|
||||||
import net.runelite.client.util.StackFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
|
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
|
||||||
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
|
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ class XpInfoBoxOverlay extends Overlay
|
|||||||
|
|
||||||
final LineComponent xpLine = LineComponent.builder()
|
final LineComponent xpLine = LineComponent.builder()
|
||||||
.left(leftStr + ":")
|
.left(leftStr + ":")
|
||||||
.right(StackFormatter.quantityToRSDecimalStack(rightNum, true))
|
.right(QuantityFormatter.quantityToRSDecimalStack(rightNum, true))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
final String bottemLeftStr;
|
final String bottemLeftStr;
|
||||||
@@ -143,7 +143,7 @@ class XpInfoBoxOverlay extends Overlay
|
|||||||
|
|
||||||
final LineComponent xpLineBottom = LineComponent.builder()
|
final LineComponent xpLineBottom = LineComponent.builder()
|
||||||
.left(bottemLeftStr + ":")
|
.left(bottemLeftStr + ":")
|
||||||
.right(StackFormatter.quantityToRSDecimalStack(bottomRightNum, true))
|
.right(QuantityFormatter.quantityToRSDecimalStack(bottomRightNum, true))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
final SplitComponent xpSplit = SplitComponent.builder()
|
final SplitComponent xpSplit = SplitComponent.builder()
|
||||||
|
|||||||
@@ -33,10 +33,9 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A set of utility functions to use when
|
* A set of utility functions to use when formatting quantities
|
||||||
* formatting numbers for to stack sizes.
|
|
||||||
*/
|
*/
|
||||||
public class StackFormatter
|
public class QuantityFormatter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* A list of suffixes to use when formatting stack sizes.
|
* A list of suffixes to use when formatting stack sizes.
|
||||||
@@ -48,36 +47,27 @@ public class StackFormatter
|
|||||||
*/
|
*/
|
||||||
private static final Pattern SUFFIX_PATTERN = Pattern.compile("^-?[0-9,.]+([a-zA-Z]?)$");
|
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);
|
private static final NumberFormat NUMBER_FORMATTER = NumberFormat.getInstance(Locale.ENGLISH);
|
||||||
|
|
||||||
/**
|
|
||||||
* A decimal number formatter
|
|
||||||
*/
|
|
||||||
private static final NumberFormat DECIMAL_FORMATTER = new DecimalFormat(
|
private static final NumberFormat DECIMAL_FORMATTER = new DecimalFormat(
|
||||||
"#,###.#",
|
"#,###.#",
|
||||||
DecimalFormatSymbols.getInstance(Locale.ENGLISH)
|
DecimalFormatSymbols.getInstance(Locale.ENGLISH)
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* A more precise decimal number formatter, outputting thousandths
|
|
||||||
*/
|
|
||||||
private static final NumberFormat PRECISE_DECIMAL_FORMATTER = new DecimalFormat(
|
private static final NumberFormat PRECISE_DECIMAL_FORMATTER = new DecimalFormat(
|
||||||
"#,###.###",
|
"#,###.###",
|
||||||
DecimalFormatSymbols.getInstance(Locale.ENGLISH)
|
DecimalFormatSymbols.getInstance(Locale.ENGLISH)
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a quantity to a nicely formatted stack size.
|
* Convert a quantity to a short, comma separated, SI-prefix style string
|
||||||
* See the StackFormatterTest to see expected output.
|
*
|
||||||
|
* example: {@code 9,450}, {@code 2.14B}, {@code 100K}
|
||||||
*
|
*
|
||||||
* @param quantity The quantity to convert.
|
* @param quantity The quantity to convert.
|
||||||
* @return A condensed version, with commas, K, M or B
|
* @return a 6 or less character string, possibly with a decimal point, commas or K/M/B suffix
|
||||||
* as needed to 3 significant figures.
|
|
||||||
*/
|
*/
|
||||||
public static String quantityToStackSize(long quantity)
|
public static synchronized String quantityToStackSize(long quantity)
|
||||||
{
|
{
|
||||||
if (quantity < 0)
|
if (quantity < 0)
|
||||||
{
|
{
|
||||||
@@ -115,49 +105,12 @@ public class StackFormatter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a quantity to stack size as it would
|
* Convert a quantity to a short SI-prefix style string, possibly with a decimal,
|
||||||
* 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,
|
|
||||||
* with K after 100,000 and M after 10,000,000
|
* 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)
|
public static String quantityToRSDecimalStack(int quantity)
|
||||||
{
|
{
|
||||||
@@ -165,19 +118,16 @@ public class StackFormatter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a quantity to stack size as it would
|
* Convert a quantity to a short SI-prefix style string, possibly with decimals,
|
||||||
* 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,
|
|
||||||
* with K after 100,000 and M after 10,000,000
|
* 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);
|
String quantityStr = String.valueOf(quantity);
|
||||||
if (quantityStr.length() <= 4)
|
if (quantityStr.length() <= 4)
|
||||||
@@ -202,7 +152,7 @@ public class StackFormatter
|
|||||||
* @param string The string to convert.
|
* @param string The string to convert.
|
||||||
* @return A long representation of it.
|
* @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);
|
int multiplier = getMultiplier(string);
|
||||||
float parsedValue = NUMBER_FORMATTER.parse(string).floatValue();
|
float parsedValue = NUMBER_FORMATTER.parse(string).floatValue();
|
||||||
@@ -210,29 +160,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
|
* example: {@code 10,123,351}, {@code 5}
|
||||||
* @return the formatted String
|
|
||||||
* @throws ArithmeticException if rounding is needed with rounding
|
|
||||||
* mode being set to RoundingMode.UNNECESSARY
|
|
||||||
* @see java.text.Format#format
|
|
||||||
*/
|
*/
|
||||||
public static String formatNumber(final long number)
|
public static synchronized String formatNumber(final long number)
|
||||||
{
|
{
|
||||||
return NUMBER_FORMATTER.format(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
|
* example: {@code 10,123,351}, {@code 5.612}
|
||||||
* @return the formatted String
|
|
||||||
* @throws ArithmeticException if rounding is needed with rounding
|
|
||||||
* mode being set to RoundingMode.UNNECESSARY
|
|
||||||
* @see java.text.Format#format
|
|
||||||
*/
|
*/
|
||||||
public static String formatNumber(double number)
|
public static synchronized String formatNumber(double number)
|
||||||
{
|
{
|
||||||
return NUMBER_FORMATTER.format(number);
|
return NUMBER_FORMATTER.format(number);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, arlyon <https://github.com/arlyon>
|
||||||
|
* 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.util;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.Locale;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class QuantityFormatterTest
|
||||||
|
{
|
||||||
|
@Before
|
||||||
|
public void setUp()
|
||||||
|
{
|
||||||
|
Locale.setDefault(Locale.ENGLISH);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void quantityToRSDecimalStackSize()
|
||||||
|
{
|
||||||
|
assertEquals("0", QuantityFormatter.quantityToRSDecimalStack(0));
|
||||||
|
assertEquals("8500", QuantityFormatter.quantityToRSDecimalStack(8_500));
|
||||||
|
assertEquals("10K", QuantityFormatter.quantityToRSDecimalStack(10_000));
|
||||||
|
assertEquals("21.7K", QuantityFormatter.quantityToRSDecimalStack(21_700));
|
||||||
|
assertEquals("100K", QuantityFormatter.quantityToRSDecimalStack(100_000));
|
||||||
|
assertEquals("100.3K", QuantityFormatter.quantityToRSDecimalStack(100_300));
|
||||||
|
assertEquals("1M", QuantityFormatter.quantityToRSDecimalStack(1_000_000));
|
||||||
|
assertEquals("8.4M", QuantityFormatter.quantityToRSDecimalStack(8_450_000));
|
||||||
|
assertEquals("10M", QuantityFormatter.quantityToRSDecimalStack(10_000_000));
|
||||||
|
assertEquals("12.8M", QuantityFormatter.quantityToRSDecimalStack(12_800_000));
|
||||||
|
assertEquals("100M", QuantityFormatter.quantityToRSDecimalStack(100_000_000));
|
||||||
|
assertEquals("250.1M", QuantityFormatter.quantityToRSDecimalStack(250_100_000));
|
||||||
|
assertEquals("1B", QuantityFormatter.quantityToRSDecimalStack(1_000_000_000));
|
||||||
|
assertEquals("1.5B", QuantityFormatter.quantityToRSDecimalStack(1500_000_000));
|
||||||
|
assertEquals("2.1B", QuantityFormatter.quantityToRSDecimalStack(Integer.MAX_VALUE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void quantityToStackSize()
|
||||||
|
{
|
||||||
|
assertEquals("0", QuantityFormatter.quantityToStackSize(0));
|
||||||
|
assertEquals("999", QuantityFormatter.quantityToStackSize(999));
|
||||||
|
assertEquals("1,000", QuantityFormatter.quantityToStackSize(1000));
|
||||||
|
assertEquals("9,450", QuantityFormatter.quantityToStackSize(9450));
|
||||||
|
assertEquals("14.5K", QuantityFormatter.quantityToStackSize(14_500));
|
||||||
|
assertEquals("99.9K", QuantityFormatter.quantityToStackSize(99_920));
|
||||||
|
assertEquals("100K", QuantityFormatter.quantityToStackSize(100_000));
|
||||||
|
assertEquals("10M", QuantityFormatter.quantityToStackSize(10_000_000));
|
||||||
|
assertEquals("2.14B", QuantityFormatter.quantityToStackSize(Integer.MAX_VALUE));
|
||||||
|
assertEquals("100B", QuantityFormatter.quantityToStackSize(100_000_000_000L));
|
||||||
|
|
||||||
|
assertEquals("0", QuantityFormatter.quantityToStackSize(-0));
|
||||||
|
assertEquals("-400", QuantityFormatter.quantityToStackSize(-400));
|
||||||
|
assertEquals("-400K", QuantityFormatter.quantityToStackSize(-400_000));
|
||||||
|
assertEquals("-40M", QuantityFormatter.quantityToStackSize(-40_000_000));
|
||||||
|
assertEquals("-2.14B", QuantityFormatter.quantityToStackSize(Integer.MIN_VALUE));
|
||||||
|
assertEquals("-400B", QuantityFormatter.quantityToStackSize(-400_000_000_000L));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void quantityToPreciseStackSize()
|
||||||
|
{
|
||||||
|
assertEquals("0", QuantityFormatter.quantityToRSDecimalStack(0));
|
||||||
|
assertEquals("8500", QuantityFormatter.quantityToRSDecimalStack(8_500, true));
|
||||||
|
assertEquals("10K", QuantityFormatter.quantityToRSDecimalStack(10_000, true));
|
||||||
|
assertEquals("21.7K", QuantityFormatter.quantityToRSDecimalStack(21_710, true));
|
||||||
|
assertEquals("100K", QuantityFormatter.quantityToRSDecimalStack(100_000, true));
|
||||||
|
assertEquals("100.3K", QuantityFormatter.quantityToRSDecimalStack(100_310, true));
|
||||||
|
assertEquals("1M", QuantityFormatter.quantityToRSDecimalStack(1_000_000, true));
|
||||||
|
assertEquals("8.45M", QuantityFormatter.quantityToRSDecimalStack(8_450_000, true));
|
||||||
|
assertEquals("8.451M", QuantityFormatter.quantityToRSDecimalStack(8_451_000, true));
|
||||||
|
assertEquals("10M", QuantityFormatter.quantityToRSDecimalStack(10_000_000, true));
|
||||||
|
assertEquals("12.8M", QuantityFormatter.quantityToRSDecimalStack(12_800_000, true));
|
||||||
|
assertEquals("12.85M", QuantityFormatter.quantityToRSDecimalStack(12_850_000, true));
|
||||||
|
assertEquals("12.851M", QuantityFormatter.quantityToRSDecimalStack(12_851_000, true));
|
||||||
|
assertEquals("100M", QuantityFormatter.quantityToRSDecimalStack(100_000_000, true));
|
||||||
|
assertEquals("250.1M", QuantityFormatter.quantityToRSDecimalStack(250_100_000, true));
|
||||||
|
assertEquals("250.151M", QuantityFormatter.quantityToRSDecimalStack(250_151_000, true));
|
||||||
|
assertEquals("1B", QuantityFormatter.quantityToRSDecimalStack(1_000_000_000, true));
|
||||||
|
assertEquals("1.5B", QuantityFormatter.quantityToRSDecimalStack(1500_000_000, true));
|
||||||
|
assertEquals("1.55B", QuantityFormatter.quantityToRSDecimalStack(1550_000_000, true));
|
||||||
|
assertEquals("2.147B", QuantityFormatter.quantityToRSDecimalStack(Integer.MAX_VALUE, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void stackSizeToQuantity() throws ParseException
|
||||||
|
{
|
||||||
|
assertEquals(0, QuantityFormatter.parseQuantity("0"));
|
||||||
|
assertEquals(907, QuantityFormatter.parseQuantity("907"));
|
||||||
|
assertEquals(1200, QuantityFormatter.parseQuantity("1200"));
|
||||||
|
assertEquals(10_500, QuantityFormatter.parseQuantity("10,500"));
|
||||||
|
assertEquals(10_500, QuantityFormatter.parseQuantity("10.5K"));
|
||||||
|
assertEquals(33_560_000, QuantityFormatter.parseQuantity("33.56M"));
|
||||||
|
assertEquals(2_000_000_000, QuantityFormatter.parseQuantity("2B"));
|
||||||
|
|
||||||
|
assertEquals(0, QuantityFormatter.parseQuantity("-0"));
|
||||||
|
assertEquals(-400, QuantityFormatter.parseQuantity("-400"));
|
||||||
|
assertEquals(-400_000, QuantityFormatter.parseQuantity("-400k"));
|
||||||
|
assertEquals(-40_543_000, QuantityFormatter.parseQuantity("-40.543M"));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QuantityFormatter.parseQuantity("0L");
|
||||||
|
fail("Should have thrown an exception for invalid suffix.");
|
||||||
|
}
|
||||||
|
catch (ParseException ignore)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QuantityFormatter.parseQuantity("badstack");
|
||||||
|
fail("Should have thrown an exception for improperly formatted stack.");
|
||||||
|
}
|
||||||
|
catch (ParseException ignore)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2018, arlyon <https://github.com/arlyon>
|
|
||||||
* 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.util;
|
|
||||||
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.Locale;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class StackFormatterTest
|
|
||||||
{
|
|
||||||
@Before
|
|
||||||
public void setUp()
|
|
||||||
{
|
|
||||||
Locale.setDefault(Locale.ENGLISH);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void quantityToRSDecimalStackSize()
|
|
||||||
{
|
|
||||||
assertEquals("0", StackFormatter.quantityToRSDecimalStack(0));
|
|
||||||
assertEquals("8500", StackFormatter.quantityToRSDecimalStack(8_500));
|
|
||||||
assertEquals("10K", StackFormatter.quantityToRSDecimalStack(10_000));
|
|
||||||
assertEquals("21.7K", StackFormatter.quantityToRSDecimalStack(21_700));
|
|
||||||
assertEquals("100K", StackFormatter.quantityToRSDecimalStack(100_000));
|
|
||||||
assertEquals("100.3K", StackFormatter.quantityToRSDecimalStack(100_300));
|
|
||||||
assertEquals("1M", StackFormatter.quantityToRSDecimalStack(1_000_000));
|
|
||||||
assertEquals("8.4M", StackFormatter.quantityToRSDecimalStack(8_450_000));
|
|
||||||
assertEquals("10M", StackFormatter.quantityToRSDecimalStack(10_000_000));
|
|
||||||
assertEquals("12.8M", StackFormatter.quantityToRSDecimalStack(12_800_000));
|
|
||||||
assertEquals("100M", StackFormatter.quantityToRSDecimalStack(100_000_000));
|
|
||||||
assertEquals("250.1M", StackFormatter.quantityToRSDecimalStack(250_100_000));
|
|
||||||
assertEquals("1B", StackFormatter.quantityToRSDecimalStack(1_000_000_000));
|
|
||||||
assertEquals("1.5B", StackFormatter.quantityToRSDecimalStack(1500_000_000));
|
|
||||||
assertEquals("2.1B", StackFormatter.quantityToRSDecimalStack(Integer.MAX_VALUE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void quantityToRSStackSize()
|
|
||||||
{
|
|
||||||
assertEquals("0", StackFormatter.quantityToRSStackSize(0));
|
|
||||||
assertEquals("99999", StackFormatter.quantityToRSStackSize(99_999));
|
|
||||||
assertEquals("100K", StackFormatter.quantityToRSStackSize(100_000));
|
|
||||||
assertEquals("10M", StackFormatter.quantityToRSStackSize(10_000_000));
|
|
||||||
assertEquals("2147M", StackFormatter.quantityToRSStackSize(Integer.MAX_VALUE));
|
|
||||||
|
|
||||||
assertEquals("0", StackFormatter.quantityToRSStackSize(-0));
|
|
||||||
assertEquals("-400", StackFormatter.quantityToRSStackSize(-400));
|
|
||||||
assertEquals("-400K", StackFormatter.quantityToRSStackSize(-400_000));
|
|
||||||
assertEquals("-40M", StackFormatter.quantityToRSStackSize(-40_000_000));
|
|
||||||
assertEquals("-2147M", StackFormatter.quantityToRSStackSize(Integer.MIN_VALUE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void quantityToStackSize()
|
|
||||||
{
|
|
||||||
assertEquals("0", StackFormatter.quantityToStackSize(0));
|
|
||||||
assertEquals("999", StackFormatter.quantityToStackSize(999));
|
|
||||||
assertEquals("1,000", StackFormatter.quantityToStackSize(1000));
|
|
||||||
assertEquals("9,450", StackFormatter.quantityToStackSize(9450));
|
|
||||||
assertEquals("14.5K", StackFormatter.quantityToStackSize(14_500));
|
|
||||||
assertEquals("99.9K", StackFormatter.quantityToStackSize(99_920));
|
|
||||||
assertEquals("100K", StackFormatter.quantityToStackSize(100_000));
|
|
||||||
assertEquals("10M", StackFormatter.quantityToStackSize(10_000_000));
|
|
||||||
assertEquals("2.14B", StackFormatter.quantityToStackSize(Integer.MAX_VALUE));
|
|
||||||
assertEquals("100B", StackFormatter.quantityToStackSize(100_000_000_000L));
|
|
||||||
|
|
||||||
assertEquals("0", StackFormatter.quantityToStackSize(-0));
|
|
||||||
assertEquals("-400", StackFormatter.quantityToStackSize(-400));
|
|
||||||
assertEquals("-400K", StackFormatter.quantityToStackSize(-400_000));
|
|
||||||
assertEquals("-40M", StackFormatter.quantityToStackSize(-40_000_000));
|
|
||||||
assertEquals("-2.14B", StackFormatter.quantityToStackSize(Integer.MIN_VALUE));
|
|
||||||
assertEquals("-400B", StackFormatter.quantityToStackSize(-400_000_000_000L));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void quantityToPreciseStackSize()
|
|
||||||
{
|
|
||||||
assertEquals("0", StackFormatter.quantityToRSDecimalStack(0));
|
|
||||||
assertEquals("8500", StackFormatter.quantityToRSDecimalStack(8_500, true));
|
|
||||||
assertEquals("10K", StackFormatter.quantityToRSDecimalStack(10_000, true));
|
|
||||||
assertEquals("21.7K", StackFormatter.quantityToRSDecimalStack(21_710, true));
|
|
||||||
assertEquals("100K", StackFormatter.quantityToRSDecimalStack(100_000, true));
|
|
||||||
assertEquals("100.3K", StackFormatter.quantityToRSDecimalStack(100_310, true));
|
|
||||||
assertEquals("1M", StackFormatter.quantityToRSDecimalStack(1_000_000, true));
|
|
||||||
assertEquals("8.45M", StackFormatter.quantityToRSDecimalStack(8_450_000, true));
|
|
||||||
assertEquals("8.451M", StackFormatter.quantityToRSDecimalStack(8_451_000, true));
|
|
||||||
assertEquals("10M", StackFormatter.quantityToRSDecimalStack(10_000_000, true));
|
|
||||||
assertEquals("12.8M", StackFormatter.quantityToRSDecimalStack(12_800_000, true));
|
|
||||||
assertEquals("12.85M", StackFormatter.quantityToRSDecimalStack(12_850_000, true));
|
|
||||||
assertEquals("12.851M", StackFormatter.quantityToRSDecimalStack(12_851_000, true));
|
|
||||||
assertEquals("100M", StackFormatter.quantityToRSDecimalStack(100_000_000, true));
|
|
||||||
assertEquals("250.1M", StackFormatter.quantityToRSDecimalStack(250_100_000, true));
|
|
||||||
assertEquals("250.151M", StackFormatter.quantityToRSDecimalStack(250_151_000, true));
|
|
||||||
assertEquals("1B", StackFormatter.quantityToRSDecimalStack(1_000_000_000, true));
|
|
||||||
assertEquals("1.5B", StackFormatter.quantityToRSDecimalStack(1500_000_000, true));
|
|
||||||
assertEquals("1.55B", StackFormatter.quantityToRSDecimalStack(1550_000_000, true));
|
|
||||||
assertEquals("2.147B", StackFormatter.quantityToRSDecimalStack(Integer.MAX_VALUE, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void stackSizeToQuantity() throws ParseException
|
|
||||||
{
|
|
||||||
assertEquals(0, StackFormatter.stackSizeToQuantity("0"));
|
|
||||||
assertEquals(907, StackFormatter.stackSizeToQuantity("907"));
|
|
||||||
assertEquals(1200, StackFormatter.stackSizeToQuantity("1200"));
|
|
||||||
assertEquals(10_500, StackFormatter.stackSizeToQuantity("10,500"));
|
|
||||||
assertEquals(10_500, StackFormatter.stackSizeToQuantity("10.5K"));
|
|
||||||
assertEquals(33_560_000, StackFormatter.stackSizeToQuantity("33.56M"));
|
|
||||||
assertEquals(2_000_000_000, StackFormatter.stackSizeToQuantity("2B"));
|
|
||||||
|
|
||||||
assertEquals(0, StackFormatter.stackSizeToQuantity("-0"));
|
|
||||||
assertEquals(-400, StackFormatter.stackSizeToQuantity("-400"));
|
|
||||||
assertEquals(-400_000, StackFormatter.stackSizeToQuantity("-400k"));
|
|
||||||
assertEquals(-40_543_000, StackFormatter.stackSizeToQuantity("-40.543M"));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
StackFormatter.stackSizeToQuantity("0L");
|
|
||||||
fail("Should have thrown an exception for invalid suffix.");
|
|
||||||
}
|
|
||||||
catch (ParseException ignore)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
StackFormatter.stackSizeToQuantity("badstack");
|
|
||||||
fail("Should have thrown an exception for improperly formatted stack.");
|
|
||||||
}
|
|
||||||
catch (ParseException ignore)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user