Example #1
0
  @Override
  protected void thinkActive() {
    Player actor = getActor();
    // FPCInfo player	= FPCInfo.getInstance(actor);

    if (actor.isActionsDisabled()) {
      return;
    }

    if (_def_think) {
      if (doTask()) {
        clearTasks();
      }
      return;
    }

    // player.cancelShop();

    if (Rnd.chance(0.5)) {
      actor.standUp();
      if (Rnd.chance(20)) randomWalk(1000);
      else {
        List<GameObject> chars = World.getAroundObjects(actor, 2000, 500);
        if (chars.size() == 0) return;
        GameObject randomChar = chars.get(Rnd.get(chars.size()));
        if (!randomChar.isDoor()) actor.moveToLocation(randomChar.getLoc(), 50, true);
      }
    }
  }
 @Override
 public void broadcastCharInfoImpl() {
   for (Player player : World.getAroundPlayers(this)) player.sendPacket(new FakePlayerInfo(this));
 }
Example #3
0
  @SuppressWarnings("unchecked")
  public GameServer() throws Exception {
    _instance = this;
    _serverStarted = time();
    _listeners = new GameServerListenerList();

    new File("./log/").mkdir();

    version = new Version(GameServer.class);

    _log.info("=================================================");
    _log.info("Project Revision: ........ " + PROJECT_REVISION);
    _log.info("Build Revision: .......... " + version.getRevisionNumber());
    _log.info("Update: .................. " + UPDATE_NAME);
    _log.info("Build date: .............. " + version.getBuildDate());
    _log.info("Compiler version: ........ " + version.getBuildJdk());
    _log.info("=================================================");
    Clients.Load();
    // Initialize config
    Config.load();
    // Check binding address
    checkFreePorts();
    // Initialize database
    Class.forName(Config.DATABASE_DRIVER).newInstance();
    DatabaseFactory.getInstance().getConnection().close();

    IdFactory _idFactory = IdFactory.getInstance();
    if (!_idFactory.isInitialized()) {
      _log.error("Could not read object IDs from DB. Please Check Your Data.");
      throw new Exception("Could not initialize the ID factory");
    }

    CacheManager.getInstance();

    ThreadPoolManager.getInstance();

    LfcDAO.LoadArenas();
    LfcStatisticDAO.LoadGlobalStatistics();
    LfcStatisticDAO.LoadLocalStatistics();

    CustomStatsDAO.LoadCustomValues();

    PremiumAccountRatesHolder.loadLists();

    BotCheckManager.loadBotQuestions();

    FreePremiumAccountsDao.LoadTable();

    HidenItemsDAO.LoadAllHiddenItems();

    CustomHeroDAO.getInstance();

    HWIDBan.getInstance().load();

    Scripts.getInstance();

    GeoEngine.load();

    Strings.reload();

    GameTimeController.getInstance();

    World.init();

    Parsers.parseAll();

    ItemsDAO.getInstance();

    CrestCache.getInstance();

    ImagesCache.getInstance();

    CharacterDAO.getInstance();

    ClanTable.getInstance();

    DailyQuestsManager.EngageSystem();

    //		FakePlayersTable.getInstance();
    SkillTreeTable.getInstance();

    SubClassTable.getInstance();

    EnchantHPBonusTable.getInstance();

    PetSkillsTable.getInstance();

    ItemAuctionManager.getInstance();

    SpawnManager.getInstance().spawnAll();

    FakePlayersSpawnManager.getInstance().spawnAll();

    StaticObjectHolder.getInstance().spawnAll();

    RaidBossSpawnManager.getInstance();

    Scripts.getInstance().init();

    ItemHolder.getInstance().initItems();

    DimensionalRiftManager.getInstance();

    Announcements.getInstance();

    LotteryManager.getInstance();

    PlayerMessageStack.getInstance();

    if (Config.AUTODESTROY_ITEM_AFTER > 0) ItemsAutoDestroy.getInstance();

    MonsterRace.getInstance();

    if (Config.ENABLE_OLYMPIAD) {
      Olympiad.load();
      Hero.getInstance();
    }

    PetitionManager.getInstance();

    CursedWeaponsManager.getInstance();

    if (Config.ALLOW_WEDDING) {
      CoupleManager.getInstance();
    }

    ItemHandler.getInstance();

    AdminCommandHandler.getInstance().log();
    UserCommandHandler.getInstance().log();
    VoicedCommandHandler.getInstance().log();

    TaskManager.getInstance();

    _log.info("=[Events]=========================================");
    ResidenceHolder.getInstance().callInit();
    EventHolder.getInstance().callInit();
    _log.info("==================================================");

    BoatHolder.getInstance().spawnAll();
    CastleManorManager.getInstance();

    Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());

    _log.info("IdFactory: Free ObjectID's remaining: " + IdFactory.getInstance().size());

    if (Config.ALT_FISH_CHAMPIONSHIP_ENABLED) FishingChampionShipManager.getInstance();

    HellboundManager.getInstance();

    NaiaTowerManager.getInstance();
    NaiaCoreManager.getInstance();

    SoDManager.getInstance();
    SoIManager.getInstance();
    SoHManager.getInstance();

    MiniGameScoreManager.getInstance();

    CommissionManager.getInstance().init();

    WorldStatisticsManager.getInstance();
    ArcanManager.getInstance();
    ToIManager.getInstance();
    ParnassusManager.getInstance();
    BaltusManager.getInstance();
    Shutdown.getInstance().schedule(Config.RESTART_AT_TIME, Shutdown.RESTART);

    /* CCP Guard START
    ccpGuard.Protection.Init();
    ** CCP Guard END*/

    _log.info("GameServer Started");
    _log.info("Maximum Numbers of Connected Players: " + Config.MAXIMUM_ONLINE_USERS);

    GamePacketHandler gph = new GamePacketHandler();

    InetAddress serverAddr =
        Config.GAMESERVER_HOSTNAME.equalsIgnoreCase("*")
            ? null
            : InetAddress.getByName(Config.GAMESERVER_HOSTNAME);

    _selectorThreads = new ArrayList<SelectorThread<GameClient>>(Config.PORTS_GAME.length);
    for (int i = 0; i < Config.PORTS_GAME.length; i++) {
      SelectorThread<GameClient> selectorThread =
          new SelectorThread<GameClient>(Config.SELECTOR_CONFIG, gph, gph, gph, null);
      selectorThread.openServerSocket(serverAddr, Config.PORTS_GAME[i]);
      selectorThread.start();
      _selectorThreads.add(i, selectorThread);
    }

    AuthServerCommunication.getInstance().start();

    if (Config.SERVICES_OFFLINE_TRADE_RESTORE_AFTER_RESTART)
      ThreadPoolManager.getInstance().schedule(new RestoreOfflineTraders(), 30000L);

    if (Config.ONLINE_GENERATOR_ENABLED)
      ThreadPoolManager.getInstance()
          .scheduleAtFixedRate(
              new OnlineTxtGenerator(), 5000L, Config.ONLINE_GENERATOR_DELAY * 60 * 1000L);

    getListeners().onStart();

    if (Config.IS_TELNET_ENABLED) statusServer = new TelnetServer();
    else _log.info("Telnet server is currently disabled.");

    _log.info("=================================================");
    String memUsage = new StringBuilder().append(StatsUtils.getMemUsage()).toString();
    for (String line : memUsage.split("\n")) _log.info(line);
    _log.info("=================================================");
  }
