Merge pull request #2307 from BentoBoxWorld/2305_respawn_to_home

Change respawn point to the default home on the island. #2305
This commit is contained in:
tastybento 2024-02-24 16:08:32 -08:00 committed by GitHub
commit 4ddb204fcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View File

@ -55,7 +55,7 @@ public class IslandRespawnListener extends FlagListener {
*
* @param e - event
*/
@EventHandler(priority = EventPriority.HIGHEST)
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerRespawn(PlayerRespawnEvent e) {
final UUID worldUUID = respawn.remove(e.getPlayer().getUniqueId());
if (worldUUID == null) {
@ -67,11 +67,11 @@ public class IslandRespawnListener extends FlagListener {
return; // world no longer available
}
World w = Util.getWorld(world);
String ownerName = e.getPlayer().getName();
if (w != null) {
final Location respawnLocation = getIslands().getPrimaryIsland(world, e.getPlayer().getUniqueId())
.getSpawnPoint(world.getEnvironment());
if (respawnLocation != null) {
final Location respawnLocation = getIslands().getHomeLocation(world, e.getPlayer().getUniqueId());
if (respawnLocation != null && getIslands().isSafeLocation(respawnLocation)) {
e.setRespawnLocation(respawnLocation);
// Get the island owner name
Island island = BentoBox.getInstance().getIslands().getIsland(w, User.getInstance(e.getPlayer()));

View File

@ -114,9 +114,10 @@ public class IslandRespawnListenerTest {
when(iwm.getAddon(any())).thenReturn(opGma);
safeLocation = mock(Location.class);
when(safeLocation.getWorld()).thenReturn(world);
when(island.getSpawnPoint(Environment.NORMAL)).thenReturn(safeLocation);
when(im.getHomeLocation(eq(world), any(UUID.class))).thenReturn(safeLocation);
when(im.getPrimaryIsland(any(), any())).thenReturn(island);
when(im.hasIsland(any(), any(UUID.class))).thenReturn(true);
when(im.isSafeLocation(safeLocation)).thenReturn(true);
when(plugin.getIslands()).thenReturn(im);
// when(im.getSafeHomeLocation(any(), any(),