MinecraftServerSettingsServiceImpl.java

net.minecraft.server.jsonrpc.internalapi.MinecraftServerSettingsServiceImpl

信息

  • 全限定名:net.minecraft.server.jsonrpc.internalapi.MinecraftServerSettingsServiceImpl
  • 类型:public class
  • 包:net.minecraft.server.jsonrpc.internalapi
  • 源码路径:src/main/java/net/minecraft/server/jsonrpc/internalapi/MinecraftServerSettingsServiceImpl.java
  • 起始行号:L10
  • 实现:MinecraftServerSettingsService
  • 职责:

    TODO

字段/常量

  • server

    • 类型: DedicatedServer
    • 修饰符: private final
    • 源码定位: L11
    • 说明:

      TODO

  • jsonrpcLogger

    • 类型: JsonRpcLogger
    • 修饰符: private final
    • 源码定位: L12
    • 说明:

      TODO

内部类/嵌套类型

构造器

public MinecraftServerSettingsServiceImpl(DedicatedServer server, JsonRpcLogger jsonrpcLogger) @ L14

  • 构造器名:MinecraftServerSettingsServiceImpl
  • 源码定位:L14
  • 修饰符:public

参数:

  • server: DedicatedServer
  • jsonrpcLogger: JsonRpcLogger

说明:

TODO

方法

下面的方法块按源码顺序生成。

public boolean isAutoSave() @ L19

  • 方法名:isAutoSave
  • 源码定位:L19
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public boolean setAutoSave(boolean enabled, ClientInfo clientInfo) @ L24

  • 方法名:setAutoSave
  • 源码定位:L24
  • 返回类型:boolean
  • 修饰符:public

参数:

  • enabled: boolean
  • clientInfo: ClientInfo

说明:

TODO

public Difficulty getDifficulty() @ L31

  • 方法名:getDifficulty
  • 源码定位:L31
  • 返回类型:Difficulty
  • 修饰符:public

参数:

说明:

TODO

public Difficulty setDifficulty(Difficulty difficulty, ClientInfo clientInfo) @ L36

  • 方法名:setDifficulty
  • 源码定位:L36
  • 返回类型:Difficulty
  • 修饰符:public

参数:

  • difficulty: Difficulty
  • clientInfo: ClientInfo

说明:

TODO

public boolean isEnforceWhitelist() @ L43

  • 方法名:isEnforceWhitelist
  • 源码定位:L43
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public boolean setEnforceWhitelist(boolean enforce, ClientInfo clientInfo) @ L48

  • 方法名:setEnforceWhitelist
  • 源码定位:L48
  • 返回类型:boolean
  • 修饰符:public

参数:

  • enforce: boolean
  • clientInfo: ClientInfo

说明:

TODO

public boolean isUsingWhitelist() @ L56

  • 方法名:isUsingWhitelist
  • 源码定位:L56
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public boolean setUsingWhitelist(boolean use, ClientInfo clientInfo) @ L61

  • 方法名:setUsingWhitelist
  • 源码定位:L61
  • 返回类型:boolean
  • 修饰符:public

参数:

  • use: boolean
  • clientInfo: ClientInfo

说明:

TODO

public int getMaxPlayers() @ L69

  • 方法名:getMaxPlayers
  • 源码定位:L69
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int setMaxPlayers(int maxPlayers, ClientInfo clientInfo) @ L74

  • 方法名:setMaxPlayers
  • 源码定位:L74
  • 返回类型:int
  • 修饰符:public

参数:

  • maxPlayers: int
  • clientInfo: ClientInfo

说明:

TODO

public int getPauseWhenEmptySeconds() @ L81

  • 方法名:getPauseWhenEmptySeconds
  • 源码定位:L81
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int setPauseWhenEmptySeconds(int emptySeconds, ClientInfo clientInfo) @ L86

  • 方法名:setPauseWhenEmptySeconds
  • 源码定位:L86
  • 返回类型:int
  • 修饰符:public

参数:

  • emptySeconds: int
  • clientInfo: ClientInfo

说明:

TODO

public int getPlayerIdleTimeout() @ L93

  • 方法名:getPlayerIdleTimeout
  • 源码定位:L93
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int setPlayerIdleTimeout(int idleTime, ClientInfo clientInfo) @ L98

  • 方法名:setPlayerIdleTimeout
  • 源码定位:L98
  • 返回类型:int
  • 修饰符:public

参数:

  • idleTime: int
  • clientInfo: ClientInfo

说明:

TODO

