improve config backups
All checks were successful
/ Build BaseBand DSM & Broadway (push) Successful in 2m11s
All checks were successful
/ Build BaseBand DSM & Broadway (push) Successful in 2m11s
This commit is contained in:
parent
666d4fc03e
commit
484117aaf5
2 changed files with 13 additions and 7 deletions
|
@ -7,10 +7,7 @@ import de.com.baseband.client.feature.Feature;
|
||||||
import de.com.baseband.client.feature.category.ClientCategory;
|
import de.com.baseband.client.feature.category.ClientCategory;
|
||||||
import de.com.baseband.client.gui.GuiTheme;
|
import de.com.baseband.client.gui.GuiTheme;
|
||||||
import de.com.baseband.client.registry.Configuration;
|
import de.com.baseband.client.registry.Configuration;
|
||||||
import de.com.baseband.client.registry.annotation.Config;
|
import de.com.baseband.client.registry.annotation.*;
|
||||||
import de.com.baseband.client.registry.annotation.Description;
|
|
||||||
import de.com.baseband.client.registry.annotation.KeyBound;
|
|
||||||
import de.com.baseband.client.registry.annotation.Trigger;
|
|
||||||
import de.com.baseband.client.util.interact.Chat;
|
import de.com.baseband.client.util.interact.Chat;
|
||||||
import de.com.baseband.client.util.interact.RotationManager;
|
import de.com.baseband.client.util.interact.RotationManager;
|
||||||
import de.com.baseband.client.util.interact.ServerDataManager;
|
import de.com.baseband.client.util.interact.ServerDataManager;
|
||||||
|
@ -60,15 +57,23 @@ public class Client extends Feature {
|
||||||
@Config("Theme")
|
@Config("Theme")
|
||||||
public GuiTheme.Theme theme = GuiTheme.Theme.TTC;
|
public GuiTheme.Theme theme = GuiTheme.Theme.TTC;
|
||||||
|
|
||||||
|
private static final String C_CONFIG = "Config";
|
||||||
|
|
||||||
|
@Section(C_CONFIG)
|
||||||
@Trigger("Save config")
|
@Trigger("Save config")
|
||||||
public void saveConfig() {
|
public void saveConfig() {
|
||||||
Configuration.save();
|
Configuration.save();
|
||||||
BaseBand.notify("Config saved to disk");
|
BaseBand.notify("Config saved to disk");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Section(C_CONFIG)
|
||||||
|
@Config("Backup file")
|
||||||
|
public String backupFile = "baseband.db.bak";
|
||||||
|
|
||||||
|
@Section(C_CONFIG)
|
||||||
@Trigger("Save backup")
|
@Trigger("Save backup")
|
||||||
public void saveBackup() {
|
public void saveBackup() {
|
||||||
try(FileOutputStream stream = new FileOutputStream("baseband.db.bak")) {
|
try(FileOutputStream stream = new FileOutputStream(backupFile)) {
|
||||||
stream.write(JSON.writeReadable(Configuration.asTCN()).getBytes());
|
stream.write(JSON.writeReadable(Configuration.asTCN()).getBytes());
|
||||||
BaseBand.notify("§aCreated backup of config");
|
BaseBand.notify("§aCreated backup of config");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -77,9 +82,10 @@ public class Client extends Feature {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Section(C_CONFIG)
|
||||||
@Trigger("Load backup")
|
@Trigger("Load backup")
|
||||||
public void loadBackup() {
|
public void loadBackup() {
|
||||||
try(FileInputStream stream = new FileInputStream("baseband.db.bak")) {
|
try(FileInputStream stream = new FileInputStream(backupFile)) {
|
||||||
String s = new StreamReader(stream).readAllAsString();
|
String s = new StreamReader(stream).readAllAsString();
|
||||||
Configuration.cloneConfigFrom(JSON.read(s));
|
Configuration.cloneConfigFrom(JSON.read(s));
|
||||||
BaseBand.notify("§aLoaded backup of config");
|
BaseBand.notify("§aLoaded backup of config");
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class HUD extends Feature {
|
||||||
BottomRight,
|
BottomRight,
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String C_INFO = "Information", C_NOTIF = "Notifications";
|
private static final String C_INFO = "Information", C_NOTIF = "Notifications";
|
||||||
|
|
||||||
@Config("Include status in length")
|
@Config("Include status in length")
|
||||||
@Description("By default, status (greyed out information tucked on the end of module names) is not factored into the sorting. This setting lets you change that.")
|
@Description("By default, status (greyed out information tucked on the end of module names) is not factored into the sorting. This setting lets you change that.")
|
||||||
|
|
Loading…
Add table
Reference in a new issue