package me.totalfreedom.totalfreedommod.command; import java.io.File; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; @CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true) @CommandParameters(description = "Update server files.", usage = "/") public class Command_tfupdate extends FreedomCommand { public static final String[] FILES = { }; @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { if (FILES.length == 0) { msg("This command is disabled."); return true; } if (!sender.getName().equalsIgnoreCase("madgeek1450")) { noPerms(); return true; } for (final String url : FILES) { new BukkitRunnable() { @Override public void run() { try { FLog.info("Downloading: " + url); File file = new File("./updates/" + url.substring(url.lastIndexOf("/") + 1)); if (file.exists()) { file.delete(); } if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } FUtil.downloadFile(url, file, true); } catch (Exception ex) { FLog.severe(ex); } } }.runTaskAsynchronously(plugin); } return true; } }