File tree Expand file tree Collapse file tree 3 files changed +9
-3
lines changed
src/main/java/world/bentobox/bentobox Expand file tree Collapse file tree 3 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -241,7 +241,9 @@ public PlayerInventory getInventory() {
241241 */
242242 @ NonNull
243243 public Location getLocation () {
244- return Objects .requireNonNull (player , "getLocation can only be called for online players!" ).getLocation ();
244+ Player p = Objects .requireNonNull (player , "getLocation can only be called for online players!" );
245+ Location loc = p .getLocation ();
246+ return Objects .requireNonNull (loc , "Player's location cannot be null! The player may not have a location (has never played)." );
245247 }
246248
247249 /**
Original file line number Diff line number Diff line change @@ -851,7 +851,11 @@ private boolean playerIsVisitor(Player player) {
851851 if (player .getGameMode () == GameMode .SPECTATOR ) {
852852 return false ;
853853 }
854-
854+ Location loc = player .getLocation ();
855+ if (location == null ) {
856+ // This will only be true if the player has never played. Allow them to be a visitor.
857+ return true ;
858+ }
855859 return onIsland (player .getLocation ()) && getRank (User .getInstance (player )) == RanksManager .VISITOR_RANK ;
856860 }
857861
Original file line number Diff line number Diff line change @@ -598,7 +598,7 @@ private Object serialize(@Nullable Object object) {
598598 return switch (object ) {
599599 case null -> "null" ;
600600
601- // UUID has it's own serialization, that is not picked up automatically
601+ // UUID has its own serialization, that is not picked up automatically
602602 case UUID uuid -> object .toString ();
603603
604604 // Only the world name is needed for worlds
You can’t perform that action at this time.
0 commit comments