Add /help emotes, fixes #374

This commit is contained in:
UnknownShadow200 2017-09-21 14:01:04 +10:00
parent ff534860ec
commit dab15609b3
5 changed files with 86 additions and 66 deletions

View File

@ -6,7 +6,7 @@ namespace MCGalaxy {
public static class EmotesHandler {
public static readonly Dictionary<string, char> EmoteKeywords = new Dictionary<string, char> {
public static readonly Dictionary<string, char> Keywords = new Dictionary<string, char> {
{ "darksmile", '☺' },
{ "smile", '☻' },
{ "heart", '♥' }, { "hearts", '♥' },
@ -16,6 +16,7 @@ namespace MCGalaxy {
{ "*", '•' }, { "bullet", '•' }, { "dot", '•' }, { "point", '•' },
{ "hole", '◘' },
{ "circle", '○' }, { "o", '○' },
{ "inversecircle", '◙' },
{ "male", '♂' }, { "mars", '♂' },
{ "female", '♀' }, { "venus", '♀' },
{ "8", '♪' }, { "note", '♪' }, { "quaver", '♪' },
@ -49,7 +50,7 @@ namespace MCGalaxy {
"█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■\u00a0";
public static string Replace(string message) {
return Unescape(message, '(', ')', EmoteKeywords);
return Unescape(message, '(', ')', Keywords);
}
public static string Unescape(string message, char start, char end,

View File

@ -27,10 +27,10 @@ namespace MCGalaxy.Commands.Info {
}
public override void Use(Player p, string message) {
if (!DoCommand(p, message)) Help(p);
if (!ListCommands(p, message)) Help(p);
}
internal static bool DoCommand(Player p, string message) {
internal static bool ListCommands(Player p, string message) {
string[] args = message.SplitSpaces();
string sort = args.Length > 1 ? args[1].ToLower() : "";
string modifier = args.Length > 2 ? args[2] : sort;

View File

@ -14,7 +14,6 @@ permissions and limitations under the Licenses.
*/
using System;
using System.Collections.Generic;
using System.Text;
using MCGalaxy.Blocks;
using MCGalaxy.Commands.CPE;
@ -26,54 +25,39 @@ namespace MCGalaxy.Commands.Info {
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
public override CommandAlias[] Aliases {
get { return new[] { new CommandAlias("CmdHelp"), new CommandAlias("Ranks", "ranks"),
new CommandAlias("Colors", "colors") }; }
new CommandAlias("Colors", "colors"), new CommandAlias("Emotes", "emotes") }; }
}
public override void Use(Player p, string message) {
switch (message.ToLower()) {
case "":
Player.Message(p, "%HCommand Categories:");
Player.Message(p, " %TBuilding Chat Economy Games Info Moderation Other World");
Player.Message(p, "%HOther Categories:");
Player.Message(p, " %TRanks Colors Shortcuts Commands");
Player.Message(p, "%HTo view help for a category, type %T/Help CategoryName");
Player.Message(p, "%HTo see detailed help for a command, type %T/Help CommandName");
Player.Message(p, "%HTo see your stats, type %T/Info");
Player.Message(p, "%HTo see loaded maps, type %T/Maps");
Player.Message(p, "%HTo view your personal world options, use %T/Realm");
Player.Message(p, "%HTo join a map, type %T/Goto WorldName");
Player.Message(p, "%HTo send private messages, type %T@PlayerName Message");
break;
case "ranks":
PrintRanks(p); break;
case "colours":
case "colors":
Player.Message(p, "&fTo use a color, put a '%' and then put the color code.");
Player.Message(p, "Colors Available:");
Player.Message(p, "0 - &0{0} %S| 1 - &1{1} %S| 2 - &2{2} %S| 3 - &3{3}",
Colors.Name('0'), Colors.Name('1'), Colors.Name('2'), Colors.Name('3'));
Player.Message(p, "4 - &4{0} %S| 5 - &5{1} %S| 6 - &6{2} %S| 7 - &7{3}",
Colors.Name('4'), Colors.Name('5'), Colors.Name('6'), Colors.Name('7'));
Player.Message(p, "8 - &8{0} %S| 9 - &9{1} %S| a - &a{2} %S| b - &b{3}",
Colors.Name('8'), Colors.Name('9'), Colors.Name('a'), Colors.Name('b'));
Player.Message(p, "c - &c{0} %S| d - &d{1} %S| e - &e{2} %S| f - &f{3}",
Colors.Name('c'), Colors.Name('d'), Colors.Name('e'), Colors.Name('f'));
foreach (ColorDesc col in Colors.List) {
if (col.Undefined || Colors.IsStandard(col.Code)) continue;
Player.Message(p, CmdCustomColors.FormatColor(col));
}
break;
default:
if (CmdCommands.DoCommand(p, message)) break;
if (ParseCommand(p, message) || ParseBlock(p, message) || ParsePlugin(p, message)) return;
Player.Message(p, "Could not find command, plugin or block specified.");
break;
if (message.Length == 0) {
PrintHelpMenu(p);
} else if (message.CaselessEq("ranks")) {
PrintRanks(p);
} else if (message.CaselessEq("colors") || message.CaselessEq("colours")) {
PrintColors(p);
} else if (message.CaselessEq("emotes") || message.CaselessStarts("emotes ")) {
PrintEmotes(p, message);
} else {
if (CmdCommands.ListCommands(p, message)) return;
if (ParseCommand(p, message) || ParseBlock(p, message) || ParsePlugin(p, message)) return;
Player.Message(p, "Could not find command, plugin or block specified.");
}
}
static void PrintHelpMenu(Player p) {
Player.Message(p, "%HCommand Categories:");
Player.Message(p, " %TBuilding Chat Economy Games Info Moderation Other World");
Player.Message(p, "%HOther Categories:");
Player.Message(p, " %TRanks Colors Emotes Shortcuts Commands");
Player.Message(p, "%HTo view help for a category, type %T/Help CategoryName");
Player.Message(p, "%HTo see detailed help for a command, type %T/Help CommandName");
Player.Message(p, "%HTo see your stats, type %T/Info");
Player.Message(p, "%HTo see loaded maps, type %T/Maps");
Player.Message(p, "%HTo view your personal world options, use %T/Realm");
Player.Message(p, "%HTo join a map, type %T/Goto WorldName");
Player.Message(p, "%HTo send private messages, type %T@PlayerName Message");
}
static void PrintRanks(Player p) {
foreach (Group grp in Group.GroupList) {
if (grp.Permission >= LevelPermission.Nobody) continue; // Note that -1 means max undo. Undo anything and everything.
@ -84,6 +68,44 @@ namespace MCGalaxy.Commands.Info {
}
}
static void PrintColors(Player p) {
Player.Message(p, "&fTo use a color, put a '%' and then put the color code.");
Player.Message(p, "Colors Available:");
Player.Message(p, "0 - &0{0} %S| 1 - &1{1} %S| 2 - &2{2} %S| 3 - &3{3}",
Colors.Name('0'), Colors.Name('1'), Colors.Name('2'), Colors.Name('3'));
Player.Message(p, "4 - &4{0} %S| 5 - &5{1} %S| 6 - &6{2} %S| 7 - &7{3}",
Colors.Name('4'), Colors.Name('5'), Colors.Name('6'), Colors.Name('7'));
Player.Message(p, "8 - &8{0} %S| 9 - &9{1} %S| a - &a{2} %S| b - &b{3}",
Colors.Name('8'), Colors.Name('9'), Colors.Name('a'), Colors.Name('b'));
Player.Message(p, "c - &c{0} %S| d - &d{1} %S| e - &e{2} %S| f - &f{3}",
Colors.Name('c'), Colors.Name('d'), Colors.Name('e'), Colors.Name('f'));
foreach (ColorDesc col in Colors.List) {
if (col.Undefined || Colors.IsStandard(col.Code)) continue;
Player.Message(p, CmdCustomColors.FormatColor(col));
}
}
static void PrintEmotes(Player p, string message) {
char[] emotes = EmotesHandler.ControlCharReplacements.ToCharArray();
emotes[0] = EmotesHandler.ExtendedCharReplacements[0]; // replace NULL with house
string[] args = message.SplitSpaces(2);
string modifier = args.Length > 1 ? args[1] : "";
MultiPageOutput.Output(p, emotes, FormatEmote,
"Help emotes", "emotes", modifier, true);
}
static string FormatEmote(char emote) {
List<string> keywords = new List<string>();
foreach (KeyValuePair<string, char> kvp in EmotesHandler.Keywords) {
if (kvp.Value == emote) keywords.Add("(%S" + kvp.Key + ")");
}
return "&f" + emote + " %S- " + keywords.Join();
}
bool ParseCommand(Player p, string message) {
string[] args = message.SplitSpaces(2);
Alias alias = Alias.Find(args[0]);

View File

@ -37,22 +37,18 @@ namespace MCGalaxy.Commands.Moderation {
}
public override void Use(Player p, string message) {
if (p != null && message.Length == 0) message = "enter";
switch (message.ToLower()) {
case "enter":
HandleEnter(p); break;
case "list":
case "view":
HandleView(p); break;
case "leave":
HandleLeave(p); break;
case "next":
HandleNext(p); break;
case "clear":
HandleClear(p); break;
default:
Help(p); break;
if (message.Length == 0 || message.CaselessEq("enter")) {
HandleEnter(p);
} else if (message.CaselessEq("list") || message.CaselessEq("view")) {
HandleView(p);
} else if (message.CaselessEq("leave")) {
HandleLeave(p);
} else if (message.CaselessEq("next")) {
HandleNext(p);
} else if (message.CaselessEq("clear")) {
HandleClear(p);
} else {
Help(p);
}
}
@ -83,7 +79,8 @@ namespace MCGalaxy.Commands.Moderation {
if (pos == 1) { Player.Message(p, "You entered the &creview %Squeue. There is &c1 %Sperson in front of you in the queue"); }
if (pos == 0) { Player.Message(p, "You entered the &creview %Squeue. You are &cfirst %Sin line!"); }
string msg = opsOn ? "The Online staff have been notified. Someone should be with you shortly." :
string msg = opsOn ?
"The Online staff have been notified. Someone should be with you shortly." :
"There are currently no staff online. Staff will be notified when they join the server.";
Player.Message(p, msg);

View File

@ -28,7 +28,7 @@ namespace MCGalaxy {
public static void Output<T>(Player p, IList<T> items, StringFormatter<T> formatter,
string cmd, string type, string modifier, bool lines) {
int page = 0, total = items.Count;
int perPage = lines ? 10 : 30;
int perPage = lines ? 8 : 30;
if (modifier.Length == 0) {
OutputPage(p, items, formatter, cmd, type, 1, lines);
@ -46,7 +46,7 @@ namespace MCGalaxy {
static void OutputPage<T>(Player p, IList<T> items, StringFormatter<T> formatter,
string cmd, string type, int start, bool lines) {
int perPage = lines ? 10 : 30;
int perPage = lines ? 8 : 30;
start = Utils.Clamp(start - 1, 0, items.Count - 1); // want item numbers to start at 1
int end = Math.Min(start + perPage, items.Count);
OutputItems(p, items, start, end, lines, formatter);