mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Tiny bit faster startup
This commit is contained in:
parent
9d66e40bef
commit
07fc31d061
@ -80,8 +80,8 @@ namespace MCGalaxy {
|
||||
Alias alias = Alias.Find(cmd);
|
||||
// Aliases should be able to override built in shortcuts
|
||||
if (alias == null) {
|
||||
string shortcut = all.FindShort(cmd);
|
||||
if (shortcut != "") cmd = shortcut;
|
||||
Command shortcut = all.FindByShortcut(cmd);
|
||||
if (shortcut != null) cmd = shortcut.name;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -44,13 +44,9 @@ namespace MCGalaxy {
|
||||
|
||||
public bool Remove(Command cmd) { return commands.Remove(cmd); }
|
||||
public bool Contains(Command cmd) { return commands.Contains(cmd); }
|
||||
public bool Contains(string name) {
|
||||
foreach (Command cmd in commands) {
|
||||
if (cmd.name.CaselessEq(name)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public bool Contains(string name) { return FindByName(name) != null; }
|
||||
|
||||
/// <summary> Finds the command which has the given name or shortcut, or null if not found. </summary>
|
||||
public Command Find(string name) {
|
||||
name = name.ToLower();
|
||||
foreach (Command cmd in commands) {
|
||||
@ -58,14 +54,22 @@ namespace MCGalaxy {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public string FindShort(string shortcut) {
|
||||
if (shortcut == "") return "";
|
||||
|
||||
|
||||
/// <summary> Finds the command which has the given name, or null if not found. </summary>
|
||||
public Command FindByName(string name) {
|
||||
foreach (Command cmd in commands) {
|
||||
if (cmd.shortcut.CaselessEq(shortcut)) return cmd.name;
|
||||
if (cmd.name.CaselessEq(name)) return cmd;
|
||||
}
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary> Finds the command which has the given shortcut, or null if not found. </summary>
|
||||
public Command FindByShortcut(string shortcut) {
|
||||
if (shortcut == "") return null;
|
||||
foreach (Command cmd in commands) {
|
||||
if (cmd.shortcut.CaselessEq(shortcut)) return cmd;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Command> All() { return new List<Command>(commands); }
|
||||
|
@ -114,7 +114,7 @@ namespace MCGalaxy.Commands {
|
||||
foreach (CommandPerms perms in list) {
|
||||
bool canUse = perms.MinRank <= perm && !perms.Disallowed.Contains(perm);
|
||||
if (canUse || perms.Allowed.Contains(perm)) {
|
||||
Command cmd = Command.all.Find(perms.CmdName);
|
||||
Command cmd = Command.all.FindByName(perms.CmdName);
|
||||
if (cmd != null) commands.Add(cmd);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user