dev.polymodloader.api.network
이 페이지는 소스의 Javadoc에서 ./gradlew apiReference로 만든 것입니다. 설명은 코드에 적힌 영어 그대로입니다. 직접 고치지 말고 소스의 주석을 고친 뒤 다시 만드세요.
| 형식 | 종류 | 설명 |
|---|---|---|
ClientPayloadHandler | 함수형 인터페이스 | Handles a payload the server sent to this client. |
ConfigurationExchange | 인터페이스 | A question the server asks each joining client before the player enters the world, during the game's configuration phase: to check versions, agree on settings, or send data the client needs first. |
ConfigurationExchange.Answer | 함수형 인터페이스 | The client's reply. |
ConfigurationExchange.Check | 함수형 인터페이스 | The server's decision. |
ConfigurationExchange.Request | 함수형 인터페이스 | The server's message for a joining player. |
NetworkRegistrar | 인터페이스 | Declares a mod's network channels. |
PayloadChannel | 인터페이스 | A two-way channel for one payload type. |
PayloadCodec | 인터페이스 | Converts a payload to and from bytes. |
PayloadReader | 인터페이스 | Reads payload values written by PayloadWriter. |
PayloadWriter | 인터페이스 | Writes payload values in big-endian order. |
ServerPayloadHandler | 함수형 인터페이스 | Handles a payload a client sent to the server. |
ClientPayloadHandler
함수형 인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public interface ClientPayloadHandler<T>
Handles a payload the server sent to this client.
receive(T)
void receive(T payload)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Called on the client thread.
| 인자 | 타입 | 설명 |
|---|---|---|
payload | T | — |
ConfigurationExchange
인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public interface ConfigurationExchange<T>
A question the server asks each joining client before the player enters the world, during the game's configuration phase: to check versions, agree on settings, or send data the client needs first. The player joins only after the exchange finishes, and the server may refuse the connection.
- The server's
serverRequestdecides what to send to the player, or skips them. - The client's
clientAnswerreplies. - The server's
serverChecksees the reply, or nothing if the client did not answer withintimeoutTicks(a client without the mod never answers), and lets the player in or refuses with a message.
Set the server parts in a common entrypoint and the client part in a client entrypoint. Without a serverCheck, a player whose client gives no answer is refused. Server parts run on the server thread, the client part on the client thread.
id()
ResourceId id()
추가된 버전 0.1.0-alpha.4 또는 그 이전
The exchange's ID, <mod id>:<path>.
반환 ResourceId
serverRequest(ConfigurationExchange.Request<T>)
ConfigurationExchange<T> serverRequest(ConfigurationExchange.Request<T> request)
추가된 버전 0.1.0-alpha.4 또는 그 이전
What the server sends to each joining player; without it the exchange is skipped.
| 인자 | 타입 | 설명 |
|---|---|---|
request | ConfigurationExchange.Request<T> | — |
반환 ConfigurationExchange<T>
clientAnswer(ConfigurationExchange.Answer<T>)
ConfigurationExchange<T> clientAnswer(ConfigurationExchange.Answer<T> answer)
추가된 버전 0.1.0-alpha.4 또는 그 이전
How the client answers; without it the client does not answer.
| 인자 | 타입 | 설명 |
|---|---|---|
answer | ConfigurationExchange.Answer<T> | — |
반환 ConfigurationExchange<T>
serverCheck(ConfigurationExchange.Check<T>)
ConfigurationExchange<T> serverCheck(ConfigurationExchange.Check<T> check)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Whether the server lets the player in after the client's answer.
| 인자 | 타입 | 설명 |
|---|---|---|
check | ConfigurationExchange.Check<T> | — |
반환 ConfigurationExchange<T>
timeoutTicks(int)
ConfigurationExchange<T> timeoutTicks(int ticks)
추가된 버전 0.1.0-alpha.4 또는 그 이전
How long the server waits for the answer, in ticks; 100 (5 seconds) by default.
| 인자 | 타입 | 설명 |
|---|---|---|
ticks | int | — |
반환 ConfigurationExchange<T>
예외 IllegalArgumentException — outside 1–1200
ConfigurationExchange.Answer
함수형 인터페이스 · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public static interface Answer<T>
The client's reply.
answer(T)
T answer(T request)
추가된 버전 0.1.0-alpha.4 또는 그 이전
The reply to the server's request.
| 인자 | 타입 | 설명 |
|---|---|---|
request | T | — |
반환 T
ConfigurationExchange.Check
함수형 인터페이스 · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public static interface Check<T>
The server's decision.
check(UUID, String, Optional<T>)
Optional<String> check(UUID playerId, String playerName, Optional<T> reply)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Empty to let the player in, or the message shown to them when the connection is refused.
| 인자 | 타입 | 설명 |
|---|---|---|
playerId | UUID | the player's UUID |
playerName | String | the player's name |
reply | Optional<T> | the client's answer, or empty when it did not answer in time or the answer could not be decoded |
반환 Optional<String>
ConfigurationExchange.Request
함수형 인터페이스 · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public static interface Request<T>
The server's message for a joining player.
request(UUID, String)
Optional<T> request(UUID playerId, String playerName)
추가된 버전 0.1.0-alpha.4 또는 그 이전
The message for player playerName, or empty to skip the exchange for them.
| 인자 | 타입 | 설명 |
|---|---|---|
playerId | UUID | the player's UUID |
playerName | String | the player's name |
반환 Optional<T>
NetworkRegistrar
인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public interface NetworkRegistrar
Declares a mod's network channels. A channel ID is <mod id>:<path> and carries one payload type in both directions.
When: inside common entrypoints, so both sides know the channel. Payloads on channels the receiver does not know are dropped by the game, like any unknown custom payload.
channel(String, PayloadCodec<T>)
<T> PayloadChannel<T> channel(String path, PayloadCodec<T> codec)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Declares a channel.
| 인자 | 타입 | 설명 |
|---|---|---|
path | String | — |
codec | PayloadCodec<T> | — |
반환 PayloadChannel<T>
예외 IllegalArgumentException — for an invalid or already used path (POLY-NETWORK-001)
예외 IllegalStateException — after registration closed (POLY-NETWORK-002)
configurationExchange(String, PayloadCodec<T>)
<T> ConfigurationExchange<T> configurationExchange(String path, PayloadCodec<T> codec)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Declares configuration exchange <mod id>:<path>: a question the server asks each joining client before the player enters the world. Declare it in the common entrypoint, on both sides, and set its parts with the returned handle.
| 인자 | 타입 | 설명 |
|---|---|---|
path | String | — |
codec | PayloadCodec<T> | — |
반환 ConfigurationExchange<T>
예외 IllegalArgumentException — for an invalid or used path (POLY-NETWORK-001)
PayloadChannel
인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public interface PayloadChannel<T>
A two-way channel for one payload type. Encoded payloads are limited to 32 KiB towards the server and 1 MiB towards clients; larger payloads throw IllegalArgumentException (POLY-NETWORK-003).
id()
ResourceId id()
추가된 버전 0.1.0-alpha.4 또는 그 이전
The channel ID.
반환 ResourceId
onServerReceive(ServerPayloadHandler<T>)
void onServerReceive(ServerPayloadHandler<T> handler)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Sets what the server does with payloads from clients. Runs on the server thread; sender is valid only during the call. Replaces an earlier handler.
| 인자 | 타입 | 설명 |
|---|---|---|
handler | ServerPayloadHandler<T> | — |
onClientReceive(ClientPayloadHandler<T>)
void onClientReceive(ClientPayloadHandler<T> handler)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Sets what the client does with payloads from the server. Runs on the client thread.
| 인자 | 타입 | 설명 |
|---|---|---|
handler | ClientPayloadHandler<T> | — |
sendToPlayer(PlayerView, T)
void sendToPlayer(PlayerView player, T payload)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Sends a payload to one player. Call on the server thread.
| 인자 | 타입 | 설명 |
|---|---|---|
player | PlayerView | — |
payload | T | — |
예외 IllegalStateException — when player is not a server-side player
sendToServer(T)
void sendToServer(T payload)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Sends a payload to the server. Call on the client thread while connected.
| 인자 | 타입 | 설명 |
|---|---|---|
payload | T | — |
예외 IllegalStateException — on a dedicated server or when not connected
PayloadCodec
인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public interface PayloadCodec<T>
Converts a payload to and from bytes. decode must read exactly what encode wrote. Runs on network threads: keep it free of game state.
encode(T, PayloadWriter)
void encode(T value, PayloadWriter out)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Writes value.
| 인자 | 타입 | 설명 |
|---|---|---|
value | T | — |
out | PayloadWriter | — |
decode(PayloadReader)
T decode(PayloadReader in)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Reads a value written by encode.
| 인자 | 타입 | 설명 |
|---|---|---|
in | PayloadReader | — |
반환 T
string()
static PayloadCodec<String> string()
추가된 버전 0.1.0-alpha.4 또는 그 이전
A codec for a single UTF-8 string.
반환 PayloadCodec<String>
PayloadReader
인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public interface PayloadReader
Reads payload values written by PayloadWriter. Reading past the end throws IllegalStateException, which drops the payload (POLY-NETWORK-004).
readBoolean()
boolean readBoolean()
추가된 버전 0.1.0-alpha.4 또는 그 이전
Reads a boolean.
반환 boolean
readInt()
int readInt()
추가된 버전 0.1.0-alpha.4 또는 그 이전
Reads an int.
반환 int
readLong()
long readLong()
추가된 버전 0.1.0-alpha.4 또는 그 이전
Reads a long.
반환 long
readDouble()
double readDouble()
추가된 버전 0.1.0-alpha.4 또는 그 이전
Reads a double.
반환 double
readString()
String readString()
추가된 버전 0.1.0-alpha.4 또는 그 이전
Reads a string.
반환 String
readBytes()
byte[] readBytes()
추가된 버전 0.1.0-alpha.4 또는 그 이전
Reads a byte array.
반환 byte[]
remaining()
int remaining()
추가된 버전 0.1.0-alpha.4 또는 그 이전
Bytes not read yet.
반환 int
PayloadWriter
인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public interface PayloadWriter
Writes payload values in big-endian order.
writeBoolean(boolean)
PayloadWriter writeBoolean(boolean value)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Writes a boolean as one byte.
| 인자 | 타입 | 설명 |
|---|---|---|
value | boolean | — |
반환 PayloadWriter
writeInt(int)
PayloadWriter writeInt(int value)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Writes a 4-byte int.
| 인자 | 타입 | 설명 |
|---|---|---|
value | int | — |
반환 PayloadWriter
writeLong(long)
PayloadWriter writeLong(long value)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Writes an 8-byte long.
| 인자 | 타입 | 설명 |
|---|---|---|
value | long | — |
반환 PayloadWriter
writeDouble(double)
PayloadWriter writeDouble(double value)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Writes an 8-byte double.
| 인자 | 타입 | 설명 |
|---|---|---|
value | double | — |
반환 PayloadWriter
writeString(String)
PayloadWriter writeString(String value)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Writes a length-prefixed UTF-8 string (at most 32767 characters).
| 인자 | 타입 | 설명 |
|---|---|---|
value | String | — |
반환 PayloadWriter
writeBytes(byte[])
PayloadWriter writeBytes(byte[] value)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Writes a length-prefixed byte array.
| 인자 | 타입 | 설명 |
|---|---|---|
value | byte[] | — |
반환 PayloadWriter
ServerPayloadHandler
함수형 인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public interface ServerPayloadHandler<T>
Handles a payload a client sent to the server. Validate it: clients are not trusted.
receive(T, PlayerView)
void receive(T payload, PlayerView sender)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Called on the server thread.
| 인자 | 타입 | 설명 |
|---|---|---|
payload | T | — |
sender | PlayerView | — |