ServerAddress.java
net.minecraft.client.multiplayer.resolver.ServerAddress
信息
- 全限定名:net.minecraft.client.multiplayer.resolver.ServerAddress
- 类型:public final class
- 包:net.minecraft.client.multiplayer.resolver
- 源码路径:src/main/java/net/minecraft/client/multiplayer/resolver/ServerAddress.java
- 起始行号:L12
- 职责:
TODO
字段/常量
-
LOGGER- 类型:
Logger - 修饰符:
private static final - 源码定位:
L13 - 说明:
TODO
- 类型:
-
hostAndPort- 类型:
HostAndPort - 修饰符:
private final - 源码定位:
L14 - 说明:
TODO
- 类型:
-
INVALID- 类型:
ServerAddress - 修饰符:
private static final - 源码定位:
L15 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public ServerAddress(String host, int port) @ L17
- 构造器名:ServerAddress
- 源码定位:L17
- 修饰符:public
参数:
- host: String
- port: int
说明:
TODO
private ServerAddress(HostAndPort hostAndPort) @ L21
- 构造器名:ServerAddress
- 源码定位:L21
- 修饰符:private
参数:
- hostAndPort: HostAndPort
说明:
TODO
方法
下面的方法块按源码顺序生成。
public String getHost() @ L25
- 方法名:getHost
- 源码定位:L25
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
public int getPort() @ L33
- 方法名:getPort
- 源码定位:L33
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public static ServerAddress parseString(String input) @ L37
- 方法名:parseString
- 源码定位:L37
- 返回类型:ServerAddress
- 修饰符:public static
参数:
- input: String
说明:
TODO
public static boolean isValidAddress(String input) @ L51
- 方法名:isValidAddress
- 源码定位:L51
- 返回类型:boolean
- 修饰符:public static
参数:
- input: String
说明:
TODO
static int parsePort(String str) @ L65
- 方法名:parsePort
- 源码定位:L65
- 返回类型:int
- 修饰符:static
参数:
- str: String
说明:
TODO
public String toString() @ L73
- 方法名:toString
- 源码定位:L73
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean equals(Object o) @ L78
- 方法名:equals
- 源码定位:L78
- 返回类型:boolean
- 修饰符:public
参数:
- o: Object
说明:
TODO
public int hashCode() @ L87
- 方法名:hashCode
- 源码定位:L87
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public final class ServerAddress {
private static final Logger LOGGER = LogUtils.getLogger();
private final HostAndPort hostAndPort;
private static final ServerAddress INVALID = new ServerAddress(HostAndPort.fromParts("server.invalid", 25565));
public ServerAddress(String host, int port) {
this(HostAndPort.fromParts(host, port));
}
private ServerAddress(HostAndPort hostAndPort) {
this.hostAndPort = hostAndPort;
}
public String getHost() {
try {
return IDN.toASCII(this.hostAndPort.getHost());
} catch (IllegalArgumentException var2) {
return "";
}
}
public int getPort() {
return this.hostAndPort.getPort();
}
public static ServerAddress parseString(@Nullable String input) {
if (input == null) {
return INVALID;
} else {
try {
HostAndPort result = HostAndPort.fromString(input).withDefaultPort(25565);
return result.getHost().isEmpty() ? INVALID : new ServerAddress(result);
} catch (IllegalArgumentException var2) {
LOGGER.info("Failed to parse URL {}", input, var2);
return INVALID;
}
}
}
public static boolean isValidAddress(String input) {
try {
HostAndPort hostAndPort = HostAndPort.fromString(input);
String host = hostAndPort.getHost();
if (!host.isEmpty()) {
IDN.toASCII(host);
return true;
}
} catch (IllegalArgumentException var3) {
}
return false;
}
static int parsePort(String str) {
try {
return Integer.parseInt(str.trim());
} catch (Exception var2) {
return 25565;
}
}
@Override
public String toString() {
return this.hostAndPort.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
} else {
return o instanceof ServerAddress ? this.hostAndPort.equals(((ServerAddress)o).hostAndPort) : false;
}
}
@Override
public int hashCode() {
return this.hostAndPort.hashCode();
}
}引用的其他类
- 无