diff --git a/src/main/java/org/mvplugins/multiverse/inventories/destination/LastLocationDestination.java b/src/main/java/org/mvplugins/multiverse/inventories/destination/LastLocationDestination.java index 49d8c003..6e9282f4 100644 --- a/src/main/java/org/mvplugins/multiverse/inventories/destination/LastLocationDestination.java +++ b/src/main/java/org/mvplugins/multiverse/inventories/destination/LastLocationDestination.java @@ -1,8 +1,6 @@ package org.mvplugins.multiverse.inventories.destination; -import com.dumptruckman.minecraft.util.Logging; import org.bukkit.command.CommandSender; -import org.checkerframework.checker.units.qual.N; import org.jvnet.hk2.annotations.Service; import org.mvplugins.multiverse.core.destination.Destination; import org.mvplugins.multiverse.core.destination.DestinationSuggestionPacket; @@ -47,7 +45,12 @@ public final class LastLocationDestination implements Destination { + private final WorldManager worldManager; private final WorldGroupManager worldGroupManager; private final ProfileContainerStoreProvider profileContainerStoreProvider; private final String worldName; LastLocationDestinationInstance( @NotNull LastLocationDestination destination, + @NotNull WorldManager worldManager, @NotNull WorldGroupManager worldGroupManager, @NotNull ProfileContainerStoreProvider profileContainerStoreProvider, @NotNull String worldName) { super(destination); + this.worldManager = worldManager; this.worldGroupManager = worldGroupManager; this.profileContainerStoreProvider = profileContainerStoreProvider; this.worldName = worldName; @@ -32,23 +37,24 @@ public final class LastLocationDestinationInstance extends DestinationInstance getLocation(@NotNull Entity teleportee) { - Logging.warning("LastLocationDestination: teleportee: " + teleportee); + Logging.finer("LastLocationDestination: teleportee: " + teleportee); if (!(teleportee instanceof Player player)) { - return Option.none(); + return worldManager.getLoadedWorld(worldName).map(MultiverseWorld::getSpawnLocation); } var playerWorld = player.getWorld().getName(); if (playerWorld.equals(worldName)) { - return Option.none(); + return worldManager.getLoadedWorld(worldName).map(MultiverseWorld::getSpawnLocation); } for (var group : worldGroupManager.getGroupsForWorld(worldName)) { - Logging.warning("LastLocationDestination: group: " + group); + Logging.finer("LastLocationDestination: group: " + group); if (!group.containsWorld(playerWorld) && group.getApplicableShares().contains(Sharables.LAST_LOCATION)) { return Option.of(profileContainerStoreProvider.getStore(ContainerType.GROUP) .getContainer(group.getName()) .getPlayerProfileNow(player) - .get(Sharables.LAST_LOCATION)); + .get(Sharables.LAST_LOCATION)) + .orElse(() -> worldManager.getLoadedWorld(worldName).map(MultiverseWorld::getSpawnLocation)); } } @@ -56,7 +62,8 @@ public final class LastLocationDestinationInstance extends DestinationInstance worldManager.getLoadedWorld(worldName).map(MultiverseWorld::getSpawnLocation)); } @Override