/cleancmd [name] - Create a command without comments.

/cleancmd [name] - Create a command without comments.

Postby Leeizazombie » 27 Dec 2013, 14:47

When you're making new commands and you might find the help comments from the original /cmdcreate classes a bit annoying or take a while removing them, this command will create the command without the comments!
Example: /cleancmd poke
Code:
Code: Select all
using System;
using System.CodeDom.Compiler;
using System.Reflection;
using System.Reflection.Emit;
using System.IO;
using System.Text;

namespace MCDzienny
{
   public class CmdCleancmd : Command
   {
      public override string name { get { return "cleancmd"; } }
      public override string shortcut { get { return ""; } }
      public override string type { get { return "other"; } }
      public override bool museumUsable { get { return false; } }
      public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
      public override void Use(Player p, string message)
        {
            string CmdName = message;
            try
            {
                if (!Directory.Exists("extra/commands/source/"))
                {
                    Directory.CreateDirectory("extra/commands/source/");
                }

                StreamWriter sw = new StreamWriter(File.Create("extra/commands/source/" + "Cmd" + CmdName + ".cs"));
                sw.Write(
                    "using System;" + Environment.NewLine +
                    Environment.NewLine +
                    "namespace MCDzienny" + Environment.NewLine +
                    "{" + Environment.NewLine +
                    "\tpublic class " + "Cmd" + (CmdName) + " : Command" + Environment.NewLine +
                    "\t{" + Environment.NewLine +
                    "\t\tpublic override string name { get { return \"" + CmdName.ToLower() + "\"; } }" + Environment.NewLine +
                    "\t\tpublic override string shortcut { get { return \"\"; } }" + Environment.NewLine +
                    "\t\tpublic override string type { get { return \"other\"; } }" + Environment.NewLine +
                    "\t\tpublic override bool museumUsable { get { return false; } }" + Environment.NewLine +
                    "\t\tpublic override LevelPermission defaultRank { get { return LevelPermission.Banned; } }" + Environment.NewLine +
                    "\t\tpublic override void Use(Player p, string message)" + Environment.NewLine +
                    "\t\t{" + Environment.NewLine +
                    "\t\t\tPlayer.SendMessage(p, \"Hello World!\");" + Environment.NewLine +
                    "\t\t}" + Environment.NewLine +
                    "\t\tpublic override void Help(Player p)" + Environment.NewLine +
                    "\t\t{" + Environment.NewLine +
                    "\t\t\tPlayer.SendMessage(p, \"/" + CmdName.ToLower() + " - Does stuff.  Example command.\");" + Environment.NewLine +
                    "\t\t}" + Environment.NewLine +
                    "\t}" + Environment.NewLine +
                    "}");
                sw.Dispose();
                Player.SendMessage(p, "Successfuly created class: Cmd" + CmdName + ".cs");
            }
            catch
            {
                Player.SendMessage(p, "An error has occured");
            }
        }

      public override void Help(Player p)
      {
         Player.SendMessage(p, "/cleancmd [name] -- Creates a clean command without comments.");
      }
   }
}


If you want to get this command with /downloadcommand then use:
Spoiler:
Last edited by ismellike on 28 Dec 2013, 17:26, edited 1 time in total.
Reason: Changed Permission
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.

Return to Custom Commands

Who is online

Users browsing this forum: No registered users and 2 guests

cron