Start to update stuff

This commit is contained in:
zontreck 2024-05-22 16:09:36 -07:00
parent 110b2d150c
commit 399d884681
18 changed files with 217 additions and 240 deletions

View file

@ -1,37 +1,50 @@
import 'package:hive/hive.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/autorestart.dart';
import 'package:servermanager/credentials.dart';
import 'package:servermanager/mod.dart';
import 'package:servermanager/serversettings.dart';
part 'settingsEntry.g.dart';
@HiveType(typeId: 0)
class SettingsEntry {
@HiveField(0, defaultValue: [])
List<Mod> mods = [];
@HiveField(3)
Credentials? steam_creds;
@HiveField(4, defaultValue: AutomaticRestartInfo())
AutomaticRestartInfo timer = AutomaticRestartInfo();
@HiveField(5,
defaultValue: ServerSettings(
RconPassword: "Password01234",
RconPort: 7779,
GamePort: 7780,
QueryPort: 7782))
ServerSettings serverSettings = ServerSettings(
RconPassword: "Password01234",
RconPort: 7779,
GamePort: 7780,
QueryPort: 7782);
@HiveField(6, defaultValue: true)
bool downloadMods = true;
@HiveField(7, defaultValue: "")
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;
}
}