-
-
Notifications
You must be signed in to change notification settings - Fork 149
Version 3.11.2 #2791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Version 3.11.2 #2791
Changes from all commits
91f0634
4fe30d7
acd61ed
4f04a82
2ef2370
ba2ef72
ea85f16
e23e1ae
a002b84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -462,7 +462,21 @@ public Set<Island> getOwnedIslands(@NonNull World world, @NonNull UUID uniqueId) | |
| */ | ||
| @Nullable | ||
| public Island getIsland(@NonNull World world, @NonNull UUID uuid) { | ||
| return islandCache.getIsland(world, uuid); | ||
| // Check if player is online and get their current island location | ||
| Player player = Bukkit.getPlayer(uuid); | ||
| if (player != null && player.isOnline()) { | ||
| // This island must be in this world and the player must be on the team | ||
| Optional<Island> currentIsland = getIslandAt(player.getLocation()) | ||
| .filter(is -> world.equals(is.getWorld()) && is.inTeam(uuid)); | ||
|
|
||
| if (currentIsland.isPresent()) { | ||
| return currentIsland.get(); | ||
| } | ||
| } | ||
| // Check cache for last island | ||
| Island cachedIsland = islandCache.getIsland(world, uuid); | ||
|
|
||
| return cachedIsland; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1102,6 +1116,7 @@ private CompletableFuture<Boolean> homeTeleportAsync(@NonNull World world, @NonN | |
| User user = User.getInstance(player); | ||
| user.sendMessage("commands.island.go.teleport"); | ||
| goingHome.add(user.getUniqueId()); | ||
|
|
||
| readyPlayer(player); | ||
| this.getAsyncSafeHomeLocation(world, user, name).thenAccept(home -> { | ||
| Island island = getIsland(world, user); | ||
|
|
@@ -1802,14 +1817,42 @@ public void setPrimaryIsland(UUID uuid, Island i) { | |
| } | ||
|
|
||
| /** | ||
| * Convenience method. See {@link IslandCache#getIsland(World, UUID)} | ||
| * Convenience method. See {@link #getIsland(World, UUID)} | ||
| * | ||
| * @param world world | ||
| * @param uuid player's UUID | ||
| * @return Island of player or null if there isn't one | ||
| */ | ||
| public Island getPrimaryIsland(World world, UUID uuid) { | ||
| return this.getIslandCache().getIsland(world, uuid); | ||
| return getIsland(world, uuid); | ||
| } | ||
|
|
||
| public CompletableFuture<Void> homeTeleportAsync(Island island, User user) { | ||
| return homeTeleportAsync(island, user, false); | ||
| } | ||
|
|
||
| /** | ||
| * Teleport the user home | ||
| * @param island island | ||
| * @param user user | ||
| * @param newIsland true if this is a new island first time teleport | ||
| * @return future when it is done | ||
| */ | ||
| public CompletableFuture<Void> homeTeleportAsync(Island island, User user, boolean newIsland) { | ||
| Location loc = island.getHome(""); | ||
| user.sendMessage("commands.island.go.teleport"); | ||
| goingHome.add(user.getUniqueId()); | ||
| readyPlayer(user.getPlayer()); | ||
| return Util.teleportAsync(Objects.requireNonNull(user.getPlayer()), loc).thenAccept(b -> { | ||
| // Only run the commands if the player is successfully teleported | ||
| if (Boolean.TRUE.equals(b)) { | ||
| teleported(island.getWorld(), user, "", newIsland, island); | ||
| this.setPrimaryIsland(user.getUniqueId(), island); | ||
| } else { | ||
| // Remove from mid-teleport set | ||
| goingHome.remove(user.getUniqueId()); | ||
| } | ||
| }); | ||
|
Comment on lines
+1830
to
+1855
|
||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
homeTeleportAsync(Island, User, boolean)callsisland.getHome("")directly and passes the result toUtil.teleportAsync(...)without any null check or fallback. For islands that do not yet have a default home (e.g., no-paste creations or legacy islands without homes),island.getHome("")can be null, which will lead to a nullLocationbeing used for teleportation and likely a runtime exception. To keep behavior consistent with the existing world-basedhomeTeleportAsyncoverload, this method should resolve a safe home location (e.g., viagetHomeLocation(island)or equivalent safe-location logic) and handle the case where no home exists before attempting teleport.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback