/Downloadcommand (finished)

/Downloadcommand (finished)

Postby Leeizazombie » 22 Dec 2013, 17:28

Command:
/downloadcommand [name] [Download URL]
or
/dlc [name] [Download URL]

What it does:
You can download uploaded commands via FTP or however (some uploads do not download properly such as Dropbox). This command will assume you've checked the command and that it has no errors, so it will basically download the command, add it to the "cmdautoload.txt" file, compile and load it so it's ready to use!
Example:
/dlc CmdDelete http://puu.sh/5R8FN.cs

Code:
Code: Select all
using System;
using System.Threading;
using System.IO;
using System.Net;
namespace MCDzienny
{
    public class CmdDownloadCommand : Command
    {
        public override string name { get { return "downloadcommand"; } }
        public override string shortcut { get { return "dlc"; } }
        public override string type { get { return "mod"; } }
        public override bool museumUsable { get { return false; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
        public override void Use(Player p, string message)
        {
            string[] a = message.Split(' ');
            if (a.Length != 2)
            {
                Help(p);
                return;
            }
            string name = "Cmd" + a[0] + ".cs"; // CmdTestCommand.cs
            string cmdname = a[0];              // TestCommand (for cmdautoload).
            try
            {

                using (WebClient web = new WebClient())
                {
                    if (a[0].Substring(0, 4) != "http")
                    {
                        message = "http://" + a[1];
                    }


                    if (System.IO.File.Exists("extra/commands/source/" + name))
                    {
                        Player.SendMessage(p, "You already have a command with that name, please choose another name.");
                        return;
                    }
                    Player.SendMessage(p, "Downloading file from: &f" + a[0] + Server.DefaultColor + ", please wait.");

                    web.DownloadFile(a[1], "extra/commands/source/" + name);
                }
                Player.SendMessage(p, "Download complete. Command name :%3" + name);
                File.AppendAllText("text/cmdautoload.txt", string.Format("{0}{1}", cmdname, Environment.NewLine));
                Thread.Sleep(1000);
                Command.all.Find("compile").Use(null, a[0]);
                Player.SendMessage(p, "%bCompiled assuming it's okay.");
                Thread.Sleep(2000);
                Command.all.Find("cmdload").Use(null, a[0]);
                Player.SendMessage(p, "%bLoaded assuming it's okay.");

            }
            catch
            {
                Player.SendMessage(p, "%cDownload failed.");
            }
        }

        public override void Help(Player p)
        {
            Player.SendMessage(p, "/DownloadCommand (name for command) (URl)- Dowload Command.");
        }
    }
}


Reference:
This command was put together thanks to qpqpqpq123's Downloadmap command!

Moderators: Please remove my old /dlc posts
Owner of:
LeeIzaZombie Freebuild and Lava Survival V2 (Shut Down and updated)
LeeIzaZombie Survival (Comming back soon)

Contact:
Skype: leeizazombie
IRC: irc.geekshed.net, #leeizazombie, #mcclassichosting
User avatar
Leeizazombie
 
Posts: 536
Joined: 10 Jun 2013, 17:45
Location: Ireland.

Re: /Downloadcommand (finished)

Postby joppiesaus » 23 Dec 2013, 11:24

Super awesome. Very usefull!

EDIT: Here's a list of commmand URLs you can download!
joppiesaus
 
Posts: 379
Joined: 20 Aug 2012, 07:28
Location: in a obsedian house, with glass in it so i can see the lava!


Return to Custom Commands

Who is online

Users browsing this forum: No registered users and 2 guests

cron