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

View File

@ -14,7 +14,6 @@ permissions and limitations under the Licenses.
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using MCGalaxy.Blocks; using MCGalaxy.Blocks;
using MCGalaxy.Commands.CPE; using MCGalaxy.Commands.CPE;
@ -26,54 +25,39 @@ namespace MCGalaxy.Commands.Info {
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } } public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
public override CommandAlias[] Aliases { public override CommandAlias[] Aliases {
get { return new[] { new CommandAlias("CmdHelp"), new CommandAlias("Ranks", "ranks"), 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) { public override void Use(Player p, string message) {
switch (message.ToLower()) { if (message.Length == 0) {
case "": PrintHelpMenu(p);
Player.Message(p, "%HCommand Categories:"); } else if (message.CaselessEq("ranks")) {
Player.Message(p, " %TBuilding Chat Economy Games Info Moderation Other World"); PrintRanks(p);
Player.Message(p, "%HOther Categories:"); } else if (message.CaselessEq("colors") || message.CaselessEq("colours")) {
Player.Message(p, " %TRanks Colors Shortcuts Commands"); PrintColors(p);
Player.Message(p, "%HTo view help for a category, type %T/Help CategoryName"); } else if (message.CaselessEq("emotes") || message.CaselessStarts("emotes ")) {
Player.Message(p, "%HTo see detailed help for a command, type %T/Help CommandName"); PrintEmotes(p, message);
Player.Message(p, "%HTo see your stats, type %T/Info"); } else {
Player.Message(p, "%HTo see loaded maps, type %T/Maps"); if (CmdCommands.ListCommands(p, message)) return;
Player.Message(p, "%HTo view your personal world options, use %T/Realm"); if (ParseCommand(p, message) || ParseBlock(p, message) || ParsePlugin(p, message)) return;
Player.Message(p, "%HTo join a map, type %T/Goto WorldName"); Player.Message(p, "Could not find command, plugin or block specified.");
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;
} }
} }
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) { static void PrintRanks(Player p) {
foreach (Group grp in Group.GroupList) { foreach (Group grp in Group.GroupList) {
if (grp.Permission >= LevelPermission.Nobody) continue; // Note that -1 means max undo. Undo anything and everything. 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) { bool ParseCommand(Player p, string message) {
string[] args = message.SplitSpaces(2); string[] args = message.SplitSpaces(2);
Alias alias = Alias.Find(args[0]); Alias alias = Alias.Find(args[0]);

View File

@ -37,22 +37,18 @@ namespace MCGalaxy.Commands.Moderation {
} }
public override void Use(Player p, string message) { public override void Use(Player p, string message) {
if (p != null && message.Length == 0) message = "enter"; if (message.Length == 0 || message.CaselessEq("enter")) {
HandleEnter(p);
switch (message.ToLower()) { } else if (message.CaselessEq("list") || message.CaselessEq("view")) {
case "enter": HandleView(p);
HandleEnter(p); break; } else if (message.CaselessEq("leave")) {
case "list": HandleLeave(p);
case "view": } else if (message.CaselessEq("next")) {
HandleView(p); break; HandleNext(p);
case "leave": } else if (message.CaselessEq("clear")) {
HandleLeave(p); break; HandleClear(p);
case "next": } else {
HandleNext(p); break; Help(p);
case "clear":
HandleClear(p); break;
default:
Help(p); break;
} }
} }
@ -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 == 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!"); } 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."; "There are currently no staff online. Staff will be notified when they join the server.";
Player.Message(p, msg); 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, public static void Output<T>(Player p, IList<T> items, StringFormatter<T> formatter,
string cmd, string type, string modifier, bool lines) { string cmd, string type, string modifier, bool lines) {
int page = 0, total = items.Count; int page = 0, total = items.Count;
int perPage = lines ? 10 : 30; int perPage = lines ? 8 : 30;
if (modifier.Length == 0) { if (modifier.Length == 0) {
OutputPage(p, items, formatter, cmd, type, 1, lines); 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, static void OutputPage<T>(Player p, IList<T> items, StringFormatter<T> formatter,
string cmd, string type, int start, bool lines) { 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 start = Utils.Clamp(start - 1, 0, items.Count - 1); // want item numbers to start at 1
int end = Math.Min(start + perPage, items.Count); int end = Math.Min(start + perPage, items.Count);
OutputItems(p, items, start, end, lines, formatter); OutputItems(p, items, start, end, lines, formatter);