From 55411cfe14542a58e2268ddabdc926a7ab8b967f Mon Sep 17 00:00:00 2001 From: Matthew Cech Date: Sun, 5 May 2019 16:34:32 -0700 Subject: [PATCH] = Fixed 'send immediate' --- locStrings.config | 4 +++- src/commands/CommandShutdown.java | 9 +++++++-- src/dataStructures/Response.java | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/locStrings.config b/locStrings.config index f68b2d6..c077078 100644 --- a/locStrings.config +++ b/locStrings.config @@ -86,6 +86,8 @@ PollVoteNotValidVote=%s That's not a vaild vote! PollVoteSuccess=You successfully voted for [CommandShutdown] +ShutdownSafe=Shutting down, but first syncing database and finishing current threads. +ShutdownUnsafe=Shutting down and immediately and abandoning all threads without sync. ShutdownInfo=Stops kitty. `-s` or `safe` as an argument attempts to sync off the database before shutdown. [CommandTeey] @@ -218,4 +220,4 @@ MapVersion=Using mapgen v0.1 MapWidth=Width MapHeight=Height - + diff --git a/src/commands/CommandShutdown.java b/src/commands/CommandShutdown.java index 812aed5..6a28ef4 100644 --- a/src/commands/CommandShutdown.java +++ b/src/commands/CommandShutdown.java @@ -41,16 +41,21 @@ public class CommandShutdown extends Command break; } + + if(isSafe) { // Force upkeep, this works so long as upkeep is on the main thread. + res.CallImmediate(LocStrings.Stub("ShutdownSafe")); DatabaseManager.instance.Upkeep(); - GlobalLog.Error(LogFilter.Command, "Forced shutdown, database synced before abandoning threads."); + GlobalLog.Warn(LogFilter.Command, LocStrings.Lookup("ShutdownSafe")); + System.exit(0); } else { - GlobalLog.Error(LogFilter.Command, "Forced immediate shutdown, threads abandoned without sync."); + res.CallImmediate(LocStrings.Stub("ShutdownUnsafe"));// "`Shutting down and immediately and abandoning all threads without sync.`"); + GlobalLog.Warn(LogFilter.Command, LocStrings.Lookup("ShutdownSafe")); System.exit(0); } } diff --git a/src/dataStructures/Response.java b/src/dataStructures/Response.java index f25ba36..b1cbd7d 100644 --- a/src/dataStructures/Response.java +++ b/src/dataStructures/Response.java @@ -61,7 +61,7 @@ public class Response } else { - event.getChannel().sendMessage(toRespondWith); + event.getChannel().sendMessage(toRespondWith).complete(); } }