use of org.spongepowered.api.scheduler.Scheduler in project TotalEconomy by Erigitic.
the class TEJobManager method startSalaryTask.
/**
* Start the timer that pays out the salary to each player after a specified time in seconds
*/
private void startSalaryTask() {
Scheduler scheduler = totalEconomy.getGame().getScheduler();
Task.Builder payTask = scheduler.createTaskBuilder();
payTask.execute(() -> {
for (Player player : totalEconomy.getServer().getOnlinePlayers()) {
Optional<TEJob> optJob = getJob(getPlayerJob(player), true);
if (!optJob.isPresent()) {
player.sendMessage(Text.of(TextColors.RED, "[TE] Cannot pay your salary! Contact your administrator!"));
return;
}
if (optJob.get().salaryEnabled()) {
BigDecimal salary = optJob.get().getSalary();
TEAccount playerAccount = (TEAccount) accountManager.getOrCreateAccount(player.getUniqueId()).get();
TransactionResult result = playerAccount.deposit(totalEconomy.getDefaultCurrency(), salary, Cause.of(NamedCause.of("TotalEconomy", totalEconomy.getPluginContainer())));
if (result.getResult() == ResultType.SUCCESS) {
player.sendMessage(Text.of(TextColors.GRAY, "Your salary of ", TextColors.GOLD, totalEconomy.getDefaultCurrency().format(salary), TextColors.GRAY, " has just been paid."));
} else {
player.sendMessage(Text.of(TextColors.RED, "[TE] Failed to pay your salary! You may want to contact your admin - TransactionResult: ", result.getResult().toString()));
}
}
}
}).delay(jobsConfig.getNode("salarydelay").getInt(), TimeUnit.SECONDS).interval(jobsConfig.getNode("salarydelay").getInt(), TimeUnit.SECONDS).name("Pay Day").submit(totalEconomy);
}
use of org.spongepowered.api.scheduler.Scheduler in project HuskyCrates-Sponge by codeHusky.
the class CrateUtilities method startParticleEffects.
public void startParticleEffects() {
if (runner != null) {
runner.cancel();
}
Scheduler scheduler = Sponge.getScheduler();
Task.Builder taskBuilder = scheduler.createTaskBuilder();
runner = taskBuilder.execute(this::particleRunner).intervalTicks(1).submit(plugin);
}
Aggregations