Added Config option to enable/disable global announcement of backup starting and finishing

This commit is contained in:
Szum123321 2021-11-27 19:56:11 +01:00
parent 3bf91ea915
commit eb6f4fdb10
4 changed files with 33 additions and 9 deletions

View File

@ -141,6 +141,16 @@ public class ConfigPOJO implements ConfigData {
@ConfigEntry.Category("Manage")
public List<String> playerBlacklist = new ArrayList<>();
@Comment("\nAnnounce to ALL players when backup starts\n")
@ConfigEntry.Gui.NoTooltip()
@ConfigEntry.Category("Manage")
public boolean broadcastBackupStart = true;
@Comment("\nAnnounce to ALL players when backup finishes\n")
@ConfigEntry.Gui.NoTooltip()
@ConfigEntry.Category("Manage")
public boolean broadcastBackupDone = true;
@Comment("""
\nFormat of date&time used to name backup files.
Remember not to use '#' symbol or any other character that is not allowed by your operating system such as:

View File

@ -37,10 +37,14 @@ public class BackupHelper {
private final static ConfigHelper config = ConfigHelper.INSTANCE;
public static Runnable create(BackupContext ctx) {
if(config.get().broadcastBackupStart) {
Utilities.notifyPlayers(ctx.getServer(),
ctx.getInitiatorUUID(),
"Warning! Server backup will begin shortly. You may experience some lag."
);
} else {
log.sendInfoAL(ctx, "Warning! Server backup will begin shortly. You may experience some lag.");
}
StringBuilder builder = new StringBuilder();

View File

@ -51,6 +51,8 @@ public class MakeBackupRunnable implements Runnable {
Utilities.disableWorldSaving(context.getServer());
Statics.disableWatchdog = true;
Utilities.updateTMPFSFlag(context.getServer());
log.sendInfoAL(context, "Starting backup");
File world = Utilities.getWorldFolder(context.getServer());
@ -113,11 +115,15 @@ public class MakeBackupRunnable implements Runnable {
BackupHelper.executeFileLimit(context.getCommandSource(), Utilities.getLevelName(context.getServer()));
if(config.get().broadcastBackupDone) {
Utilities.notifyPlayers(
context.getServer(),
context.getInitiatorUUID(),
"Done!"
);
} else {
log.sendInfoAL(context, "Done!");
}
} finally {
Utilities.enableWorldSaving(context.getServer());
Statics.disableWatchdog = false;

View File

@ -12,6 +12,10 @@
"text.autoconfig.textile_backup.option.restoreDelay": "Restore Delay",
"text.autoconfig.textile_backup.option.restoreDelay.@Tooltip": "In seconds",
"text.autoconfig.textile_backup.option.broadcastBackupStart": "Announce backup start",
"text.autoconfig.textile_backup.option.broadcastBackupDone": "Announce backup done",
"text.autoconfig.textile_backup.option.doBackupsOnEmptyServer": "Make automatic backups on empty server",
"text.autoconfig.textile_backup.option.shutdownBackup": "Make a backup on shutdown",