Skip to content

Commit 4ddb204

Browse files
authored
Merge pull request #2307 from BentoBoxWorld/2305_respawn_to_home
Change respawn point to the default home on the island. #2305
2 parents 0a9da71 + 562b515 commit 4ddb204

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/main/java/world/bentobox/bentobox/listeners/flags/worldsettings/IslandRespawnListener.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void onPlayerDeath(PlayerDeathEvent e) {
5555
*
5656
* @param e - event
5757
*/
58-
@EventHandler(priority = EventPriority.HIGHEST)
58+
@EventHandler(priority = EventPriority.NORMAL)
5959
public void onPlayerRespawn(PlayerRespawnEvent e) {
6060
final UUID worldUUID = respawn.remove(e.getPlayer().getUniqueId());
6161
if (worldUUID == null) {
@@ -67,11 +67,11 @@ public void onPlayerRespawn(PlayerRespawnEvent e) {
6767
return; // world no longer available
6868
}
6969
World w = Util.getWorld(world);
70+
7071
String ownerName = e.getPlayer().getName();
7172
if (w != null) {
72-
final Location respawnLocation = getIslands().getPrimaryIsland(world, e.getPlayer().getUniqueId())
73-
.getSpawnPoint(world.getEnvironment());
74-
if (respawnLocation != null) {
73+
final Location respawnLocation = getIslands().getHomeLocation(world, e.getPlayer().getUniqueId());
74+
if (respawnLocation != null && getIslands().isSafeLocation(respawnLocation)) {
7575
e.setRespawnLocation(respawnLocation);
7676
// Get the island owner name
7777
Island island = BentoBox.getInstance().getIslands().getIsland(w, User.getInstance(e.getPlayer()));

src/test/java/world/bentobox/bentobox/listeners/flags/worldsettings/IslandRespawnListenerTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,10 @@ public void setUp() throws Exception {
114114
when(iwm.getAddon(any())).thenReturn(opGma);
115115
safeLocation = mock(Location.class);
116116
when(safeLocation.getWorld()).thenReturn(world);
117-
when(island.getSpawnPoint(Environment.NORMAL)).thenReturn(safeLocation);
117+
when(im.getHomeLocation(eq(world), any(UUID.class))).thenReturn(safeLocation);
118118
when(im.getPrimaryIsland(any(), any())).thenReturn(island);
119119
when(im.hasIsland(any(), any(UUID.class))).thenReturn(true);
120+
when(im.isSafeLocation(safeLocation)).thenReturn(true);
120121
when(plugin.getIslands()).thenReturn(im);
121122

122123
// when(im.getSafeHomeLocation(any(), any(),

0 commit comments

Comments
 (0)