vote_mute #2
|
|
@ -28,8 +28,10 @@ public class ChatLogHandler {
|
||||||
private final HashMap<UUID, List<ChatLog>> chatLogs = new HashMap<>();
|
private final HashMap<UUID, List<ChatLog>> chatLogs = new HashMap<>();
|
||||||
|
|
||||||
public ChatLogHandler(boolean enableLogging) {
|
public ChatLogHandler(boolean enableLogging) {
|
||||||
if (!enableLogging)
|
if (!enableLogging) {
|
||||||
|
ALogger.info("Logging is not enabled on this server.");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
Duration deleteThreshold = Duration.ofDays(Config.CHAT_LOG_DELETE_OLDER_THAN_DAYS);
|
Duration deleteThreshold = Duration.ofDays(Config.CHAT_LOG_DELETE_OLDER_THAN_DAYS);
|
||||||
ChatLogQueries.deleteOldMessages(deleteThreshold).thenAccept(success -> {
|
ChatLogQueries.deleteOldMessages(deleteThreshold).thenAccept(success -> {
|
||||||
if (success) {
|
if (success) {
|
||||||
|
|
@ -41,6 +43,7 @@ public class ChatLogHandler {
|
||||||
executorService = Executors.newSingleThreadScheduledExecutor();
|
executorService = Executors.newSingleThreadScheduledExecutor();
|
||||||
executorService.scheduleAtFixedRate(() -> saveToDatabase(false),
|
executorService.scheduleAtFixedRate(() -> saveToDatabase(false),
|
||||||
Config.CHAT_LOG_SAVE_DELAY_MINUTES, Config.CHAT_LOG_SAVE_DELAY_MINUTES, TimeUnit.MINUTES);
|
Config.CHAT_LOG_SAVE_DELAY_MINUTES, Config.CHAT_LOG_SAVE_DELAY_MINUTES, TimeUnit.MINUTES);
|
||||||
|
ALogger.info("Logging started!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -78,6 +81,8 @@ public class ChatLogHandler {
|
||||||
booleanCompletableFuture.whenComplete((result, throwable) -> {
|
booleanCompletableFuture.whenComplete((result, throwable) -> {
|
||||||
if (throwable == null && result) {
|
if (throwable == null && result) {
|
||||||
chatLogs.clear();
|
chatLogs.clear();
|
||||||
|
} else {
|
||||||
|
ALogger.error("Failed to save chat messages.");
|
||||||
}
|
}
|
||||||
savingToDatabase(false);
|
savingToDatabase(false);
|
||||||
while (!chatLogQueue.isEmpty()) {
|
while (!chatLogQueue.isEmpty()) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user