Skip to content
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

Release 2.6.0 #2527

Merged
merged 22 commits into from
Oct 5, 2024
Merged
Changes from 4 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
541d966
Fix for 2515
tastybento Sep 27, 2024
69de5ea
Merge pull request #2516 from BentoBoxWorld/2515_Island_Settings_Icon…
tastybento Sep 27, 2024
fd1ab22
Implements admin command to set an island's max homes #2517
tastybento Sep 28, 2024
2784f19
Added test class and made some methods easier to test
tastybento Sep 28, 2024
4a972a8
Add placeholders. Put in defensive code against nulls.
tastybento Sep 28, 2024
f1219ec
Remove test class
tastybento Sep 28, 2024
83b7c66
Merge pull request #2518 from BentoBoxWorld/2517_Admin_command_for_ma…
tastybento Sep 29, 2024
80e1063
Add AdminResetHome command #2522
tastybento Oct 1, 2024
6d8ac15
Merge pull request #2523 from BentoBoxWorld/2522_admin_command_to_res…
tastybento Oct 1, 2024
aa19319
Improve teleporting #2524 - this commit has debug.
tastybento Oct 1, 2024
a7f9f21
Make all islands Op's
tastybento Oct 2, 2024
1782dd6
Remove unused imports
tastybento Oct 2, 2024
81fb17d
Merge pull request #2526 from BentoBoxWorld/oraxen
tastybento Oct 2, 2024
3992102
Merge branch 'develop' into 2524_is_teleport_command_delay
tastybento Oct 2, 2024
b949727
Update IslandGoCommand.java
tastybento Oct 2, 2024
1085332
Merge pull request #2525 from BentoBoxWorld/2524_is_teleport_command_…
tastybento Oct 2, 2024
9cb8d1c
Test fix for teleporting using new in-progress message
tastybento Oct 2, 2024
0da7130
Add clickable text and hover text
tastybento Oct 5, 2024
97aff7a
Merge pull request #2529 from BentoBoxWorld/clickable_text
tastybento Oct 5, 2024
29c5057
Fix tests, optimize tests, reord imports.
tastybento Oct 5, 2024
bac59d7
Merge pull request #2530 from BentoBoxWorld/test_fixing
tastybento Oct 5, 2024
32a9f71
Merge branch 'master' into develop
tastybento Oct 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ public boolean canExecute(User user, String label, List<String> args) {
// Check if mid-teleport
if (getIslands().isGoingHome(user)) {
// Tell them again that it's in progress
user.sendMessage("commands.island.go.teleport");
user.sendMessage("commands.island.go.in-progress");
return false;
}
List<Island> islands = getIslands().getIslands(getWorld(), user.getUniqueId());
@@ -76,7 +76,15 @@ public boolean execute(User user, String label, List<String> args) {
getIslands().setPrimaryIsland(user.getUniqueId(), info.island);
if (!info.islandName) {
this.delayCommand(user, () -> getIslands().homeTeleportAsync(getWorld(), user.getPlayer(), name)
.thenAccept((r) -> getIslands().setPrimaryIsland(user.getUniqueId(), info.island)));
.thenAccept((r) -> {
if (r.booleanValue()) {
// Success
getIslands().setPrimaryIsland(user.getUniqueId(), info.island);
} else {
user.sendMessage("commands.island.go.failure");
getPlugin().logError(user.getName() + " could not teleport to their island - async teleport issue");
}
}));
return true;
}
}
26 changes: 26 additions & 0 deletions src/main/java/world/bentobox/bentobox/managers/IslandsManager.java
Original file line number Diff line number Diff line change
@@ -650,6 +650,7 @@ public Optional<Island> getProtectedIslandAt(@NonNull Location location) {
*/
private CompletableFuture<Location> getAsyncSafeHomeLocation(@NonNull World world, @NonNull User user,
String homeName) {
BentoBox.getInstance().logDebug("Getting safe home location for " + user.getName());
CompletableFuture<Location> result = new CompletableFuture<>();
// Check if the world is a gamemode world and the player has an island
Location islandLoc = getIslandLocation(world, user.getUniqueId());
@@ -669,10 +670,16 @@ private CompletableFuture<Location> getAsyncSafeHomeLocation(@NonNull World worl
Location namedHome = homeName.isBlank() ? null : getHomeLocation(world, user, name);
Location l = namedHome != null ? namedHome : defaultHome;
if (l != null) {
BentoBox.getInstance().logDebug("Loading the destination chunk asyc for " + user.getName());
long time = System.currentTimeMillis();
Util.getChunkAtAsync(l).thenRun(() -> {
long duration = System.currentTimeMillis() - time;
BentoBox.getInstance().logDebug("Chunk loaded asyc for " + user.getName() + " in " + duration + "ms");
BentoBox.getInstance().logDebug("Checking if the location is safe for " + user.getName());
// Check if it is safe
if (isSafeLocation(l)) {
result.complete(l);
BentoBox.getInstance().logDebug("Location is safe for " + user.getName());
return;
}
// To cover slabs, stairs and other half blocks, try one block above
@@ -681,51 +688,64 @@ private CompletableFuture<Location> getAsyncSafeHomeLocation(@NonNull World worl
// Adjust the home location accordingly
setHomeLocation(user, lPlusOne, name);
result.complete(lPlusOne);
BentoBox.getInstance().logDebug("Location is safe for " + user.getName());
return;
}
// Try island
tryIsland(result, islandLoc, user, name);
});
return result;
}
BentoBox.getInstance().logDebug("No home locations found for " + user.getName());
// Try island
tryIsland(result, islandLoc, user, name);
return result;
}

private void tryIsland(CompletableFuture<Location> result, Location islandLoc, @NonNull User user, String name) {
BentoBox.getInstance().logDebug(user.getName() + ": we need to try other locations on the island. Load the island center chunk async...");
long time = System.currentTimeMillis();
Util.getChunkAtAsync(islandLoc).thenRun(() -> {
long duration = System.currentTimeMillis() - time;
BentoBox.getInstance().logDebug("Island center chunk loaded for " + user.getName() + " in " + duration + "ms");
World w = islandLoc.getWorld();
if (isSafeLocation(islandLoc)) {
BentoBox.getInstance().logDebug("Location is safe for " + user.getName());
setHomeLocation(user, islandLoc, name);
result.complete(islandLoc.clone().add(new Vector(0.5D, 0, 0.5D)));
return;
} else {
BentoBox.getInstance().logDebug("Location is not safe for " + user.getName());
// If these island locations are not safe, then we need to get creative
// Try the default location
Location dl = islandLoc.clone().add(new Vector(0.5D, 5D, 2.5D));
if (isSafeLocation(dl)) {
setHomeLocation(user, dl, name);
result.complete(dl);
BentoBox.getInstance().logDebug("Found that the default spot is safe " + user.getName());
return;
}
// Try just above the bedrock
dl = islandLoc.clone().add(new Vector(0.5D, 5D, 0.5D));
if (isSafeLocation(dl)) {
setHomeLocation(user, dl, name);
result.complete(dl);
BentoBox.getInstance().logDebug("Location above bedrock is safe for " + user.getName());
return;
}
BentoBox.getInstance().logDebug("Trying all locations up to max height above bedrock for " + user.getName());
// Try all the way up to the sky
for (int y = islandLoc.getBlockY(); y < w.getMaxHeight(); y++) {
dl = new Location(w, islandLoc.getX() + 0.5D, y, islandLoc.getZ() + 0.5D);
if (isSafeLocation(dl)) {
setHomeLocation(user, dl, name);
result.complete(dl);
BentoBox.getInstance().logDebug("Location is safe for " + user.getName());
return;
}
}
}
BentoBox.getInstance().logDebug("Nowhere is safe for " + user.getName());
result.complete(null);
});

@@ -1051,21 +1071,27 @@ private CompletableFuture<Boolean> homeTeleportAsync(@NonNull World world, @NonN
user.sendMessage("commands.island.go.teleport");
goingHome.add(user.getUniqueId());
readyPlayer(player);
BentoBox.getInstance().logDebug(user.getName() + " is going home");
this.getAsyncSafeHomeLocation(world, user, name).thenAccept(home -> {
Island island = getIsland(world, user);
if (home == null) {
BentoBox.getInstance().logDebug("Try to fix this teleport location and teleport the player if possible " + user.getName());
// Try to fix this teleport location and teleport the player if possible
new SafeSpotTeleport.Builder(plugin).entity(player).island(island).homeName(name)
.thenRun(() -> teleported(world, user, name, newIsland, island))
.ifFail(() -> goingHome.remove(user.getUniqueId())).buildFuture().thenAccept(result::complete);
return;
}
BentoBox.getInstance().logDebug("Teleporting " + player.getName() + " async");
long time = System.currentTimeMillis();
PaperLib.teleportAsync(Objects.requireNonNull(player), home).thenAccept(b -> {
// Only run the commands if the player is successfully teleported
if (Boolean.TRUE.equals(b)) {
BentoBox.getInstance().logDebug("Teleported " + player.getName() + " async - took " + (System.currentTimeMillis() - time) + "ms");
teleported(world, user, name, newIsland, island);
result.complete(true);
} else {
BentoBox.getInstance().logDebug("Failed to teleport " + player.getName() + " async! - took " + (System.currentTimeMillis() - time) + "ms");
// Remove from mid-teleport set
goingHome.remove(user.getUniqueId());
result.complete(false);
Original file line number Diff line number Diff line change
@@ -279,7 +279,11 @@ void teleportEntity(final Location loc) {
task.cancel();
// Return to main thread and teleport the player
Bukkit.getScheduler().runTask(plugin, () -> {
BentoBox.getInstance().logDebug("Home number = " + homeNumber + " Home name = '" + homeName + "'");
plugin.getIslands().getIslandAt(loc).ifPresent(is ->
plugin.getIslands().getHomeLocations(is).forEach((k,v) -> BentoBox.getInstance().logDebug("'" + k + "' => " + v)));
if (!portal && entity instanceof Player && (homeNumber > 0 || !homeName.isEmpty())) {
BentoBox.getInstance().logDebug("Setting home");
// Set home if so marked
plugin.getIslands().setHomeLocation(User.getInstance(entity), loc, homeName);
}
2 changes: 2 additions & 0 deletions src/main/resources/locales/en-US.yml
Original file line number Diff line number Diff line change
@@ -551,7 +551,9 @@ commands:
parameters: '[home name]'
description: teleport you to your island
teleport: '&a Teleporting you to your island.'
in-progress: '&a Teleporting in progress, please wait...'
teleported: '&a Teleported you to home &e [number].'
failure: '&c Teleporting failed for some reason. Please try again later.'
unknown-home: '&c Unknown home name!'
help:
description: the main island command