From 80a788019cd773f763840a13f83d6ca01db28e47 Mon Sep 17 00:00:00 2001 From: kumu7y Date: Tue, 14 Jan 2025 09:22:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20ConnectCommand.java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复控制台不能connect域名的bug --- .../cn/evole/mods/mcbot/common/command/ConnectCommand.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/cn/evole/mods/mcbot/common/command/ConnectCommand.java b/common/src/main/java/cn/evole/mods/mcbot/common/command/ConnectCommand.java index 8f1a62d..83d1109 100644 --- a/common/src/main/java/cn/evole/mods/mcbot/common/command/ConnectCommand.java +++ b/common/src/main/java/cn/evole/mods/mcbot/common/command/ConnectCommand.java @@ -18,11 +18,12 @@ public class ConnectCommand { private static final Pattern ipv4Pattern = Pattern.compile("(\\d+\\.\\d+\\.\\d+\\.\\d+):(\\d+)"); private static final Pattern ipv6Pattern = Pattern.compile("\\[([0-9a-fA-F:]+)]:(\\d+)"); + private static final Pattern domainPattern = Pattern.compile("([a-zA-Z0-9.-]+):(\\d+)"); public static int execute(CommandContext context) throws CommandSyntaxException { val parameter = context.getArgument("parameter", String.class); - if (ipv4Pattern.matcher(parameter).find() || ipv6Pattern.matcher(parameter).find()) { + if (ipv4Pattern.matcher(parameter).find() || ipv6Pattern.matcher(parameter).find()|| domainPattern.matcher(parameter).find()) { ModConfig.get().getBotConfig().getUrl().setValueFromString(String.format("ws://%s", parameter)); doConnect(context); return 1;