File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 11using MelonLoader ;
2- using Tomlet ;
32
43namespace WorldLink ;
54
@@ -17,7 +16,7 @@ public override void OnInitializeMelon()
1716 {
1817 // Load config
1918 LoggerInstance . Msg ( "Loading config..." ) ;
20- Config = TomletMain . To < Config > ( File . ReadAllText ( "WorldLink.toml" ) ) ;
19+ Config = TomletShim . To < Config > ( File . ReadAllText ( "WorldLink.toml" ) ) ;
2120
2221 LoggerInstance . Msg ( "Patching..." ) ;
2322 Futari . OnBeforePatch ( ) ;
Original file line number Diff line number Diff line change 1+ using System . Reflection ;
2+ using Tomlet ;
3+
4+ namespace WorldLink ;
5+
6+ public static class TomletShim
7+ {
8+ private static MethodInfo methodOld ;
9+ private static MethodInfo methodNew ;
10+
11+ static TomletShim ( )
12+ {
13+ var method = typeof ( TomletMain ) . GetMethods ( BindingFlags . Public | BindingFlags . Static ) . Where ( it => it . Name == "To" ) ;
14+ methodOld = method . FirstOrDefault ( it => it . GetParameters ( ) . Length == 1 && it . GetParameters ( ) [ 0 ] . ParameterType == typeof ( string ) ) ;
15+ methodNew = method . FirstOrDefault ( it => it . GetParameters ( ) . Length == 2 && it . GetParameters ( ) [ 0 ] . ParameterType == typeof ( string ) ) ;
16+ }
17+
18+ public static T To < T > ( string toml )
19+ {
20+ if ( methodOld != null )
21+ {
22+ return ( T ) methodOld . MakeGenericMethod ( typeof ( T ) ) . Invoke ( null , [ toml ] ) ;
23+ }
24+ if ( methodNew != null )
25+ {
26+ return ( T ) methodNew . MakeGenericMethod ( typeof ( T ) ) . Invoke ( null , [ toml , null ] ) ;
27+ }
28+ throw new InvalidOperationException ( "Tomlet methods not found. Please ensure you are using the correct version of Tomlet." ) ;
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments