@Test public void onPlayerMove() { GameOptions gameOptions = mock(GameOptions.class); Location lobby = mock(Location.class); when(gameOptions.getLobby()).thenReturn(lobby); WaitingMoveListener waitingMoveListener = new WaitingMoveListener(gameOptions); Player player = mock(Player.class); Location to = mock(Location.class); when(to.getY()).thenReturn(-1D); PlayerMoveEvent playerMoveEvent = new PlayerMoveEvent(player, mock(Location.class), to); waitingMoveListener.onPlayerMove(playerMoveEvent); verify(player).teleport(eq(lobby)); }
@EventHandler public void onPlayerMove(PlayerMoveEvent playerMoveEvent) { if (playerMoveEvent.getTo().getY() < 0) { playerMoveEvent.getPlayer().teleport(gameOptions.getLobby()); } }
WaitingMoveListener extends WaitingStateListener { @EventHandler public void onPlayerMove(PlayerMoveEvent playerMoveEvent) { if (playerMoveEvent.getTo().getY() < 0) { playerMoveEvent.getPlayer().teleport(gameOptions.getLobby()); } } }
WaitingMoveListener extends WaitingStateListener { @EventHandler public void onPlayerMove(PlayerMoveEvent playerMoveEvent) { if (playerMoveEvent.getTo().getY() < 0) { playerMoveEvent.getPlayer().teleport(gameOptions.getLobby()); } }  }
WaitingMoveListener extends WaitingStateListener { @EventHandler public void onPlayerMove(PlayerMoveEvent playerMoveEvent) { if (playerMoveEvent.getTo().getY() < 0) { playerMoveEvent.getPlayer().teleport(gameOptions.getLobby()); } }  @EventHandler void onPlayerMove(PlayerMoveEvent playerMoveEvent); }
WaitingMoveListener extends WaitingStateListener { @EventHandler public void onPlayerMove(PlayerMoveEvent playerMoveEvent) { if (playerMoveEvent.getTo().getY() < 0) { playerMoveEvent.getPlayer().teleport(gameOptions.getLobby()); } }  @EventHandler void onPlayerMove(PlayerMoveEvent playerMoveEvent);  }