mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Add /help emotes, fixes #374
This commit is contained in:
parent
ff534860ec
commit
dab15609b3
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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,16 +25,30 @@ 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 "":
|
||||
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 Shortcuts Commands");
|
||||
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");
|
||||
@ -43,11 +56,19 @@ namespace MCGalaxy.Commands.Info {
|
||||
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":
|
||||
}
|
||||
|
||||
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.
|
||||
int count = grp.Players.Count;
|
||||
Player.Message(p, "{0} %S- Cmd: {2}, Undo: {3}, Perm: {4}",
|
||||
grp.ColoredName, count, grp.DrawLimit,
|
||||
grp.MaxUndo == -1 ? "max" : grp.MaxUndo.ToString(), (int)grp.Permission);
|
||||
}
|
||||
}
|
||||
|
||||
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:");
|
||||
|
||||
@ -65,23 +86,24 @@ namespace MCGalaxy.Commands.Info {
|
||||
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 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.
|
||||
int count = grp.Players.Count;
|
||||
Player.Message(p, "{0} %S- Cmd: {2}, Undo: {3}, Perm: {4}",
|
||||
grp.ColoredName, count, grp.DrawLimit,
|
||||
grp.MaxUndo == -1 ? "max" : grp.MaxUndo.ToString(), (int)grp.Permission);
|
||||
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) {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user