Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ private static void registerLtrynekCommand(
"profile", activeProfile
));
ctx.getSource().sendFeedback(ColorUtils.translateColorCodes(msg));

// Auto-save config after adding item
autoSaveConfig();
} catch (NumberFormatException e) {
ctx.getSource().sendError(Text.literal("Invalid price format: " + maxPriceStr));
}
Expand All @@ -137,6 +140,9 @@ private static void registerLtrynekCommand(
"profile", activeProfile
));
ctx.getSource().sendFeedback(ColorUtils.translateColorCodes(msg));

// Auto-save config after removing item
autoSaveConfig();
return 1;
})
)
Expand Down Expand Up @@ -227,9 +233,7 @@ private static void registerLtrynekCommand(
.then(ClientCommandManager.literal("config")
.then(ClientCommandManager.literal("save")
.executes(ctx -> {
syncMemoryToConfig();

ConfigLoader.saveConfig(LtrynekClient.serversConfig);
autoSaveConfig();

String msg = Messages.get("command.config.save.success");
ctx.getSource().sendFeedback(ColorUtils.translateColorCodes(msg));
Expand Down Expand Up @@ -268,7 +272,11 @@ private static void syncMemoryToConfig() {

ServerEntry se = findServerEntryByProfile(profileName);
if (se == null) {
continue;
se = new ServerEntry();
se.profileName = profileName;
LtrynekClient.serversConfig.servers.add(se);
} else {
se.prices.clear();
}

for (Map.Entry<String, Double> itemEntry : items.entrySet()) {
Expand All @@ -283,6 +291,14 @@ private static void syncMemoryToConfig() {
}
}

/**
* Synchronizes and saves configuration to disk.
*/
private static void autoSaveConfig() {
syncMemoryToConfig();
ConfigLoader.saveConfig(LtrynekClient.serversConfig);
}

/**
* Czyści i na nowo inicjalizuje ClientPriceListManager z LtrynekClient.serversConfig.
*/
Expand Down