Cleanup /help and make it have one consistent style, also add /help commandsall which also shows min rank colours.

This commit is contained in:
UnknownShadow200 2016-02-17 12:41:41 +11:00
parent 431c3d2cd1
commit ea833ebfca
8 changed files with 110 additions and 184 deletions

View File

@ -15,37 +15,22 @@
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/
namespace MCGalaxy.Commands
{
public sealed class CmdGlobalCLS : Command
{
namespace MCGalaxy.Commands {
public sealed class CmdGlobalCLS : Command {
public override string name { get { return "globalcls"; } }
public override string shortcut { get { return "gcls"; } }
public override string type { get { return CommandTypes.Chat; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public override void Use(Player p, string message)
{
int i = 0;
for (i = 0; i < 20; i++)
{
PlayerInfo.players.ForEach(delegate(Player p1) { BlankMessage(p1); });
}
public override void Use(Player p, string message) {
for (int i = 0; i < 20; i++)
PlayerInfo.players.ForEach(pl => pl.SendBlankMessage());
Player.GlobalMessage("%4Global Chat Cleared.");
}
//Yes this does work
//Trust me...I'm a doctor
public void BlankMessage(Player p)
{
byte[] buffer = new byte[66];
buffer[0] = Opcode.Message;
NetUtils.WriteAscii("", buffer, 2);
p.SendRaw(buffer);
buffer = null;
}
public override void Help(Player p)
{
public override void Help(Player p) {
Player.SendMessage(p, "/globalcls - Clears the chat for all users.");
}
}

View File

@ -15,37 +15,22 @@
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/
namespace MCGalaxy.Commands
{
public sealed class CmdPlayerCLS : Command
{
namespace MCGalaxy.Commands {
public sealed class CmdPlayerCLS : Command {
public override string name { get { return "playercls"; } }
public override string shortcut { get { return "cls"; } }
public override string type { get { return CommandTypes.Chat; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
public override void Use(Player p, string message)
{
int i = 0;
for (i = 0; i < 20; i++)
{
BlankMessage(p);
}
public override void Use(Player p, string message) {
for (int i = 0; i < 20; i++)
p.SendBlankMessage();
Player.SendMessage(p, "%4Chat cleared.");
}
//Yes this does work
//Trust me...I'm a doctor
public void BlankMessage(Player p)
{
byte[] buffer = new byte[66];
buffer[0] = Opcode.Message;
NetUtils.WriteAscii("", buffer, 2);
p.SendRaw(buffer);
buffer = null;
}
public override void Help(Player p)
{
public override void Help(Player p) {
Player.SendMessage(p, "/playercls - Clears your chat.");
}
}

View File

@ -30,96 +30,49 @@ namespace MCGalaxy.Commands
switch (message.ToLower())
{
case "":
if (Server.oldHelp)
{
goto case "old";
}
if (Server.menustyle != 1)
{
Player.SendMessage(p, "Use &b/help ranks" + Server.DefaultColor + " for a list of ranks.");
Player.SendMessage(p, "Use &b/help build" + Server.DefaultColor + " for a list of building commands.");
Player.SendMessage(p, "Use &b/help chat" + Server.DefaultColor + " for a list of chat commands.");
Player.SendMessage(p, "Use &b/help economy" + Server.DefaultColor + " for a list of economy commands.");
Player.SendMessage(p, "Use &b/help games" + Server.DefaultColor + " for a list of game commands.");
Player.SendMessage(p, "Use &b/help information" + Server.DefaultColor + " for a list of information commands.");
Player.SendMessage(p, "Use &b/help mod" + Server.DefaultColor + " for a list of moderation commands.");
Player.SendMessage(p, "Use &b/help other" + Server.DefaultColor + " for a list of other commands.");
Player.SendMessage(p, "Use &b/help world" + Server.DefaultColor + " for a list of world/map commands.");
Player.SendMessage(p, "Use &b/help colors" + Server.DefaultColor + " to view the color codes.");
Player.SendMessage(p, "Use &b/help shortcuts" + Server.DefaultColor + " for a list of shortcuts.");
Player.SendMessage(p, "Use &b/help old" + Server.DefaultColor + " to view the Old help menu.");
Player.SendMessage(p, "Use &b/help [command] or /help [block] " + Server.DefaultColor + "to view more info.");
}
else
{
Player.SendMessage(p, Server.DefaultColor + " To see a list of all commands, write %a/Help List");
Player.SendMessage(p, Server.DefaultColor + " To see detailed help for a command, write %a/Help Command");
Player.SendMessage(p, Server.DefaultColor + " To see your stats, write %a/Whois");
Player.SendMessage(p, Server.DefaultColor + " To see loaded maps, write %a/Maps");
Player.SendMessage(p, Server.DefaultColor + " To view your personal world options, use %a/OS");
Player.SendMessage(p, Server.DefaultColor + " To join a Map, write %a/Goto WorldName");
Player.SendMessage(p, Server.DefaultColor + " To send private messages, write %a@PlayerName Message");
}
break;
case "list":
message = "";
Player.SendMessage(p, Server.DefaultColor + " To view all commands in a category, write %a/Help Category");
Player.SendMessage(p, Server.DefaultColor + "Command Categories:");
Player.SendMessage(p, " %aBuilding");
Player.SendMessage(p, " %aChat");
Player.SendMessage(p, " %aEconomy");
Player.SendMessage(p, " %aGames");
Player.SendMessage(p, " %aInfo");
Player.SendMessage(p, " %aModeration");
Player.SendMessage(p, " %aOther");
Player.SendMessage(p, " %aWorld");
Player.SendMessage(p, " %aRanks");
Player.SendMessage(p, " %aColors");
Player.SendMessage(p, " %aShortcuts");
Player.SendMessage(p, " %aOldMenu");
Player.SendMessage(p, "Command Categories:");
Player.SendMessage(p, " %aBuilding Chat Economy Games Info Moderation Other World");
Player.SendMessage(p, "Other Categories:");
Player.SendMessage(p, " %aRanks Colors Shortcuts Commands");
Player.SendMessage(p, "To view help for a category, type %T/help CategoryName");
Player.SendMessage(p, "To see detailed help for a command, type %T/help CommandName");
Player.SendMessage(p, "To see your stats, type %T/whois");
Player.SendMessage(p, "To see loaded maps, type %T/maps");
Player.SendMessage(p, "To view your personal world options, use %T/OS");
Player.SendMessage(p, "To join a map, type %T/goto WorldName");
Player.SendMessage(p, "To send private messages, type %T@PlayerName Message");
break;
case "ranks":
message = "";
foreach (Group grp in Group.GroupList)
{
if (grp.name != "nobody") // Note that -1 means max undo. Undo anything and everything.
if (grp.Permission < LevelPermission.Nobody) // Note that -1 means max undo. Undo anything and everything.
Player.SendMessage(p, grp.color + grp.name + " - &bCmd: " + grp.maxBlocks + " - &2Undo: " + ((grp.maxUndo != -1) ? grp.maxUndo.ToString() : "max") + " - &cPerm: " + (int)grp.Permission);
}
break;
case "build":
case "building":
PrintHelpForGroup(p, "build", "Building" );
break;
PrintHelpForGroup(p, "build", "Building" ); break;
case "chat":
PrintHelpForGroup(p, "chat", "Chat" );
break;
PrintHelpForGroup(p, "chat", "Chat" ); break;
case "eco":
case "economy":
PrintHelpForGroup(p, "eco", "Economy" );
break;
PrintHelpForGroup(p, "eco", "Economy" ); break;
case "mod":
case "moderation":
PrintHelpForGroup(p, "mod", "Moderation" );
break;
PrintHelpForGroup(p, "mod", "Moderation" ); break;
case "info":
case "information":
PrintHelpForGroup(p, "info", "Information" );
break;
PrintHelpForGroup(p, "info", "Information" ); break;
case "game":
case "games":
PrintHelpForGroup(p, "game", "Game" );
break;
PrintHelpForGroup(p, "game", "Game" ); break;
case "other":
case "others":
PrintHelpForGroup(p, "other", "Other" );
break;
PrintHelpForGroup(p, "other", "Other" ); break;
case "maps":
case "world":
PrintHelpForGroup(p, "world", "World" );
break;
PrintHelpForGroup(p, "world", "World" ); break;
case "short":
case "shortcut":
case "shortcuts":
@ -129,13 +82,12 @@ namespace MCGalaxy.Commands
case "short 2":
case "shortcut 2":
case "shortcuts 2":
bool list1 = true;
try { if (message.Split()[1] == "2") list1 = false; } catch { }
bool list1 = message[message.Length - 1] != '2';
message = "";
List<string> shortcuts = new List<string>();
foreach (Command comm in Command.all.commands)
if (p == null || p.group.commands.All().Contains(comm))
if (comm.shortcut != "") shortcuts.Add(", &b" + comm.shortcut + " " + Server.DefaultColor + "[" + comm.name + "]");
if (comm.shortcut != "") shortcuts.Add(", &b" + comm.shortcut + " %S[" + comm.name + "]");
int top = list1 ? shortcuts.Count / 2 : shortcuts.Count;
for (int i = list1 ? 0 : shortcuts.Count / 2; i < top; i++)
message += shortcuts[i];
@ -153,14 +105,14 @@ namespace MCGalaxy.Commands
case "colors":
Player.SendMessage(p, "&fTo use a color simply put a '%' sign symbol before you put the color code.");
Player.SendMessage(p, "Colors Available:");
Player.SendMessage(p, "0 - &0Black " + Server.DefaultColor + "| 8 - &8Gray");
Player.SendMessage(p, "1 - &1Navy " + Server.DefaultColor + "| 9 - &9Blue");
Player.SendMessage(p, "2 - &2Green " + Server.DefaultColor + "| a - &aLime");
Player.SendMessage(p, "3 - &3Teal " + Server.DefaultColor + "| b - &bAqua");
Player.SendMessage(p, "4 - &4Maroon " + Server.DefaultColor + "| c - &cRed");
Player.SendMessage(p, "5 - &5Purple " + Server.DefaultColor + "| d - &dPink");
Player.SendMessage(p, "6 - &6Gold " + Server.DefaultColor + "| e - &eYellow");
Player.SendMessage(p, "7 - &7Silver " + Server.DefaultColor + "| f - &fWhite");
Player.SendMessage(p, "0 - &0Black %S| 8 - &8Gray");
Player.SendMessage(p, "1 - &1Navy %S| 9 - &9Blue");
Player.SendMessage(p, "2 - &2Green %S| a - &aLime");
Player.SendMessage(p, "3 - &3Teal %S| b - &bAqua");
Player.SendMessage(p, "4 - &4Maroon %S| c - &cRed");
Player.SendMessage(p, "5 - &5Purple %S| d - &dPink");
Player.SendMessage(p, "6 - &6Gold %S| e - &eYellow");
Player.SendMessage(p, "7 - &7Silver %S| f - &fWhite");
break;
case "old":
case "oldmenu":
@ -174,7 +126,18 @@ namespace MCGalaxy.Commands
Player.SendMessage(p, commandsFound.Remove(0, 2));
Player.SendMessage(p, "Type \"/help <command>\" for more help.");
Player.SendMessage(p, "Type \"/help shortcuts\" for shortcuts.");
if (!Server.oldHelp) Player.SendMessage(p, "%bIf you can't see all commands, type %f/help %band choose a help type.");
Player.SendMessage(p, "%bIf you can't see all commands, type %f/help %band choose a help category.");
break;
case "commandsall":
case "commandall":
string commandsAllFound = "";
foreach (Command comm in Command.all.commands)
try { commandsAllFound += ", " + getColor(comm.name) + comm.name; } catch { }
Player.SendMessage(p, "All commands:");
Player.SendMessage(p, commandsAllFound.Remove(0, 2));
Player.SendMessage(p, "Type \"/help <command>\" for more help.");
Player.SendMessage(p, "Type \"/help shortcuts\" for shortcuts.");
Player.SendMessage(p, "%bIf you can't see all commands, type %f/help %band choose a help category.");
break;
default:
Command cmd = Command.all.Find(message);

View File

@ -249,7 +249,6 @@ namespace MCGalaxy.Commands
Server.physUndo = 20000;
Server.totalUndo = 200;
Server.rankSuper = true;
Server.oldHelp = false;
Server.parseSmiley = true;
Server.useWhitelist = false;
Server.forceCuboid = false;

View File

@ -153,6 +153,13 @@ namespace MCGalaxy {
}
}
public void SendBlankMessage() {
byte[] buffer = new byte[66];
buffer[0] = Opcode.Message;
NetUtils.WriteAscii("", buffer, 2);
SendRaw(buffer);
}
public static void SendMessage(Player p, string message) {
SendMessage(p, message, true);
}

View File

@ -1556,7 +1556,7 @@ return;
case "box": cmd = "cuboid"; return true;
case "sphere": cmd = "spheroid"; return true;
case "cmdlist":
case "commands": cmd = "help"; message = "old"; return true;
case "commands": cmd = "help"; message = "commands"; return true;
case "cmdhelp": cmd = "help"; return true;
case "worlds":
case "mapsave": cmd = "save"; return true;

View File

@ -239,10 +239,6 @@ namespace MCGalaxy {
}
Server.IRCColour = color;
break;
case "old-help":
try { Server.oldHelp = bool.Parse(value); }
catch { Server.s.Log("Invalid " + key + ". Using default."); break; }
break;
case "opchat-perm":
try {
sbyte parsed = sbyte.Parse(value);
@ -629,11 +625,6 @@ namespace MCGalaxy {
Server.IgnoreOmnibans = false;
}
break;
case "menu-style":
try { Server.menustyle = Convert.ToInt32(value); }
catch { Server.s.Log("menu-style value invalid! setting to default."); }
break;
}
}
}
@ -771,7 +762,6 @@ namespace MCGalaxy {
w.WriteLine("auto-restart = " + Server.autorestart.ToString().ToLower());
w.WriteLine("restarttime = " + Server.restarttime.ToShortTimeString());
w.WriteLine("restart-on-error = " + Server.restartOnError);
w.WriteLine("menu-style = " + Server.menustyle.ToString());
w.WriteLine("main-name = " + Server.level);
w.WriteLine("default-texture-url = " + Server.defaultTerrainUrl);
w.WriteLine("default-texture-pack-url = " + Server.defaultTexturePackUrl);
@ -792,7 +782,6 @@ namespace MCGalaxy {
w.WriteLine("rplimit = " + Server.rpLimit.ToString().ToLower());
w.WriteLine("rplimit-norm = " + Server.rpNormLimit.ToString().ToLower());
w.WriteLine("physicsrestart = " + Server.physicsRestart.ToString().ToLower());
w.WriteLine("old-help = " + Server.oldHelp.ToString().ToLower());
w.WriteLine("deathcount = " + Server.deathcount.ToString().ToLower());
w.WriteLine("afk-minutes = " + Server.afkminutes.ToString());
w.WriteLine("afk-kick = " + Server.afkkick.ToString());

View File

@ -232,7 +232,6 @@ namespace MCGalaxy
public static string name = "[MCGalaxy] Default";
public static string motd = "Welcome!";
public static byte players = 12;
public static int menustyle = 0;
//for the limiting no. of guests:
public static byte maxGuests = 10;
@ -287,7 +286,6 @@ namespace MCGalaxy
public static int physUndo = 20000;
public static int totalUndo = 200;
public static bool rankSuper = true;
public static bool oldHelp = false;
public static bool parseSmiley = true;
public static bool useWhitelist = false;
public static bool PremiumPlayersOnly = false;