MCServer

导入相关包

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
Copy
import crafttweaker.api.server.MCServer;

已实现的接口

MCServer implements the following interfaces. That means all methods defined in these interfaces are also available in MCServer

  • AutoCloseable

方法

executeCommand

Runs a command.

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) as int
参数类型描述
commandstringNo Description Provided
executeCommand

let a player send a command

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) as int
参数类型描述
commandstringNo Description Provided
playerMCPlayerEntity #MC玩家实体No Description Provided
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

myMCServer.getWorld(<resource:minecraft:the_end>);
参数类型描述
位置MCResourceLocationNo Description Provided

参数

名称类型可获得可设置描述
worldsCollection<MCServerWorld>truefalseNo Description Provided