grounditems: make priceChecks threadsafe
This commit is contained in:
@@ -28,6 +28,7 @@ package net.runelite.client.plugins.grounditems;
|
|||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.LoadingCache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.EvictingQueue;
|
import com.google.common.collect.EvictingQueue;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
@@ -163,7 +164,7 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Map<GroundItem.GroundItemKey, GroundItem> collectedGroundItems = new LinkedHashMap<>();
|
private final Map<GroundItem.GroundItemKey, GroundItem> collectedGroundItems = new LinkedHashMap<>();
|
||||||
private final Map<Integer, Color> priceChecks = new LinkedHashMap<>();
|
private Map<Integer, Color> priceChecks = ImmutableMap.of();
|
||||||
private LoadingCache<NamedQuantity, Boolean> highlightedItems;
|
private LoadingCache<NamedQuantity, Boolean> highlightedItems;
|
||||||
private LoadingCache<NamedQuantity, Boolean> hiddenItems;
|
private LoadingCache<NamedQuantity, Boolean> hiddenItems;
|
||||||
private final Queue<Integer> droppedItemQueue = EvictingQueue.create(16); // recently dropped items
|
private final Queue<Integer> droppedItemQueue = EvictingQueue.create(16); // recently dropped items
|
||||||
@@ -429,32 +430,33 @@ public class GroundItemsPlugin extends Plugin
|
|||||||
.build(new WildcardMatchLoader(hiddenItemList));
|
.build(new WildcardMatchLoader(hiddenItemList));
|
||||||
|
|
||||||
// Cache colors
|
// Cache colors
|
||||||
priceChecks.clear();
|
ImmutableMap.Builder<Integer, Color> priceCheckBuilder = ImmutableMap.builder();
|
||||||
|
|
||||||
if (config.getHighlightOverValue() > 0)
|
if (config.getHighlightOverValue() > 0)
|
||||||
{
|
{
|
||||||
priceChecks.put(config.getHighlightOverValue(), config.highlightedColor());
|
priceCheckBuilder.put(config.getHighlightOverValue(), config.highlightedColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.insaneValuePrice() > 0)
|
if (config.insaneValuePrice() > 0)
|
||||||
{
|
{
|
||||||
priceChecks.put(config.insaneValuePrice(), config.insaneValueColor());
|
priceCheckBuilder.put(config.insaneValuePrice(), config.insaneValueColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.highValuePrice() > 0)
|
if (config.highValuePrice() > 0)
|
||||||
{
|
{
|
||||||
priceChecks.put(config.highValuePrice(), config.highValueColor());
|
priceCheckBuilder.put(config.highValuePrice(), config.highValueColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.mediumValuePrice() > 0)
|
if (config.mediumValuePrice() > 0)
|
||||||
{
|
{
|
||||||
priceChecks.put(config.mediumValuePrice(), config.mediumValueColor());
|
priceCheckBuilder.put(config.mediumValuePrice(), config.mediumValueColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.lowValuePrice() > 0)
|
if (config.lowValuePrice() > 0)
|
||||||
{
|
{
|
||||||
priceChecks.put(config.lowValuePrice(), config.lowValueColor());
|
priceCheckBuilder.put(config.lowValuePrice(), config.lowValueColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
priceChecks = priceCheckBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|||||||
Reference in New Issue
Block a user