public boolean allowFlight() @ L105

  • 方法名:allowFlight
  • 源码定位:L105
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public boolean setAllowFlight(boolean allow, ClientInfo clientInfo) @ L110

  • 方法名:setAllowFlight
  • 源码定位:L110
  • 返回类型:boolean
  • 修饰符:public

参数:

  • allow: boolean
  • clientInfo: ClientInfo

说明:

TODO

public int getSpawnProtectionRadius() @ L117

  • 方法名:getSpawnProtectionRadius
  • 源码定位:L117
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int setSpawnProtectionRadius(int spawnProtection, ClientInfo clientInfo) @ L122

  • 方法名:setSpawnProtectionRadius
  • 源码定位:L122
  • 返回类型:int
  • 修饰符:public

参数:

  • spawnProtection: int
  • clientInfo: ClientInfo

说明:

TODO

public String getMotd() @ L129

  • 方法名:getMotd
  • 源码定位:L129
  • 返回类型:String
  • 修饰符:public

参数:

说明:

TODO

public String setMotd(String motd, ClientInfo clientInfo) @ L134

  • 方法名:setMotd
  • 源码定位:L134
  • 返回类型:String
  • 修饰符:public

参数:

  • motd: String
  • clientInfo: ClientInfo

说明:

TODO

public boolean forceGameMode() @ L141

  • 方法名:forceGameMode
  • 源码定位:L141
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public boolean setForceGameMode(boolean force, ClientInfo clientInfo) @ L146

  • 方法名:setForceGameMode
  • 源码定位:L146
  • 返回类型:boolean
  • 修饰符:public

参数:

  • force: boolean
  • clientInfo: ClientInfo

说明:

TODO

public GameType getGameMode() @ L153

  • 方法名:getGameMode
  • 源码定位:L153
  • 返回类型:GameType
  • 修饰符:public

参数:

说明:

TODO

public GameType setGameMode(GameType gameMode, ClientInfo clientInfo) @ L158

  • 方法名:setGameMode
  • 源码定位:L158
  • 返回类型:GameType
  • 修饰符:public

参数:

  • gameMode: GameType
  • clientInfo: ClientInfo

说明:

TODO

public int getViewDistance() @ L165

  • 方法名:getViewDistance
  • 源码定位:L165
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int setViewDistance(int viewDistance, ClientInfo clientInfo) @ L170

  • 方法名:setViewDistance
  • 源码定位:L170
  • 返回类型:int
  • 修饰符:public

参数:

  • viewDistance: int
  • clientInfo: ClientInfo

说明:

TODO

public int getSimulationDistance() @ L177

  • 方法名:getSimulationDistance
  • 源码定位:L177
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int setSimulationDistance(int simulationDistance, ClientInfo clientInfo) @ L182

  • 方法名:setSimulationDistance
  • 源码定位:L182
  • 返回类型:int
  • 修饰符:public

参数:

  • simulationDistance: int
  • clientInfo: ClientInfo

说明:

TODO

public boolean acceptsTransfers() @ L189

  • 方法名:acceptsTransfers
  • 源码定位:L189
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public boolean setAcceptsTransfers(boolean accept, ClientInfo clientInfo) @ L194

  • 方法名:setAcceptsTransfers
  • 源码定位:L194
  • 返回类型:boolean
  • 修饰符:public

参数:

  • accept: boolean
  • clientInfo: ClientInfo

说明:

TODO

public int getStatusHeartbeatInterval() @ L201

  • 方法名:getStatusHeartbeatInterval
  • 源码定位:L201
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int setStatusHeartbeatInterval(int statusHeartbeatInterval, ClientInfo clientInfo) @ L206

  • 方法名:setStatusHeartbeatInterval
  • 源码定位:L206
  • 返回类型:int
  • 修饰符:public

参数:

  • statusHeartbeatInterval: int
  • clientInfo: ClientInfo

说明:

TODO

public LevelBasedPermissionSet getOperatorUserPermissions() @ L213

  • 方法名:getOperatorUserPermissions
  • 源码定位:L213
  • 返回类型:LevelBasedPermissionSet
  • 修饰符:public

参数:

说明:

TODO

public LevelBasedPermissionSet setOperatorUserPermissions(LevelBasedPermissionSet permissions, ClientInfo clientInfo) @ L218

  • 方法名:setOperatorUserPermissions
  • 源码定位:L218
  • 返回类型:LevelBasedPermissionSet
  • 修饰符:public

参数:

  • permissions: LevelBasedPermissionSet
  • clientInfo: ClientInfo

说明:

TODO

