59 lines
1.9 KiB
Dart
59 lines
1.9 KiB
Dart
import 'package:libac_dart/nbt/NbtUtils.dart';
|
|
import 'package:libac_dart/nbt/Tag.dart';
|
|
import 'package:libac_dart/nbt/impl/CompoundTag.dart';
|
|
import 'package:libac_dart/nbt/impl/ListTag.dart';
|
|
import 'package:libac_dart/utils/TimeUtils.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;
|
|
bool pterodactylMode = true; // Default is to be compatible
|
|
AutomaticRestartInfo timer =
|
|
AutomaticRestartInfo(time: Time(hours: 0, minutes: 0, seconds: 0));
|
|
ServerSettings serverSettings = ServerSettings(
|
|
RconPassword: "Password01234",
|
|
RconPort: 7779,
|
|
GamePort: 7780,
|
|
QueryPort: 7782);
|
|
|
|
static SettingsEntry deserialize(CompoundTag tag) {
|
|
SettingsEntry st = SettingsEntry();
|
|
|
|
st.timer = AutomaticRestartInfo.deserialize(
|
|
tag.get(AutomaticRestartInfo.TAG_NAME) as CompoundTag);
|
|
st.serverSettings = ServerSettings.deserialize(
|
|
tag.get(ServerSettings.TAG_NAME) as CompoundTag);
|
|
|
|
if (tag.containsKey("pterodactyl")) {
|
|
st.pterodactylMode = NbtUtils.readBoolean(tag, "pterodactyl");
|
|
}
|
|
|
|
st.mods.clear();
|
|
ListTag lMods = tag.get("mods") as ListTag;
|
|
for (Tag tag in lMods.value) {
|
|
CompoundTag cTag = tag.asCompoundTag();
|
|
st.mods.add(Mod.deserialize(cTag));
|
|
}
|
|
|
|
return st;
|
|
}
|
|
|
|
CompoundTag serialize() {
|
|
CompoundTag tag = CompoundTag();
|
|
tag.put(AutomaticRestartInfo.TAG_NAME, timer.serialize());
|
|
tag.put(ServerSettings.TAG_NAME, serverSettings.serialize());
|
|
NbtUtils.writeBoolean(tag, "pterodactyl", pterodactylMode);
|
|
|
|
ListTag lMods = ListTag();
|
|
for (Mod mod in mods) {
|
|
lMods.add(mod.serialize());
|
|
}
|
|
tag.put("mods", lMods);
|
|
|
|
return tag;
|
|
}
|
|
}
|