Skip to content

Commit

Permalink
Fixed Core.Blacklist.Commands reference bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bertie2011 committed Feb 12, 2021
1 parent 56879a3 commit 5af1707
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions Core.Blacklist/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,15 @@ private Dictionary<Command, HashSet<string>> BuildReferencesStore(DataPack pack)
foreach (var ownerF in f.ReferencesFlat) {
foreach (var c in ownerF.CommandsFlat) {
if (c.ContentType != Command.Type.Command) continue;
if (!commands.TryGetValue(c, out HashSet<string> info)) {
info = new HashSet<string>();
commands.Add(c, info);
}
info.Add(f.NamespacedIdentifier);
GetOrCreate(commands, c).Add(f.NamespacedIdentifier);
}
}
}
foreach (var ft in ns.TagData.FunctionTags) {
foreach (var ownerF in ft.References.SelectMany(refF => refF.ReferencesFlat)) {
foreach (var c in ownerF.CommandsFlat) {
if (c.ContentType != Command.Type.Command) continue;
commands[c].Add(ft.NamespacedIdentifier);
GetOrCreate(commands, c).Add(ft.NamespacedIdentifier);
}
}
}
Expand All @@ -176,6 +172,14 @@ private Dictionary<Command, HashSet<string>> BuildReferencesStore(DataPack pack)
return commands;
}

private HashSet<string> GetOrCreate(Dictionary<Command, HashSet<string>> references, Command key) {
if (!references.TryGetValue(key, out HashSet<string> result)) {
result = new HashSet<string>();
references.Add(key, result);
}
return result;
}

private bool ValidateConfig(JsonElement? config) {
return config.TryValue(out JsonElement c) && c.IsObject()
&& c.TryAsArray("filters", out JsonElement filters)
Expand Down
2 changes: 1 addition & 1 deletion RecommendedConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"-.*"
],
"commands": [
"-(ban|ban-ip|pardon|kick|op|deop|forceload|stop).*"
"-(ban|ban-ip|pardon|kick|op|deop|forceload|stop|debug).*"
]
}
]
Expand Down

0 comments on commit 5af1707

Please sign in to comment.