Update plugins to use either NumberFormat or the StackFormatter

This commit is contained in:
arlyon
2018-03-04 23:21:35 +00:00
committed by Adam
parent a098965d4c
commit 326da42c1e
5 changed files with 19 additions and 13 deletions

View File

@@ -27,7 +27,6 @@ package net.runelite.client.plugins.blastfurnace;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import java.text.NumberFormat;
import javax.inject.Inject;
import net.runelite.api.Client;
import static net.runelite.api.Varbits.BLAST_FURNACE_COFFER;
@@ -36,11 +35,10 @@ import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.PanelComponent;
import net.runelite.client.util.StackFormatter;
class BlastFurnaceCofferOverlay extends Overlay
{
private static final NumberFormat NUMBER_FORMATTER = NumberFormat.getInstance();
private final Client client;
private final BlastFurnacePlugin plugin;
private final PanelComponent panelComponent = new PanelComponent();
@@ -71,7 +69,7 @@ class BlastFurnaceCofferOverlay extends Overlay
panelComponent.getLines().add(new PanelComponent.Line(
"Coffer:",
NUMBER_FORMATTER.format(client.getSetting(BLAST_FURNACE_COFFER)) + " gp"
StackFormatter.quantityToStackSize(client.getSetting(BLAST_FURNACE_COFFER)) + " gp"
));
}
return panelComponent.render(graphics, parent);

View File

@@ -28,6 +28,7 @@ package net.runelite.client.plugins.chatcommands;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Provides;
import java.io.IOException;
import java.text.NumberFormat;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ScheduledExecutorService;
@@ -64,6 +65,7 @@ import net.runelite.http.api.item.SearchResult;
public class ChatCommandsPlugin extends Plugin
{
private static final float HIGH_ALCHEMY_CONSTANT = 0.6f;
private static final NumberFormat NUMBER_FORMATTER = NumberFormat.getInstance();
private final HiscoreClient hiscoreClient = new HiscoreClient();
@@ -247,7 +249,7 @@ public class ChatCommandsPlugin extends Plugin
.append(ChatColorType.NORMAL)
.append(": GE average ")
.append(ChatColorType.HIGHLIGHT)
.append(String.format("%,d", itemPrice.getPrice()));
.append(NUMBER_FORMATTER.format(itemPrice.getPrice()));
ItemComposition itemComposition = itemManager.getItemComposition(itemId);
if (itemComposition != null)
@@ -257,7 +259,7 @@ public class ChatCommandsPlugin extends Plugin
.append(ChatColorType.NORMAL)
.append(" HA value ")
.append(ChatColorType.HIGHLIGHT)
.append(String.format("%,d", alchPrice));
.append(NUMBER_FORMATTER.format(alchPrice));
}
String response = builder.build();

View File

@@ -31,6 +31,7 @@ import com.google.common.cache.CacheBuilder;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Provides;
import java.io.IOException;
import java.text.NumberFormat;
import java.time.Instant;
import java.util.ArrayDeque;
import java.util.Deque;
@@ -72,6 +73,7 @@ import net.runelite.http.api.item.ItemPrice;
public class ExaminePlugin extends Plugin
{
private static final float HIGH_ALCHEMY_CONSTANT = 0.6f;
private static final NumberFormat NUMBER_FORMATTER = NumberFormat.getInstance();
private final ExamineClient examineClient = new ExamineClient();
private final Deque<PendingExamine> pending = new ArrayDeque<>();
@@ -333,7 +335,7 @@ public class ExaminePlugin extends Plugin
if (quantity > 1)
{
message
.append(String.format("%,d", quantity))
.append(NUMBER_FORMATTER.format(quantity))
.append(" x ");
}
@@ -348,7 +350,7 @@ public class ExaminePlugin extends Plugin
.append(ChatColorType.NORMAL)
.append(" GE average ")
.append(ChatColorType.HIGHLIGHT)
.append(String.format("%,d", gePrice * quantity));
.append(NUMBER_FORMATTER.format(gePrice * quantity));
}
if (quantity > 1)
@@ -357,7 +359,7 @@ public class ExaminePlugin extends Plugin
.append(ChatColorType.NORMAL)
.append(" (")
.append(ChatColorType.HIGHLIGHT)
.append(Integer.toString(gePrice))
.append(NUMBER_FORMATTER.format(gePrice))
.append(ChatColorType.NORMAL)
.append("ea)");
}
@@ -368,7 +370,7 @@ public class ExaminePlugin extends Plugin
.append(ChatColorType.NORMAL)
.append(" HA value ")
.append(ChatColorType.HIGHLIGHT)
.append(String.format("%,d", alchPrice * quantity));
.append(NUMBER_FORMATTER.format(alchPrice * quantity));
}
if (quantity > 1)
@@ -377,7 +379,7 @@ public class ExaminePlugin extends Plugin
.append(ChatColorType.NORMAL)
.append(" (")
.append(ChatColorType.HIGHLIGHT)
.append(Integer.toString(alchPrice))
.append(NUMBER_FORMATTER.format(alchPrice))
.append(ChatColorType.NORMAL)
.append("ea)");
}

View File

@@ -28,6 +28,7 @@ package net.runelite.client.plugins.grandexchange;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.text.NumberFormat;
import javax.annotation.Nullable;
import javax.swing.BorderFactory;
import javax.swing.Box;
@@ -47,6 +48,8 @@ import net.runelite.client.game.ItemManager;
@Slf4j
public class GrandExchangeOfferSlot extends JPanel
{
private static final NumberFormat NUMBER_FORMATTER = NumberFormat.getInstance();
private static final Color GE_INPROGRESS_ORANGE = new Color(0xd8, 0x80, 0x20).brighter();
private static final Color GE_FINISHED_GREEN = new Color(0, 0x5f, 0);
private static final Color GE_CANCELLED_RED = new Color(0x8f, 0, 0);
@@ -141,7 +144,7 @@ public class GrandExchangeOfferSlot extends JPanel
ImageIcon newItemIcon = new ImageIcon(itemManager.getImage(newOffer.getItemId(), newOffer.getTotalQuantity(), shouldStack));
itemIcon.setIcon(newItemIcon);
offerState.setText(getNameForState(newOffer.getState()) + " at " + newOffer.getPrice() + (newOffer.getTotalQuantity() > 1 ? "gp ea" : "gp"));
offerState.setText(getNameForState(newOffer.getState()) + " at " + NUMBER_FORMATTER.format(newOffer.getPrice()) + (newOffer.getTotalQuantity() > 1 ? "gp ea" : "gp"));
progressBar.setMaximum(newOffer.getTotalQuantity());
progressBar.setValue(newOffer.getQuantitySold());

View File

@@ -52,6 +52,7 @@ import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.util.StackFormatter;
import net.runelite.http.api.item.ItemPrice;
public class GroundItemsOverlay extends Overlay
@@ -259,7 +260,7 @@ public class GroundItemsOverlay extends Overlay
}
itemStringBuilder.append(" (EX: ")
.append(ItemManager.quantityToStackSize(cost))
.append(StackFormatter.quantityToStackSize(cost))
.append(" gp)");
}