@Override public ModuleCollection<Tnt> load(Match match) { ModuleCollection<Tnt> results = new ModuleCollection<>(); for (Element element : match.getDocument().getRootElement().getChildren("tnt")) { boolean instantIgnite = false; if (element.getChild("instantignite") != null) { instantIgnite = Numbers.parseBoolean(element.getChildText("instantignite")); } boolean blockDamage = true; if (element.getChild("blockdamage") != null) { blockDamage = Numbers.parseBoolean(element.getChildText("blockdamage")); } double yield = 0.3; if (element.getChild("yield") != null) { yield = Double.parseDouble(element.getChildText("yield")); } double power = 4.0; if (element.getChild("power") != null) { power = Double.parseDouble(element.getChildText("power")); } int fuse = 4; if (element.getChild("fuse") != null) { fuse = Strings.timeStringToSeconds(element.getChildText("fuse")); } results.add(new Tnt(instantIgnite, blockDamage, yield, power, fuse)); } return results; }
@Override public void run() { if (GameHandler.getGameHandler().getMatch().isRunning()) { double time = MatchTimer.getTimeInSeconds(); double timeRemaining; if (TimeLimit.getMatchTimeLimit() == 0) { if (time >= nextTimeMessage) { ChatUtil.getGlobalChannel() .sendLocalizedMessage( new UnlocalizedChatMessage( ChatColor.AQUA + "{0}", new LocalizedChatMessage( ChatConstant.UI_TIME_ELAPSED, new UnlocalizedChatMessage( ChatColor.GREEN + Strings.formatTime(nextTimeMessage))))); nextTimeMessage += 300; } return; } timeRemaining = TimeLimit.getMatchTimeLimit() - time; if (GameHandler.getGameHandler().getMatch().getModules().getModule(MonumentModes.class) != null) { ModuleCollection<MonumentModes> modes = GameHandler.getGameHandler().getMatch().getModules().getModules(MonumentModes.class); HashMap<MonumentModes, Integer> modesWithTime = new HashMap<>(); for (MonumentModes modeForTime : modes) { modesWithTime.put(modeForTime, modeForTime.getTimeAfter()); } List<MonumentModes> sortedModes = MiscUtil.getSortedHashMapKeyset(modesWithTime); int timeBeforeMode = 1; int showBefore = 60; String name = MonumentModes.getModeName(); for (MonumentModes mode : sortedModes) { if (!mode.hasRan()) { timeBeforeMode = mode.getTimeAfter() - (int) MatchTimer.getTimeInSeconds(); name = mode.getName(); showBefore = mode.getShowBefore(); } } int timeLeft = TimeLimit.getMatchTimeLimit() - (int) MatchTimer.getTimeInSeconds(); if (((timeBeforeMode > showBefore) || (name == null)) && (TimeLimit.getMatchTimeLimit() > 0)) { int percent = (int) ((100F * timeLeft) / TimeLimit.getMatchTimeLimit()); BossBar.sendGlobalBossBar( new UnlocalizedChatMessage( ChatColor.AQUA + "{0} " + ChatUtil.getTimerColor(timeRemaining) + "{1}", new LocalizedChatMessage(ChatConstant.UI_TIMER), new UnlocalizedChatMessage(Strings.formatTime(timeRemaining + 1))), percent); } if (timeBeforeMode == showBefore || timeBeforeMode <= 0) { BossBar.delete(); } } else if (TimeLimit.getMatchTimeLimit() > 0) { int timeLeft = ((TimeLimit.getMatchTimeLimit() - (int) MatchTimer.getTimeInSeconds())); int percent = (int) ((100F * timeLeft) / TimeLimit.getMatchTimeLimit()); BossBar.sendGlobalBossBar( new UnlocalizedChatMessage( ChatColor.AQUA + "{0} " + ChatUtil.getTimerColor(timeRemaining) + "{1}", new LocalizedChatMessage(ChatConstant.UI_TIMER), new UnlocalizedChatMessage(Strings.formatTime(timeRemaining + 1))), percent); } if (nextTimeMessage >= timeRemaining) { if (nextTimeMessage <= 5) { ChatUtil.getGlobalChannel() .sendLocalizedMessage( new UnlocalizedChatMessage( ChatColor.AQUA + "{0} " + ChatColor.DARK_RED + Strings.formatTime(nextTimeMessage), new LocalizedChatMessage(ChatConstant.UI_TIMER))); nextTimeMessage--; } else if (nextTimeMessage <= 30) { ChatUtil.getGlobalChannel() .sendLocalizedMessage( new UnlocalizedChatMessage( ChatColor.AQUA + "{0} " + ChatColor.GOLD + Strings.formatTime(nextTimeMessage), new LocalizedChatMessage(ChatConstant.UI_TIMER))); nextTimeMessage -= 5; } else if (nextTimeMessage <= 60) { ChatUtil.getGlobalChannel() .sendLocalizedMessage( new UnlocalizedChatMessage( ChatColor.AQUA + "{0} " + ChatColor.YELLOW + Strings.formatTime(nextTimeMessage), new LocalizedChatMessage(ChatConstant.UI_TIMER))); nextTimeMessage -= 15; } else { ChatUtil.getGlobalChannel() .sendLocalizedMessage( new UnlocalizedChatMessage( ChatColor.AQUA + "{0} " + ChatColor.GREEN + Strings.formatTime(nextTimeMessage), new LocalizedChatMessage(ChatConstant.UI_TIMER))); if ((nextTimeMessage / 60) % 5 == 0 && nextTimeMessage != 300) { nextTimeMessage -= 300; } else if (nextTimeMessage % 60 == 0 && nextTimeMessage <= 300) { nextTimeMessage -= 60; } else { nextTimeMessage = (nextTimeMessage / 300) * 300; } } } } }