TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tfupdate.java
Jerom van der Sar 6edb6be7d9 Many changes for TFM 5.0
Improved admin system
Improved Rank system
Implemented config converter
Improved command handling
Updated Aero
2016-03-06 16:58:59 +01:00

71 lines
2.1 KiB
Java

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 = "/<command>")
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;
}
}