2015-10-19 17:43:46 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.commands;
|
2012-12-22 03:22:08 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.permission.PlayerRank;
|
2012-12-22 03:22:08 +00:00
|
|
|
import java.io.File;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
2012-12-22 03:22:08 +00:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
2013-07-27 21:49:25 +00:00
|
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
2012-12-22 03:22:08 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
@CommandPermissions(level = PlayerRank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
2013-04-10 02:05:24 +00:00
|
|
|
@CommandParameters(description = "Update server files.", usage = "/<command>")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_tfupdate extends FreedomCommand
|
2012-12-22 03:22:08 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-12-22 03:22:08 +00:00
|
|
|
if (!sender.getName().equalsIgnoreCase("madgeek1450"))
|
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
playerMsg(FreedomCommand.MSG_NO_PERMS);
|
2012-12-22 03:22:08 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (final String url : FILES)
|
|
|
|
{
|
2013-07-27 21:49:25 +00:00
|
|
|
new BukkitRunnable()
|
2012-12-22 03:22:08 +00:00
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void run()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
FLog.info("Downloading: " + url);
|
2012-12-22 03:22:08 +00:00
|
|
|
|
|
|
|
File file = new File("./updates/" + url.substring(url.lastIndexOf("/") + 1));
|
|
|
|
if (file.exists())
|
|
|
|
{
|
|
|
|
file.delete();
|
|
|
|
}
|
|
|
|
if (!file.getParentFile().exists())
|
|
|
|
{
|
|
|
|
file.getParentFile().mkdirs();
|
|
|
|
}
|
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.downloadFile(url, file, true);
|
2012-12-22 03:22:08 +00:00
|
|
|
}
|
2013-08-14 13:28:19 +00:00
|
|
|
catch (Exception ex)
|
2012-12-22 03:22:08 +00:00
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
FLog.severe(ex);
|
2012-12-22 03:22:08 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-27 21:49:25 +00:00
|
|
|
}.runTaskAsynchronously(plugin);
|
2012-12-22 03:22:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|