mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-10-03 02:21:53 -04:00
Fix unloading custom commands not removing command aliases
This commit is contained in:
parent
89221b1110
commit
59b86d578d
@ -85,5 +85,21 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary> Registers default aliases specified by a command. </summary>
|
||||
internal static void RegisterDefaults(Command cmd) {
|
||||
CommandAlias[] aliases = cmd.Aliases;
|
||||
if (aliases == null) return;
|
||||
|
||||
foreach (CommandAlias a in aliases) {
|
||||
Alias alias = new Alias(a.Trigger, cmd.name, a.Format);
|
||||
coreAliases.Add(alias);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void UnregisterDefaults(Command cmd) {
|
||||
if (cmd.Aliases == null) return;
|
||||
coreAliases.RemoveAll(a => a.Target == cmd.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,14 +87,8 @@ namespace MCGalaxy {
|
||||
CommandExtraPerms.Set(cmd.name, i + 1, extra[i].Description,
|
||||
extra[i].Perm, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
CommandAlias[] aliases = cmd.Aliases;
|
||||
if (aliases == null) return;
|
||||
foreach (CommandAlias a in aliases) {
|
||||
Alias alias = new Alias(a.Trigger, cmd.name, a.Format);
|
||||
Alias.coreAliases.Add(alias);
|
||||
}
|
||||
}
|
||||
Alias.RegisterDefaults(cmd);
|
||||
}
|
||||
|
||||
public static Command Find(string name) {
|
||||
@ -109,6 +103,8 @@ namespace MCGalaxy {
|
||||
foreach (Group grp in Group.GroupList) {
|
||||
grp.Commands.Remove(cmd);
|
||||
}
|
||||
|
||||
Alias.UnregisterDefaults(cmd);
|
||||
return removed;
|
||||
}
|
||||
|
||||
@ -148,7 +144,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
// Clunky design, but needed to stay backwards compatible with custom commands
|
||||
public abstract class Command2 : Command {
|
||||
public abstract class Command2 : Command {
|
||||
public override void Use(Player p, string message) {
|
||||
if (p == null) p = Player.Console;
|
||||
Use(p, message, p.DefaultCmdData);
|
||||
|
Loading…
x
Reference in New Issue
Block a user