use of org.apollo.game.model.entity.Player in project apollo by apollo-rsps.
the class GameService method finalizeRegistrations.
/**
* Finalizes the registration of Player's queued to be registered.
*/
private void finalizeRegistrations() {
for (int count = 0; count < REGISTRATIONS_PER_CYCLE; count++) {
LoginPlayerRequest request = newPlayers.poll();
if (request == null) {
break;
}
Player player = request.player;
if (world.isPlayerOnline(player.getUsername())) {
request.session.sendLoginFailure(LoginConstants.STATUS_ACCOUNT_ONLINE);
} else if (world.getPlayerRepository().full()) {
request.session.sendLoginFailure(LoginConstants.STATUS_SERVER_FULL);
} else {
request.session.sendLoginSuccess(player);
finalizePlayerRegistration(player);
}
}
}
use of org.apollo.game.model.entity.Player in project apollo by apollo-rsps.
the class GameService method finalizeUnregistrations.
/**
* Finalizes the unregistration of Player's queued to be unregistered.
*/
private void finalizeUnregistrations() {
LoginService loginService = context.getLoginService();
for (int count = 0; count < DEREGISTRATIONS_PER_CYCLE; count++) {
Player player = oldPlayers.poll();
if (player == null) {
break;
}
loginService.submitSaveRequest(player.getSession(), player);
}
}
use of org.apollo.game.model.entity.Player in project apollo by apollo-rsps.
the class LoginSession method handlePlayerLoaderResponse.
/**
* Handles a response from the login service.
*
* @param request The request this response corresponds to.
* @param response The response.
*/
public void handlePlayerLoaderResponse(LoginRequest request, PlayerLoaderResponse response) {
this.request = request;
GameService service = context.getGameService();
Optional<Player> optional = response.getPlayer();
if (optional.isPresent()) {
service.registerPlayer(optional.get(), this);
} else {
sendLoginFailure(response.getStatus());
}
}
use of org.apollo.game.model.entity.Player in project apollo by apollo-rsps.
the class DummyPlayerSerializer method loadPlayer.
@Override
public PlayerLoaderResponse loadPlayer(PlayerCredentials credentials) {
int status = LoginConstants.STATUS_OK;
Player player = new Player(world, credentials, TUTORIAL_ISLAND_SPAWN);
player.setPrivilegeLevel(PrivilegeLevel.ADMINISTRATOR);
player.setMembers(MembershipStatus.PAID);
return new PlayerLoaderResponse(status, player);
}
use of org.apollo.game.model.entity.Player in project apollo by apollo-rsps.
the class PlayerActionVerificationHandler method handle.
@Override
public void handle(Player player, PlayerActionMessage message) {
int index = message.getIndex();
MobRepository<Player> repository = world.getPlayerRepository();
if (index < 0 || index >= repository.capacity()) {
message.terminate();
return;
}
Player other = repository.get(index);
if (other == null || !player.getPosition().isWithinDistance(other.getPosition(), player.getViewingDistance() + 1)) {
// +1 in case it was decremented after the player clicked the action.
message.terminate();
return;
}
}
Aggregations