Fixed using anonymous class for saving user data.
Fixed being unable to configure logging/saving frequency
This commit is contained in:
parent
5ce29f3967
commit
0440ab102f
|
|
@ -2,21 +2,21 @@ package com.alttd;
|
|||
|
||||
import com.alttd.GUI.GUIListener;
|
||||
import com.alttd.commands.CommandManager;
|
||||
import com.alttd.database.Database;
|
||||
import com.alttd.config.Config;
|
||||
import com.alttd.config.VillagerConfig;
|
||||
import com.alttd.config.WorthConfig;
|
||||
import com.alttd.database.Database;
|
||||
import com.alttd.database.Queries;
|
||||
import com.alttd.datalock.DataLockAPI;
|
||||
import com.alttd.events.*;
|
||||
import com.alttd.logging.LogInOut;
|
||||
import com.alttd.objects.EconUser;
|
||||
import com.alttd.util.Logger;
|
||||
import com.alttd.util.SaveTask;
|
||||
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;
|
||||
|
||||
public class VillagerUI extends JavaPlugin {
|
||||
|
||||
|
|
@ -69,22 +69,8 @@ public class VillagerUI extends JavaPlugin {
|
|||
}
|
||||
|
||||
private void scheduleTasks() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Config.DEBUG)
|
||||
Logger.info("Syncing users.");
|
||||
EconUser.getEconUsers().forEach(econUser -> {
|
||||
if (econUser == null)
|
||||
return;
|
||||
if (Config.DEBUG)
|
||||
Logger.info("Syncing %", econUser.getUuid().toString());
|
||||
econUser.removePoints();
|
||||
econUser.syncPoints();
|
||||
});
|
||||
}
|
||||
}.runTaskTimerAsynchronously(getInstance(), 0L, 10 * 60 * 20L);
|
||||
logInOut.runTaskTimerAsynchronously(this, 20 * 60 * 5, 20 * 60 * 10);
|
||||
new SaveTask().runTaskTimerAsynchronously(getInstance(), 0L, Config.SAVE_TIME * 60 * 20L);
|
||||
logInOut.runTaskTimerAsynchronously(this, 20 * 60 * 5, Config.LOG_TIME * 60 * 20L);
|
||||
}
|
||||
|
||||
private void registerEvents() {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import java.io.File;
|
|||
import java.util.*;
|
||||
|
||||
public final class Config extends AbstractConfig {
|
||||
|
||||
static Config config;
|
||||
static int version;
|
||||
public Config() {
|
||||
|
|
@ -43,6 +42,13 @@ public final class Config extends AbstractConfig {
|
|||
PASSWORD = config.getString("database.password", PASSWORD);
|
||||
}
|
||||
|
||||
public static int SAVE_TIME = 10;
|
||||
public static int LOG_TIME = 10;
|
||||
private static void loadTaskSettings() {
|
||||
SAVE_TIME = config.getInt("tasks.save-time", SAVE_TIME);
|
||||
LOG_TIME = config.getInt("tasks.log-time", LOG_TIME);
|
||||
}
|
||||
|
||||
public static String INITIAL_VILLAGER_WINDOW = "<trader> points: <points>";
|
||||
public static String BUY_WINDOW = "<trader> points: <points>";
|
||||
public static String SELL_WINDOW = "<trader> points: <points>";
|
||||
|
|
@ -119,6 +125,7 @@ public final class Config extends AbstractConfig {
|
|||
public static String NOT_A_VILLAGER = "<red><villager_type> is not a valid villager type.</red>";
|
||||
public static String LOADING_ECON_DATA = "<red>Loading your economy data, please wait...</red>";
|
||||
public static String NO_VILLAGER_POINTS = "<red>You don't have any villager points.</red>";
|
||||
public static String NOTIFY_POINTS_RESET = "<green>Your points for <villager_type> reset to 0!</green>";
|
||||
|
||||
private static void loadMessages() {
|
||||
NOT_ENOUGH_MONEY = config.getString("messages.not-enough-money", NOT_ENOUGH_MONEY);
|
||||
|
|
@ -136,6 +143,7 @@ public final class Config extends AbstractConfig {
|
|||
NOT_A_VILLAGER = config.getString("messages.not-a-villager", NOT_A_VILLAGER);
|
||||
LOADING_ECON_DATA = config.getString("messages.loading-econ-data", LOADING_ECON_DATA);
|
||||
NO_VILLAGER_POINTS = config.getString("messages.no-villager-points", NO_VILLAGER_POINTS);
|
||||
NOTIFY_POINTS_RESET = config.getString("messages.notify-points-reset", NOTIFY_POINTS_RESET);
|
||||
}
|
||||
|
||||
public static boolean DEBUG = false;
|
||||
|
|
|
|||
21
src/main/java/com/alttd/util/SaveTask.java
Normal file
21
src/main/java/com/alttd/util/SaveTask.java
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package com.alttd.util;
|
||||
|
||||
import com.alttd.config.Config;
|
||||
import com.alttd.objects.EconUser;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class SaveTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Config.DEBUG)
|
||||
Logger.info("Syncing users.");
|
||||
EconUser.getEconUsers().forEach(econUser -> {
|
||||
if (econUser == null)
|
||||
return;
|
||||
if (Config.DEBUG)
|
||||
Logger.info("Syncing %", econUser.getUuid().toString());
|
||||
econUser.removePoints();
|
||||
econUser.syncPoints();
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user