(Few commands like chat filters require server restart)
Here you go:
- Code: Select all
using System;
using System.IO;
namespace MCDzienny
{
public class CmdCmdRemove : Command
{
public override string name { get { return "removecommand"; } }
public override string shortcut { get { return "cmdremove"; } }
public override string type { get { return "mod"; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
public override void Use(Player p, string message)
{
string text = File.ReadAllText("text\\cmdautoload.txt");
string command = message;
string dll = "";
string source = "";
string autoload = command + " wasn't in the cmdautoload.txt file.";
try
{
text = text.Replace(command, "");
File.WriteAllText("text\\cmdautoload.txt", text);
autoload = "removed " + command + " from cmdautoload.txt";
}
catch
{
Player.SendMessage(p, "%cError: %fCommand not found in cmdautoload.txt");
}
if (File.Exists("extra/commands/source/" + "Cmd" + command + ".cs"))
{
File.Delete("extra/commands/source/" + "Cmd" + command + ".cs");
source = "Cmd" + command + ".cs";
}
else
{
Player.SendMessage(p, "%cError: %fCommand not found in Source Folder");
}
try
{
Command.all.Find("cmdunload").Use(null, " " + command);
}
catch
{
Player.SendMessage(p, "%cError: %fCould not unload command.");
}
if (File.Exists("extra/commands/dll/" + "Cmd" + command + ".dll"))
{
File.Delete("extra/commands/dll/" + "Cmd" + command + ".dll");
dll = "Cmd" + command + ".dll";
}
else
{
Player.SendMessage(p, "%cError: %fCommand not found in DLL Folder");
}
Player.SendMessage(p, "%0----------%2Operation complete%0----------");
Player.SendMessage(p, "%fYou've removed %7" + source + ", " + dll + " %fand %7" + autoload);
}
public override void Help(Player p)
{
Player.SendMessage(p, "/cmdremoved [command] - Completely remove a command from the server. (Few commands require a restart)");
}
}
}
Tell if you have any problems or suggestions!