Skip to content

Commit

Permalink
Fixes server list not working
Browse files Browse the repository at this point in the history
Fixes server list not working
  • Loading branch information
Alvarocda authored Dec 9, 2023
2 parents 486f89e + 8312890 commit ffde2cc
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 97 deletions.
1 change: 0 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ linter:
avoid_type_to_string: true
cancel_subscriptions: true
close_sinks: true
invariant_booleans: true # experimental
literal_only_boolean_expressions: true
no_adjacent_strings_in_list: true
test_types_in_equals: true
Expand Down
17 changes: 12 additions & 5 deletions lib/models/server_properties.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ServerProperties {
late String gamename;
late String hostname;
late String gamever;
late String serverVersion;
late String? serverVersion;
late String gamevariant;
late int numplayers;
late int maxplayers;
Expand Down Expand Up @@ -44,10 +44,17 @@ class ServerProperties {
reservedSlots = int.parse(json['bf2_reservedslots']);
map = MapDetail.fromJson(json);

// Get the server version from hostname
serverVersion = hostname.substring(4, hostname.indexOf(']'));
// Remove the version from hostname
hostname = hostname.substring(hostname.indexOf(']') + 1);


if(hostname.startsWith('[') && hostname.contains(']')){
// Get the server version from hostname
serverVersion = hostname.substring(4, hostname.indexOf(']'));
// Remove the version from hostname
hostname = hostname.substring(hostname.indexOf(']') + 1);
} else {
serverVersion = null;
}


_extractNextMapFromSponsorText();
sponsortext = sponsortext.replaceAll('-', '').replaceAll('|', '\n').trim();
Expand Down
9 changes: 5 additions & 4 deletions lib/widgets/custom_server_information_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ class CustomServerInformationDrawer extends StatelessWidget {
label: 'Next map:',
value: server.properties.nextMap,
),
CustomDescription(
label: 'Server version:',
value: server.properties.serverVersion,
),
if(server.properties.serverVersion != null)
CustomDescription(
label: 'Server version:',
value: server.properties.serverVersion!,
),
CustomDescription(
label: 'Server Message',
value: server.properties.sponsortext.trim(),
Expand Down
Loading

0 comments on commit ffde2cc

Please sign in to comment.