Administrator's Toolkit VS plugin
Revisión | 42bea37764f1ce9e875fe81362abeea72ee21e09 (tree) |
---|---|
Tiempo | 2022-01-31 13:30:53 |
Autor | melchior <melchior@user...> |
Commiter | melchior |
Update for VS, Plus backup announcer
Updated references for VS1.16.0, Global backup announcer
@@ -20,7 +20,7 @@ | ||
20 | 20 | <ConsolePause>false</ConsolePause> |
21 | 21 | <CustomCommands> |
22 | 22 | <CustomCommands> |
23 | - <Command type="AfterBuild" command="7z -tzip a AdminMod_${ProjectConfig}.zip" workingdir="${TargetDir}" /> | |
23 | + <Command type="AfterBuild" command="7z a -tzip -x!*.zip -aoa ${ProjectName}_${ProjectConfig}.zip" workingdir="${TargetDir}" /> | |
24 | 24 | <Command type="BeforeClean" command="rm -f *.zip" workingdir="${TargetDir}" /> |
25 | 25 | </CustomCommands> |
26 | 26 | </CustomCommands> |
@@ -33,7 +33,7 @@ | ||
33 | 33 | <ConsolePause>false</ConsolePause> |
34 | 34 | <CustomCommands> |
35 | 35 | <CustomCommands> |
36 | - <Command type="AfterBuild" command="7z -tzip a AdminMod_${ProjectConfig}.zip" workingdir="${TargetDir}" /> | |
36 | + <Command type="AfterBuild" command="7z a -tzip -x!*.zip -aoa ${ProjectName}_${ProjectConfig}.zip" workingdir="${TargetDir}" /> | |
37 | 37 | <Command type="BeforeClean" command="rm -f *.zip" workingdir="${TargetDir}" /> |
38 | 38 | </CustomCommands> |
39 | 39 | </CustomCommands> |
@@ -17,10 +17,9 @@ namespace AdminToolkit | ||
17 | 17 | private long backupTickerID; |
18 | 18 | private const string _timeFormat = @"d\D\ hh\H\ mm\M\ ss\S"; |
19 | 19 | |
20 | - | |
21 | 20 | private DateTimeOffset _lastBackupTime = DateTimeOffset.MinValue; |
22 | - | |
23 | 21 | private string fileFilter; |
22 | + private FileSystemWatcher backupDirMonitor; | |
24 | 23 | |
25 | 24 | public BackupCycleCommand(ICoreServerAPI _serverAPI) : base(_serverAPI) |
26 | 25 | { |
@@ -31,7 +30,6 @@ namespace AdminToolkit | ||
31 | 30 | this.Syntax = "enable / disable / delay [hours] / stats"; |
32 | 31 | |
33 | 32 | |
34 | - | |
35 | 33 | ServerAPI.Event.ServerRunPhase(EnumServerRunPhase.RunGame, ServerStarts); |
36 | 34 | } |
37 | 35 |
@@ -148,7 +146,7 @@ namespace AdminToolkit | ||
148 | 146 | |
149 | 147 | |
150 | 148 | private void BackupCycleHandler(float elapsed) |
151 | - { | |
149 | + { | |
152 | 150 | Logger.Event("Backup cycle triggered, elasped {0} @{1} Uptime", elapsed, ServerAPI.Server.ServerUptimeSeconds); |
153 | 151 | //Peek at backup DIR, count files of the backup type |
154 | 152 | var backupDir = new DirectoryInfo(GamePaths.Backups); |
@@ -177,12 +175,6 @@ namespace AdminToolkit | ||
177 | 175 | |
178 | 176 | this.backupTickerID = ServerAPI.Event.RegisterCallback(BackupCycleHandler, ( int )this.CachedConfiguration.BackupDelay.TotalMilliseconds); |
179 | 177 | Logger.Notification("BackupCycle re-engaged, delay: {0} next time: {1}", this.CachedConfiguration.BackupDelay.ToString(_timeFormat), DateTimeOffset.UtcNow.Add(this.CachedConfiguration.BackupDelay).ToString("u")); |
180 | - | |
181 | - //GlobalConstants.ConsoleGroup | |
182 | - /* | |
183 | - backupFileName = Path.GetFileName(server.Config.WorldConfig.SaveFileLocation).Replace(GlobalConstants.WorldSaveExtension, "") + "-" + string.Format("{0:yyyy-MM-dd_HH-mm-ss}", DateTime.Now) + GlobalConstants.WorldSaveExtension; | |
184 | - */ | |
185 | - | |
186 | 178 | } |
187 | 179 | |
188 | 180 | private void AlterTimeDelay(int delay) |
@@ -281,10 +273,21 @@ namespace AdminToolkit | ||
281 | 273 | |
282 | 274 | fileFilter = $"{worldNameTrimmed}-*{GlobalConstants.WorldSaveExtension}"; |
283 | 275 | Logger.VerboseDebug("File Filter: {0}", fileFilter); |
276 | + backupDirMonitor = new FileSystemWatcher(GamePaths.Backups, fileFilter); | |
277 | + backupDirMonitor.Created += BackupFileCreation; | |
278 | + backupDirMonitor.IncludeSubdirectories = false; | |
279 | + backupDirMonitor.EnableRaisingEvents = true; | |
284 | 280 | |
285 | 281 | if (CachedConfiguration.Autobackup) { ToggleBackupCycle(true); } |
286 | 282 | } |
287 | - } | |
283 | + | |
284 | + private void BackupFileCreation(object sender, FileSystemEventArgs e) | |
285 | + { | |
286 | + if (ServerAPI.Server.CurrentRunPhase == EnumServerRunPhase.RunGame) { | |
287 | + ServerAPI.BroadcastMessageToAllGroups($"Backup procceeds concurrently... '{e.Name}'", EnumChatType.Notification); | |
288 | + } | |
289 | + } | |
290 | +} | |
288 | 291 | |
289 | 292 | |
290 | 293 | } |
@@ -2,11 +2,11 @@ | ||
2 | 2 | "type": "code", |
3 | 3 | "name": "Administrator's Toolkit mod", |
4 | 4 | "ModID":"atk", |
5 | - "description" : "Provides misc. Admin functions;\n admin listing, rules display (multi-lingual), auto-backup & much more.", | |
5 | + "description" : "Provides Admin functions;\n admin listing, rules display (multi-lingual), auto-backup & more.", | |
6 | 6 | "authors": ["Melchior", ], |
7 | - "version": "0.3.7", | |
7 | + "version": "0.3.8", | |
8 | 8 | "dependencies": { |
9 | - "game": "1.15.0-rc.3" | |
9 | + "game": "1.16.0" | |
10 | 10 | }, |
11 | 11 | "requiredonclient":false, |
12 | 12 | "website": "https://osdn.net/users/melchior/pf/admintoolkit/" |