1212import com .rtm516 .mcxboxbroadcast .core .models .FollowerResponse ;
1313import org .java_websocket .util .NamedThreadFactory ;
1414import org .slf4j .LoggerFactory ;
15+ import org .slf4j .impl .SimpleLogger ;
1516
1617import java .io .File ;
1718import java .io .FileOutputStream ;
1819import java .io .IOException ;
1920import java .io .InputStream ;
21+ import java .lang .reflect .Field ;
2022import java .net .InetSocketAddress ;
2123import java .util .concurrent .ExecutionException ;
2224import java .util .concurrent .Executors ;
@@ -32,8 +34,6 @@ public static void main(String[] args) throws Exception {
3234
3335 ScheduledExecutorService scheduledThreadPool = Executors .newScheduledThreadPool (2 , new NamedThreadFactory ("Scheduled Thread" ));
3436
35- SessionManager sessionManager = new SessionManager ("./cache" , logger );
36-
3737 String configFileName = "config.yml" ;
3838 File configFile = new File (configFileName );
3939
@@ -63,6 +63,15 @@ public static void main(String[] args) throws Exception {
6363 return ;
6464 }
6565
66+ // Use reflection to put the logger in debug mode
67+ if (config .debugLog ) {
68+ Field currentLogLevel = SimpleLogger .class .getDeclaredField ("currentLogLevel" );
69+ currentLogLevel .setAccessible (true );
70+ currentLogLevel .set (LoggerFactory .getLogger (StandaloneMain .class ), 10 );
71+ }
72+
73+ SessionManager sessionManager = new SessionManager ("./cache" , logger );
74+
6675 SessionInfo sessionInfo = config .sessionConfig .sessionInfo ;
6776
6877 // Sync the session info from the server if needed
@@ -78,6 +87,10 @@ public static void main(String[] args) throws Exception {
7887 updateSessionInfo (sessionInfo );
7988
8089 try {
90+ // Make sure the connection is still active
91+ sessionManager .checkConnection ();
92+
93+ // Update the session
8194 sessionManager .updateSession (sessionInfo );
8295 logger .info ("Updated session!" );
8396 } catch (SessionUpdateException e ) {
@@ -88,7 +101,7 @@ public static void main(String[] args) throws Exception {
88101 if (config .friendSyncConfig .autoFollow || config .friendSyncConfig .autoUnfollow ) {
89102 scheduledThreadPool .scheduleWithFixedDelay (() -> {
90103 try {
91- for (FollowerResponse .Person person : sessionManager .getXboxFriends (true , true )) {
104+ for (FollowerResponse .Person person : sessionManager .getXboxFriends (config . friendSyncConfig . autoFollow , config . friendSyncConfig . autoUnfollow )) {
92105 // Follow the person back
93106 if (config .friendSyncConfig .autoFollow && person .isFollowingCaller && !person .isFollowedByCaller ) {
94107 logger .info ("Added " + person .displayName + " (" + person .xuid + ") as a friend" );
0 commit comments