mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-14 20:21:53 +01:00
Avoid server crash if the character is a metacharacter
This commit is contained in:
parent
0a9fa31804
commit
107e1e3e19
@ -14,6 +14,7 @@ import net.minestom.server.network.packet.server.play.TabCompletePacket;
|
||||
import net.minestom.server.utils.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
public class TabCompleteListener {
|
||||
|
||||
@ -23,8 +24,13 @@ public class TabCompleteListener {
|
||||
String commandString = packet.text.replaceFirst(CommandManager.COMMAND_PREFIX, "");
|
||||
String[] split = commandString.split(StringUtils.SPACE);
|
||||
String commandName = split[0];
|
||||
String args;
|
||||
|
||||
String args = commandString.replaceFirst(commandName, "");
|
||||
try {
|
||||
args = commandString.replaceFirst(commandName, "");
|
||||
} catch (PatternSyntaxException exception) {
|
||||
args = commandName.replaceFirst(String.format("\\%s", commandName), "");
|
||||
}
|
||||
|
||||
final CommandQueryResult commandQueryResult = CommandParser.findCommand(commandString);
|
||||
if (commandQueryResult == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user