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); } }
private void regions() { for (Region region : regions) { String message = region(region); if (region instanceof AppliedRegion) { AppliedRegion filtered = (AppliedRegion) region; try { message = message + " (" + filtered.getValues().size() + ")"; } catch (NullPointerException e) { message = message + " (Unknown)"; } } Log.info(message); } }
public boolean load(Match match) { String name = "match-" + match.getID(); File copyto = new File(name); try { FileUtil.copy(getFolder(), copyto); File sessionLock = new File(copyto.getAbsolutePath() + "/session.lock"); if (sessionLock.exists()) { FileUtil.delete(sessionLock); } File uid = new File(copyto.getAbsolutePath() + "/uid.dat"); if (uid.exists()) { FileUtil.delete(uid); } File old = new File(copyto.getAbsolutePath() + "/level.dat_old"); if (old.exists()) { FileUtil.delete(old); } } catch (IOException e) { e.printStackTrace(); return false; } WorldCreator creator = new WorldCreator(name); creator.generator(new NullChunkGenerator()); this.world = creator.createWorld(); startModules(ModuleStage.LOAD); this.timer.setMatch(match); scoreboard(); for (VisibleRegion region : visible) { region.set(world); } for (VisibleRegion region : visible) { Log.info( "Using " + region.getMaterial().name() + ":" + region.getDye().name() + " for " + region.getRegion()); } return true; }
private void filters() { for (Filter filter : filters) { Log.info(filter(filter)); } }
@Override public void run() { if (complete) return; // Log.debug((NumberUtil.randomBoolean() ? "tick" : "tock")); Rotation rotation = Rotation.get(); RotationSlot next = rotation.getNext(); rotation.setRestart(); if (!rotation.isRestarting()) { next.load(true); } this.next = next; String what = getMessage(); ChatColor colour = ChatColor.GRAY; if (next != null) { colour = ChatColor.DARK_AQUA; } try { List<User> players = match.getMap().getWinner().getPlayers(); if (players.size() > 0 && isFullSecond()) { // check for more than 1 player User player = players.get(NumberUtil.getRandom(0, players.size() - 1)); Location location = player.getPlayer().getLocation(); Firework firework = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK); FireworkMeta meta = firework.getFireworkMeta(); meta.clearEffects(); meta.addEffect(getFirework()); firework.setFireworkMeta(meta); try { firework.detonate(); } catch (Exception e) { Log.warning( "Server isn't running a version of Bukkit which allows the use of Firework.detonate() - resorting to manual detonation."); try { Object craft = NMSUtil.getClassBukkit("entity.CraftFirework").cast(firework); Method method = craft.getClass().getMethod("getHandle"); method.setAccessible(true); Object handle = method.invoke(craft); handle.getClass().getField("expectedLifespan").set(handle, 0); } catch (Exception e2) { e2.printStackTrace(); } } } } catch (NullPointerException ignored) { } if (duration <= 0 && next == null) { for (User player : User.getUsers()) { player.getPlayer().kickPlayer(ChatColor.GREEN + "Server restarting!"); } complete = true; Bukkit.getServer().shutdown(); return; } if (duration <= 0) { broadcast(what + "!"); match.stop(); complete = true; rotation.cycle(); return; } boolean show = false; if (getTicks() % 20 == 0) { if (getSeconds() % 30 == 0) show = true; else if (getSeconds() < 30 && getSeconds() % 15 == 0) show = true; else if (getSeconds() < 15 && getSeconds() % 5 == 0) show = true; else if (getSeconds() < 5) show = true; } if (show) broadcast( what + " in " + ChatColor.RED + getSeconds() + " second" + (getSeconds() != 1 ? "s" : "") + colour + "!"); setTicks(getTicks() - 1); }