It's pretty self-explanatory. It adds Help Information to the command "Help". It's very easy to add help information to new commands, or edit existing ones. You're going to need add this under switch( command ) { in Commands.cs:
Code: Select all
case "help":
case "h":
Help(player, param);
break;
Code: Select all
static void Help([NotNull] Player player, String cmd)
{
if (String.IsNullOrWhiteSpace(cmd))
{
player.Message("&eTo use Help, type &9/help <command>");
return;
}
else
{
HelpCommand.Parse(player, cmd);
}
}
Now create a new class named HelpCommand.cs and post this within it:
Code: Select all
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using JetBrains.Annotations;
namespace FemtoCraft {
static class HelpCommand {
public static void Parse([NotNull] Player player, [NotNull] string command)
{
if (player == null) throw new ArgumentNullException("player");
if (command == null) throw new ArgumentNullException("command");
string Info;
string Usage;
string cmd = command;
bool OpCmd;
switch (command)
{
case "help":
case "h":
Info = "Gives useful information the specified command.";
Usage = "/h <command>&e, &9/help <command>";
OpCmd = false;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "ops":
Info = "Shows a list of the OPs.";
Usage = "/ops";
OpCmd = false;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "op":
Info = "Promotes the specified player to OP.";
Usage = "/op <player>";
OpCmd = true;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "deop":
Info = "Demoted the specified player from OP.";
Usage = "/deop <player>";
OpCmd = true;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "kick":
case "k":
Info = "Kicks the specified player from the Server.";
Usage = "/k <player>&e, &9/kick <player>";
OpCmd = true;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "ban":
Info = "Bans the specified player from the Server, disallowing him/her to reconnect.";
Usage = "/ban <player>";
OpCmd = true;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "unban":
Info = "Unbans the specified player from the Server, allowing the banned player to reconnect again.";
Usage = "/unban <player>";
OpCmd = true;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "banip":
Info = "Bans the specified IP Address from the server, disallowing anyone accessing from that IP Address to reconnect.";
Usage = "/banip <IP>";
OpCmd = true;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "unbanip":
Info = "Unbans the specified IP Address from the server, allowing anyone accessing from that IP to reconnect again.";
Usage = "/unbanip <IP>";
OpCmd = true;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "solid":
case "s":
Info = "Allows the player to place Admincrete while equipping a Stone Block.";
Usage = "/s&e, &9/solid";
OpCmd = true;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "water":
case "w":
Info = "Allows the player to place Water blocks while equipping a Blue Block.";
Usage = "/w&e, &9/water";
OpCmd = false;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "lava":
case "l":
Info = "Allows the player to place Lava blocks while equipping a Red Block.";
Usage = "/l&e, &9/lava";
OpCmd = false;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "grass":
case "g":
Info = "Allows the player to place Grass blocks while equipping a Dirt Block.";
Usage = "/g&e, &9/grass";
OpCmd = false;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "say":
case "broadcast":
Info = "Globally broadcasts a message to every player connected to the server.";
Usage = "/broadcast <message>&e, &9/say <message>";
OpCmd = true;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "tp":
case "teleport":
Info = "Teleports you to the specified player.";
Usage = "/tp <player>&e, &9/teleport <player>";
OpCmd = true;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "bring":
Info = "Teleports the specified player to you.";
Usage = "/bring <player>";
OpCmd = true;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "setspawn":
Info = "Sets the spawnpoint of the map to the absolute position the time you used the command.";
Usage = "/setspawn";
OpCmd = true;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "whitelist":
Info = "Lists everyone who is whitelisted.";
Usage = "/whitelist";
OpCmd = false;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "whitelistadd":
Info = "Adds the specified player to the whitelist.";
Usage = "/whitelistadd <player>";
OpCmd = true;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "whitelistremove":
Info = "Removes the specified player from the whitelist.";
Usage = "/whitelistremove <player>";
OpCmd = true;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "load":
Info = "Loads the specified map to the server.";
Usage = "/load <filename>";
OpCmd = true;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "save":
Info = "Force Saves the map to the specified file.";
Usage = "/save <filename>";
OpCmd = true;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "physics":
Info = "Shows the enabled physics options on the server.";
Usage = "/physics&e, &9/physics <on|off>&e, &9/physics <module>";
OpCmd = true;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "p":
case "paint":
Info = "Automatically replaces deleted blocks with the block equipped.";
Usage = "/p&e, &9/paint";
OpCmd = false;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "players":
Info = "Shows a list of all the current players online.";
Usage = "/players";
OpCmd = false;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "gen":
Info = "Generates a new map.";
Usage = "/gen";
OpCmd = true;
Help(player, cmd, Info, Usage, OpCmd);
break;
case "genflat":
Info = "Generates a new flat map.";
Usage = "";
OpCmd = true;
Help(player, cmd, Info, Usage, OpCmd);
break;
}
}
static void Help([NotNull] Player player, String cmd, String Info, String Usage, bool OpCmd) {
player.Message("&eInformation on &9" + cmd + "&e: ");
if (String.IsNullOrWhiteSpace(Usage))
{
player.Message("&eUsage: &7unknown?");
}
else
{
player.Message("&eUsage: &9" + Usage);
}
if (OpCmd != true)
{
player.Message("&eOP Command: &cFalse");
}
else
{
player.Message("&eOP Command: &aTrue");
}
if (!String.IsNullOrWhiteSpace(Info))
{
player.Message("&eInfo: &9" + Info);
}
else if(String.IsNullOrWhiteSpace(Info)){
player.Message("&eNo Information on the command \"" + cmd + "\".");
}
}
}
}
I'd like to thank fragmer for helping me stop herping the derp :D.
- Moose