IncomingRpcMethods .java

net.minecraft.server.jsonrpc.IncomingRpcMethods (class): members: bootstrap. strings: "Get the current difficulty level of the server", "bans", "allow".

net.minecraft.server.jsonrpcclass365 linesserver19.6 KB

API Surface (1)

IncomingRpcMethod<?, ?> bootstrap(final Registry<IncomingRpcMethod<?, ?>> methodRegistry)

String literals (138)

"result"
"rpc.discover"
"Get the allowlist"
"allowlist"
"Set the allowlist"
"players"
"allowlist/set"
"Add players to allowlist"
"allowlist/add"
"Remove players from allowlist"
"remove"
"allowlist/remove"
"Clear all players in allowlist"
"allowlist/clear"
"Get the ban list"
"banlist"
"bans"
"Set the banlist"
"bans/set"
"Add players to ban list"
"bans/add"
"Remove players from ban list"
"bans/remove"
"Clear all players in ban list"

Full Source

IncomingRpcMethods.java365 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.server.jsonrpc;
2
3
import net.minecraft.core.Registry;
4
import net.minecraft.server.jsonrpc.api.Schema;
5
import net.minecraft.server.jsonrpc.methods.AllowlistService;
6
import net.minecraft.server.jsonrpc.methods.BanlistService;
7
import net.minecraft.server.jsonrpc.methods.DiscoveryService;
8
import net.minecraft.server.jsonrpc.methods.GameRulesService;
9
import net.minecraft.server.jsonrpc.methods.IpBanlistService;
10
import net.minecraft.server.jsonrpc.methods.OperatorService;
11
import net.minecraft.server.jsonrpc.methods.PlayerService;
12
import net.minecraft.server.jsonrpc.methods.ServerSettingsService;
13
import net.minecraft.server.jsonrpc.methods.ServerStateService;
14
15
public class IncomingRpcMethods {
16
	public static IncomingRpcMethod<?, ?> bootstrap(final Registry<IncomingRpcMethod<?, ?>> methodRegistry) {
17
		registerAllowListService(methodRegistry);
18
		registerBanlistService(methodRegistry);
19
		registerIpBanlistService(methodRegistry);
20
		registerPlayerService(methodRegistry);
21
		registerOperatorService(methodRegistry);
22
		registerServerStateService(methodRegistry);
23
		registerServerSettingsService(methodRegistry);
24
		registerGameRuleService(methodRegistry);
25
		return IncomingRpcMethod.<DiscoveryService.DiscoverResponse>method(apiService -> DiscoveryService.discover(Schema.getSchemaRegistry()))
26
			.undiscoverable()
27
			.allowPreServerInit()
28
			.notOnMainThread()
29
			.response("result", Schema.DISCOVERY_SCHEMA)
30
			.register(methodRegistry, "rpc.discover");
31
	}
32
33
	private static void registerAllowListService(final Registry<IncomingRpcMethod<?, ?>> methodRegistry) {
34
		IncomingRpcMethod.method(AllowlistService::get)
35
			.description("Get the allowlist")
36
			.response("allowlist", Schema.PLAYER_SCHEMA.asArray())
37
			.register(methodRegistry, "allowlist");
38
		IncomingRpcMethod.method(AllowlistService::set)
39
			.description("Set the allowlist")
40
			.param("players", Schema.PLAYER_SCHEMA.asArray())
41
			.response("allowlist", Schema.PLAYER_SCHEMA.asArray())
42
			.register(methodRegistry, "allowlist/set");
43
		IncomingRpcMethod.method(AllowlistService::add)
44
			.description("Add players to allowlist")
45
			.param("add", Schema.PLAYER_SCHEMA.asArray())
46
			.response("allowlist", Schema.PLAYER_SCHEMA.asArray())
47
			.register(methodRegistry, "allowlist/add");
48
		IncomingRpcMethod.method(AllowlistService::remove)
49
			.description("Remove players from allowlist")
50
			.param("remove", Schema.PLAYER_SCHEMA.asArray())
51
			.response("allowlist", Schema.PLAYER_SCHEMA.asArray())
52
			.register(methodRegistry, "allowlist/remove");
53
		IncomingRpcMethod.method(AllowlistService::clear)
54
			.description("Clear all players in allowlist")
55
			.response("allowlist", Schema.PLAYER_SCHEMA.asArray())
56
			.register(methodRegistry, "allowlist/clear");
57
	}
58
59
	private static void registerBanlistService(final Registry<IncomingRpcMethod<?, ?>> methodRegistry) {
60
		IncomingRpcMethod.method(BanlistService::get)
61
			.description("Get the ban list")
62
			.response("banlist", Schema.PLAYER_BAN_SCHEMA.asArray())
63
			.register(methodRegistry, "bans");
64
		IncomingRpcMethod.method(BanlistService::set)
65
			.description("Set the banlist")
66
			.param("bans", Schema.PLAYER_BAN_SCHEMA.asArray())
67
			.response("banlist", Schema.PLAYER_BAN_SCHEMA.asArray())
68
			.register(methodRegistry, "bans/set");
69
		IncomingRpcMethod.method(BanlistService::add)
70
			.description("Add players to ban list")
71
			.param("add", Schema.PLAYER_BAN_SCHEMA.asArray())
72
			.response("banlist", Schema.PLAYER_BAN_SCHEMA.asArray())
73
			.register(methodRegistry, "bans/add");
74
		IncomingRpcMethod.method(BanlistService::remove)
75
			.description("Remove players from ban list")
76
			.param("remove", Schema.PLAYER_SCHEMA.asArray())
77
			.response("banlist", Schema.PLAYER_BAN_SCHEMA.asArray())
78
			.register(methodRegistry, "bans/remove");
79
		IncomingRpcMethod.method(BanlistService::clear)
80
			.description("Clear all players in ban list")
81
			.response("banlist", Schema.PLAYER_BAN_SCHEMA.asArray())
82
			.register(methodRegistry, "bans/clear");
83
	}
84
85
	private static void registerIpBanlistService(final Registry<IncomingRpcMethod<?, ?>> methodRegistry) {
86
		IncomingRpcMethod.method(IpBanlistService::get)
87
			.description("Get the ip ban list")
88
			.response("banlist", Schema.IP_BAN_SCHEMA.asArray())
89
			.register(methodRegistry, "ip_bans");
90
		IncomingRpcMethod.method(IpBanlistService::set)
91
			.description("Set the ip banlist")
92
			.param("banlist", Schema.IP_BAN_SCHEMA.asArray())
93
			.response("banlist", Schema.IP_BAN_SCHEMA.asArray())
94
			.register(methodRegistry, "ip_bans/set");
95
		IncomingRpcMethod.method(IpBanlistService::add)
96
			.description("Add ip to ban list")
97
			.param("add", Schema.INCOMING_IP_BAN_SCHEMA.asArray())
98
			.response("banlist", Schema.IP_BAN_SCHEMA.asArray())
99
			.register(methodRegistry, "ip_bans/add");
100
		IncomingRpcMethod.method(IpBanlistService::remove)
101
			.description("Remove ip from ban list")
102
			.param("ip", Schema.STRING_SCHEMA.asArray())
103
			.response("banlist", Schema.IP_BAN_SCHEMA.asArray())
104
			.register(methodRegistry, "ip_bans/remove");
105
		IncomingRpcMethod.method(IpBanlistService::clear)
106
			.description("Clear all ips in ban list")
107
			.response("banlist", Schema.IP_BAN_SCHEMA.asArray())
108
			.register(methodRegistry, "ip_bans/clear");
109
	}
110
111
	private static void registerPlayerService(final Registry<IncomingRpcMethod<?, ?>> methodRegistry) {
112
		IncomingRpcMethod.method(PlayerService::get)
113
			.description("Get all connected players")
114
			.response("players", Schema.PLAYER_SCHEMA.asArray())
115
			.register(methodRegistry, "players");
116
		IncomingRpcMethod.method(PlayerService::kick)
117
			.description("Kick players")
118
			.param("kick", Schema.KICK_PLAYER_SCHEMA.asArray())
119
			.response("kicked", Schema.PLAYER_SCHEMA.asArray())
120
			.register(methodRegistry, "players/kick");
121
	}
122
123
	private static void registerOperatorService(final Registry<IncomingRpcMethod<?, ?>> methodRegistry) {
124
		IncomingRpcMethod.method(OperatorService::get)
125
			.description("Get all oped players")
126
			.response("operators", Schema.OPERATOR_SCHEMA.asArray())
127
			.register(methodRegistry, "operators");
128
		IncomingRpcMethod.method(OperatorService::set)
129
			.description("Set all oped players")
130
			.param("operators", Schema.OPERATOR_SCHEMA.asArray())
131
			.response("operators", Schema.OPERATOR_SCHEMA.asArray())
132
			.register(methodRegistry, "operators/set");
133
		IncomingRpcMethod.method(OperatorService::add)
134
			.description("Op players")
135
			.param("add", Schema.OPERATOR_SCHEMA.asArray())
136
			.response("operators", Schema.OPERATOR_SCHEMA.asArray())
137
			.register(methodRegistry, "operators/add");
138
		IncomingRpcMethod.method(OperatorService::remove)
139
			.description("Deop players")
140
			.param("remove", Schema.PLAYER_SCHEMA.asArray())
141
			.response("operators", Schema.OPERATOR_SCHEMA.asArray())
142
			.register(methodRegistry, "operators/remove");
143
		IncomingRpcMethod.method(OperatorService::clear)
144
			.description("Deop all players")
145
			.response("operators", Schema.OPERATOR_SCHEMA.asArray())
146
			.register(methodRegistry, "operators/clear");
147
	}
148
149
	private static void registerServerStateService(final Registry<IncomingRpcMethod<?, ?>> methodRegistry) {
150
		IncomingRpcMethod.method(ServerStateService::status)
151
			.description("Get server status")
152
			.response("status", Schema.SERVER_STATE_SCHEMA.asRef())
153
			.register(methodRegistry, "server/status");
154
		IncomingRpcMethod.method(ServerStateService::save)
155
			.description("Save server state")
156
			.param("flush", Schema.BOOL_SCHEMA)
157
			.response("saving", Schema.BOOL_SCHEMA)
158
			.register(methodRegistry, "server/save");
159
		IncomingRpcMethod.method(ServerStateService::stop)
160
			.description("Stop server")
161
			.response("stopping", Schema.BOOL_SCHEMA)
162
			.register(methodRegistry, "server/stop");
163
		IncomingRpcMethod.method(ServerStateService::systemMessage)
164
			.description("Send a system message")
165
			.param("message", Schema.SYSTEM_MESSAGE_SCHEMA.asRef())
166
			.response("sent", Schema.BOOL_SCHEMA)
167
			.register(methodRegistry, "server/system_message");
168
	}
169
170
	private static void registerServerSettingsService(final Registry<IncomingRpcMethod<?, ?>> methodRegistry) {
171
		IncomingRpcMethod.method(ServerSettingsService::autosave)
172
			.description("Get whether automatic world saving is enabled on the server")
173
			.response("enabled", Schema.BOOL_SCHEMA)
174
			.register(methodRegistry, "serversettings/autosave");
175
		IncomingRpcMethod.method(ServerSettingsService::setAutosave)
176
			.description("Enable or disable automatic world saving on the server")
177
			.param("enable", Schema.BOOL_SCHEMA)
178
			.response("enabled", Schema.BOOL_SCHEMA)
179
			.register(methodRegistry, "serversettings/autosave/set");
180
		IncomingRpcMethod.method(ServerSettingsService::difficulty)
181
			.description("Get the current difficulty level of the server")
182
			.response("difficulty", Schema.DIFFICULTY_SCHEMA.asRef())
183
			.register(methodRegistry, "serversettings/difficulty");
184
		IncomingRpcMethod.method(ServerSettingsService::setDifficulty)
185
			.description("Set the difficulty level of the server")
186
			.param("difficulty", Schema.DIFFICULTY_SCHEMA.asRef())
187
			.response("difficulty", Schema.DIFFICULTY_SCHEMA.asRef())
188
			.register(methodRegistry, "serversettings/difficulty/set");
189
		IncomingRpcMethod.method(ServerSettingsService::enforceAllowlist)
190
			.description("Get whether allowlist enforcement is enabled (kicks players immediately when removed from allowlist)")
191
			.response("enforced", Schema.BOOL_SCHEMA)
192
			.register(methodRegistry, "serversettings/enforce_allowlist");
193
		IncomingRpcMethod.method(ServerSettingsService::setEnforceAllowlist)
194
			.description("Enable or disable allowlist enforcement (when enabled, players are kicked immediately upon removal from allowlist)")
195
			.param("enforce", Schema.BOOL_SCHEMA)
196
			.response("enforced", Schema.BOOL_SCHEMA)
197
			.register(methodRegistry, "serversettings/enforce_allowlist/set");
198
		IncomingRpcMethod.method(ServerSettingsService::usingAllowlist)
199
			.description("Get whether the allowlist is enabled on the server")
200
			.response("used", Schema.BOOL_SCHEMA)
201
			.register(methodRegistry, "serversettings/use_allowlist");
202
		IncomingRpcMethod.method(ServerSettingsService::setUsingAllowlist)
203
			.description("Enable or disable the allowlist on the server (controls whether only allowlisted players can join)")
204
			.param("use", Schema.BOOL_SCHEMA)
205
			.response("used", Schema.BOOL_SCHEMA)
206
			.register(methodRegistry, "serversettings/use_allowlist/set");
207
		IncomingRpcMethod.method(ServerSettingsService::maxPlayers)
208
			.description("Get the maximum number of players allowed to connect to the server")
209
			.response("max", Schema.INT_SCHEMA)
210
			.register(methodRegistry, "serversettings/max_players");
211
		IncomingRpcMethod.method(ServerSettingsService::setMaxPlayers)
212
			.description("Set the maximum number of players allowed to connect to the server")
213
			.param("max", Schema.INT_SCHEMA)
214
			.response("max", Schema.INT_SCHEMA)
215
			.register(methodRegistry, "serversettings/max_players/set");
216
		IncomingRpcMethod.method(ServerSettingsService::pauseWhenEmpty)
217
			.description("Get the number of seconds before the game is automatically paused when no players are online")
218
			.response("seconds", Schema.INT_SCHEMA)
219
			.register(methodRegistry, "serversettings/pause_when_empty_seconds");
220
		IncomingRpcMethod.method(ServerSettingsService::setPauseWhenEmpty)
221
			.description("Set the number of seconds before the game is automatically paused when no players are online")
222
			.param("seconds", Schema.INT_SCHEMA)
223
			.response("seconds", Schema.INT_SCHEMA)
224
			.register(methodRegistry, "serversettings/pause_when_empty_seconds/set");
225
		IncomingRpcMethod.method(ServerSettingsService::playerIdleTimeout)
226
			.description("Get the number of seconds before idle players are automatically kicked from the server")
227
			.response("seconds", Schema.INT_SCHEMA)
228
			.register(methodRegistry, "serversettings/player_idle_timeout");
229
		IncomingRpcMethod.method(ServerSettingsService::setPlayerIdleTimeout)
230
			.description("Set the number of seconds before idle players are automatically kicked from the server")
231
			.param("seconds", Schema.INT_SCHEMA)
232
			.response("seconds", Schema.INT_SCHEMA)
233
			.register(methodRegistry, "serversettings/player_idle_timeout/set");
234
		IncomingRpcMethod.method(ServerSettingsService::allowFlight)
235
			.description("Get whether flight is allowed for players in Survival mode")
236
			.response("allowed", Schema.BOOL_SCHEMA)
237
			.register(methodRegistry, "serversettings/allow_flight");
238
		IncomingRpcMethod.method(ServerSettingsService::setAllowFlight)
239
			.description("Allow or disallow flight for players in Survival mode")
240
			.param("allow", Schema.BOOL_SCHEMA)
241
			.response("allowed", Schema.BOOL_SCHEMA)
242
			.register(methodRegistry, "serversettings/allow_flight/set");
243
		IncomingRpcMethod.method(ServerSettingsService::motd)
244
			.description("Get the server's message of the day displayed to players")
245
			.response("message", Schema.STRING_SCHEMA)
246
			.register(methodRegistry, "serversettings/motd");
247
		IncomingRpcMethod.method(ServerSettingsService::setMotd)
248
			.description("Set the server's message of the day displayed to players")
249
			.param("message", Schema.STRING_SCHEMA)
250
			.response("message", Schema.STRING_SCHEMA)
251
			.register(methodRegistry, "serversettings/motd/set");
252
		IncomingRpcMethod.method(ServerSettingsService::spawnProtection)
253
			.description("Get the spawn protection radius in blocks (only operators can edit within this area)")
254
			.response("radius", Schema.INT_SCHEMA)
255
			.register(methodRegistry, "serversettings/spawn_protection_radius");
256
		IncomingRpcMethod.method(ServerSettingsService::setSpawnProtection)
257
			.description("Set the spawn protection radius in blocks (only operators can edit within this area)")
258
			.param("radius", Schema.INT_SCHEMA)
259
			.response("radius", Schema.INT_SCHEMA)
260
			.register(methodRegistry, "serversettings/spawn_protection_radius/set");
261
		IncomingRpcMethod.method(ServerSettingsService::forceGameMode)
262
			.description("Get whether players are forced to use the server's default game mode")
263
			.response("forced", Schema.BOOL_SCHEMA)
264
			.register(methodRegistry, "serversettings/force_game_mode");
265
		IncomingRpcMethod.method(ServerSettingsService::setForceGameMode)
266
			.description("Enable or disable forcing players to use the server's default game mode")
267
			.param("force", Schema.BOOL_SCHEMA)
268
			.response("forced", Schema.BOOL_SCHEMA)
269
			.register(methodRegistry, "serversettings/force_game_mode/set");
270
		IncomingRpcMethod.method(ServerSettingsService::gameMode)
271
			.description("Get the server's default game mode")
272
			.response("mode", Schema.GAME_TYPE_SCHEMA.asRef())
273
			.register(methodRegistry, "serversettings/game_mode");
274
		IncomingRpcMethod.method(ServerSettingsService::setGameMode)
275
			.description("Set the server's default game mode")
276
			.param("mode", Schema.GAME_TYPE_SCHEMA.asRef())
277
			.response("mode", Schema.GAME_TYPE_SCHEMA.asRef())
278
			.register(methodRegistry, "serversettings/game_mode/set");
279
		IncomingRpcMethod.method(ServerSettingsService::viewDistance)
280
			.description("Get the server's view distance in chunks")
281
			.response("distance", Schema.INT_SCHEMA)
282
			.register(methodRegistry, "serversettings/view_distance");
283
		IncomingRpcMethod.method(ServerSettingsService::setViewDistance)
284
			.description("Set the server's view distance in chunks")
285
			.param("distance", Schema.INT_SCHEMA)
286
			.response("distance", Schema.INT_SCHEMA)
287
			.register(methodRegistry, "serversettings/view_distance/set");
288
		IncomingRpcMethod.method(ServerSettingsService::simulationDistance)
289
			.description("Get the server's simulation distance in chunks")
290
			.response("distance", Schema.INT_SCHEMA)
291
			.register(methodRegistry, "serversettings/simulation_distance");
292
		IncomingRpcMethod.method(ServerSettingsService::setSimulationDistance)
293
			.description("Set the server's simulation distance in chunks")
294
			.param("distance", Schema.INT_SCHEMA)
295
			.response("distance", Schema.INT_SCHEMA)
296
			.register(methodRegistry, "serversettings/simulation_distance/set");
297
		IncomingRpcMethod.method(ServerSettingsService::acceptTransfers)
298
			.description("Get whether the server accepts player transfers from other servers")
299
			.response("accepted", Schema.BOOL_SCHEMA)
300
			.register(methodRegistry, "serversettings/accept_transfers");
301
		IncomingRpcMethod.method(ServerSettingsService::setAcceptTransfers)
302
			.description("Enable or disable accepting player transfers from other servers")
303
			.param("accept", Schema.BOOL_SCHEMA)
304
			.response("accepted", Schema.BOOL_SCHEMA)
305
			.register(methodRegistry, "serversettings/accept_transfers/set");
306
		IncomingRpcMethod.method(ServerSettingsService::statusHeartbeatInterval)
307
			.description("Get the interval in seconds between server status heartbeats")
308
			.response("seconds", Schema.INT_SCHEMA)
309
			.register(methodRegistry, "serversettings/status_heartbeat_interval");
310
		IncomingRpcMethod.method(ServerSettingsService::setStatusHeartbeatInterval)
311
			.description("Set the interval in seconds between server status heartbeats")
312
			.param("seconds", Schema.INT_SCHEMA)
313
			.response("seconds", Schema.INT_SCHEMA)
314
			.register(methodRegistry, "serversettings/status_heartbeat_interval/set");
315
		IncomingRpcMethod.method(ServerSettingsService::operatorUserPermissionLevel)
316
			.description("Get default operator permission level")
317
			.response("level", Schema.PERMISSION_LEVEL_SCHEMA)
318
			.register(methodRegistry, "serversettings/operator_user_permission_level");
319
		IncomingRpcMethod.method(ServerSettingsService::setOperatorUserPermissionLevel)
320
			.description("Set default operator permission level")
321
			.param("level", Schema.PERMISSION_LEVEL_SCHEMA)
322
			.response("level", Schema.PERMISSION_LEVEL_SCHEMA)
323
			.register(methodRegistry, "serversettings/operator_user_permission_level/set");
324
		IncomingRpcMethod.method(ServerSettingsService::hidesOnlinePlayers)
325
			.description("Get whether the server hides online player information from status queries")
326
			.response("hidden", Schema.BOOL_SCHEMA)
327
			.register(methodRegistry, "serversettings/hide_online_players");
328
		IncomingRpcMethod.method(ServerSettingsService::setHidesOnlinePlayers)
329
			.description("Enable or disable hiding online player information from status queries")
330
			.param("hide", Schema.BOOL_SCHEMA)
331
			.response("hidden", Schema.BOOL_SCHEMA)
332
			.register(methodRegistry, "serversettings/hide_online_players/set");
333
		IncomingRpcMethod.method(ServerSettingsService::repliesToStatus)
334
			.description("Get whether the server responds to connection status requests")
335
			.response("enabled", Schema.BOOL_SCHEMA)
336
			.register(methodRegistry, "serversettings/status_replies");
337
		IncomingRpcMethod.method(ServerSettingsService::setRepliesToStatus)
338
			.description("Enable or disable the server responding to connection status requests")
339
			.param("enable", Schema.BOOL_SCHEMA)
340
			.response("enabled", Schema.BOOL_SCHEMA)
341
			.register(methodRegistry, "serversettings/status_replies/set");
342
		IncomingRpcMethod.method(ServerSettingsService::entityBroadcastRangePercentage)
343
			.description("Get the entity broadcast range as a percentage")
344
			.response("percentage_points", Schema.INT_SCHEMA)
345
			.register(methodRegistry, "serversettings/entity_broadcast_range");
346
		IncomingRpcMethod.method(ServerSettingsService::setEntityBroadcastRangePercentage)
347
			.description("Set the entity broadcast range as a percentage")
348
			.param("percentage_points", Schema.INT_SCHEMA)
349
			.response("percentage_points", Schema.INT_SCHEMA)
350
			.register(methodRegistry, "serversettings/entity_broadcast_range/set");
351
	}
352
353
	private static void registerGameRuleService(final Registry<IncomingRpcMethod<?, ?>> methodRegistry) {
354
		IncomingRpcMethod.method(GameRulesService::get)
355
			.description("Get the available game rule keys and their current values")
356
			.response("gamerules", Schema.TYPED_GAME_RULE_SCHEMA.asRef().asArray())
357
			.register(methodRegistry, "gamerules");
358
		IncomingRpcMethod.method(GameRulesService::update)
359
			.description("Update game rule value")
360
			.param("gamerule", Schema.UNTYPED_GAME_RULE_SCHEMA.asRef())
361
			.response("gamerule", Schema.TYPED_GAME_RULE_SCHEMA.asRef())
362
			.register(methodRegistry, "gamerules/update");
363
	}
364
}
365

Decompiled Minecraft 26.3 source of IncomingRpcMethods (net/minecraft/server/jsonrpc/IncomingRpcMethods.java) with Mojang official mappings, stored verbatim on the site.