mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-13 03:07:34 +00:00
-New class extending from the HashMap class, only takes CacheHashMap.CachedObject as values, which itself is a template class. -On every call to get(), it goes through its values and removes any that are past a set age in millis. ClientCache: -New class with static CacheHashMap and function to get image data, will do more caching later on.
17 lines
621 B
Java
17 lines
621 B
Java
package noppes.npcs.client;
|
|
|
|
import noppes.npcs.client.renderer.customitem.ImageData;
|
|
import noppes.npcs.util.CacheHashMap;
|
|
|
|
public class ClientCache {
|
|
private static final CacheHashMap<String, CacheHashMap.CachedObject<ImageData>> imageDataCache = new CacheHashMap<>(10*1000);
|
|
|
|
public static ImageData getImageData(String directory) {
|
|
if (!imageDataCache.containsKey(directory)) {
|
|
ImageData imageData = new ImageData(directory);
|
|
imageDataCache.put(directory, new CacheHashMap.CachedObject<>(imageData));
|
|
}
|
|
return imageDataCache.get(directory).getObject();
|
|
}
|
|
}
|