Convert item stats mapping to use item ids instead of names
Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -204,11 +204,12 @@ public class ItemClient
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, ItemStats> getStats() throws IOException
|
||||
public Map<Integer, ItemStats> getStats() throws IOException
|
||||
{
|
||||
HttpUrl.Builder urlBuilder = RuneLiteAPI.getStaticBase().newBuilder()
|
||||
.addPathSegment("item")
|
||||
.addPathSegment("stats.min.json");
|
||||
// TODO: Change this to stats.min.json later after release is undeployed
|
||||
.addPathSegment("stats.ids.min.json");
|
||||
|
||||
HttpUrl url = urlBuilder.build();
|
||||
|
||||
@@ -227,7 +228,7 @@ public class ItemClient
|
||||
}
|
||||
|
||||
InputStream in = response.body().byteStream();
|
||||
final Type typeToken = new TypeToken<Map<String, ItemStats>>()
|
||||
final Type typeToken = new TypeToken<Map<Integer, ItemStats>>()
|
||||
{
|
||||
}.getType();
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), typeToken);
|
||||
|
||||
@@ -84,7 +84,7 @@ public class ItemManager
|
||||
|
||||
private final ItemClient itemClient = new ItemClient();
|
||||
private Map<Integer, ItemPrice> itemPrices = Collections.emptyMap();
|
||||
private Map<String, ItemStats> itemStats = Collections.emptyMap();
|
||||
private Map<Integer, ItemStats> itemStats = Collections.emptyMap();
|
||||
private final LoadingCache<ImageKey, AsyncBufferedImage> itemImages;
|
||||
private final LoadingCache<Integer, ItemComposition> itemCompositions;
|
||||
private final LoadingCache<OutlineKey, BufferedImage> itemOutlines;
|
||||
@@ -226,7 +226,7 @@ public class ItemManager
|
||||
{
|
||||
try
|
||||
{
|
||||
final Map<String, ItemStats> stats = itemClient.getStats();
|
||||
final Map<Integer, ItemStats> stats = itemClient.getStats();
|
||||
if (stats != null)
|
||||
{
|
||||
itemStats = ImmutableMap.copyOf(stats);
|
||||
@@ -307,16 +307,16 @@ public class ItemManager
|
||||
* @return item stats
|
||||
*/
|
||||
@Nullable
|
||||
public ItemStats getItemStats(int itemId)
|
||||
public ItemStats getItemStats(int itemId, boolean allowNote)
|
||||
{
|
||||
ItemComposition itemComposition = getItemComposition(itemId);
|
||||
|
||||
if (itemComposition == null || itemComposition.getName() == null)
|
||||
if (itemComposition == null || itemComposition.getName() == null || (!allowNote && itemComposition.getNote() != -1))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return itemStats.get(itemComposition.getName());
|
||||
return itemStats.get(canonicalize(itemId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -139,7 +139,7 @@ public class ItemStatOverlay extends Overlay
|
||||
|
||||
if (config.equipmentStats())
|
||||
{
|
||||
final ItemStats stats = itemManager.getItemStats(itemId);
|
||||
final ItemStats stats = itemManager.getItemStats(itemId, false);
|
||||
|
||||
if (stats != null)
|
||||
{
|
||||
@@ -205,7 +205,7 @@ public class ItemStatOverlay extends Overlay
|
||||
final Item item = items[slot];
|
||||
if (item != null)
|
||||
{
|
||||
other = itemManager.getItemStats(item.getId());
|
||||
other = itemManager.getItemStats(item.getId(), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user