@Test public void testUpdatePlayer() throws Exception { WorldClientHandler worldClientHandler = Mockito.mock(WorldClientHandler.class); WorldAuthenticator worldAuthenticator = new WorldAuthenticator(connection); Actor actor = mock(Actor.class); User user = new User(); user.setUsername("TestAccount1"); when(actor.getVector2D()).thenReturn(new Vector2D(10, 10)); when(worldClientHandler.getPlayer()).thenReturn(actor); when(worldClientHandler.getUser()).thenReturn(user); worldAuthenticator.updatePlayer(worldClientHandler); String query = "SELECT * FROM jenjin_user_properties WHERE username='TestAccount1' AND propertyName='xCoord'"; PreparedStatement statement = connection.prepareStatement(query, TYPE_SCROLL_SENSITIVE, CONCUR_UPDATABLE); ResultSet results = statement.executeQuery(); results.next(); assertEquals(results.getDouble("propertyValue"), 10d); }
public void updatePlayer(WorldClientHandler worldClientHandler) { Actor player = worldClientHandler.getPlayer(); User user = worldClientHandler.getUser(); user.getProperties().put(X_COORD, player.getVector2D().getXCoordinate()); user.getProperties().put(Y_COORD, player.getVector2D().getYCoordinate()); user.getProperties().put(ZONE_ID, player.getZoneID()); try { super.updateUserProperties(user); } catch (SQLException e) { LOGGER.log(Level.SEVERE, "Unable to update player information in database!", e); } }
WorldAuthenticator extends Authenticator { public void updatePlayer(WorldClientHandler worldClientHandler) { Actor player = worldClientHandler.getPlayer(); User user = worldClientHandler.getUser(); user.getProperties().put(X_COORD, player.getVector2D().getXCoordinate()); user.getProperties().put(Y_COORD, player.getVector2D().getYCoordinate()); user.getProperties().put(ZONE_ID, player.getZoneID()); try { super.updateUserProperties(user); } catch (SQLException e) { LOGGER.log(Level.SEVERE, "Unable to update player information in database!", e); } } }
WorldAuthenticator extends Authenticator { public void updatePlayer(WorldClientHandler worldClientHandler) { Actor player = worldClientHandler.getPlayer(); User user = worldClientHandler.getUser(); user.getProperties().put(X_COORD, player.getVector2D().getXCoordinate()); user.getProperties().put(Y_COORD, player.getVector2D().getYCoordinate()); user.getProperties().put(ZONE_ID, player.getZoneID()); try { super.updateUserProperties(user); } catch (SQLException e) { LOGGER.log(Level.SEVERE, "Unable to update player information in database!", e); } } WorldAuthenticator(Connection connection); }
WorldAuthenticator extends Authenticator { public void updatePlayer(WorldClientHandler worldClientHandler) { Actor player = worldClientHandler.getPlayer(); User user = worldClientHandler.getUser(); user.getProperties().put(X_COORD, player.getVector2D().getXCoordinate()); user.getProperties().put(Y_COORD, player.getVector2D().getYCoordinate()); user.getProperties().put(ZONE_ID, player.getZoneID()); try { super.updateUserProperties(user); } catch (SQLException e) { LOGGER.log(Level.SEVERE, "Unable to update player information in database!", e); } } WorldAuthenticator(Connection connection); void updatePlayer(WorldClientHandler worldClientHandler); }
WorldAuthenticator extends Authenticator { public void updatePlayer(WorldClientHandler worldClientHandler) { Actor player = worldClientHandler.getPlayer(); User user = worldClientHandler.getUser(); user.getProperties().put(X_COORD, player.getVector2D().getXCoordinate()); user.getProperties().put(Y_COORD, player.getVector2D().getYCoordinate()); user.getProperties().put(ZONE_ID, player.getZoneID()); try { super.updateUserProperties(user); } catch (SQLException e) { LOGGER.log(Level.SEVERE, "Unable to update player information in database!", e); } } WorldAuthenticator(Connection connection); void updatePlayer(WorldClientHandler worldClientHandler);  }