mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-28 11:01:35 +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 net.minestom.server.utils.StringUtils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.regex.PatternSyntaxException;
|
||||||
|
|
||||||
public class TabCompleteListener {
|
public class TabCompleteListener {
|
||||||
|
|
||||||
@ -23,8 +24,13 @@ public class TabCompleteListener {
|
|||||||
String commandString = packet.text.replaceFirst(CommandManager.COMMAND_PREFIX, "");
|
String commandString = packet.text.replaceFirst(CommandManager.COMMAND_PREFIX, "");
|
||||||
String[] split = commandString.split(StringUtils.SPACE);
|
String[] split = commandString.split(StringUtils.SPACE);
|
||||||
String commandName = split[0];
|
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);
|
final CommandQueryResult commandQueryResult = CommandParser.findCommand(commandString);
|
||||||
if (commandQueryResult == null) {
|
if (commandQueryResult == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user