MinecraftServerSettingsServiceImpl .java

net.minecraft.server.jsonrpc.internalapi.MinecraftServerSettingsServiceImpl (class, 276 lines): members: getEntityBroadcastRangePercentage, setAutoSave.

net.minecraft.server.jsonrpc.internalapiclass276 linesserver9.2 KB

Implements

API Surface (40)

boolean isAutoSave()
boolean setAutoSave(final boolean enabled, final ClientInfo clientInfo)
Difficulty getDifficulty()
Difficulty setDifficulty(final Difficulty difficulty, final ClientInfo clientInfo)
boolean isEnforceWhitelist()
boolean setEnforceWhitelist(final boolean enforce, final ClientInfo clientInfo)
boolean isUsingWhitelist()
boolean setUsingWhitelist(final boolean use, final ClientInfo clientInfo)
int getMaxPlayers()
int setMaxPlayers(final int maxPlayers, final ClientInfo clientInfo)
int getPauseWhenEmptySeconds()
int setPauseWhenEmptySeconds(final int emptySeconds, final ClientInfo clientInfo)
int getPlayerIdleTimeout()
int setPlayerIdleTimeout(final int idleTime, final ClientInfo clientInfo)
boolean allowFlight()
boolean setAllowFlight(final boolean allow, final ClientInfo clientInfo)
int getSpawnProtectionRadius()
int setSpawnProtectionRadius(final int spawnProtection, final ClientInfo clientInfo)
String getMotd()
String setMotd(final String motd, final ClientInfo clientInfo)
boolean forceGameMode()
boolean setForceGameMode(final boolean force, final ClientInfo clientInfo)
GameType getGameMode()
GameType setGameMode(final GameType gameMode, final ClientInfo clientInfo)
int getViewDistance()
int setViewDistance(final int viewDistance, final ClientInfo clientInfo)
int getSimulationDistance()
int setSimulationDistance(final int simulationDistance, final ClientInfo clientInfo)
boolean acceptsTransfers()
boolean setAcceptsTransfers(final boolean accept, final ClientInfo clientInfo)
int getStatusHeartbeatInterval()
int setStatusHeartbeatInterval(final int statusHeartbeatInterval, final ClientInfo clientInfo)
LevelBasedPermissionSet getOperatorUserPermissions()
LevelBasedPermissionSet setOperatorUserPermissions(final LevelBasedPermissionSet permissions, final ClientInfo clientInfo)
boolean hidesOnlinePlayers()
boolean setHidesOnlinePlayers(final boolean hide, final ClientInfo clientInfo)
boolean repliesToStatus()
boolean setRepliesToStatus(final boolean enable, final ClientInfo clientInfo)
int getEntityBroadcastRangePercentage()
int setEntityBroadcastRangePercentage(final int percentage, final ClientInfo clientInfo)

Fields & Constants (2)

notificationManager
jsonrpcLogger

Full Source

