mirror of
https://github.com/ChipmunkMC/node-brigadier-commands.git
synced 2024-11-14 19:14:55 -05:00
findAmbiguities (not tested yet)
This commit is contained in:
parent
0bc661110e
commit
428dcabe2f
1 changed files with 22 additions and 1 deletions
|
@ -33,7 +33,28 @@ class CommandNode {
|
|||
}
|
||||
}
|
||||
|
||||
// findAmbiguities (consumer) {}
|
||||
findAmbiguities (consumer) {
|
||||
const matches = new Set()
|
||||
|
||||
for (const child of Object.values(this.children)) {
|
||||
for (const sibling of Object.values(this.children)) {
|
||||
if (child === sibling) continue
|
||||
|
||||
for (const input of child.getExamples()) {
|
||||
if (sibling.isValidInput(input)) {
|
||||
matches.add(input)
|
||||
}
|
||||
}
|
||||
|
||||
if (matches.size > 0) {
|
||||
consumer.ambiguous(this, child, sibling, matches)
|
||||
matches = new Set()
|
||||
}
|
||||
}
|
||||
|
||||
child.findAmbiguities(consumer)
|
||||
}
|
||||
}
|
||||
|
||||
equals (that) {
|
||||
if (this === that) return true
|
||||
|
|
Loading…
Reference in a new issue