Fixed an issue with item caching

This commit is contained in:
Indyuce 2019-11-03 16:46:14 +01:00
parent 69a8df439b
commit 4b80343d12
2 changed files with 7 additions and 13 deletions

View File

@ -147,7 +147,7 @@ public class MMOItems extends JavaPlugin {
abilityManager.stopRegistration();
configManager = new ConfigManager();
itemManager = new ItemManager();
itemManager = new ItemManager(getConfig().getBoolean("use-item-caching"));
tierManager = new TierManager();
setManager = new SetManager();
upgradeManager = new UpgradeManager();

View File

@ -15,20 +15,14 @@ import net.Indyuce.mmoitems.api.item.MMOItem;
import net.Indyuce.mmoitems.stat.type.ItemStat;
public class ItemManager extends BukkitRunnable {
private Map<Type, Map<String, LoadedItem>> map = new HashMap<>();
private boolean cache = false;
private final Map<Type, Map<String, LoadedItem>> map = new HashMap<>();
private final boolean cache;
public ItemManager() {
runTaskTimerAsynchronously(MMOItems.plugin, 60 * 20, 2 * 60 * 20);
}
public void useCache(boolean cache) {
public ItemManager(boolean cache) {
this.cache = cache;
if (!cache) {
map.clear();
if (!isCancelled())
cancel();
}
if (cache)
runTaskTimerAsynchronously(MMOItems.plugin, 60 * 20, 2 * 60 * 20);
}
public void uncache(Type type, String id) {