记录类 ServerStatusPing
{
"fmlNetworkVersion" : FMLNETVERSION,
"channels": [
{
"res": "fml:handshake",
"version": "1.2.3.4",
"required": true
}
],
"mods": [
{
"modid": "modid",
"modmarker": "{@literal <somestring>}"
}
]
}
Due to size of the ping packet (32767 UTF-16 code points of JSON data) this could exceed this limit and cause issues. To work around this, a truncation mechanism was introduced, to heuristically truncate the size of the data, at the expense of making the compatibility info on the server screen inaccurate.
Modern versions will send binary data, which is encoded in a custom format optimized for UTF-16 code point count.
See encodeOptimized(ByteBuf)
and decodeOptimized(String)
.
Essentially 15 bits of binary data are encoded into every UTF-16 code point. The resulting string is then stored in
the "d" property of the resulting JSON.
The "channels" and "mods" properties are retained for backwards compatibility, but left empty. A client that cannot read the old format would not be able to connect anyways, but the properties must exist to not cause exceptions.
{
"fmlNetworkVersion": FMLNETVERSION,
"channels": [],
"mods": [],
"d": "<binary data>"
}
-
嵌套类概要
嵌套类修饰符和类型类说明static final record
static final record
-
字段概要
字段修饰符和类型字段说明private static final com.mojang.serialization.Codec
<io.netty.buffer.ByteBuf> private final Map
<ResourceLocation, ServerStatusPing.ChannelData> channels
记录组件的字段。static final com.mojang.serialization.Codec
<ServerStatusPing> private final int
fmlNetworkVer
记录组件的字段。mods
记录组件的字段。private final boolean
truncated
记录组件的字段。private static final int
-
构造器概要
构造器构造器说明ServerStatusPing
(Map<ResourceLocation, ServerStatusPing.ChannelData> channels, Map<String, String> mods, int fmlNetworkVer, boolean truncated) 创建ServerStatusPing
记录类的实例。 -
方法概要
修饰符和类型方法说明channels()
返回channels
记录组件的值。private static io.netty.buffer.ByteBuf
Decode binary data encoded byencodeOptimized(io.netty.buffer.ByteBuf)
private static ServerStatusPing
deserializeOptimized
(int fmlNetworkVersion, io.netty.buffer.ByteBuf bbuf) private static String
encodeOptimized
(io.netty.buffer.ByteBuf buf) Encode given ByteBuf to a String.boolean
指示某个其他对象是否“等于”此对象。int
返回fmlNetworkVer
记录组件的值。getChannelsForMod
(String modId) int
int
hashCode()
返回此对象的哈希代码值。boolean
mods()
返回mods
记录组件的值。io.netty.buffer.ByteBuf
toBuf()
final String
toString()
返回此记录类的字符串表示形式。boolean
返回truncated
记录组件的值。
-
字段详细资料
-
channels
channels
记录组件的字段。 -
mods
mods
记录组件的字段。 -
fmlNetworkVer
private final int fmlNetworkVerfmlNetworkVer
记录组件的字段。 -
truncated
private final boolean truncatedtruncated
记录组件的字段。 -
BYTE_BUF_CODEC
private static final com.mojang.serialization.Codec<io.netty.buffer.ByteBuf> BYTE_BUF_CODEC -
CODEC
-
VERSION_FLAG_IGNORESERVERONLY
private static final int VERSION_FLAG_IGNORESERVERONLY- 另请参阅:
-
-
构造器详细资料
-
ServerStatusPing
public ServerStatusPing() -
ServerStatusPing
public ServerStatusPing(Map<ResourceLocation, ServerStatusPing.ChannelData> channels, Map<String, String> mods, int fmlNetworkVer, boolean truncated) 创建ServerStatusPing
记录类的实例。- 参数:
channels
-channels
记录组件的值mods
-mods
记录组件的值fmlNetworkVer
-fmlNetworkVer
记录组件的值truncated
-truncated
记录组件的值
-
-
方法详细资料
-
equals
指示某个其他对象是否“等于”此对象。如果两个对象属于同一个类,而且所有记录组件都相等,则这两个对象相等。 使用Objects::equals(Object,Object)
对参考组件进行比较;使用 '==' 对基元组件进行比较 -
hashCode
public int hashCode()返回此对象的哈希代码值。此值派生自每个记录组件的哈希代码。 -
getChannelsForMod
private List<Map.Entry<ResourceLocation,ServerStatusPing.ChannelData>> getChannelsForMod(String modId) -
getNonModChannels
-
toBuf
public io.netty.buffer.ByteBuf toBuf() -
deserializeOptimized
private static ServerStatusPing deserializeOptimized(int fmlNetworkVersion, io.netty.buffer.ByteBuf bbuf) -
encodeOptimized
Encode given ByteBuf to a String. This is optimized for UTF-16 Code-Point count. Supports at most 2^30 bytes in length -
decodeOptimized
Decode binary data encoded byencodeOptimized(io.netty.buffer.ByteBuf)
-
getRemoteChannels
-
getRemoteModData
-
getFMLNetworkVersion
public int getFMLNetworkVersion() -
isTruncated
public boolean isTruncated() -
toString
返回此记录类的字符串表示形式。此表示形式包含类的名称,后跟每个记录组件的名称和值。 -
channels
返回channels
记录组件的值。- 返回:
channels
记录组件的值
-
mods
返回mods
记录组件的值。- 返回:
mods
记录组件的值
-
fmlNetworkVer
public int fmlNetworkVer()返回fmlNetworkVer
记录组件的值。- 返回:
fmlNetworkVer
记录组件的值
-
truncated
public boolean truncated()返回truncated
记录组件的值。- 返回:
truncated
记录组件的值
-