Change respawn point to the default home on the island. #2305

This commit is contained in:
tastybento 2024-02-24 16:06:56 -08:00
parent 0a9da71c65
commit 562b515bfe
2 changed files with 6 additions and 5 deletions

View File

@ -55,7 +55,7 @@ public class IslandRespawnListener extends FlagListener {
* *
* @param e - event * @param e - event
*/ */
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.NORMAL)
public void onPlayerRespawn(PlayerRespawnEvent e) { public void onPlayerRespawn(PlayerRespawnEvent e) {
final UUID worldUUID = respawn.remove(e.getPlayer().getUniqueId()); final UUID worldUUID = respawn.remove(e.getPlayer().getUniqueId());
if (worldUUID == null) { if (worldUUID == null) {
@ -67,11 +67,11 @@ public class IslandRespawnListener extends FlagListener {
return; // world no longer available return; // world no longer available
} }
World w = Util.getWorld(world); World w = Util.getWorld(world);
String ownerName = e.getPlayer().getName(); String ownerName = e.getPlayer().getName();
if (w != null) { if (w != null) {
final Location respawnLocation = getIslands().getPrimaryIsland(world, e.getPlayer().getUniqueId()) final Location respawnLocation = getIslands().getHomeLocation(world, e.getPlayer().getUniqueId());
.getSpawnPoint(world.getEnvironment()); if (respawnLocation != null && getIslands().isSafeLocation(respawnLocation)) {
if (respawnLocation != null) {
e.setRespawnLocation(respawnLocation); e.setRespawnLocation(respawnLocation);
// Get the island owner name // Get the island owner name
Island island = BentoBox.getInstance().getIslands().getIsland(w, User.getInstance(e.getPlayer())); 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); when(iwm.getAddon(any())).thenReturn(opGma);
safeLocation = mock(Location.class); safeLocation = mock(Location.class);
when(safeLocation.getWorld()).thenReturn(world); 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.getPrimaryIsland(any(), any())).thenReturn(island);
when(im.hasIsland(any(), any(UUID.class))).thenReturn(true); when(im.hasIsland(any(), any(UUID.class))).thenReturn(true);
when(im.isSafeLocation(safeLocation)).thenReturn(true);
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);
// when(im.getSafeHomeLocation(any(), any(), // when(im.getSafeHomeLocation(any(), any(),