From 5b4da9c4f1311677500d812c92efe7e0bfd30b9f Mon Sep 17 00:00:00 2001 From: Bixilon Date: Tue, 23 May 2023 20:48:43 +0200 Subject: [PATCH] profiles: print message on profile save --- .../de/bixilon/minosoft/config/profile/ProfileManager.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/bixilon/minosoft/config/profile/ProfileManager.kt b/src/main/java/de/bixilon/minosoft/config/profile/ProfileManager.kt index 10cfd7d35..0f6a58e38 100644 --- a/src/main/java/de/bixilon/minosoft/config/profile/ProfileManager.kt +++ b/src/main/java/de/bixilon/minosoft/config/profile/ProfileManager.kt @@ -181,6 +181,7 @@ interface ProfileManager { profile.ignoreReloads.incrementAndGet() FileUtil.safeSaveToFile(file, jsonString) profile.saved = true + Log.log(LogMessageType.PROFILES, LogLevels.VERBOSE) { "Saved profile ${profile.name} ($namespace)" } } catch (exception: Exception) { exception.printStackTrace() exception.crash() @@ -257,13 +258,14 @@ interface ProfileManager { } fun watchProfile(profileName: String, path: File = getPath(profileName).toFile()) { - FileWatcherService.register(FileWatcher(path.toPath(), arrayOf(StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_CREATE)) { _, it -> + FileWatcherService.register(FileWatcher(path.toPath(), arrayOf(StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_CREATE)) { a, _ -> val profile = profiles[profileName] ?: return@FileWatcher if (profile.ignoreReloads.get() > 0) { profile.ignoreReloads.decrementAndGet() return@FileWatcher } try { + profile.reloading = true val data = readAndMigrate(path.toPath()).second updateValue(profile, data) } catch (exception: Exception) { @@ -272,7 +274,7 @@ interface ProfileManager { } finally { profile.reloading = false } - Log.log(LogMessageType.PROFILES, LogLevels.INFO) { "Reloaded profile: $profileName ($it)" } + Log.log(LogMessageType.PROFILES, LogLevels.INFO) { "Reloaded profile: $profileName ($namespace);" } }) }