Fix fuzzy matching bug

This commit is contained in:
Gabriel Tofvesson 2021-05-06 18:41:42 +02:00
parent 5c380cccc3
commit 424bc4f706

View File

@ -109,9 +109,11 @@ public class TabCompletionListener implements Listener {
public static Material getMaterialMatching(final String arg) {
final List<Material> mats = getAllMaterialsMatching(arg).collect(Collectors.toList());
if (mats.size() != 1)
return null;
final Material exact = mats.stream()
.filter(it -> multiNS ? arg.equals(it.getKey().toString()) : arg.equals(it.getKey().getKey()))
.findFirst()
.orElse(null);
return mats.get(0);
return exact != null ? exact : mats.size() == 1 ? mats.get(0) : null;
}
}