Start to update stuff
This commit is contained in:
parent
110b2d150c
commit
399d884681
18 changed files with 217 additions and 240 deletions
|
@ -1,23 +1,12 @@
|
|||
import 'dart:ffi';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:libac_flutter/nbt/impl/CompoundTag.dart';
|
||||
import 'package:libac_flutter/nbt/impl/IntTag.dart';
|
||||
import 'package:libac_flutter/nbt/impl/StringTag.dart';
|
||||
|
||||
part 'serversettings.g.dart';
|
||||
|
||||
@HiveType(typeId: 5)
|
||||
class ServerSettings {
|
||||
@HiveField(0, defaultValue: "Password01234")
|
||||
final String RconPassword;
|
||||
|
||||
@HiveField(1, defaultValue: 7779)
|
||||
final int RconPort;
|
||||
|
||||
@HiveField(2, defaultValue: 7780)
|
||||
final int GamePort;
|
||||
|
||||
@HiveField(3, defaultValue: 7782)
|
||||
final int QueryPort;
|
||||
|
||||
const ServerSettings(
|
||||
|
@ -25,6 +14,30 @@ class ServerSettings {
|
|||
required this.RconPort,
|
||||
required this.GamePort,
|
||||
required this.QueryPort});
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
class ServerSettingsPage extends StatefulWidget {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue