50 lines
1.7 KiB
Dart
50 lines
1.7 KiB
Dart
import 'package:libac_flutter/nbt/NbtUtils.dart';
|
|
import 'package:libac_flutter/nbt/impl/CompoundTag.dart';
|
|
import 'package:libac_flutter/nbt/impl/StringTag.dart';
|
|
import 'package:servermanager/structs/autorestarts.dart';
|
|
import 'package:servermanager/structs/credentials.dart';
|
|
import 'package:servermanager/structs/mod.dart';
|
|
import 'package:servermanager/structs/serversettings.dart';
|
|
|
|
class SettingsEntry {
|
|
List<Mod> mods = [];
|
|
Credentials? steam_creds;
|
|
AutomaticRestartInfo timer = AutomaticRestartInfo();
|
|
ServerSettings serverSettings = ServerSettings(
|
|
RconPassword: "Password01234",
|
|
RconPort: 7779,
|
|
GamePort: 7780,
|
|
QueryPort: 7782);
|
|
|
|
bool downloadMods = true;
|
|
String conanExilesLibraryPath = "";
|
|
|
|
static SettingsEntry deserialize(CompoundTag tag) {
|
|
SettingsEntry st = SettingsEntry();
|
|
|
|
if (tag.containsKey(Credentials.TAG_NAME))
|
|
st.steam_creds =
|
|
Credentials.deserialize(tag.get(Credentials.TAG_NAME) as CompoundTag);
|
|
st.timer = AutomaticRestartInfo.deserialize(
|
|
tag.get(AutomaticRestartInfo.TAG_NAME) as CompoundTag);
|
|
st.serverSettings = ServerSettings.deserialize(
|
|
tag.get(ServerSettings.TAG_NAME) as CompoundTag);
|
|
|
|
st.downloadMods = NbtUtils.readBoolean(tag, "download");
|
|
st.conanExilesLibraryPath = tag.get("libpath")?.asString() ?? "";
|
|
|
|
return st;
|
|
}
|
|
|
|
CompoundTag serialize() {
|
|
CompoundTag tag = CompoundTag();
|
|
if (steam_creds != null) tag.put(Credentials.TAG_NAME, steam_creds!.save());
|
|
tag.put(AutomaticRestartInfo.TAG_NAME, timer.serialize());
|
|
tag.put(ServerSettings.TAG_NAME, serverSettings.serialize());
|
|
NbtUtils.writeBoolean(tag, "download", downloadMods);
|
|
|
|
tag.put("libpath", StringTag.valueOf(conanExilesLibraryPath));
|
|
|
|
return tag;
|
|
}
|
|
}
|