Skip to content

Commit

Permalink
更新 ConnectCommand.java (#171)
Browse files Browse the repository at this point in the history
修复控制台不能connect域名的bug
  • Loading branch information
kumu7y authored Jan 16, 2025
1 parent e1f51d4 commit 36952ab
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<CommandSourceStack> 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;
Expand Down

0 comments on commit 36952ab

Please sign in to comment.