increase http api item stat parsing by a really really negligible amt
This commit is contained in:
@@ -28,14 +28,9 @@ import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import java.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -137,12 +132,11 @@ public class ItemManager
|
||||
private final Client client;
|
||||
private final ClientThread clientThread;
|
||||
private final ItemClient itemClient;
|
||||
private final ImmutableMap<Integer, ItemStats> itemStatMap;
|
||||
private final LoadingCache<ImageKey, AsyncBufferedImage> itemImages;
|
||||
private final LoadingCache<Integer, ItemDefinition> itemDefinitions;
|
||||
private final LoadingCache<OutlineKey, BufferedImage> itemOutlines;
|
||||
private Map<Integer, ItemPrice> itemPrices = Collections.emptyMap();
|
||||
private Map<Integer, ItemStats> itemStats = Collections.emptyMap();
|
||||
private ImmutableMap<Integer, ItemStats> itemStats = ImmutableMap.of();
|
||||
|
||||
@Inject
|
||||
public ItemManager(
|
||||
@@ -196,16 +190,6 @@ public class ItemManager
|
||||
}
|
||||
});
|
||||
|
||||
final Gson gson = new Gson();
|
||||
|
||||
final Type typeToken = new TypeToken<Map<Integer, ItemStats>>()
|
||||
{
|
||||
}.getType();
|
||||
|
||||
final InputStream statsFile = getClass().getResourceAsStream("/item_stats.json");
|
||||
final Map<Integer, ItemStats> stats = gson.fromJson(new InputStreamReader(statsFile), typeToken);
|
||||
itemStatMap = ImmutableMap.copyOf(stats);
|
||||
|
||||
eventbus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
|
||||
eventbus.subscribe(PostItemDefinition.class, this, this::onPostItemDefinition);
|
||||
}
|
||||
@@ -238,16 +222,9 @@ public class ItemManager
|
||||
itemClient.getStats()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(
|
||||
(stats) ->
|
||||
{
|
||||
if (stats != null)
|
||||
{
|
||||
itemStats = ImmutableMap.copyOf(stats);
|
||||
}
|
||||
|
||||
log.debug("Loaded {} stats", itemStats.size());
|
||||
},
|
||||
(e) -> log.warn("error loading stats!", e)
|
||||
m -> itemStats = m,
|
||||
e -> log.warn("Error fetching stats", e),
|
||||
() -> log.debug("Loaded {} stats", itemStats.size())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -376,12 +353,12 @@ public class ItemManager
|
||||
{
|
||||
ItemDefinition itemDefinition = getItemDefinition(itemId);
|
||||
|
||||
if (itemDefinition.getName() == null || !allowNote && itemDefinition.getNote() != -1)
|
||||
if (!allowNote && itemDefinition.getNote() != -1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return itemStatMap.get(canonicalize(itemId));
|
||||
return itemStats.get(canonicalize(itemId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package net.runelite.client.game;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
public class ItemStat
|
||||
{
|
||||
private int slot;
|
||||
|
||||
private int astab;
|
||||
private int aslash;
|
||||
private int acrush;
|
||||
private int amagic;
|
||||
private int arange;
|
||||
|
||||
private int dstab;
|
||||
private int dslash;
|
||||
private int dcrush;
|
||||
private int dmagic;
|
||||
private int drange;
|
||||
|
||||
private int str;
|
||||
private int rstr;
|
||||
private int mdmg;
|
||||
private int prayer;
|
||||
private int aspeed;
|
||||
}
|
||||
@@ -48,7 +48,7 @@ import net.runelite.http.api.item.ItemStats;
|
||||
public class ItemStatOverlay extends Overlay
|
||||
{
|
||||
// Unarmed attack speed is 6
|
||||
private static final ItemStats UNARMED = new ItemStats("", false, true, 0,
|
||||
private static final ItemStats UNARMED = new ItemStats(false, true, 0,
|
||||
ItemEquipmentStats.builder()
|
||||
.aspeed(6)
|
||||
.build());
|
||||
|
||||
@@ -551,6 +551,7 @@ public class PlayerScouter extends Plugin
|
||||
}
|
||||
|
||||
ItemStats item = itemManager.getItemStats(gear, false);
|
||||
String name = itemManager.getItemDefinition(gear).getName();
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
@@ -559,7 +560,7 @@ public class PlayerScouter extends Plugin
|
||||
}
|
||||
|
||||
fieldList.add(FieldEmbed.builder()
|
||||
.name(item.getName())
|
||||
.name(name)
|
||||
.value("Value: " + StackFormatter.quantityToRSDecimalStack(value))
|
||||
.inline(true)
|
||||
.build());
|
||||
|
||||
Reference in New Issue
Block a user