mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-16 20:32:29 +01:00
Faster teleports (#2267)
* Fixed bug with teleporting where home name would not be used. * Remove debug
This commit is contained in:
parent
26e5d750a0
commit
be9b429308
@ -15,7 +15,6 @@ import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.lists.Flags;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
import world.bentobox.bentobox.util.teleport.SafeSpotTeleport;
|
||||
|
||||
/**
|
||||
* @author tastybento
|
||||
@ -76,23 +75,14 @@ public class IslandGoCommand extends DelayedTeleportCommand {
|
||||
} else {
|
||||
IslandInfo info = names.get(name);
|
||||
getIslands().setPrimaryIsland(user.getUniqueId(), info.island);
|
||||
if (info.islandName) {
|
||||
this.delayCommand(user, () -> new SafeSpotTeleport.Builder(getPlugin())
|
||||
.entity(user.getPlayer())
|
||||
.location(getIslands().getHomeLocation(info.island))
|
||||
.thenRun(() -> user.sendMessage("general.success"))
|
||||
.build());
|
||||
} else {
|
||||
this.delayCommand(user, () -> new SafeSpotTeleport.Builder(getPlugin())
|
||||
.entity(user.getPlayer())
|
||||
.location(getIslands().getHomeLocation(info.island, name))
|
||||
.thenRun(() -> user.sendMessage("general.success"))
|
||||
.build());
|
||||
if (!info.islandName) {
|
||||
this.delayCommand(user, () -> getIslands().homeTeleportAsync(getWorld(), user.getPlayer(), name)
|
||||
.thenAccept((r) -> getIslands().setPrimaryIsland(user.getUniqueId(), info.island)));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.delayCommand(user, () -> getIslands().homeTeleportAsync(getWorld(), user.getPlayer()));
|
||||
}
|
||||
this.delayCommand(user, () -> getIslands().homeTeleportAsync(getWorld(), user.getPlayer()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1721,9 +1721,10 @@ public class Island implements DataObject, MetaDataAble {
|
||||
* @since 1.16.0
|
||||
*/
|
||||
@NonNull
|
||||
public Location getHome(String name) {
|
||||
Location l = getHomes().get(name.toLowerCase());
|
||||
return l == null ? getProtectionCenter() : l;
|
||||
public Location getHome(final String nameToLookFor) {
|
||||
return getHomes().entrySet().stream().filter(en -> en.getKey().equalsIgnoreCase(nameToLookFor))
|
||||
.map(Entry::getValue)
|
||||
.findFirst().orElse(getProtectionCenter());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -609,7 +609,6 @@ public class IslandsManager {
|
||||
this.setPrimaryIsland(user.getUniqueId(), island);
|
||||
return "";
|
||||
}).orElse(homeName);
|
||||
|
||||
// Try the home location first
|
||||
Location defaultHome = getHomeLocation(world, user);
|
||||
Location namedHome = homeName.isBlank() ? null : getHomeLocation(world, user, name);
|
||||
@ -899,7 +898,8 @@ public class IslandsManager {
|
||||
*/
|
||||
@Nullable
|
||||
public Location getHomeLocation(@NonNull World world, @NonNull UUID uuid, String name) {
|
||||
return getIslands(world, uuid).stream().map(is -> is.getHome(name)).filter(Objects::nonNull).findFirst()
|
||||
return getIslands(world, uuid).stream().filter(is -> is.getHomes().containsKey(name))
|
||||
.map(is -> is.getHome(name)).findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user