Package com.l2jfrozen.gameserver.datatables

Examples of com.l2jfrozen.gameserver.datatables.GameServerTable


    }
  }

  private void handleRegProcess(GameServerAuth gameServerAuth)
  {
    GameServerTable gameServerTable = GameServerTable.getInstance();

    int id = gameServerAuth.getDesiredID();
    byte[] hexId = gameServerAuth.getHexID();

    GameServerInfo gsi = gameServerTable.getRegisteredGameServerById(id);
    // is there a gameserver registered with this id?
    if(gsi != null)
    {
      // does the hex id match?
      if(Arrays.equals(gsi.getHexId(), hexId))
      {
        // check to see if this GS is already connected
        synchronized (gsi)
        {
          if(gsi.isAuthed())
          {
            forceClose(LoginServerFail.REASON_ALREADY_LOGGED8IN);
          }
          else
          {
            attachGameServerInfo(gsi, gameServerAuth);
          }
        }
      }
      else
      {
        // there is already a server registered with the desired id and different hex id
        // try to register this one with an alternative id
        if(Config.ACCEPT_NEW_GAMESERVER && gameServerAuth.acceptAlternateID())
        {
          gsi = new GameServerInfo(id, hexId, this);

          if(gameServerTable.registerWithFirstAvaliableId(gsi))
          {
            attachGameServerInfo(gsi, gameServerAuth);
            gameServerTable.registerServerOnDB(gsi);
          }
          else
          {
            forceClose(LoginServerFail.REASON_NO_FREE_ID);
          }
        }
        else
        {
          // server id is already taken, and we cant get a new one for you
          forceClose(LoginServerFail.REASON_WRONG_HEXID);
        }
      }
    }
    else
    {
      // can we register on this id?
      if(Config.ACCEPT_NEW_GAMESERVER)
      {
        gsi = new GameServerInfo(id, hexId, this);

        if(gameServerTable.register(id, gsi))
        {
          attachGameServerInfo(gsi, gameServerAuth);
          gameServerTable.registerServerOnDB(gsi);
        }
        else
        {
          // some one took this ID meanwhile
          forceClose(LoginServerFail.REASON_ID_RESERVED);
View Full Code Here


    {
      System.out.println("FATAL: Failed loading GameServerTable. Reason: " + e.getMessage());
      e.printStackTrace();
      System.exit(1);
    }
    GameServerTable gameServerTable = GameServerTable.getInstance();
    System.out.println("Welcome to L2JFrozen GameServer Regitering");
    System.out.println("Enter The id of the server you want to register");
    System.out.println("Type 'help' to get a list of ids.");
    System.out.println("Type 'clean' to unregister all currently registered gameservers on this LoginServer.");
    while (!_choiceOk)
    {
      System.out.println("Your choice:");
      _choice = _in.readLine();
      if (_choice.equalsIgnoreCase("help"))
      {
        for (Map.Entry<Integer, String> entry : gameServerTable.getServerNames().entrySet())
        {
          System.out.println("Server: ID: " + entry.getKey() + "\t- " + entry.getValue() + " - In Use: " + (gameServerTable.hasRegisteredGameServerOnId(entry.getKey()) ? "YES" : "NO"));
        }
        System.out.println("You can also see servername.xml");
      }
      else if (_choice.equalsIgnoreCase("clean"))
      {
        System.out.print("This is going to UNREGISTER ALL servers from this LoginServer. Are you sure? (y/n) ");
        _choice = _in.readLine();
        if (_choice.equals("y"))
        {
          GameServerRegister.cleanRegisteredGameServersFromDB();
          gameServerTable.getRegisteredGameServers().clear();
        }
        else
        {
          System.out.println("ABORTED");
        }
      }
      else
      {
        try
        {
          int id = Integer.parseInt(_choice);
          int size = gameServerTable.getServerNames().size();
          if (size == 0)
          {
            System.out.println("No server names avalible, please make sure that servername.xml is in the LoginServer directory.");
            System.exit(1);
          }
         
          _choice="";
         
         
          while (!_choice.equalsIgnoreCase(""))
          {
            System.out.println("External Server Ip:");
            _choice = _in.readLine();
          }
         
          String ip = _choice;
         
          String name = gameServerTable.getServerNameById(id);
          if (name == null)
          {
            System.out.println("No name for id: " + id);
            continue;
          }
         
          if (gameServerTable.hasRegisteredGameServerOnId(id))
          {
            System.out.println("This id is not free");
          }
          else
          {
            byte[] hexId = LoginServerThread.generateHex(16);
            gameServerTable.registerServerOnDB(hexId, id, ip);
            Config.saveHexid(id, new BigInteger(hexId).toString(16), "hexid.txt");
            System.out.println("Server Registered hexid saved to 'hexid.txt'");
            System.out.println("Put this file in the /config folder of your gameserver.");
            return;
          }
View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.datatables.GameServerTable

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.