Fixed cache clearing task being cancelled

This commit is contained in:
Auxilor
2021-08-29 12:15:44 +01:00
parent 8b9fbb3b99
commit 4c8b330464
2 changed files with 13 additions and 2 deletions

View File

@@ -101,6 +101,11 @@ public class EcoEnchantsPlugin extends EcoPlugin {
}
}, 1);
}
this.getScheduler().runTimer(() -> {
for (EcoEnchant enchant : EcoEnchants.values()) {
enchant.clearCachedRequirements();
}
}, 300, 300);
}
@Override

View File

@@ -263,8 +263,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche
postUpdate();
this.register();
this.cachedRequirements.clear();
this.getPlugin().getScheduler().runTimer(this.cachedRequirements::clear, 300, 300);
this.clearCachedRequirements();
}
protected void postUpdate() {
@@ -279,6 +278,13 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche
EnchantmentUtils.register(this);
}
/**
* Clear requirements cache.
*/
public void clearCachedRequirements() {
this.cachedRequirements.clear();
}
/**
* Format the %value% placeholder in description lore.
*