Suggestions for unknown command response (#5165)
This commit is contained in:
@@ -236,8 +236,23 @@ public class NetClient implements ApplicationListener{
|
|||||||
}else if(response.type == ResponseType.fewArguments){
|
}else if(response.type == ResponseType.fewArguments){
|
||||||
text = "[scarlet]Too few arguments. Usage:[lightgray] " + response.command.text + "[gray] " + response.command.paramText;
|
text = "[scarlet]Too few arguments. Usage:[lightgray] " + response.command.text + "[gray] " + response.command.paramText;
|
||||||
}else{ //unknown command
|
}else{ //unknown command
|
||||||
|
int minDst = 0;
|
||||||
|
Command closest = null;
|
||||||
|
|
||||||
|
for(Command command : netServer.clientCommands.getCommandList()){
|
||||||
|
int dst = Strings.levenshtein(command.text, response.runCommand);
|
||||||
|
if(dst < 3 && (closest == null || dst < minDst)){
|
||||||
|
minDst = dst;
|
||||||
|
closest = command;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(closest != null){
|
||||||
|
text = "[scarlet]Unknown command. Did you mean \"[lightgray]" + closest.text + "[]\"?";
|
||||||
|
}else{
|
||||||
text = "[scarlet]Unknown command. Check [lightgray]/help[scarlet].";
|
text = "[scarlet]Unknown command. Check [lightgray]/help[scarlet].";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
player.sendMessage(text);
|
player.sendMessage(text);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user