use of com.nextplugins.economy.api.event.operations.AsyncPurseUpdateEvent in project NextEconomy by NextPlugins.
the class PurseAPI method updatePurse.
/**
* Change purse value with messages and calling event (Better way)
*
* @param newValue to purse
*/
public void updatePurse(int newValue) {
val lastNextUpdate = nextUpdate;
val duration = PurseValue.get(PurseValue::nextUpdate);
setNextUpdate(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(duration));
Bukkit.getScheduler().runTaskAsynchronously(NextEconomy.getInstance(), () -> {
val asyncPurseUpdateEvent = new AsyncPurseUpdateEvent(newValue, purse, lastNextUpdate);
PluginManager pluginManager = Bukkit.getPluginManager();
pluginManager.callEvent(asyncPurseUpdateEvent);
});
}
Aggregations