Remove points from user every 10 minutes and sync them at the same time
This commit is contained in:
1 parent
68978ad13c
commit
b3ae5e67d8
2 files changed
+51
-13
No files matched your search
@@ -6,14 +6,22 @@ import com.alttd.database.Database;
|
||||
import com.alttd.config.Config;
|
||||
import com.alttd.config.VillagerConfig;
|
||||
import com.alttd.config.WorthConfig;
|
||||
import com.alttd.database.Queries;
|
||||
import com.alttd.events.LoginEvent;
|
||||
import com.alttd.events.LogoutEvent;
|
||||
import com.alttd.events.VillagerInteract;
|
||||
import com.alttd.objects.EconUser;
|
||||
import com.alttd.util.Logger;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class VillagerUI extends JavaPlugin {
|
||||
|
||||
@@ -39,11 +47,24 @@ public class VillagerUI extends JavaPlugin {
|
||||
if (!setupEconomy())
|
||||
return;
|
||||
Database.getDatabase().init();
|
||||
scheduleTasks();
|
||||
Logger.info("--------------------------------------------------");
|
||||
Logger.info("Villager UI started");
|
||||
Logger.info("--------------------------------------------------");
|
||||
}
|
||||
|
||||
private void scheduleTasks() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
EconUser.getEconUsers().forEach(econUser -> {
|
||||
econUser.removePoints();
|
||||
econUser.syncPoints();
|
||||
});
|
||||
}
|
||||
}.runTaskTimerAsynchronously(getInstance(), 0L, 5 * 60 * 20L);
|
||||
}
|
||||
|
||||
private void registerEvents() {
|
||||
getServer().getPluginManager().registerEvents(new GUIListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new VillagerInteract(), this);
|
||||
|
||||
Reference in new issue
Block a user