Esempio n. 1
0
  public void loadModules() {
    modules.addAll(Spork.get().getModules(this));

    List<Module> remove = new ArrayList<>();
    for (Module module : modules) {
      ModuleAbout info = module.getInfo();
      if (info.getRequires().size() > 0) {
        boolean ignore = false;
        for (Class<? extends Module> type : info.getRequires()) {
          if (!remove.contains(module) && !ignore && !hasModule(type)) {
            remove.add(module);
            Log.warning(
                "Removing "
                    + module.getInfo().getName()
                    + " because "
                    + type.getName()
                    + " was missing!");
          }
        }
      }
    }

    for (Module toRemove : remove) {
      modules.remove(toRemove);
    }
  }
Esempio n. 2
0
  public void stopModules(ModuleStage stage) {
    for (Module module : modules) {
      try {
        if (new BuilderAbout(module.builder()).getStage() != stage) {
          continue;
        }
      } catch (Exception e) {
        continue;
      }

      if (module.getInfo().isListener()) {
        Spork.unregisterListener(module);
      }

      if (module instanceof TaskedModule) {
        ((TaskedModule) module).setTasks(false);
      }

      if (module instanceof InitModule) {
        ((InitModule) module).stop();
      }
    }
  }