mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-16 20:36:12 +00:00
6edb6be7d9
Improved admin system Improved Rank system Implemented config converter Improved command handling Updated Aero
71 lines
2.1 KiB
Java
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;
|
|
}
|
|
}
|