public boolean hidesOnlinePlayers() @ L225

  • 方法名:hidesOnlinePlayers
  • 源码定位:L225
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public boolean setHidesOnlinePlayers(boolean hide, ClientInfo clientInfo) @ L230

  • 方法名:setHidesOnlinePlayers
  • 源码定位:L230
  • 返回类型:boolean
  • 修饰符:public

参数:

  • hide: boolean
  • clientInfo: ClientInfo

说明:

TODO

public boolean repliesToStatus() @ L237

  • 方法名:repliesToStatus
  • 源码定位:L237
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public boolean setRepliesToStatus(boolean enable, ClientInfo clientInfo) @ L242

  • 方法名:setRepliesToStatus
  • 源码定位:L242
  • 返回类型:boolean
  • 修饰符:public

参数:

  • enable: boolean
  • clientInfo: ClientInfo

说明:

TODO

public int getEntityBroadcastRangePercentage() @ L249

  • 方法名:getEntityBroadcastRangePercentage
  • 源码定位:L249
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int setEntityBroadcastRangePercentage(int percentage, ClientInfo clientInfo) @ L254

  • 方法名:setEntityBroadcastRangePercentage
  • 源码定位:L254
  • 返回类型:int
  • 修饰符:public

参数:

  • percentage: int
  • clientInfo: ClientInfo

说明:

TODO

代码

public class MinecraftServerSettingsServiceImpl implements MinecraftServerSettingsService {
    private final DedicatedServer server;
    private final JsonRpcLogger jsonrpcLogger;
 
    public MinecraftServerSettingsServiceImpl(DedicatedServer server, JsonRpcLogger jsonrpcLogger) {
        this.server = server;
        this.jsonrpcLogger = jsonrpcLogger;
    }
 
    @Override
    public boolean isAutoSave() {
        return this.server.isAutoSave();
    }
 
    @Override
    public boolean setAutoSave(boolean enabled, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update autosave from {} to {}", this.isAutoSave(), enabled);
        this.server.setAutoSave(enabled);
        return this.isAutoSave();
    }
 
    @Override
    public Difficulty getDifficulty() {
        return this.server.getWorldData().getDifficulty();
    }
 
    @Override
    public Difficulty setDifficulty(Difficulty difficulty, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update difficulty from '{}' to '{}'", this.getDifficulty(), difficulty);
        this.server.setDifficulty(difficulty);
        return this.getDifficulty();
    }
 
    @Override
    public boolean isEnforceWhitelist() {
        return this.server.isEnforceWhitelist();
    }
 
    @Override
    public boolean setEnforceWhitelist(boolean enforce, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update enforce allowlist from {} to {}", this.isEnforceWhitelist(), enforce);
        this.server.setEnforceWhitelist(enforce);
        this.server.kickUnlistedPlayers();
        return this.isEnforceWhitelist();
    }
 
    @Override
    public boolean isUsingWhitelist() {
        return this.server.isUsingWhitelist();
    }
 
    @Override
    public boolean setUsingWhitelist(boolean use, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update using allowlist from {} to {}", this.isUsingWhitelist(), use);
        this.server.setUsingWhitelist(use);
        this.server.kickUnlistedPlayers();
        return this.isUsingWhitelist();
    }
 
    @Override
    public int getMaxPlayers() {
        return this.server.getMaxPlayers();
    }
 
    @Override
    public int setMaxPlayers(int maxPlayers, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update max players from {} to {}", this.getMaxPlayers(), maxPlayers);
        this.server.setMaxPlayers(maxPlayers);
        return this.getMaxPlayers();
    }
 
    @Override
    public int getPauseWhenEmptySeconds() {
        return this.server.pauseWhenEmptySeconds();
    }
 
    @Override
    public int setPauseWhenEmptySeconds(int emptySeconds, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update pause when empty from {} seconds to {} seconds", this.getPauseWhenEmptySeconds(), emptySeconds);
        this.server.setPauseWhenEmptySeconds(emptySeconds);
        return this.getPauseWhenEmptySeconds();
    }
 
    @Override
    public int getPlayerIdleTimeout() {
        return this.server.playerIdleTimeout();
    }
 
    @Override
    public int setPlayerIdleTimeout(int idleTime, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update player idle timeout from {} minutes to {} minutes", this.getPlayerIdleTimeout(), idleTime);
        this.server.setPlayerIdleTimeout(idleTime);
        return this.getPlayerIdleTimeout();
    }
 
    @Override
    public boolean allowFlight() {
        return this.server.allowFlight();
    }
 
    @Override
    public boolean setAllowFlight(boolean allow, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update allow flight from {} to {}", this.allowFlight(), allow);
        this.server.setAllowFlight(allow);
        return this.allowFlight();
    }
 
