Search in sources :

Example 1 with PreGameItemOption

use of com.ebicep.warlords.game.option.PreGameItemOption in project Warlords by ebicep.

the class PreLobbyState method begin.

@Override
public void begin() {
    this.maxTimer = game.getMap().getLobbyCountdown();
    this.resetTimer();
    game.setAcceptsPlayers(true);
    game.setAcceptsSpectators(false);
    for (Option option : game.getOptions()) {
        if (option instanceof PreGameItemOption) {
            PreGameItemOption preGameItemOption = (PreGameItemOption) option;
            items[preGameItemOption.getSlot()] = preGameItemOption;
        }
    }
}
Also used : PreGameItemOption(com.ebicep.warlords.game.option.PreGameItemOption) Option(com.ebicep.warlords.game.option.Option) PreGameItemOption(com.ebicep.warlords.game.option.PreGameItemOption)

Example 2 with PreGameItemOption

use of com.ebicep.warlords.game.option.PreGameItemOption in project Warlords by ebicep.

the class PreLobbyState method onPlayerReJoinGame.

@Override
public void onPlayerReJoinGame(Player player) {
    State.super.onPlayerReJoinGame(player);
    Team team = game.getPlayerTeam(player.getUniqueId());
    player.getActivePotionEffects().clear();
    if (team == null) {
        player.getInventory().clear();
        player.setAllowFlight(true);
        player.setGameMode(GameMode.SPECTATOR);
    } else {
        player.getInventory().clear();
        player.setAllowFlight(false);
        player.setGameMode(GameMode.ADVENTURE);
        for (PreGameItemOption item : items) {
            if (item != null) {
                player.getInventory().setItem(item.getSlot(), item.getItem(game, player));
            }
        }
        ArmorManager.resetArmor(player, Warlords.getPlayerSettings(player.getUniqueId()).getSelectedClass(), team);
    }
    LobbyLocationMarker location = LobbyLocationMarker.getRandomLobbyLocation(game, team);
    if (location != null) {
        player.teleport(location.getLocation());
        Warlords.setRejoinPoint(player.getUniqueId(), location.getLocation());
    } else {
        System.out.println("Unable to warp player to lobby!, no lobby marker found");
    }
}
Also used : LobbyLocationMarker(com.ebicep.warlords.game.option.marker.LobbyLocationMarker) Team(com.ebicep.warlords.game.Team) PreGameItemOption(com.ebicep.warlords.game.option.PreGameItemOption)

Aggregations

PreGameItemOption (com.ebicep.warlords.game.option.PreGameItemOption)2 Team (com.ebicep.warlords.game.Team)1 Option (com.ebicep.warlords.game.option.Option)1 LobbyLocationMarker (com.ebicep.warlords.game.option.marker.LobbyLocationMarker)1