Package marauroa.common

Examples of marauroa.common.Configuration


    marauroad.setArguments(args);

    String log4jConfiguration = null;

    try {
      Configuration conf = Configuration.getConfiguration();
      log4jConfiguration = conf.get("log4j_url");
    } catch (IOException e) {
      System.out.println("ERROR: Marauroa can't find configuration file.");
      System.out.println("Run game configuration to get a valid \"server.ini\" file");
      System.exit(1);
    }
View Full Code Here


  /**
   * Print to $statistics_filename file the content of the statistics object.
   */
  public void print() {
    try {
      Configuration conf = Configuration.getConfiguration();
      String filename = conf.get("statistics_filename");
      if (filename == null) {
        return;
      }

      long currentTime = System.currentTimeMillis();
View Full Code Here

   * @return A shared instance of RPObjectFactory
     * @throws NoFactoryConfException if the factory is not configured correctly
   */
  public static RPObjectFactory get() throws NoFactoryConfException {
    try {
          Configuration conf = Configuration.getConfiguration();
          String factoryName = conf.get("factory_implementation");
          if (factoryName == null) {
            factoryName = RPObjectFactory.class.getName();
          }

          return get(factoryName);
View Full Code Here

      playerContainer = PlayerEntryContainer.getContainer();

      playersToRemove = new LinkedList<PlayerEntry>();
      this.netMan = netMan;

      Configuration conf = Configuration.getConfiguration();
      /*
       * This method loads the extensions that implement the game server
       * code.
       */
      initializeExtensions(conf);

      String duration = conf.get("turn_length");
      turnDuration = Long.parseLong(duration);
      turn = 0;
    } catch (Exception e) {
      logger.warn("ABORT: Unable to create RPZone, RPRuleProcessor or RPAIManager instances",
              e);
View Full Code Here

     *             if there is any database problem.
     */
    public void addLoginEvent(InetAddress addr, boolean loginResult) throws SQLException {
      String service = null;
      try {
        Configuration conf = Configuration.getConfiguration();
        if (conf.has("server_service")) {
          service = conf.get("server_service");
        } else {
          service = conf.get("server_typeGame");
        }
      } catch (IOException e) {
        logger.error(e, e);
      }
      DAORegister.get().get(LoginEventDAO.class).addLoginEvent(username, addr, service, seed, loginResult);
View Full Code Here

    // empty
  }

  private void configureGameDatabaseAccess() {
    try {
      Configuration conf = Configuration.getConfiguration();
      String database_type = conf.get("database_implementation");

      // compatibility: Ignore old JDBCDatabase entry and invoke initialize()
      // using reflecting because old database factories are not required
      // to extend this class.
      if ((database_type != null) && (!database_type.equals("marauroa.server.game.db.JDBCDatabase"))) {
View Full Code Here

   * @return DatabaseAdapter for the specified database
   */
  @SuppressWarnings("unchecked")
    public DatabaseAdapter create() {
    try {
      Configuration configuration = Configuration.getConfiguration();
      String adapter = configuration.get("database_adapter");
      if (adapter == null) {
        return new MySQLDatabaseAdapter(connInfo);
      }
      Class<DatabaseAdapter> clazz= (Class<DatabaseAdapter>) Class.forName(adapter);
      Constructor<DatabaseAdapter> ctor = clazz.getConstructor(Properties.class);
View Full Code Here

   * @throws SQLException in case of an database error
   * @throws IOException in case of an input/output error
   */
  public boolean isAccountCreationLimitReached(DBTransaction transaction, String address) throws SQLException, IOException  {

    Configuration conf = Configuration.getConfiguration();
    String whiteList = "," + conf.get("ip_whitelist", "127.0.0.1") + ",";
    if (whiteList.indexOf("," + address + ",") > -1) {
      return false;
    }

    // count the number of recently created accounts from this ip-address
    String query = "SELECT count(DISTINCT username) "
      + "FROM account, loginEvent "
      + "WHERE account.id=loginEvent.player_id AND address='[address]' AND account.timedate>'[timestamp]'";

    Map<String, Object> params = new HashMap<String, Object>();
    params.put("address", address);

    // apply the time frame
    Calendar calendar = new GregorianCalendar();
    calendar.add(Calendar.SECOND, -1 * conf.getInt("account_creation_counting_time", TimeoutConf.ACCOUNT_CREATION_COUNTINGTIME));
    params.put("timestamp", new Timestamp(calendar.getTimeInMillis()).toString());

    // do the database query and evaluate the result
    int attemps = transaction.querySingleCellInt(query, params);
    return attemps > conf.getInt("account_creation_limit", TimeoutConf.ACCOUNT_CREATION_LIMIT);
  }
View Full Code Here

   * @throws SQLException if there is any problem at database
   */
  public boolean isCharacterCreationLimitReached(DBTransaction transaction,
      String username, String address) throws IOException, SQLException {

    Configuration conf = Configuration.getConfiguration();
    String whiteList = "," + conf.get("ip_whitelist", "127.0.0.1") + ",";
    if (whiteList.indexOf("," + address + ",") > -1) {
      return false;
    }

    Map<String, Object> params = new HashMap<String, Object>();
    params.put("address", address);
    params.put("username", username);

    // apply the time frame
    Calendar calendar = new GregorianCalendar();
    calendar.add(Calendar.SECOND, -1 * conf.getInt("character_creation_counting_time", TimeoutConf.CHARACTER_CREATION_COUNTINGTIME));
    params.put("timestamp", new Timestamp(calendar.getTimeInMillis()).toString());

    // count the number of recently created characters from this ip-address
    String query = "SELECT count(DISTINCT charname) "
      + "FROM characters, account "
      + "WHERE characters.player_id=account.id AND account.username='[username]' AND characters.timedate>'[timestamp]'";

    // do the database query and evaluate the result
    int attemps = transaction.querySingleCellInt(query, params);
    if (attemps > conf.getInt("character_creation_limit", TimeoutConf.CHARACTER_CREATION_LIMIT)) {
      return true;
    }

    // count the number of recently created characters from this ip-address
    query = "SELECT count(DISTINCT charname) "
      + "FROM characters, account, loginEvent "
      + "WHERE characters.player_id=account.id AND account.id=loginEvent.player_id AND address='[address]' AND characters.timedate>'[timestamp]'";

    attemps = transaction.querySingleCellInt(query, params);
    return attemps > conf.getInt("character_creation_limit", TimeoutConf.CHARACTER_CREATION_LIMIT);
  }
View Full Code Here

        return;
      }

      /* Now we count the number of connections from this ip-address */
      int count = info.countConnectionsFromSameIPAddress(playerContainer);
      Configuration conf = Configuration.getConfiguration();
      int limit = conf.getInt("parallel_connection_limit", TimeoutConf.PARALLEL_CONNECTION_LIMIT);
      if (count > limit) {
        String whiteList = "," + conf.get("ip_whitelist", "127.0.0.1") + ",";
        if (whiteList.indexOf("," + info.address + ",") < 0) {
          logger.info("to many parallel connections from " + info.address + " rejecting login of " + info.username);

          /* Send player the Login NACK message */
          MessageS2CLoginMessageNACK msgLoginMessageNACK = new MessageS2CLoginMessageNACK(command.getChannel(),
View Full Code Here

TOP

Related Classes of marauroa.common.Configuration

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.