Search in sources :

Example 11 with Player

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);
        }
    }
}
Also used : Player(org.apollo.game.model.entity.Player)

Example 12 with 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);
    }
}
Also used : Player(org.apollo.game.model.entity.Player)

Example 13 with 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());
    }
}
Also used : Player(org.apollo.game.model.entity.Player) GameService(org.apollo.game.service.GameService)

Example 14 with Player

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);
}
Also used : Player(org.apollo.game.model.entity.Player)

Example 15 with 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;
    }
}
Also used : Player(org.apollo.game.model.entity.Player)

Aggregations

Player (org.apollo.game.model.entity.Player)17 Position (org.apollo.game.model.Position)7 Test (org.junit.Test)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 Region (org.apollo.game.model.area.Region)6 RegionRepository (org.apollo.game.model.area.RegionRepository)6 HashSet (java.util.HashSet)5 World (org.apollo.game.model.World)5 Entity (org.apollo.game.model.entity.Entity)5 StaticGameObject (org.apollo.game.model.entity.obj.StaticGameObject)4 Inventory (org.apollo.game.model.inv.Inventory)4 ItemOnObjectMessage (org.apollo.game.message.impl.ItemOnObjectMessage)3 RegionCoordinates (org.apollo.game.model.area.RegionCoordinates)3 ArrayList (java.util.ArrayList)2 Set (java.util.Set)2 ObjectActionMessage (org.apollo.game.message.impl.ObjectActionMessage)2 Item (org.apollo.game.model.Item)2 Npc (org.apollo.game.model.entity.Npc)2 BufferedInputStream (java.io.BufferedInputStream)1 DataInputStream (java.io.DataInputStream)1