Skip to content

Commit

Permalink
small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
JoCat committed Oct 15, 2023
1 parent 5e64ef6 commit 4eee162
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
25 changes: 8 additions & 17 deletions lib/config.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import 'dart:convert';
import 'dart:io';

import 'package:json_annotation/json_annotation.dart';
part 'config.g.dart';

Config configFromJson(String str) => Config.fromJson(json.decode(str));

String configToJson(Config data) => json.encode(data.toJson());
String configToJson(Config data) =>
JsonEncoder.withIndent(' ').convert(data.toJson());

Future<Config> loadConfig() async {
var file = File(Config.configFilename);
Expand All @@ -19,6 +23,7 @@ Future<Config> loadConfig() async {
exit(0);
}

@JsonSerializable()
class Config {
final String javaExecutablePath;
final String additionalFlags;
Expand Down Expand Up @@ -46,21 +51,7 @@ class Config {
apiUrl: "example.com",
);

factory Config.fromJson(Map<String, dynamic> json) => Config(
javaExecutablePath: json["javaExecutablePath"],
additionalFlags: json["additionalFlags"],
arguments: json["arguments"],
injectorFilename: json["injectorFilename"],
serverFilename: json["serverFilename"],
apiUrl: json["apiUrl"],
);
factory Config.fromJson(Map<String, dynamic> json) => _$ConfigFromJson(json);

Map<String, dynamic> toJson() => {
"javaExecutablePath": javaExecutablePath,
"additionalFlags": additionalFlags,
"arguments": arguments,
"injectorFilename": injectorFilename,
"serverFilename": serverFilename,
"apiUrl": apiUrl,
};
Map<String, dynamic> toJson() => _$ConfigToJson(this);
}
25 changes: 25 additions & 0 deletions lib/config.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: serverwrapper
description: Aurora ServerWrapper
version: 1.0.1
version: 1.0.2
repository: https://github.com/AuroraTeam/ServerWrapper

environment:
Expand Down

0 comments on commit 4eee162

Please sign in to comment.