MCServer
Link to mcserver
导入类
Link to 导入类
It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.
ZenScript Copyimport crafttweaker.api.server.MCServer;
已实现的接口
Link to 已实现的接口
MCServer implements the following interfaces. That means all methods defined in these interfaces are also available in MCServer
- AutoCloseable
使用方式
Link to 使用方式
Name: executeCommand
Runs a command, if silent is true, the output is hidden.
Returns The success value of the command, or 0 if an exception occurred.
Note: Some commands' success value is 0
Return Type: int
ZenScript Copy// MCServer.executeCommand(command as string, silent as boolean) as int
world.asServerWorld().server.executeCommand("time set day", true);
参数 | 类型 | 描述 | 可选 | DefaultValue |
---|---|---|---|---|
参数 command | 类型 string | 描述 No Description Provided | 可选 false | DefaultValue |
参数 silent | 类型 布尔值 | 描述 No Description Provided | 可选 true | DefaultValue false |
Name: executeCommand
let a player send a command, if silent is true, the output is hidden.
Returns The success value of the command, or 0 if an exception occurred.
Note: Some commands' success value is 0
Return Type: int
ZenScript Copy// MCServer.executeCommand(command as string, player as MCPlayerEntity, silent as boolean) as int
world.asServerWorld().server.executeCommand("time set day", player, true);
参数 | 类型 | 描述 | 可选 | DefaultValue |
---|---|---|---|---|
参数 command | 类型 string | 描述 No Description Provided | 可选 false | DefaultValue |
参数 player | 类型 MCPlayerEntity #MC玩家实体 | 描述 No Description Provided | 可选 false | DefaultValue |
参数 silent | 类型 布尔值 | 描述 No Description Provided | 可选 true | DefaultValue false |
Name: getWorld
Get a server world instance based on resource location Throws an exception if the world location is unknown
Return Type: MCServerWorld
ZenScript Copy// MCServer.getWorld(location as MCResourceLocation) as MCServerWorld
world.asServerWorld().server.getWorld(<resource:minecraft:the_end>);
参数 | 类型 | 描述 |
---|---|---|
参数 位置 | 类型 MCResourceLocation | 描述 No Description Provided |
名称 | 类型 | 可获得 | 可设置 | 描述 |
---|---|---|---|---|
名称 worlds | 类型 Collection<MCServerWorld> | 可获得 true | 可设置 false | 描述 No Description Provided |