    @Override
    public int getSpawnProtectionRadius() {
        return this.server.spawnProtectionRadius();
    }
 
    @Override
    public int setSpawnProtectionRadius(int spawnProtection, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update spawn protection radius from {} to {}", this.getSpawnProtectionRadius(), spawnProtection);
        this.server.setSpawnProtectionRadius(spawnProtection);
        return this.getSpawnProtectionRadius();
    }
 
    @Override
    public String getMotd() {
        return this.server.getMotd();
    }
 
    @Override
    public String setMotd(String motd, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update MOTD from '{}' to '{}'", this.getMotd(), motd);
        this.server.setMotd(motd);
        return this.getMotd();
    }
 
    @Override
    public boolean forceGameMode() {
        return this.server.forceGameMode();
    }
 
    @Override
    public boolean setForceGameMode(boolean force, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update force game mode from {} to {}", this.forceGameMode(), force);
        this.server.setForceGameMode(force);
        return this.forceGameMode();
    }
 
    @Override
    public GameType getGameMode() {
        return this.server.gameMode();
    }
 
    @Override
    public GameType setGameMode(GameType gameMode, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update game mode from '{}' to '{}'", this.getGameMode(), gameMode);
        this.server.setGameMode(gameMode);
        return this.getGameMode();
    }
 
    @Override
    public int getViewDistance() {
        return this.server.viewDistance();
    }
 
    @Override
    public int setViewDistance(int viewDistance, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update view distance from {} to {}", this.getViewDistance(), viewDistance);
        this.server.setViewDistance(viewDistance);
        return this.getViewDistance();
    }
 
    @Override
    public int getSimulationDistance() {
        return this.server.simulationDistance();
    }
 
    @Override
    public int setSimulationDistance(int simulationDistance, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update simulation distance from {} to {}", this.getSimulationDistance(), simulationDistance);
        this.server.setSimulationDistance(simulationDistance);
        return this.getSimulationDistance();
    }
 
    @Override
    public boolean acceptsTransfers() {
        return this.server.acceptsTransfers();
    }
 
    @Override
    public boolean setAcceptsTransfers(boolean accept, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update accepts transfers from {} to {}", this.acceptsTransfers(), accept);
        this.server.setAcceptsTransfers(accept);
        return this.acceptsTransfers();
    }
 
    @Override
    public int getStatusHeartbeatInterval() {
        return this.server.statusHeartbeatInterval();
    }
 
    @Override
    public int setStatusHeartbeatInterval(int statusHeartbeatInterval, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update status heartbeat interval from {} to {}", this.getStatusHeartbeatInterval(), statusHeartbeatInterval);
        this.server.setStatusHeartbeatInterval(statusHeartbeatInterval);
        return this.getStatusHeartbeatInterval();
    }
 
    @Override
    public LevelBasedPermissionSet getOperatorUserPermissions() {
        return this.server.operatorUserPermissions();
    }
 
    @Override
    public LevelBasedPermissionSet setOperatorUserPermissions(LevelBasedPermissionSet permissions, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update operator user permission level from {} to {}", this.getOperatorUserPermissions(), permissions.level());
        this.server.setOperatorUserPermissions(permissions);
        return this.getOperatorUserPermissions();
    }
 
    @Override
    public boolean hidesOnlinePlayers() {
        return this.server.hidesOnlinePlayers();
    }
 
    @Override
    public boolean setHidesOnlinePlayers(boolean hide, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update hides online players from {} to {}", this.hidesOnlinePlayers(), hide);
        this.server.setHidesOnlinePlayers(hide);
        return this.hidesOnlinePlayers();
    }
 
    @Override
    public boolean repliesToStatus() {
        return this.server.repliesToStatus();
    }
 
    @Override
    public boolean setRepliesToStatus(boolean enable, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update replies to status from {} to {}", this.repliesToStatus(), enable);
        this.server.setRepliesToStatus(enable);
        return this.repliesToStatus();
    }
 
    @Override
    public int getEntityBroadcastRangePercentage() {
        return this.server.entityBroadcastRangePercentage();
    }
 
    @Override
    public int setEntityBroadcastRangePercentage(int percentage, ClientInfo clientInfo) {
        this.jsonrpcLogger.log(clientInfo, "Update entity broadcast range percentage from {}% to {}%", this.getEntityBroadcastRangePercentage(), percentage);
        this.server.setEntityBroadcastRangePercentage(percentage);
        return this.getEntityBroadcastRangePercentage();
    }
}

引用的其他类