Ejemplo n.º 1
0
  @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();
    }
  }
Ejemplo n.º 2
0
  @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();
    }
  }