kotlin
val players: KattonPlayerList访问所有在线玩家。
val players: KattonPlayerList访问所有在线玩家。
val entities: KattonServerEntityCollection访问所有维度中的全部实体。
val storage: CommandStorage用于保存持久数据的服务器命令存储。
val scoreboard: Scoreboard服务器计分板实例。
var difficulty: Difficulty当前服务器难度设置。
fun executeCommand(source: CommandSourceStack, command: String)以指定的命令源执行命令。
| 参数 | 说明 |
|---|---|
source | 用作执行主体的命令源。 |
command | 要执行的命令字符串。 |
fun setDifficulty(difficulty: Difficulty, ignoreLock: Boolean = true)设置服务器难度。
| 参数 | 说明 |
|---|---|
difficulty | 新的 Difficulty。 |
ignoreLock | 是否忽略难度锁定。 |
fun runFunction(id: Identifier, source: CommandSourceStack = requireServer().createCommandSourceStack())使用可选的命令源执行函数(数据包函数)。
| 参数 | 说明 |
|---|---|
id | 函数标识符。 |
source | 要使用的命令源(默认使用服务器)。 |
fun setGameMode(player: ServerPlayer, gameMode: GameType)设置玩家的游戏模式。
| 参数 | 说明 |
|---|---|
player | 目标 ServerPlayer。 |
gameMode | 目标 GameType。 |
fun <T : Any> setGameRule(key: GameRule<T>, value: T)在服务器主世界中设置游戏规则值。
| 参数 | 说明 |
|---|---|
key | GameRule 键。 |
value | 要设置的值。 |
fun kick(player: Player, reason: Component = Component.translatable("multiplayer.disconnect.kicked"))踢出玩家,并可附带可选的原因组件。
| 参数 | 说明 |
|---|---|
player | 目标玩家(需要是 ServerPlayer 才能断开连接)。 |
reason | 断开连接原因组件。 |