@@ -650,7 +650,6 @@ public Optional<Island> getProtectedIslandAt(@NonNull Location location) {
650
650
*/
651
651
private CompletableFuture <Location > getAsyncSafeHomeLocation (@ NonNull World world , @ NonNull User user ,
652
652
String homeName ) {
653
- BentoBox .getInstance ().logDebug ("Getting safe home location for " + user .getName ());
654
653
CompletableFuture <Location > result = new CompletableFuture <>();
655
654
// Check if the world is a gamemode world and the player has an island
656
655
Location islandLoc = getIslandLocation (world , user .getUniqueId ());
@@ -670,16 +669,10 @@ private CompletableFuture<Location> getAsyncSafeHomeLocation(@NonNull World worl
670
669
Location namedHome = homeName .isBlank () ? null : getHomeLocation (world , user , name );
671
670
Location l = namedHome != null ? namedHome : defaultHome ;
672
671
if (l != null ) {
673
- BentoBox .getInstance ().logDebug ("Loading the destination chunk asyc for " + user .getName ());
674
- long time = System .currentTimeMillis ();
675
672
Util .getChunkAtAsync (l ).thenRun (() -> {
676
- long duration = System .currentTimeMillis () - time ;
677
- BentoBox .getInstance ().logDebug ("Chunk loaded asyc for " + user .getName () + " in " + duration + "ms" );
678
- BentoBox .getInstance ().logDebug ("Checking if the location is safe for " + user .getName ());
679
673
// Check if it is safe
680
674
if (isSafeLocation (l )) {
681
675
result .complete (l );
682
- BentoBox .getInstance ().logDebug ("Location is safe for " + user .getName ());
683
676
return ;
684
677
}
685
678
// To cover slabs, stairs and other half blocks, try one block above
@@ -688,64 +681,51 @@ private CompletableFuture<Location> getAsyncSafeHomeLocation(@NonNull World worl
688
681
// Adjust the home location accordingly
689
682
setHomeLocation (user , lPlusOne , name );
690
683
result .complete (lPlusOne );
691
- BentoBox .getInstance ().logDebug ("Location is safe for " + user .getName ());
692
684
return ;
693
685
}
694
686
// Try island
695
687
tryIsland (result , islandLoc , user , name );
696
688
});
697
689
return result ;
698
690
}
699
- BentoBox .getInstance ().logDebug ("No home locations found for " + user .getName ());
700
691
// Try island
701
692
tryIsland (result , islandLoc , user , name );
702
693
return result ;
703
694
}
704
695
705
696
private void tryIsland (CompletableFuture <Location > result , Location islandLoc , @ NonNull User user , String name ) {
706
- BentoBox .getInstance ().logDebug (user .getName () + ": we need to try other locations on the island. Load the island center chunk async..." );
707
- long time = System .currentTimeMillis ();
708
697
Util .getChunkAtAsync (islandLoc ).thenRun (() -> {
709
- long duration = System .currentTimeMillis () - time ;
710
- BentoBox .getInstance ().logDebug ("Island center chunk loaded for " + user .getName () + " in " + duration + "ms" );
711
698
World w = islandLoc .getWorld ();
712
699
if (isSafeLocation (islandLoc )) {
713
- BentoBox .getInstance ().logDebug ("Location is safe for " + user .getName ());
714
700
setHomeLocation (user , islandLoc , name );
715
701
result .complete (islandLoc .clone ().add (new Vector (0.5D , 0 , 0.5D )));
716
702
return ;
717
703
} else {
718
- BentoBox .getInstance ().logDebug ("Location is not safe for " + user .getName ());
719
704
// If these island locations are not safe, then we need to get creative
720
705
// Try the default location
721
706
Location dl = islandLoc .clone ().add (new Vector (0.5D , 5D , 2.5D ));
722
707
if (isSafeLocation (dl )) {
723
708
setHomeLocation (user , dl , name );
724
709
result .complete (dl );
725
- BentoBox .getInstance ().logDebug ("Found that the default spot is safe " + user .getName ());
726
710
return ;
727
711
}
728
712
// Try just above the bedrock
729
713
dl = islandLoc .clone ().add (new Vector (0.5D , 5D , 0.5D ));
730
714
if (isSafeLocation (dl )) {
731
715
setHomeLocation (user , dl , name );
732
716
result .complete (dl );
733
- BentoBox .getInstance ().logDebug ("Location above bedrock is safe for " + user .getName ());
734
717
return ;
735
718
}
736
- BentoBox .getInstance ().logDebug ("Trying all locations up to max height above bedrock for " + user .getName ());
737
719
// Try all the way up to the sky
738
720
for (int y = islandLoc .getBlockY (); y < w .getMaxHeight (); y ++) {
739
721
dl = new Location (w , islandLoc .getX () + 0.5D , y , islandLoc .getZ () + 0.5D );
740
722
if (isSafeLocation (dl )) {
741
723
setHomeLocation (user , dl , name );
742
724
result .complete (dl );
743
- BentoBox .getInstance ().logDebug ("Location is safe for " + user .getName ());
744
725
return ;
745
726
}
746
727
}
747
728
}
748
- BentoBox .getInstance ().logDebug ("Nowhere is safe for " + user .getName ());
749
729
result .complete (null );
750
730
});
751
731
@@ -1071,27 +1051,21 @@ private CompletableFuture<Boolean> homeTeleportAsync(@NonNull World world, @NonN
1071
1051
user .sendMessage ("commands.island.go.teleport" );
1072
1052
goingHome .add (user .getUniqueId ());
1073
1053
readyPlayer (player );
1074
- BentoBox .getInstance ().logDebug (user .getName () + " is going home" );
1075
1054
this .getAsyncSafeHomeLocation (world , user , name ).thenAccept (home -> {
1076
1055
Island island = getIsland (world , user );
1077
1056
if (home == null ) {
1078
- BentoBox .getInstance ().logDebug ("Try to fix this teleport location and teleport the player if possible " + user .getName ());
1079
1057
// Try to fix this teleport location and teleport the player if possible
1080
1058
new SafeSpotTeleport .Builder (plugin ).entity (player ).island (island ).homeName (name )
1081
1059
.thenRun (() -> teleported (world , user , name , newIsland , island ))
1082
1060
.ifFail (() -> goingHome .remove (user .getUniqueId ())).buildFuture ().thenAccept (result ::complete );
1083
1061
return ;
1084
1062
}
1085
- BentoBox .getInstance ().logDebug ("Teleporting " + player .getName () + " async" );
1086
- long time = System .currentTimeMillis ();
1087
1063
PaperLib .teleportAsync (Objects .requireNonNull (player ), home ).thenAccept (b -> {
1088
1064
// Only run the commands if the player is successfully teleported
1089
1065
if (Boolean .TRUE .equals (b )) {
1090
- BentoBox .getInstance ().logDebug ("Teleported " + player .getName () + " async - took " + (System .currentTimeMillis () - time ) + "ms" );
1091
1066
teleported (world , user , name , newIsland , island );
1092
1067
result .complete (true );
1093
1068
} else {
1094
- BentoBox .getInstance ().logDebug ("Failed to teleport " + player .getName () + " async! - took " + (System .currentTimeMillis () - time ) + "ms" );
1095
1069
// Remove from mid-teleport set
1096
1070
goingHome .remove (user .getUniqueId ());
1097
1071
result .complete (false );
0 commit comments