/** Makes the update checker check for a update */ public void checkUpdate() throws Exception { updateChecker = new UpdateChecker(); updateChecker.checkUpdate(getCurrentVersion()); latestVersion = updateChecker.getLatestVersion(); if (latestVersion != null) { latestVersion = "v" + latestVersion; for (Player p : Bukkit.getOnlinePlayers()) if (p.hasPermission("hungergames.update")) p.sendMessage( String.format( HungergamesApi.getTranslationManager().getMessagePlayerUpdateAvailable(), getCurrentVersion(), getLatestVersion())); } }
public class Spawn implements CommandExecutor { public String[] aliases = new String[] {"hgspawn"}; private TranslationManager cm = HungergamesApi.getTranslationManager(); public String description = "If spectating you can teleport back to spawn"; private PlayerManager pm = HungergamesApi.getPlayerManager(); public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { Gamer gamer = pm.getGamer(sender.getName()); if (!gamer.isAlive()) { pm.sendToSpawn(gamer); return true; } else { ((Player) sender).setCompassTarget(HungergamesApi.getHungergames().world.getSpawnLocation()); gamer.getPlayer().sendMessage(cm.getCommandSpawnPointingToSpawn()); } return true; } }
/** Reload the config. This doesn't reload some values however */ public void loadConfig() { hg.saveDefaultConfig(); final TranslationManager cm = HungergamesApi.getTranslationManager(); if (Bukkit.getServer().getAllowEnd() && hg.getConfig().getBoolean("DisableEnd", true)) { YamlConfiguration config = YamlConfiguration.loadConfiguration(new File("bukkit.yml")); config.set("settings.allow-end", false); try { config.save(new File("bukkit.yml")); } catch (IOException e) { e.printStackTrace(); } System.out.println(cm.getLoggerDisabledEnd()); } ReflectionManager rm = HungergamesApi.getReflectionManager(); if (hg.getServer().getAllowNether() && hg.getConfig().getBoolean("DisableNether", true)) { rm.setPropertiesConfig("allow-nether", false); rm.savePropertiesConfig(); System.out.println(cm.getLoggerDisabledNether()); } if (hg.getServer().getSpawnRadius() > 0 && hg.getConfig().getBoolean("ChangeSpawnLimit", true)) { rm.setPropertiesConfig("spawn-protection", 0); rm.savePropertiesConfig(); System.out.println(cm.getLoggerChangedSpawnRadius()); } if ((Integer) rm.getPropertiesConfig("max-build-height", 128) > 128 && hg.getConfig().getBoolean("ChangeHeightLimit", true)) { rm.setPropertiesConfig("max-build-height", 128); rm.savePropertiesConfig(); System.out.println(cm.getLoggerChangedHeightLimit()); } currentVersion = "v" + hg.getDescription().getVersion(); if (hg.getConfig().getBoolean("CheckUpdates")) Bukkit.getScheduler() .scheduleAsyncDelayedTask( hg, new Runnable() { public void run() { try { checkUpdate(); } catch (Exception ex) { System.out.print( String.format(cm.getLoggerFailedToCheckUpdate(), ex.getMessage())); } } }); hg.currentTime = -Math.abs(hg.getConfig().getInt("Countdown", 270)); mysqlEnabled = hg.getConfig().getBoolean("UseMySql", false); displayScoreboards = hg.getConfig().getBoolean("Scoreboards", false); displayMessages = hg.getConfig().getBoolean("Messages", true); minPlayers = hg.getConfig().getInt("MinPlayers", 2); fireSpread = hg.getConfig().getBoolean("DisableFireSpread", false); wonBroadcastsDelay = hg.getConfig().getInt("WinnerBroadcastingDelay"); gameShutdownDelay = hg.getConfig().getInt("GameShutdownDelay"); feastSize = hg.getConfig().getInt("FeastSize", 20); invincibility = hg.getConfig().getInt("Invincibility", 120); chestLayers = hg.getConfig().getInt("ChestLayers", 500); timeTillFeast = hg.getConfig().getInt("TimeTillFeast", 500); spectatorChat = !hg.getConfig().getBoolean("SpectatorChat", true); shortenNames = hg.getConfig().getBoolean("ShortenNames"); spectators = hg.getConfig().getBoolean("Spectators", true); kickOnDeath = hg.getConfig().getBoolean("KickOnDeath"); mushroomStew = hg.getConfig().getBoolean("MushroomStew", false); mushroomStewRestores = hg.getConfig().getInt("MushroomStewRestores", 5); kitSelector = hg.getConfig().getBoolean("EnableKitSelector", true); feastTnt = hg.getConfig().getBoolean("FeastTnt", true); feastGround = parseItem(hg.getConfig().getString("FeastGround")); feast = parseItem(hg.getConfig().getString("Feast")); generatePillars = hg.getConfig().getBoolean("Pillars", true); feastInsides = parseItem(hg.getConfig().getString("FeastInsides")); pillarCorner = parseItem(hg.getConfig().getString("PillarCorner")); pillarInsides = parseItem(hg.getConfig().getString("PillarInsides")); forceCords = hg.getConfig().getBoolean("ForceCords", true); x = hg.getConfig().getInt("ForceX", 0); z = hg.getConfig().getInt("ForceZ", 0); kitSelectorIcon = parseItem(hg.getConfig().getString("KitSelectorIcon")); if (kitSelectorIcon == null) kitSelectorIcon = new ItemStack(Material.FEATHER); kitSelectorBack = parseItem(hg.getConfig().getString("KitSelectorForward")); if (kitSelectorBack == null) kitSelectorBack = new ItemStack(Material.SUGAR_CANE_BLOCK); kitSelectorForward = parseItem(hg.getConfig().getString("KitSelectorBack")); if (kitSelectorForward == null) kitSelectorForward = new ItemStack(Material.SUGAR_CANE_BLOCK); spectatorItemBack = parseItem(hg.getConfig().getString("SpectatorInventoryForward")); if (spectatorItemBack == null) spectatorItemBack = new ItemStack(Material.SUGAR_CANE_BLOCK); spectatorItemForwards = parseItem(hg.getConfig().getString("SpectatorInventoryBack")); if (spectatorItemForwards == null) spectatorItemForwards = new ItemStack(Material.SUGAR_CANE_BLOCK); kitSelectorDynamicSize = hg.getConfig().getBoolean("KitSelectorDynamicSize"); kitSelectorInventorySize = hg.getConfig().getInt("KitSelectorInventorySize"); mobSpawnChance = hg.getConfig().getInt("MobSpawnChance"); if (hg.getConfig().contains("CommandsToRunBeforeShutdown")) commandsToRunBeforeShutdown = hg.getConfig().getStringList("CommandsToRunBeforeShutdown"); else commandsToRunBeforeShutdown = new ArrayList<String>(); disableMetrics = hg.getConfig().getBoolean("DisableMetrics"); flyPreGame = hg.getConfig().getBoolean("FlyPregame"); if (hg.getConfig().getBoolean("ChangeAlivePrefix")) alivePrefix = hg.getConfig().getString("AlivePrefix"); if (hg.getConfig().getBoolean("ChangeSpectatingPrefix")) spectatingPrefix = hg.getConfig().getString("SpectatingPrefix"); invisSpectators = !hg.getConfig().getBoolean("InvisibleSpectators"); // Create the times where it broadcasts and advertises the feast feastBroadcastTimes.clear(); for (int i = 1; i < 6; i++) feastBroadcastTimes.add(i); feastBroadcastTimes.add(30); feastBroadcastTimes.add(15); feastBroadcastTimes.add(10); invincibilityBroadcastTimes.clear(); // Create the times where it advertises invincibility for (int i = 1; i <= 5; i++) invincibilityBroadcastTimes.add(i); invincibilityBroadcastTimes.add(30); invincibilityBroadcastTimes.add(15); invincibilityBroadcastTimes.add(10); // Create the times where it advertises when the game starts gameStartingBroadcastTimes.clear(); for (int i = 1; i <= 5; i++) gameStartingBroadcastTimes.add(-i); gameStartingBroadcastTimes.add(-30); gameStartingBroadcastTimes.add(-15); gameStartingBroadcastTimes.add(-10); }