Package lineage2.gameserver

Examples of lineage2.gameserver.ThreadPoolManager


  public void onEvtDead(Creature killer)
  {
    final NpcInstance actor = getActor();
    super.onEvtDead(killer);
    actor.deleteMe();
    ThreadPoolManager.getInstance().schedule(new RunnableImpl()
    {
      @Override
      public void runImpl()
      {
        final NpcTemplate template = NpcHolder.getInstance().getTemplate(18602);
View Full Code Here


          getZone("[soi_hos_attack_attackup_5]").setActive(false);
          spawnRoom(6);
        }
      }
      else if(self.getNpcId() == Yehan)
        ThreadPoolManager.getInstance().schedule(new RunnableImpl(){
          @Override
          public void runImpl() throws Exception
          {
            spawnRoom(7);
            setReenterTime(System.currentTimeMillis());
View Full Code Here

   * @param time String
   * @param shutdownMode int
   */
  public void schedule(String time, int shutdownMode)
  {
    SchedulingPattern cronTime;
    try
    {
      cronTime = new SchedulingPattern(time);
    }
    catch (InvalidPatternException e)
    {
      return;
    }
    int seconds = (int) ((cronTime.next(System.currentTimeMillis()) / 1000L) - (System.currentTimeMillis() / 1000L));
    schedule(seconds, shutdownMode);
  }
View Full Code Here

  {
    _instance = this;
    _serverStarted = time();
    _listeners = new GameServerListenerList();
    new File("./log/").mkdir();
    version = new Version(GameServer.class);
    _log.info("=================================================");
    _log.info("Revision: ................ " + version.getRevisionNumber());
    _log.info("Build date: .............. " + version.getBuildDate());
    _log.info("Compiler version: ........ " + version.getBuildJdk());
    _log.info("=================================================");
View Full Code Here

   * @param task ExecutedTask
   * @return boolean
   */
  private boolean launchTask(ExecutedTask task)
  {
    final ThreadPoolManager scheduler = ThreadPoolManager.getInstance();
    final TaskTypes type = task.getType();
    if (type == TYPE_STARTUP)
    {
      task.run();
      return false;
    }
    else if (type == TYPE_SHEDULED)
    {
      long delay = Long.valueOf(task.getParams()[0]);
      task._scheduled = scheduler.schedule(task, delay);
      return true;
    }
    else if (type == TYPE_FIXED_SHEDULED)
    {
      long delay = Long.valueOf(task.getParams()[0]);
      long interval = Long.valueOf(task.getParams()[1]);
      task._scheduled = scheduler.scheduleAtFixedRate(task, delay, interval);
      return true;
    }
    else if (type == TYPE_TIME)
    {
      try
      {
        Date desired = DateFormat.getInstance().parse(task.getParams()[0]);
        long diff = desired.getTime() - System.currentTimeMillis();
        if (diff >= 0)
        {
          task._scheduled = scheduler.schedule(task, diff);
          return true;
        }
        _log.info("Task " + task.getId() + " is obsoleted.");
      }
      catch (Exception e)
      {
      }
    }
    else if (type == TYPE_SPECIAL)
    {
      ScheduledFuture<?> result = task.getTask().launchSpecial(task);
      if (result != null)
      {
        task._scheduled = result;
        return true;
      }
    }
    else if (type == TYPE_GLOBAL_TASK)
    {
      long interval = Long.valueOf(task.getParams()[0]) * 86400000L;
      String[] hour = task.getParams()[1].split(":");
      if (hour.length != 3)
      {
        _log.warn("Task " + task.getId() + " has incorrect parameters");
        return false;
      }
      Calendar check = Calendar.getInstance();
      check.setTimeInMillis(task.getLastActivation() + interval);
      Calendar min = Calendar.getInstance();
      try
      {
        min.set(Calendar.HOUR_OF_DAY, Integer.valueOf(hour[0]));
        min.set(Calendar.MINUTE, Integer.valueOf(hour[1]));
        min.set(Calendar.SECOND, Integer.valueOf(hour[2]));
      }
      catch (Exception e)
      {
        _log.warn("Bad parameter on task " + task.getId() + ": " + e.getMessage());
        return false;
      }
      long delay = min.getTimeInMillis() - System.currentTimeMillis();
      if (check.after(min) || (delay < 0))
      {
        delay += interval;
      }
      task._scheduled = scheduler.scheduleAtFixedRate(task, delay, interval);
      return true;
    }
    return false;
  }
View Full Code Here

    {
      notInitialized = false;
      _raceNumber = ServerVariables.getInt("monster_race", 1);
      history = new ArrayList<>();
      managers = new CopyOnWriteArraySet<>();
      ThreadPoolManager s = ThreadPoolManager.getInstance();
      s.scheduleAtFixedRate(new Announcement(SystemMessage.TICKETS_ARE_NOW_AVAILABLE_FOR_THE_S1TH_MONSTER_RACE), 0, 10 * MINUTE);
      s.scheduleAtFixedRate(new Announcement(SystemMessage.WE_ARE_NOW_SELLING_TICKETS_FOR_THE_S1TH_MONSTER_RACE), 30 * SECOND, 10 * MINUTE);
      s.scheduleAtFixedRate(new Announcement(SystemMessage.TICKETS_ARE_NOW_AVAILABLE_FOR_THE_S1TH_MONSTER_RACE), MINUTE, 10 * MINUTE);
      s.scheduleAtFixedRate(new Announcement(SystemMessage.WE_ARE_NOW_SELLING_TICKETS_FOR_THE_S1TH_MONSTER_RACE), MINUTE + (30 * SECOND), 10 * MINUTE);
      s.scheduleAtFixedRate(new Announcement(SystemMessage.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_CEASE_IN_S1_MINUTE_S), 2 * MINUTE, 10 * MINUTE);
      s.scheduleAtFixedRate(new Announcement(SystemMessage.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_CEASE_IN_S1_MINUTE_S), 3 * MINUTE, 10 * MINUTE);
      s.scheduleAtFixedRate(new Announcement(SystemMessage.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_CEASE_IN_S1_MINUTE_S), 4 * MINUTE, 10 * MINUTE);
      s.scheduleAtFixedRate(new Announcement(SystemMessage.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_CEASE_IN_S1_MINUTE_S), 5 * MINUTE, 10 * MINUTE);
      s.scheduleAtFixedRate(new Announcement(SystemMessage.TICKETS_SALES_ARE_CLOSED_FOR_THE_S1TH_MONSTER_RACE_ODDS_ARE_POSTED), 6 * MINUTE, 10 * MINUTE);
      s.scheduleAtFixedRate(new Announcement(SystemMessage.TICKETS_SALES_ARE_CLOSED_FOR_THE_S1TH_MONSTER_RACE_ODDS_ARE_POSTED), 7 * MINUTE, 10 * MINUTE);
      s.scheduleAtFixedRate(new Announcement(SystemMessage.THE_S2TH_MONSTER_RACE_WILL_BEGIN_IN_S1_MINUTES), 7 * MINUTE, 10 * MINUTE);
      s.scheduleAtFixedRate(new Announcement(SystemMessage.THE_S2TH_MONSTER_RACE_WILL_BEGIN_IN_S1_MINUTES), 8 * MINUTE, 10 * MINUTE);
      s.scheduleAtFixedRate(new Announcement(SystemMessage.THE_S1TH_MONSTER_RACE_WILL_BEGIN_IN_30_SECONDS), (8 * MINUTE) + (30 * SECOND), 10 * MINUTE);
      s.scheduleAtFixedRate(new Announcement(SystemMessage.THE_S1TH_MONSTER_RACE_IS_ABOUT_TO_BEGIN_COUNTDOWN_IN_FIVE_SECONDS), (8 * MINUTE) + (50 * SECOND), 10 * MINUTE);
      s.scheduleAtFixedRate(new Announcement(SystemMessage.THE_RACE_WILL_BEGIN_IN_S1_SECONDS), (8 * MINUTE) + (55 * SECOND), 10 * MINUTE);
      s.scheduleAtFixedRate(new Announcement(SystemMessage.THE_RACE_WILL_BEGIN_IN_S1_SECONDS), (8 * MINUTE) + (56 * SECOND), 10 * MINUTE);
      s.scheduleAtFixedRate(new Announcement(SystemMessage.THE_RACE_WILL_BEGIN_IN_S1_SECONDS), (8 * MINUTE) + (57 * SECOND), 10 * MINUTE);
      s.scheduleAtFixedRate(new Announcement(SystemMessage.THE_RACE_WILL_BEGIN_IN_S1_SECONDS), (8 * MINUTE) + (58 * SECOND), 10 * MINUTE);
      s.scheduleAtFixedRate(new Announcement(SystemMessage.THE_RACE_WILL_BEGIN_IN_S1_SECONDS), (8 * MINUTE) + (59 * SECOND), 10 * MINUTE);
      s.scheduleAtFixedRate(new Announcement(SystemMessage.THEYRE_OFF), 9 * MINUTE, 10 * MINUTE);
    }
    managers.add(this);
  }
 
View Full Code Here

    {
      synchronized (this)
      {
        if (_ai == null)
        {
          _ai = new ClonePlayerAI(this);
        }
      }
    }
    return (ClonePlayerAI) _ai;
  }
View Full Code Here

    }
    catch (Exception e)
    {
      _log.error("Unable to create ai of doorId " + _id, e);
    }
    return new DoorAI(door);
  }
View Full Code Here

   * Constructor for UserCommandHandler.
   */
  private UserCommandHandler()
  {
    registerUserCommandHandler(new ClanWarsList());
    registerUserCommandHandler(new ClanPenalty());
    registerUserCommandHandler(new CommandChannel());
    registerUserCommandHandler(new Escape());
    registerUserCommandHandler(new Loc());
    registerUserCommandHandler(new MyBirthday());
    registerUserCommandHandler(new OlympiadStat());
View Full Code Here

  /**
   * Constructor for UserCommandHandler.
   */
  private UserCommandHandler()
  {
    registerUserCommandHandler(new ClanWarsList());
    registerUserCommandHandler(new ClanPenalty());
    registerUserCommandHandler(new CommandChannel());
    registerUserCommandHandler(new Escape());
    registerUserCommandHandler(new Loc());
    registerUserCommandHandler(new MyBirthday());
View Full Code Here

TOP

Related Classes of lineage2.gameserver.ThreadPoolManager

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.