@@ -194,26 +194,7 @@ public void onInitializeClient() {
194194 System .out .println ("Connected to Hypixel" );
195195
196196 // Update username in case of account switch before joining
197- String currentUsername = MinecraftClient .getInstance ().getSession ().getUsername ();
198- if (!currentUsername .equals (username )) {
199- System .out .println ("Account changed before joining server: " + username + " -> " + currentUsername );
200- username = currentUsername ;
201- lastCheckedUsername = currentUsername ;
202- }
203-
204- if (!CoflCore .Wrapper .isRunning && CoflCore .config .autoStart )
205- CoflSkyCommand .start (username );
206- Thread .startVirtualThread (() -> {
207- try {
208- Thread .sleep (5000 ); // wait 5 seconds for the scoreboard to be populated
209- if (!CoflCore .Wrapper .isRunning )
210- return ;
211- uploadScoreboard ();
212- uploadTabList ();
213- } catch (InterruptedException e ) {
214- e .printStackTrace ();
215- }
216- });
197+ autoStart ();
217198 }
218199 // reset cached data for different island
219200 DescriptionHandler .emptyTooltipData ();
@@ -452,6 +433,12 @@ public void onInitializeClient() {
452433 Pair <String ,String > newData = getRelevantLinesFromScoreboard (scores );
453434 if (newData .getLeft ().equals (lastScoreboardUploaded .getLeft ()) && newData .getRight ().equals (lastScoreboardUploaded .getRight ())) return ;
454435 System .out .println ("Uploading Scoreboard..." );
436+ if (CoflCore .Wrapper == null || !CoflCore .Wrapper .isRunning ) {
437+ // Only auto-start if the scoreboard's last line indicates Hypixel (contains "hypixel.net")
438+ if (scores .length > 0 && scores [scores .length - 1 ].toLowerCase ().contains ("hypixel.net" )) {
439+ autoStart ();
440+ }
441+ }
455442 uploadScoreboard ();
456443 });
457444
@@ -464,9 +451,29 @@ public void onInitializeClient() {
464451
465452 return ActionResult .PASS ;
466453 });
454+ }
467455
468- ScreenEvents .AFTER_INIT .register ((minecraftClient , screen , i , i1 ) -> {
469-
456+ private void autoStart (){
457+ if (CoflCore .Wrapper .isRunning || !CoflCore .config .autoStart )
458+ return ;
459+ String currentUsername = MinecraftClient .getInstance ().getSession ().getUsername ();
460+ if (!currentUsername .equals (username )) {
461+ System .out .println ("Account changed before joining server: " + username + " -> " + currentUsername );
462+ username = currentUsername ;
463+ lastCheckedUsername = currentUsername ;
464+ }
465+
466+ CoflSkyCommand .start (username );
467+ Thread .startVirtualThread (() -> {
468+ try {
469+ Thread .sleep (5000 ); // wait 5 seconds for the scoreboard to be populated
470+ if (!CoflCore .Wrapper .isRunning )
471+ return ;
472+ uploadScoreboard ();
473+ uploadTabList ();
474+ } catch (InterruptedException e ) {
475+ e .printStackTrace ();
476+ }
470477 });
471478 }
472479
0 commit comments