Example #4
0
  @Override
  protected void runImpl() {
    Player activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    if (activeChar.isOutOfControl()) {
      activeChar.sendActionFailed();
      return;
    }

    if (activeChar.isProcessingRequest()) {
      activeChar.sendPacket(SystemMsg.WAITING_FOR_ANOTHER_REPLY);
      return;
    }

    if (activeChar.isChaosFestivalParticipant()) {
      activeChar.sendPacket(
          SystemMsg
              .YOU_CANNOT_INVITE_A_FRIEND_OR_PARTY_WHILE_PARTICIPATING_IN_THE_CEREMONY_OF_CHAOS);
      return;
    }

    Player target = World.getPlayer(_name);
    if (target == null) {
      FakePlayerInstance fakePlayer = GameObjectsStorage.getFakePlayerByName(_name);
      if (fakePlayer != null) {
        new Request(L2RequestType.PARTY, activeChar, null)
            .setTimeout(10000L)
            .set("itemDistribution", _itemDistribution);
        activeChar.sendPacket(
            new SystemMessage2(SystemMsg.C1_HAS_BEEN_INVITED_TO_THE_PARTY).addName(fakePlayer));
        return;
      }
      activeChar.sendPacket(SystemMsg.THAT_PLAYER_IS_NOT_ONLINE);
      return;
    }

    if (target == activeChar) {
      activeChar.sendPacket(SystemMsg.THAT_IS_AN_INCORRECT_TARGET);
      activeChar.sendActionFailed();
      return;
    }

    if (Config.DISABLE_PARTY_ON_EVENT && target.isInPvPEvent()) {
      activeChar.sendPacket(new SystemMessage2(SystemMsg.C1_IS_ON_ANOTHER_TASK).addName(target));
      return;
    }

    if (Config.DISABLE_PARTY_ON_EVENT && activeChar.isInPvPEvent()) {
      activeChar.sendPacket(new SystemMessage2(SystemMsg.C1_IS_ON_ANOTHER_TASK).addName(target));
      return;
    }

    if (target.isChaosFestivalParticipant()) {
      activeChar.sendActionFailed();
      return;
    }

    if (target.isBusy()) {
      activeChar.sendPacket(new SystemMessage2(SystemMsg.C1_IS_ON_ANOTHER_TASK).addName(target));
      return;
    }

    IStaticPacket problem = target.canJoinParty(activeChar);
    if (problem != null) {
      activeChar.sendPacket(problem);
      return;
    }

    if (activeChar.isInParty()) {
      if (activeChar.getParty().getMemberCount() >= Party.MAX_SIZE) {
        activeChar.sendPacket(SystemMsg.THE_PARTY_IS_FULL);
        return;
      }

      // Только Party Leader может приглашать новых членов
      if (Config.PARTY_LEADER_ONLY_CAN_INVITE && !activeChar.getParty().isLeader(activeChar)) {
        activeChar.sendPacket(SystemMsg.ONLY_THE_LEADER_CAN_GIVE_OUT_INVITATIONS);
        return;
      }

      if (activeChar.getParty().isInDimensionalRift()) {
        activeChar.sendMessage(
            new CustomMessage(
                "l2s.gameserver.clientpackets.RequestJoinParty.InDimensionalRift", activeChar));
        activeChar.sendActionFailed();
        return;
      }
    }

    if (target.isFakePlayer() && activeChar.isGM()) {
      Party party = activeChar.getParty();

      if (party == null) {
        activeChar.setParty(party = new Party(activeChar, Party.ITEM_ORDER_SPOIL));
      }

      party.addPartyMember(target);
      return;
    }

    new Request(L2RequestType.PARTY, activeChar, target)
        .setTimeout(10000L)
        .set("itemDistribution", _itemDistribution);

    target.sendPacket(new AskJoinParty(activeChar.getName(), _itemDistribution));
    activeChar.sendPacket(
        new SystemMessage2(SystemMsg.C1_HAS_BEEN_INVITED_TO_THE_PARTY).addName(target));
  }