diff --git a/lib/statemachine.dart b/lib/statemachine.dart index edb6d85..11dd7e8 100644 --- a/lib/statemachine.dart +++ b/lib/statemachine.dart @@ -33,7 +33,7 @@ enum WarnIntervals { warning: "The server has 10 seconds until restart"), TWENTY_SECONDS( seconds: 20, - type: WarnType.Intrusive, + type: WarnType.NonIntrusive, warning: "The server is about to go down in 20 seconds"), THIRTY_SECONDS( seconds: 30, @@ -41,7 +41,7 @@ enum WarnIntervals { warning: "The server will restart in 30 seconds"), ONE_MINUTE( seconds: 60, - type: WarnType.NonIntrusive, + type: WarnType.Intrusive, warning: "The server will restart in 1 minute"), FIVE_MIN( seconds: (5 * 60), @@ -247,7 +247,9 @@ class StateMachine { WarnIntervals current = SessionData.CURRENT_INTERVAL; bool send = false; for (WarnIntervals WI in WarnIntervals.values) { - if (WI.seconds <= sec && WI.seconds <= current.seconds) { + if (WI == WarnIntervals.NONE) continue; + + if (WI.seconds >= sec && WI.seconds <= current.seconds) { current = WI; send = true; @@ -277,6 +279,10 @@ class StateMachine { if (current.type == WarnType.Intrusive) { print("Sending alert '${current.warning}'"); settings.sendRconCommand("broadcast ${current.warning}"); + } else if (current.type == WarnType.NonIntrusive) { + print("Sending chat message '${current.warning}'"); + settings.sendRconCommand( + "ast chat \"global\" \"${current.warning}\""); } } diff --git a/lib/wine.dart b/lib/wine.dart index 2c84124..20a35e1 100644 --- a/lib/wine.dart +++ b/lib/wine.dart @@ -1,4 +1,3 @@ -import 'dart:convert'; import 'dart:io'; import 'package:libac_dart/utils/IOTools.dart'; @@ -88,14 +87,10 @@ Future runDetachedWine( workingDirectory: workingDir, mode: ProcessStartMode.detachedWithStdio); - StateMachine.PROC!.stdout - .transform(utf8.decoder) - .transform(LineSplitter()) - .forEach((line) {}); - StateMachine.PROC!.stderr - .transform(utf8.decoder) - .transform(LineSplitter()) - .forEach((line) {}); + try { + StateMachine.PROC!.stdout.forEach((line) {}); + StateMachine.PROC!.stderr.forEach((line) {}); + } catch (E) {} StateMachine.monitorProcess(); } catch (e) { diff --git a/pubspec.yaml b/pubspec.yaml index 127bc8c..dbc8498 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -40,7 +40,7 @@ dependencies: crypto: libac_dart: hosted: https://git.zontreck.com/api/packages/AriasCreations/pub/ - version: 1.0.30 + version: 1.0.33 dev_dependencies: flutter_test: