mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-13 02:41:20 +01:00
Teleports void visitors to same environment as they left.
https://github.com/BentoBoxWorld/BentoBox/issues/814
This commit is contained in:
parent
edd7bbf97a
commit
d6b0859d40
@ -112,7 +112,13 @@ public class InvincibleVisitorsListener extends FlagListener implements ClickHan
|
||||
Player p = (Player) e.getEntity();
|
||||
// Handle the void - teleport player back to island in a safe spot
|
||||
if(e.getCause().equals(DamageCause.VOID)) {
|
||||
if (getIslands().getIslandAt(p.getLocation()).isPresent()) { getIslands().getIslandAt(p.getLocation()).ifPresent(i -> new SafeSpotTeleport.Builder(getPlugin()).entity(p).island(i).build());
|
||||
if (getIslands().getIslandAt(p.getLocation()).isPresent()) {
|
||||
getIslands().getIslandAt(p.getLocation()).ifPresent(island ->
|
||||
// Teleport
|
||||
new SafeSpotTeleport.Builder(getPlugin())
|
||||
.entity(p)
|
||||
.location(island.getCenter().toVector().toLocation(p.getWorld()))
|
||||
.build());
|
||||
} else if (getIslands().hasIsland(p.getWorld(), p.getUniqueId())) {
|
||||
// No island in this location - if the player has an island try to teleport them back
|
||||
getIslands().homeTeleport(p.getWorld(), p);
|
||||
@ -122,5 +128,7 @@ public class InvincibleVisitorsListener extends FlagListener implements ClickHan
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,8 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemFactory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -114,6 +116,11 @@ public class InvincibleVisitorsListenerTest {
|
||||
// Island Manager
|
||||
Island island = mock(Island.class);
|
||||
when(island.getOwner()).thenReturn(uuid);
|
||||
@Nullable
|
||||
Location location = mock(Location.class);
|
||||
Vector vector = mock(Vector.class);
|
||||
when(location.toVector()).thenReturn(vector);
|
||||
when(island.getCenter()).thenReturn(location);
|
||||
when(im.getIsland(Mockito.any(World.class), Mockito.any(User.class))).thenReturn(island);
|
||||
optionalIsland = Optional.of(island);
|
||||
// Visitor
|
||||
|
Loading…
Reference in New Issue
Block a user