Importing the class

Link to importing-the-class

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;

Implemented Interfaces

Link to implemented-interfaces

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

  • AutoCloseable

Name: 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

world.asServerWorld().server.executeCommand("time set day");
ParameterTypeDescription
Parameter
command
Type
string
Description
No Description Provided

Name: 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

world.asServerWorld().server.executeCommand("time set day", player);
ParameterTypeDescription
Parameter
command
Type
string
Description
No Description Provided
Parameter
player
Type
MCPlayerEntity
Description
No Description Provided

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>);
ParameterTypeDescription
Parameter
場所
Type
MCResourceLocation
Description
No Description Provided
名称TypeHas GetterHas SetterDescription
名称
worlds
Type
Collection<MCServerWorld>
Has Getter
true
Has Setter
false
Description
No Description Provided