Properly invalidate cache and load icons in Clan
Properly invalidate cache on plugin shutdown and load clan chat icons on plugin startup. Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -70,16 +70,7 @@ public class ClanChatPlugin extends Plugin
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
private LoadingCache<String, ClanMemberRank> clanRanksCache;
|
private final LoadingCache<String, ClanMemberRank> clanRanksCache = CacheBuilder.newBuilder()
|
||||||
private int modIconsLength;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private Client client;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void startUp() throws Exception
|
|
||||||
{
|
|
||||||
clanRanksCache = CacheBuilder.newBuilder()
|
|
||||||
.maximumSize(100)
|
.maximumSize(100)
|
||||||
.expireAfterAccess(1, TimeUnit.MINUTES)
|
.expireAfterAccess(1, TimeUnit.MINUTES)
|
||||||
.build(new CacheLoader<String, ClanMemberRank>()
|
.build(new CacheLoader<String, ClanMemberRank>()
|
||||||
@@ -102,6 +93,25 @@ public class ClanChatPlugin extends Plugin
|
|||||||
.orElse(ClanMemberRank.UNRANKED);
|
.orElse(ClanMemberRank.UNRANKED);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
private int modIconsLength;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Client client;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void startUp() throws Exception
|
||||||
|
{
|
||||||
|
if (modIconsLength == 0 && client.getGameState().compareTo(GameState.LOGIN_SCREEN) >= 0)
|
||||||
|
{
|
||||||
|
loadClanChatIcons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void shutDown()
|
||||||
|
{
|
||||||
|
clanRanksCache.invalidateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|||||||
Reference in New Issue
Block a user