コード例 #1
0
ファイル: AbstractAutoEvent.java プロジェクト: sabracx/tera
  @Override
  public boolean start() {
    lock();
    try {

      if (isStarted()) {
        return false;
      }

      if (eventTerritory != null) {
        eventTerritory.addListener(this);
      }

      ObjectEventManager objectEventManager = ObjectEventManager.getInstance();
      objectEventManager.addDeleteListener(this);
      objectEventManager.addDieListener(this);

      time = getRegisterTime();

      EventManager eventManager = EventManager.getInstance();
      eventManager.start(this);

      World.sendAnnounce("Запущен автоматический ивент \"" + getName() + "\"");

      setStarted(true);
      setState(EventState.REGISTER);

      ExecutorManager executor = ExecutorManager.getInstance();
      schedule = executor.scheduleGeneralAtFixedRate(this, 60000, 60000);
      return true;

    } finally {
      unlock();
    }
  }
コード例 #2
0
ファイル: AbstractAutoEvent.java プロジェクト: sabracx/tera
  @Override
  public boolean stop() {
    lock();
    try {

      if (!isStarted()) {
        return false;
      }

      players.clear();
      activePlayers.clear();

      if (eventTerritory != null) {
        eventTerritory.removeListener(this);
      }

      ObjectEventManager objectEventManager = ObjectEventManager.getInstance();
      objectEventManager.removeDeleteListener(this);
      objectEventManager.removeDieListener(this);

      World.sendAnnounce("Ивент \"" + getName() + "\" завершен.");

      setStarted(false);
      setState(EventState.FINISHED);
      return true;

    } finally {
      unlock();
    }
  }
コード例 #3
0
ファイル: AbstractAutoEvent.java プロジェクト: sabracx/tera
  /** Очистить территорию от левых игроков. */
  protected final void clearTerritory() {

    if (eventTerritory == null) {
      return;
    }

    WorldZoneTable worldZoneTable = WorldZoneTable.getInstance();
    Array<TObject> objects = eventTerritory.getObjects();

    TObject[] objs = objects.array();

    objects.writeLock();
    try {

      for (int i = 0, length = objects.size(); i < length; i++) {

        TObject object = objs[i];

        if (!object.isPlayer()) {
          continue;
        }

        Player player = object.getPlayer();

        if (!players.containsKey(player.getObjectId())) {
          player.teleToLocation(worldZoneTable.getRespawn(player));
          i--;
          length--;
        }
      }

    } finally {
      objects.writeUnlock();
    }
  }