45 lines
1.5 KiB
Dart
45 lines
1.5 KiB
Dart
import 'package:libac_dart/nbt/impl/CompoundTag.dart';
|
|
import 'package:libac_dart/nbt/impl/IntTag.dart';
|
|
import 'package:libac_dart/nbt/impl/StringTag.dart';
|
|
|
|
class ServerSettings {
|
|
final String RconPassword;
|
|
final int RconPort;
|
|
final int GamePort;
|
|
final int QueryPort;
|
|
final int WrapperPort;
|
|
|
|
const ServerSettings(
|
|
{required this.RconPassword,
|
|
required this.RconPort,
|
|
required this.GamePort,
|
|
required this.QueryPort,
|
|
required this.WrapperPort});
|
|
|
|
static ServerSettings deserialize(CompoundTag tag) {
|
|
return ServerSettings(
|
|
RconPassword: tag.get(TAG_PASSWORD)?.asString() ?? "",
|
|
RconPort: tag.get(TAG_RCON_PORT)?.asInt() ?? 25565,
|
|
GamePort: tag.get(TAG_GAME_PORT)?.asInt() ?? 0,
|
|
QueryPort: tag.get(TAG_QUERY_PORT)?.asInt() ?? 0,
|
|
WrapperPort: tag.get(TAG_WRAPPER_PORT)?.asInt() ?? 25306);
|
|
}
|
|
|
|
CompoundTag serialize() {
|
|
CompoundTag tag = CompoundTag();
|
|
tag.put(TAG_PASSWORD, StringTag.valueOf(RconPassword));
|
|
tag.put(TAG_RCON_PORT, IntTag.valueOf(RconPort));
|
|
tag.put(TAG_GAME_PORT, IntTag.valueOf(GamePort));
|
|
tag.put(TAG_QUERY_PORT, IntTag.valueOf(QueryPort));
|
|
tag.put(TAG_WRAPPER_PORT, IntTag.valueOf(WrapperPort));
|
|
|
|
return tag;
|
|
}
|
|
|
|
static const TAG_NAME = "serverSettings";
|
|
static const TAG_PASSWORD = "password";
|
|
static const TAG_RCON_PORT = "rcon";
|
|
static const TAG_GAME_PORT = "game";
|
|
static const TAG_QUERY_PORT = "query";
|
|
static const TAG_WRAPPER_PORT = "wrapper";
|
|
}
|