TFM-4.3-Reloaded/src/me/totalfreedom/totalfreedommod/commands/Command_tfupdate.java

69 lines
2.1 KiB
Java
Raw Normal View History

package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank;
import java.io.File;
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 = PlayerRank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Update server files.", usage = "/<command>")
public class Command_tfupdate extends FreedomCommand
{
public static final String[] FILES =
{
};
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
2014-07-20 21:25:45 +00:00
if (FILES.length == 0)
{
playerMsg("This command is disabled.");
return true;
}
if (!sender.getName().equalsIgnoreCase("madgeek1450"))
{
playerMsg(FreedomCommand.MSG_NO_PERMS);
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;
}
}