Skip to content

Commit

Permalink
Fixed Core.Blacklist.Commands reference bug.
Browse files Browse the repository at this point in the history
Bertie2011 committed Feb 12, 2021

Verified

This commit was signed with the committer’s verified signature.
1 parent 56879a3 commit 5af1707
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
@@ -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);
}
}
}
@@ -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)
2 changes: 1 addition & 1 deletion RecommendedConfig.json
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
"-.*"
],
"commands": [
"-(ban|ban-ip|pardon|kick|op|deop|forceload|stop).*"
"-(ban|ban-ip|pardon|kick|op|deop|forceload|stop|debug).*"
]
}
]

0 comments on commit 5af1707

Please sign in to comment.