mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-23 19:25:12 +01:00
Fixes drop into block after island reset issue.
https://github.com/BentoBoxWorld/BentoBox/issues/705
This commit is contained in:
parent
110deea28e
commit
c7f2eb5f2a
@ -3,7 +3,6 @@ package world.bentobox.bentobox.api.commands.island;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||
@ -98,7 +97,6 @@ public class IslandResetCommand extends ConfirmableCommand {
|
||||
private boolean resetIsland(User user, String name) {
|
||||
// Reset the island
|
||||
Player player = user.getPlayer();
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
user.sendMessage("commands.island.create.creating-island");
|
||||
// Get the player's old island
|
||||
Island oldIsland = getIslands().getIsland(getWorld(), player.getUniqueId());
|
||||
|
@ -639,11 +639,12 @@ public class IslandsManager {
|
||||
} else {
|
||||
user.sendMessage("commands.island.go.teleported", TextVariables.NUMBER, String.valueOf(number));
|
||||
}
|
||||
// Exit spectator mode if in it
|
||||
|
||||
if (player.getGameMode().equals(GameMode.SPECTATOR)) {
|
||||
player.setGameMode(plugin.getIWM().getDefaultGameMode(world));
|
||||
}
|
||||
// Exit spectator mode if in it - running this too quickly after teleporting can result in the player dropping a block
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
if (player.getGameMode().equals(GameMode.SPECTATOR)) {
|
||||
player.setGameMode(plugin.getIWM().getDefaultGameMode(world));
|
||||
}
|
||||
}, 4L);
|
||||
// If this is a new island, then run commands and do resets
|
||||
if (newIsland) {
|
||||
// TODO add command running
|
||||
|
@ -604,26 +604,8 @@ public class IslandsManagerTest {
|
||||
IslandsManager im = new IslandsManager(plugin);
|
||||
when(pm.getHomeLocation(Mockito.any(), Mockito.any(User.class), Mockito.eq(0))).thenReturn(null);
|
||||
when(pm.getHomeLocation(Mockito.any(), Mockito.any(User.class), Mockito.eq(1))).thenReturn(location);
|
||||
when(player.getGameMode()).thenReturn(GameMode.SPECTATOR);
|
||||
im.homeTeleport(world, player, 0);
|
||||
Mockito.verify(player).teleport(location);
|
||||
Mockito.verify(player).setGameMode(GameMode.SURVIVAL);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#homeTeleport(World, Player, int)}.
|
||||
*/
|
||||
@Test
|
||||
public void testHomeTeleportPlayerIntDifferentGameMode() {
|
||||
when(iwm.getDefaultGameMode(world)).thenReturn(GameMode.CREATIVE);
|
||||
IslandsManager im = new IslandsManager(plugin);
|
||||
when(pm.getHomeLocation(Mockito.any(), Mockito.any(User.class), Mockito.eq(0))).thenReturn(null);
|
||||
when(pm.getHomeLocation(Mockito.any(), Mockito.any(User.class), Mockito.eq(1))).thenReturn(location);
|
||||
when(player.getGameMode()).thenReturn(GameMode.SPECTATOR);
|
||||
im.homeTeleport(world, player, 0);
|
||||
Mockito.verify(player).teleport(location);
|
||||
Mockito.verify(player).setGameMode(GameMode.CREATIVE);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user