Package mage

Examples of mage.MageException


    @Override
    public boolean registerAdmin(String password, String sessionId, MageVersion version) throws MageException {
        try {
            if (version.compareTo(Main.getVersion()) != 0) {
                throw new MageException("Wrong client version " + version + ", expecting version " + Main.getVersion());
            }
            if (!password.equals(this.password)) {
                throw new MageException("Wrong password");
            }
            return SessionManager.getInstance().registerAdmin(sessionId);
        } catch (Exception ex) {
            handleException(ex);
        }
View Full Code Here


                        if (aiPlayers > max) {
                            User user = UserManager.getInstance().getUser(userId);
                            if (user != null) {
                                user.showUserMessage("Create tournament", "It's only allowed to use a maximum of " + max + " AI players.");
                            }
                            throw new MageException("No message");
                        }
                    }
                    TableView table = GamesRoomManager.getInstance().getRoom(roomId).createTournamentTable(userId, options);
                    logger.debug("Tournament table " + table.getTableId() + " created");
                    LogServiceImpl.instance.log(LogKeys.KEY_TOURNAMENT_TABLE_CREATED, sessionId, userId.toString(), table.getTableId().toString());
View Full Code Here

     }

    public void handleException(Exception ex) throws MageException {
        if (!ex.getMessage().equals("No message")) {
            logger.fatal("", ex);
            throw new MageException("Server error: " + ex.getMessage());
        }
    }
View Full Code Here

                                endGameInfo();
                                break;
                            case INIT_TIMER:
                                final UUID initPlayerId = event.getPlayerId();
                                if (initPlayerId == null) {
                                    throw new MageException("INIT_TIMER: playerId can't be null");
                                }
                                createPlayerTimer(event.getPlayerId(), game.getPriorityTime());
                                break;
                            case RESUME_TIMER:
                                playerId = event.getPlayerId();
                                if (playerId == null) {
                                    throw new MageException("RESUME_TIMER: playerId can't be null");
                                }
                                timer = timers.get(playerId);
                                if (timer == null) {
                                    Player player = game.getState().getPlayer(playerId);
                                    if (player != null) {
                                        timer = createPlayerTimer(event.getPlayerId(), player.getPriorityTimeLeft());
                                    } else {
                                        throw new MageException("RESUME_TIMER: player can't be null");
                                    }
                                }
                                timer.resume();
                                break;
                            case PAUSE_TIMER:
                                playerId = event.getPlayerId();
                                if (playerId == null) {
                                    throw new MageException("PAUSE_TIMER: playerId can't be null");
                                }
                                timer = timers.get(playerId);
                                if (timer == null) {
                                    throw new MageException("PAUSE_TIMER: couldn't find timer for player: " + playerId);
                                }
                                timer.pause();
                                break;
                        }
                    } catch (MageException ex) {
View Full Code Here

                    }
                    opponent.append(mPlayer.getName());
                }
            }
            if (activePlayers < 2) {
                throw new MageException("Can't start game - Less than two players active - " +activePlayers);
            }
            ServerMessagesUtil.getInstance().incGamesStarted();


            // log about game started
View Full Code Here

        try {
            if (isConnected()) {
                long startTime = System.nanoTime();
                if (!server.ping(sessionId, pingInfo)) {
                    logger.error(new StringBuilder("Ping failed: ").append(this.getUserName()).append(" Session: ").append(sessionId).append(" to MAGE server at ").append(connection.getHost()).append(":").append(connection.getPort()).toString());
                    throw new MageException("Ping failed");
                }
                pingTime.add(System.nanoTime() - startTime);
                long milliSeconds = TimeUnit.MILLISECONDS.convert(pingTime.getLast(), TimeUnit.NANOSECONDS);
                String lastPing = milliSeconds > 0 ? milliSeconds+"ms" : "<1ms";
                if (pingTime.size() > PING_CYCLES) {
View Full Code Here

TOP

Related Classes of mage.MageException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.