Example #1
0
  public boolean unload(Match match) {
    String name = "match-" + match.getID();
    File delete = new File(name);

    stopModules(ModuleStage.LOAD);
    World world = Spork.get().getServer().getWorld(name);
    Spork.get().getServer().unloadWorld(world, false);
    FileUtil.delete(delete);

    return true;
  }
Example #2
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);
    }
  }
Example #3
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();
      }
    }
  }
Example #4
0
  public SporkMap(MapBuilder builder)
      throws MapLoadException, ModuleLoadException, InvalidRegionException, InvalidFilterException {
    this.builder = builder;
    this.document = builder.getDocument();
    this.folder = builder.getFolder();
    Element root = document.getRootElement();

    this.scoreboard = Spork.get().getServer().getScoreboardManager().getNewScoreboard();
    this.objective = scoreboard.registerNewObjective("Objectives", "dummy");

    this.teams = SporkTeamBuilder.build(this);
    this.observers = SporkTeamBuilder.observers(this);

    this.filters = FilterBuilder.build(this);
    // filters();

    this.regions = new ArrayList<>();
    if (root.element("regions") != null) {
      this.regions = RegionBuilder.parseSubRegions(root.element("regions"));
      this.regions.addAll(filtered());
      search();
    }
    // regions();

    this.visible = visible(false);

    this.kits = builder.getKits();
    this.spawns = SporkSpawnBuilder.build(this);
    for (SporkTeam team : teams) {
      if (team.getSpawns().size() == 0) {
        throw new MapLoadException("No Spawns specified for " + team.getName());
      }
    }

    this.modules = builder.getModules();
    this.timer = ((TimerModule) getModule(TimerModule.class));
    loadModules();

    this.kits = SporkKitBuilder.build(document);
    if (kits == null) {
      this.kits = new ArrayList<>();
    }

    /*
    for(SporkTeam team : teams) {
    	List<ObjectiveModule> fetched = team.getObjectives();
    	// Log.info(team.getName() + ": " + fetched + " (" + fetched.size() + ")");

    	List<ObjectiveModule> objectives = new ArrayList<>();
    	for(Module module : modules) {
    		// Log.info("Checking " + module.getClass().getSimpleName() + " to see if it is an instance of ObjectiveModule");
    		if(module instanceof ObjectiveModule) {
    			ObjectiveModule objective = (ObjectiveModule) module;
    			// Log.info("'" + objective.getName() + "' has been found (" + objective.getTeam().getName().toUpperCase() + ")");
    			if(objective.getTeam().equals(team)) {
    				// Log.info("Found '" + objective.getName() + "' for " + objective.getTeam().getName().toUpperCase());
    				objectives.add(objective);
    			}
    		}
    	}
    	// Log.info(team.getName() + ": " + objectives + " (" + objectives.size() + ")");
    }
    */
  }