MinecraftServerSettingsServiceImpl.java276 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.server.jsonrpc.internalapi;
2
3
import java.util.Objects;
4
import net.minecraft.server.dedicated.DedicatedServer;
5
import net.minecraft.server.jsonrpc.JsonRpcLogger;
6
import net.minecraft.server.jsonrpc.methods.ClientInfo;
7
import net.minecraft.server.notifications.NotificationManager;
8
import net.minecraft.server.permissions.LevelBasedPermissionSet;
9
import net.minecraft.world.Difficulty;
10
import net.minecraft.world.level.GameType;
11
12
public class MinecraftServerSettingsServiceImpl implements MinecraftServerSettingsService {
13
	private final NotificationManager notificationManager;
14
	private final JsonRpcLogger jsonrpcLogger;
15
16
	public MinecraftServerSettingsServiceImpl(final NotificationManager notificationManager, final JsonRpcLogger jsonrpcLogger) {
17
		this.notificationManager = notificationManager;
18
		this.jsonrpcLogger = jsonrpcLogger;
19
	}
20
21
	private DedicatedServer server() {
22
		return Objects.requireNonNull(this.notificationManager.server());
23
	}
24
25
	@Override
26
	public boolean isAutoSave() {
27
		return this.server().isAutoSave();
28
	}
29
30
	@Override
31
	public boolean setAutoSave(final boolean enabled, final ClientInfo clientInfo) {
32
		this.jsonrpcLogger.log(clientInfo, "Update autosave from {} to {}", this.isAutoSave(), enabled);
33
		this.server().setAutoSave(enabled);
34
		return this.isAutoSave();
35
	}
36
37
	@Override
38
	public Difficulty getDifficulty() {
39
		return this.server().getWorldData().getDifficulty();
40
	}
41
42
	@Override
43
	public Difficulty setDifficulty(final Difficulty difficulty, final ClientInfo clientInfo) {
44
		this.jsonrpcLogger.log(clientInfo, "Update difficulty from '{}' to '{}'", this.getDifficulty(), difficulty);
45
		this.server().setDifficulty(difficulty);
46
		return this.getDifficulty();
47
	}
48
49
	@Override
50
	public boolean isEnforceWhitelist() {
51
		return this.server().isEnforceWhitelist();
52
	}
53
54
	@Override
55
	public boolean setEnforceWhitelist(final boolean enforce, final ClientInfo clientInfo) {
56
		this.jsonrpcLogger.log(clientInfo, "Update enforce allowlist from {} to {}", this.isEnforceWhitelist(), enforce);
57
		this.server().setEnforceWhitelist(enforce);
58
		this.server().kickUnlistedPlayers();
59
		return this.isEnforceWhitelist();
60
	}
61
62
	@Override
63
	public boolean isUsingWhitelist() {
64
		return this.server().isUsingWhitelist();
65
	}
66
67
	@Override
68
	public boolean setUsingWhitelist(final boolean use, final ClientInfo clientInfo) {
69
		this.jsonrpcLogger.log(clientInfo, "Update using allowlist from {} to {}", this.isUsingWhitelist(), use);
70
		this.server().setUsingWhitelist(use);
71
		this.server().kickUnlistedPlayers();
72
		return this.isUsingWhitelist();
73
	}
74
75
	@Override
76
	public int getMaxPlayers() {
77
		return this.server().getMaxPlayers();
78
	}
79
80
	@Override
81
	public int setMaxPlayers(final int maxPlayers, final ClientInfo clientInfo) {
82
		this.jsonrpcLogger.log(clientInfo, "Update max players from {} to {}", this.getMaxPlayers(), maxPlayers);
83
		this.server().setMaxPlayers(maxPlayers);
84
		return this.getMaxPlayers();
85
	}
86
87
	@Override
88
	public int getPauseWhenEmptySeconds() {
89
		return this.server().pauseWhenEmptySeconds();
90
	}
91
92
	@Override
93
	public int setPauseWhenEmptySeconds(final int emptySeconds, final ClientInfo clientInfo) {
94
		this.jsonrpcLogger.log(clientInfo, "Update pause when empty from {} seconds to {} seconds", this.getPauseWhenEmptySeconds(), emptySeconds);
95
		this.server().setPauseWhenEmptySeconds(emptySeconds);
96
		return this.getPauseWhenEmptySeconds();
97
	}
98
99
	@Override
100
	public int getPlayerIdleTimeout() {
101
		return this.server().playerIdleTimeout();
102
	}
103
104
	@Override
105
	public int setPlayerIdleTimeout(final int idleTime, final ClientInfo clientInfo) {
106
		this.jsonrpcLogger.log(clientInfo, "Update player idle timeout from {} minutes to {} minutes", this.getPlayerIdleTimeout(), idleTime);
107
		this.server().setPlayerIdleTimeout(idleTime);
108
		return this.getPlayerIdleTimeout();
109
	}
110
111
	@Override
112
	public boolean allowFlight() {
113
		return this.server().allowFlight();
114
	}
115
116
	@Override
117
	public boolean setAllowFlight(final boolean allow, final ClientInfo clientInfo) {
118
		this.jsonrpcLogger.log(clientInfo, "Update allow flight from {} to {}", this.allowFlight(), allow);
119
		this.server().setAllowFlight(allow);
120
		return this.allowFlight();
121
	}
122
123
	@Override
124
	public int getSpawnProtectionRadius() {
125
		return this.server().spawnProtectionRadius();
126
	}
127
128
	@Override
129
	public int setSpawnProtectionRadius(final int spawnProtection, final ClientInfo clientInfo) {
130
		this.jsonrpcLogger.log(clientInfo, "Update spawn protection radius from {} to {}", this.getSpawnProtectionRadius(), spawnProtection);
131
		this.server().setSpawnProtectionRadius(spawnProtection);
132
		return this.getSpawnProtectionRadius();
133
	}
134
135
	@Override
136
	public String getMotd() {
137
		return this.server().getMotd();
138
	}
139
140
	@Override
141
	public String setMotd(final String motd, final ClientInfo clientInfo) {
142
		this.jsonrpcLogger.log(clientInfo, "Update MOTD from '{}' to '{}'", this.getMotd(), motd);
143
		this.server().setMotd(motd);
144
		return this.getMotd();
145
	}
146
147
	@Override
148
	public boolean forceGameMode() {
149
		return this.server().forceGameMode();
150
	}
151
152
	@Override
153
	public boolean setForceGameMode(final boolean force, final ClientInfo clientInfo) {
154
		this.jsonrpcLogger.log(clientInfo, "Update force game mode from {} to {}", this.forceGameMode(), force);
155
		this.server().setForceGameMode(force);
156
		return this.forceGameMode();
157
	}
158
159
	@Override
160
	public GameType getGameMode() {
161
		return this.server().gameMode();
162
	}
163
164
	@Override
165
	public GameType setGameMode(final GameType gameMode, final ClientInfo clientInfo) {
166
		this.jsonrpcLogger.log(clientInfo, "Update game mode from '{}' to '{}'", this.getGameMode(), gameMode);
167
		this.server().setGameMode(gameMode);
168
		return this.getGameMode();
169
	}
170
171
	@Override
172
	public int getViewDistance() {
173
		return this.server().viewDistance();
174
	}
175
176
	@Override
177
	public int setViewDistance(final int viewDistance, final ClientInfo clientInfo) {
178
		this.jsonrpcLogger.log(clientInfo, "Update view distance from {} to {}", this.getViewDistance(), viewDistance);
179
		this.server().setViewDistance(viewDistance);
180
		return this.getViewDistance();
181
	}
182
183
	@Override
184
	public int getSimulationDistance() {
185
		return this.server().simulationDistance();
186
	}
187
188
	@Override
189
	public int setSimulationDistance(final int simulationDistance, final ClientInfo clientInfo) {
190
		this.jsonrpcLogger.log(clientInfo, "Update simulation distance from {} to {}", this.getSimulationDistance(), simulationDistance);
191
		this.server().setSimulationDistance(simulationDistance);
192
		return this.getSimulationDistance();
193
	}
194
195
	@Override
196
	public boolean acceptsTransfers() {
197
		return this.server().acceptsTransfers();
198
	}
199
200
	@Override
201
	public boolean setAcceptsTransfers(final boolean accept, final ClientInfo clientInfo) {
202
		this.jsonrpcLogger.log(clientInfo, "Update accepts transfers from {} to {}", this.acceptsTransfers(), accept);
203
		this.server().setAcceptsTransfers(accept);
204
		return this.acceptsTransfers();
205
	}
206
207
	@Override
208
	public int getStatusHeartbeatInterval() {
209
		return this.server().statusHeartbeatInterval();
210
	}
211
212
	@Override
213
	public int setStatusHeartbeatInterval(final int statusHeartbeatInterval, final ClientInfo clientInfo) {
214
		if (this.server().setStatusHeartbeatInterval(statusHeartbeatInterval)) {
215
			this.jsonrpcLogger.log(clientInfo, "Updated status heartbeat interval from {} to {}", this.getStatusHeartbeatInterval(), statusHeartbeatInterval);
216
		} else {
217
			this.jsonrpcLogger
218
				.log(
219
					clientInfo,
220
					"The heartbeat interval was not updated to the new value of {} seconds as the json rpc server is null or a pre-existing heartbeat failed to get canceled",
221
					statusHeartbeatInterval
222
				);
223
		}
224
225
		return this.getStatusHeartbeatInterval();
226
	}
227
228
	@Override
229
	public LevelBasedPermissionSet getOperatorUserPermissions() {
230
		return this.server().operatorUserPermissions();
231
	}
232
233
	@Override
234
	public LevelBasedPermissionSet setOperatorUserPermissions(final LevelBasedPermissionSet permissions, final ClientInfo clientInfo) {
235
		this.jsonrpcLogger.log(clientInfo, "Update operator user permission level from {} to {}", this.getOperatorUserPermissions(), permissions.level());
236
		this.server().setOperatorUserPermissions(permissions);
237
		return this.getOperatorUserPermissions();
238
	}
239
240
	@Override
241
	public boolean hidesOnlinePlayers() {
242
		return this.server().hidesOnlinePlayers();
243
	}
244
245
	@Override
246
	public boolean setHidesOnlinePlayers(final boolean hide, final ClientInfo clientInfo) {
247
		this.jsonrpcLogger.log(clientInfo, "Update hides online players from {} to {}", this.hidesOnlinePlayers(), hide);
248
		this.server().setHidesOnlinePlayers(hide);
249
		return this.hidesOnlinePlayers();
250
	}
251
252
	@Override
253
	public boolean repliesToStatus() {
254
		return this.server().repliesToStatus();
255
	}
256
257
	@Override
258
	public boolean setRepliesToStatus(final boolean enable, final ClientInfo clientInfo) {
259
		this.jsonrpcLogger.log(clientInfo, "Update replies to status from {} to {}", this.repliesToStatus(), enable);
260
		this.server().setRepliesToStatus(enable);
261
		return this.repliesToStatus();
262
	}
263
264
	@Override
265
	public int getEntityBroadcastRangePercentage() {
266
		return this.server().entityBroadcastRangePercentage();
267
	}
268
269
	@Override
270
	public int setEntityBroadcastRangePercentage(final int percentage, final ClientInfo clientInfo) {
271
		this.jsonrpcLogger.log(clientInfo, "Update entity broadcast range percentage from {}% to {}%", this.getEntityBroadcastRangePercentage(), percentage);
272
		this.server().setEntityBroadcastRangePercentage(percentage);
273
		return this.getEntityBroadcastRangePercentage();
274
	}
275
}
276

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