Example #1
0
  public void setGalaxyStatus(int statusId) {

    int galaxyId = config.getInt("GALAXY_ID");

    try {
      PreparedStatement ps =
          databaseConnection.preparedStatement(
              "UPDATE \"connectionServers\" SET \"statusId\"=? WHERE \"galaxyId\"=?");
      ps.setInt(1, statusId);
      ps.setInt(2, galaxyId);
      ps.executeUpdate();
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
Example #2
0
  public void start() {
    config = new Config();
    config.setFilePath("nge.cfg");
    if (!(config.loadConfigFile())) {
      config = DefaultConfig.getConfig();
    }

    // Database
    databaseConnection = new DatabaseConnection();
    databaseConnection.connect(
        config.getString("DB.URL"),
        config.getString("DB.NAME"),
        config.getString("DB.USER"),
        config.getString("DB.PASS"),
        "postgresql");

    databaseConnection2 = new DatabaseConnection();
    setGalaxyStatus(1);
    creatureODB = new ObjectDatabase("creature", true, false, true);
    mailODB = new ObjectDatabase("mails", true, false, true);

    // Services
    loginService = new LoginService(this);
    connectionService = new ConnectionService(this);
    characterService = new CharacterService(this);
    mapService = new MapService(this);

    objectService = new ObjectService(this);
    terrainService = new TerrainService(this);
    updateService = new UpdateService(this);
    scriptService = new ScriptService(this);
    commandService = new CommandService(this);
    chatService = new ChatService(this);
    attributeService = new AttributeService(this);
    suiService = new SUIService(this);
    combatService = new CombatService(this);
    playerService = new PlayerService(this);
    buffService = new BuffService(this);
    groupService = new GroupService(this);
    skillModService = new SkillModService(this);

    // Ping Server
    try {
      PingServer pingServer = new PingServer(config.getInt("PING.PORT"));
      pingServer.bind();
    } catch (IOException e) {
      e.printStackTrace();
    }

    // Login Server
    loginDispatch = new NetworkDispatch(this, false);
    loginDispatch.addService(loginService);

    loginServer = new MINAServer(loginDispatch, config.getInt("LOGIN.PORT"));
    loginServer.start();

    // Zone Server
    zoneDispatch = new NetworkDispatch(this, true);
    zoneDispatch.addService(connectionService);
    zoneDispatch.addService(characterService);
    zoneDispatch.addService(objectService);
    zoneDispatch.addService(commandService);
    zoneDispatch.addService(chatService);
    zoneDispatch.addService(suiService);
    zoneDispatch.addService(mapService);
    zoneDispatch.addService(playerService);

    zoneServer = new MINAServer(zoneDispatch, config.getInt("ZONE.PORT"));
    zoneServer.start();

    // Planets
    terrainService.addPlanet(1, "tatooine", "terrain/tatooine.trn", true);
    terrainService.addPlanet(2, "naboo", "terrain/naboo.trn", true);
    terrainService.addPlanet(3, "corellia", "terrain/corellia.trn", true);
    terrainService.addPlanet(4, "rori", "terrain/rori.trn", true);
    terrainService.addPlanet(5, "lok", "terrain/lok.trn", true);
    terrainService.addPlanet(6, "dantooine", "terrain/dantooine.trn", true);
    terrainService.addPlanet(7, "talus", "terrain/talus.trn", true);
    terrainService.addPlanet(8, "yavin4", "terrain/yavin4.trn", true);
    terrainService.addPlanet(9, "endor", "terrain/endor.trn", true);
    terrainService.addPlanet(10, "dathomir", "terrain/dathomir.trn", true);
    terrainService.loadSnapShotObjects();

    // Zone services that need to be loaded after the above
    simulationService = new SimulationService(this);
    zoneDispatch.addService(simulationService);

    // Static Spawns
    staticService = new StaticService(this);
    staticService.spawnStatics();

    guildService = new GuildService(this);
    zoneDispatch.addService(guildService);

    gcwService = new GCWService(this);
    zoneDispatch.addService(gcwService);

    tradeService = new TradeService(this);
    zoneDispatch.addService(tradeService);

    didServerCrash = false;
    System.out.println("Started Server.");
    setGalaxyStatus(2);
  }