Add in more implementation
This commit is contained in:
parent
fc0c1c7e7a
commit
1b2ec0e74d
14 changed files with 62 additions and 35 deletions
|
@ -35,7 +35,6 @@ void main() async {
|
||||||
|
|
||||||
print("Initializing SteamCMD");
|
print("Initializing SteamCMD");
|
||||||
await settings.initializeSteamCmd();
|
await settings.initializeSteamCmd();
|
||||||
await settings.initializeSteamCmd2FA();
|
|
||||||
print("Initialized Steamcmd and Proton");
|
print("Initialized Steamcmd and Proton");
|
||||||
|
|
||||||
print("Checking for game server updates...");
|
print("Checking for game server updates...");
|
||||||
|
@ -50,13 +49,20 @@ void main() async {
|
||||||
print(
|
print(
|
||||||
"Aborting server startup procedure, initial server setup is not yet complete\n\n[ You must log in with the ServerManager to continue ]");
|
"Aborting server startup procedure, initial server setup is not yet complete\n\n[ You must log in with the ServerManager to continue ]");
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
print("Downloading mods...");
|
print("Downloading mods...");
|
||||||
await doDownloadMods(false);
|
await doDownloadMods(false);
|
||||||
|
|
||||||
print("Scanning mods...");
|
print("Scanning mods...");
|
||||||
settings.inst!.mods = await doScanMods();
|
settings.inst!.mods = await doScanMods();
|
||||||
|
settings.Write();
|
||||||
|
|
||||||
|
print("Starting scheduler...");
|
||||||
await settings.subsys.startScheduler();
|
await settings.subsys.startScheduler();
|
||||||
|
} catch (E) {
|
||||||
|
settings.FTS = true;
|
||||||
|
settings.Write();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print("Starting up server manager server wrapper");
|
print("Starting up server manager server wrapper");
|
||||||
|
|
|
@ -13,7 +13,10 @@ class CredentialsPrompt extends State<CredentialsPage> {
|
||||||
bool initialInitDone = false;
|
bool initialInitDone = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
final args = ModalRoute.of(context)!.settings.arguments as Credentials?;
|
final args = ModalRoute.of(context)!.settings.arguments as Credentials?;
|
||||||
|
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:servermanager/packets/ClientPackets.dart';
|
import 'package:servermanager/packets/ClientPackets.dart';
|
||||||
import 'package:servermanager/pages/Constants.dart';
|
import 'package:servermanager/pages/Constants.dart';
|
||||||
|
import 'package:servermanager/structs/credentials.dart';
|
||||||
import 'package:servermanager/structs/settings.dart';
|
import 'package:servermanager/structs/settings.dart';
|
||||||
|
|
||||||
class HomePage extends StatefulWidget {
|
class HomePage extends StatefulWidget {
|
||||||
|
@ -93,9 +94,13 @@ class HomePageState extends State<HomePage> {
|
||||||
title: Text("Manager Credentials"),
|
title: Text("Manager Credentials"),
|
||||||
subtitle: Text("Edit ServerManager credentials"),
|
subtitle: Text("Edit ServerManager credentials"),
|
||||||
leading: Icon(Icons.key),
|
leading: Icon(Icons.key),
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
Navigator.pushNamed(context, "/creds",
|
var reply = await Navigator.pushNamed(context, "/creds",
|
||||||
arguments: settings.serverLoginCreds);
|
arguments: settings.serverLoginCreds);
|
||||||
|
if (reply != null) {
|
||||||
|
Credentials creds = reply as Credentials;
|
||||||
|
settings.serverLoginCreds = creds;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
|
|
|
@ -23,7 +23,8 @@ Future<void> runProton(String command, List<String> argx) async {
|
||||||
args.addAll(argx);
|
args.addAll(argx);
|
||||||
|
|
||||||
ProcessResult res = await Process.run(
|
ProcessResult res = await Process.run(
|
||||||
"proton", args, // Run arbitrary command with arguments
|
settings.getProtonExecutablePath(),
|
||||||
|
args, // Run arbitrary command with arguments
|
||||||
environment: env,
|
environment: env,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -54,10 +55,12 @@ Future<void> runDetachedProton(
|
||||||
List<String> args = ["run", command];
|
List<String> args = ["run", command];
|
||||||
args.addAll(argx);
|
args.addAll(argx);
|
||||||
|
|
||||||
StateMachine.PROC = await Process.start(
|
StateMachine.PROC = await Process.start(settings.getProtonExecutablePath(),
|
||||||
"proton", args, // Run arbitrary command with arguments
|
args, // Run arbitrary command with arguments
|
||||||
environment: env,
|
environment: env,
|
||||||
workingDirectory: workingDir);
|
workingDirectory: workingDir);
|
||||||
|
|
||||||
|
StateMachine.monitorProcess();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Error executing command: $e');
|
print('Error executing command: $e');
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,21 @@ enum WarnIntervals {
|
||||||
|
|
||||||
class StateMachine {
|
class StateMachine {
|
||||||
static Process? PROC;
|
static Process? PROC;
|
||||||
|
static Completer<void> DeadProcKillswitch = Completer();
|
||||||
|
|
||||||
|
void resetKillswitch() {
|
||||||
|
DeadProcKillswitch = Completer();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<void> monitorProcess() async {
|
||||||
|
try {
|
||||||
|
int code = await PROC!.exitCode;
|
||||||
|
DeadProcKillswitch.complete();
|
||||||
|
} catch (E) {
|
||||||
|
DeadProcKillswitch.complete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var _currentState = States.Inactive;
|
var _currentState = States.Inactive;
|
||||||
StreamController<States> _stateController = StreamController.broadcast();
|
StreamController<States> _stateController = StreamController.broadcast();
|
||||||
Stream<States> get stateChanges => _stateController.stream;
|
Stream<States> get stateChanges => _stateController.stream;
|
||||||
|
@ -99,6 +114,7 @@ class StateMachine {
|
||||||
await doDownloadMods(false);
|
await doDownloadMods(false);
|
||||||
|
|
||||||
settings.inst!.mods = await doScanMods();
|
settings.inst!.mods = await doScanMods();
|
||||||
|
settings.Write();
|
||||||
|
|
||||||
await settings.writeOutModListFile();
|
await settings.writeOutModListFile();
|
||||||
|
|
||||||
|
@ -153,6 +169,8 @@ class StateMachine {
|
||||||
SessionData.timer = settings.inst!.timer.time.copy();
|
SessionData.timer = settings.inst!.timer.time.copy();
|
||||||
changeState(States.PreStart);
|
changeState(States.PreStart);
|
||||||
|
|
||||||
|
resetKillswitch();
|
||||||
|
|
||||||
// Schedule the server task
|
// Schedule the server task
|
||||||
task = Timer.periodic(Duration(seconds: 1), (timer) {
|
task = Timer.periodic(Duration(seconds: 1), (timer) {
|
||||||
switch (currentState) {
|
switch (currentState) {
|
||||||
|
@ -201,6 +219,13 @@ class StateMachine {
|
||||||
if (SessionData.timer.getTotalSeconds() == 0) {
|
if (SessionData.timer.getTotalSeconds() == 0) {
|
||||||
SessionData.shutdownPending = true;
|
SessionData.shutdownPending = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check Dead Process
|
||||||
|
if (DeadProcKillswitch.isCompleted) {
|
||||||
|
// Switch state
|
||||||
|
changeState(States.FullStop); // This has the stop logic
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import 'package:libac_flutter/nbt/impl/CompoundTag.dart';
|
import 'package:libac_flutter/nbt/impl/CompoundTag.dart';
|
||||||
import 'package:libac_flutter/nbt/impl/IntTag.dart';
|
import 'package:libac_flutter/nbt/impl/LongTag.dart';
|
||||||
import 'package:libac_flutter/nbt/impl/StringTag.dart';
|
import 'package:libac_flutter/nbt/impl/StringTag.dart';
|
||||||
import 'package:libac_flutter/utils/uuid/UUID.dart';
|
import 'package:libac_flutter/utils/uuid/UUID.dart';
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class Mod {
|
||||||
CompoundTag serialize() {
|
CompoundTag serialize() {
|
||||||
CompoundTag tag = CompoundTag();
|
CompoundTag tag = CompoundTag();
|
||||||
tag.put("name", StringTag.valueOf(mod_name));
|
tag.put("name", StringTag.valueOf(mod_name));
|
||||||
tag.put("id", IntTag.valueOf(mod_id));
|
tag.put("id", LongTag.valueOf(mod_id));
|
||||||
tag.put("pak", StringTag.valueOf(mod_pak));
|
tag.put("pak", StringTag.valueOf(mod_pak));
|
||||||
tag.put("hash", StringTag.valueOf(mod_hash));
|
tag.put("hash", StringTag.valueOf(mod_hash));
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class Mod {
|
||||||
|
|
||||||
return Mod(
|
return Mod(
|
||||||
mod_name: ct.get("name")!.asString(),
|
mod_name: ct.get("name")!.asString(),
|
||||||
mod_id: ct.get("id")!.asInt(),
|
mod_id: ct.get("id")!.asLong(),
|
||||||
mod_pak: ct.get("pak")!.asString(),
|
mod_pak: ct.get("pak")!.asString(),
|
||||||
mod_hash: ct.get("hash")!.asString());
|
mod_hash: ct.get("hash")!.asString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import 'package:libac_flutter/packets/packets.dart';
|
||||||
import 'package:libac_flutter/utils/IOTools.dart';
|
import 'package:libac_flutter/utils/IOTools.dart';
|
||||||
import 'package:libac_flutter/utils/uuid/NbtUUID.dart';
|
import 'package:libac_flutter/utils/uuid/NbtUUID.dart';
|
||||||
import 'package:libac_flutter/utils/uuid/UUID.dart';
|
import 'package:libac_flutter/utils/uuid/UUID.dart';
|
||||||
import 'package:rcon/rcon.dart';
|
|
||||||
import 'package:servermanager/statemachine.dart';
|
import 'package:servermanager/statemachine.dart';
|
||||||
import 'package:servermanager/structs/credentials.dart';
|
import 'package:servermanager/structs/credentials.dart';
|
||||||
import 'package:servermanager/structs/mod.dart';
|
import 'package:servermanager/structs/mod.dart';
|
||||||
|
@ -274,11 +273,7 @@ class Settings {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> sendRconCommand(String command) async {
|
Future<String> sendRconCommand(String command) async {
|
||||||
Client cli =
|
createSocket("127.0.0.1", port: inst!.serverSettings.RconPort);
|
||||||
await Client.create("127.0.0.1", inst!.serverSettings.RconPort);
|
|
||||||
Message msg = Message.create(cli, PacketType.command, command);
|
|
||||||
|
|
||||||
return cli.send(msg).payload;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> initializeProton() async {
|
Future<void> initializeProton() async {
|
||||||
|
|
|
@ -6,10 +6,6 @@
|
||||||
|
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <file_selector_linux/file_selector_plugin.h>
|
|
||||||
|
|
||||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||||
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
|
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
|
|
||||||
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
file_selector_linux
|
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
import FlutterMacOS
|
import FlutterMacOS
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
import file_selector_macos
|
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,14 +35,13 @@ dependencies:
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^1.0.2
|
cupertino_icons: ^1.0.2
|
||||||
file_selector:
|
|
||||||
archive:
|
archive:
|
||||||
dio:
|
dio:
|
||||||
crypto:
|
crypto:
|
||||||
libac_flutter:
|
libac_flutter:
|
||||||
hosted: https://git.zontreck.com/api/packages/AriasCreations/pub/
|
hosted: https://git.zontreck.com/api/packages/AriasCreations/pub/
|
||||||
version: 1.0.20
|
version: 1.0.20
|
||||||
rcon: ^1.0.0
|
mc_rcon_dart: ^1.1.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
|
@ -8,6 +8,8 @@ void main() {
|
||||||
settings.server = false;
|
settings.server = false;
|
||||||
settings.inst = SettingsEntry();
|
settings.inst = SettingsEntry();
|
||||||
|
|
||||||
await settings.sendRconCommand("help");
|
var reply = await settings.sendRconCommand("help");
|
||||||
|
|
||||||
|
print(reply);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,6 @@
|
||||||
|
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <file_selector_windows/file_selector_windows.h>
|
|
||||||
|
|
||||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||||
FileSelectorWindowsRegisterWithRegistrar(
|
|
||||||
registry->GetRegistrarForPlugin("FileSelectorWindows"));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
file_selector_windows
|
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||||
|
|
Loading…
Reference in a new issue