Use Pattern#quote instead of \\

This commit is contained in:
R0bbyYT 2021-05-17 20:40:29 +02:00
parent 107e1e3e19
commit 17ce859bdd

View File

@ -14,7 +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;
import java.util.regex.Pattern;
public class TabCompleteListener {
@ -24,13 +24,7 @@ public class TabCompleteListener {
String commandString = packet.text.replaceFirst(CommandManager.COMMAND_PREFIX, "");
String[] split = commandString.split(StringUtils.SPACE);
String commandName = split[0];
String args;
try {
args = commandString.replaceFirst(commandName, "");
} catch (PatternSyntaxException exception) {
args = commandName.replaceFirst(String.format("\\%s", commandName), "");
}
String args = commandString.replaceFirst(Pattern.quote(commandName), "");
final CommandQueryResult commandQueryResult = CommandParser.findCommand(commandString);
if (commandQueryResult == null) {