Home Commands Examples Getting Started With Scripts Global Keywords 1.21 Migration Guide
BracketDumpers BracketHandlers BracketValidators ResourceLocationBracketHandler

Server

Importing the class

If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.

script.zs
import crafttweaker.api.game.Server;

Extends

Server extends ReentrantBlockableEventLoop<TickTask>.

Implements

Server implements the following interfaces:

CommandSource

Undocumented Interfaces

ServerInfo,ChunkIOErrorReporter,ProfilerMeasured,ProcessorHandle<Runnable>,Executor

Members

Getter
Gets the absolute maximum world size.
script.zs
// MinecraftServer.absoluteMaxWorldSize as int
myMinecraftServer.absoluteMaxWorldSize

Return Type: int

absoluteMaxWorldSize() as int
Gets the absolute maximum world size.

Returns: The absolute maximum world size.

script.zs
// MinecraftServer.absoluteMaxWorldSize() as int;
myMinecraftServer.absoluteMaxWorldSize();

Return Type: int

Getter
Checks if the commands from this source should return failure messages
script.zs
// MinecraftServer.acceptsFailure as bool
myMinecraftServer.acceptsFailure

Return Type: bool

acceptsFailure() as bool
Checks if the commands from this source should return failure messages

Returns: True if the commands from this source should return failure messages, false otherwise.

script.zs
// MinecraftServer.acceptsFailure() as bool;
myMinecraftServer.acceptsFailure();

Return Type: bool

Getter
Checks if the commands from this source should return successful messages
script.zs
// MinecraftServer.acceptsSuccess as bool
myMinecraftServer.acceptsSuccess

Return Type: bool

acceptsSuccess() as bool
Checks if the commands from this source should return successful messages

Returns: True if the commands from this source should return successful messages, false otherwise.

script.zs
// MinecraftServer.acceptsSuccess() as bool;
myMinecraftServer.acceptsSuccess();

Return Type: bool

Getter
Gets the advancements manager.
script.zs
// MinecraftServer.advancements as ServerAdvancementManager
myMinecraftServer.advancements

Return Type: ServerAdvancementManager

Getter
Gets all levels.
script.zs
// MinecraftServer.allLevels as Iterable<ServerLevel>
myMinecraftServer.allLevels

Return Type: Iterable<ServerLevel>

allLevels() as Iterable<ServerLevel>
Gets all levels.

Returns: All levels.

script.zs
// MinecraftServer.allLevels() as Iterable<ServerLevel>;
myMinecraftServer.allLevels();

Return Type: Iterable<ServerLevel>

Getter
Checks if the command source always accepts.
script.zs
// MinecraftServer.alwaysAccepts as bool
myMinecraftServer.alwaysAccepts

Return Type: bool

alwaysAccepts() as bool
Checks if the command source always accepts.

Returns: True if the command source always accepts, false otherwise.

script.zs
// MinecraftServer.alwaysAccepts() as bool;
myMinecraftServer.alwaysAccepts();

Return Type: bool

Getter
Checks if NPCs are enabled.
script.zs
// MinecraftServer.areNpcsEnabled as bool
myMinecraftServer.areNpcsEnabled

Return Type: bool

areNpcsEnabled() as bool
Checks if NPCs are enabled.

Returns: True if NPCs are enabled, false otherwise.

script.zs
// MinecraftServer.areNpcsEnabled() as bool;
myMinecraftServer.areNpcsEnabled();

Return Type: bool

Getter
Gets the current smoothed tick time.
script.zs
// MinecraftServer.currentSmoothedTickTime as float
myMinecraftServer.currentSmoothedTickTime

Return Type: float

currentSmoothedTickTime() as float
Gets the current smoothed tick time.

Returns: The current smoothed tick time.

script.zs
// MinecraftServer.currentSmoothedTickTime() as float;
myMinecraftServer.currentSmoothedTickTime();

Return Type: float

Getter
Gets the default game type.
script.zs
// MinecraftServer.defaultGameTime as GameType
myMinecraftServer.defaultGameTime

Return Type: GameType

defaultGameTime() as GameType
Gets the default game type.

Returns: The default game type.

script.zs
// MinecraftServer.defaultGameTime() as GameType;
myMinecraftServer.defaultGameTime();

Return Type: GameType

executeCommand(command as string, silent as bool = false)
Runs a command, if silent is true, the output is hidden.
script.zs
// MinecraftServer.executeCommand(command as string, silent as bool = false);
myMinecraftServer.executeCommand("time set day", true);

Parameters:

command Type: string
silent (optional) Type: bool

Default Value: false

executeCommand(command as string, player as Player, silent as bool = false)
let a player send a command, if silent is true, the output is hidden.
script.zs
// MinecraftServer.executeCommand(command as string, player as Player, silent as bool = false);
myMinecraftServer.executeCommand("time set day", player, true);

Parameters:

command Type: string
player Type: Player
silent (optional) Type: bool

Default Value: false

Getter
Gets the forced game type.
script.zs
// MinecraftServer.forcedGameType as GameType
myMinecraftServer.forcedGameType

Return Type: GameType

forcedGameType() as GameType
Gets the forced game type.

Returns: The forced game type.

script.zs
// MinecraftServer.forcedGameType() as GameType;
myMinecraftServer.forcedGameType();

Return Type: GameType

getLevel(location as ResourceLocation) as ServerLevel
Gets a level by its key.

Returns: The level.

script.zs
// MinecraftServer.getLevel(location as ResourceLocation) as ServerLevel;
myMinecraftServer.getLevel(myResourceLocation);

Parameters:

location Type: ResourceLocation - The key of the level.

Return Type: ServerLevel

getSpawnRadius(level as ServerLevel) as int
Gets the spawn radius.

Returns: The spawn radius.

script.zs
// MinecraftServer.getSpawnRadius(level as ServerLevel) as int;
myMinecraftServer.getSpawnRadius(myServerLevel);

Parameters:

level Type: ServerLevel - The level.

Return Type: int

Getter
Checks if command blocks are enabled.
script.zs
// MinecraftServer.isCommandBlockEnabled as bool
myMinecraftServer.isCommandBlockEnabled

Return Type: bool

isCommandBlockEnabled() as bool
Checks if command blocks are enabled.

Returns: True if command blocks are enabled, false otherwise.

script.zs
// MinecraftServer.isCommandBlockEnabled() as bool;
myMinecraftServer.isCommandBlockEnabled();

Return Type: bool

Getter
Checks if the server is dedicated.
script.zs
// MinecraftServer.isDedicatedServer as bool
myMinecraftServer.isDedicatedServer

Return Type: bool

isDedicatedServer() as bool
Checks if the server is dedicated.

Returns: True if the server is dedicated, false otherwise.

script.zs
// MinecraftServer.isDedicatedServer() as bool;
myMinecraftServer.isDedicatedServer();

Return Type: bool

Getter
Checks if the whitelist is enforced.
script.zs
// MinecraftServer.isEnforceWhitelist as bool
myMinecraftServer.isEnforceWhitelist

Return Type: bool

isEnforceWhitelist() as bool
Checks if the whitelist is enforced.

Returns: True if the whitelist is enforced, false otherwise.

script.zs
// MinecraftServer.isEnforceWhitelist() as bool;
myMinecraftServer.isEnforceWhitelist();

Return Type: bool

Getter
Checks if flight is allowed.
script.zs
// MinecraftServer.isFlightAllowed as bool
myMinecraftServer.isFlightAllowed

Return Type: bool

isFlightAllowed() as bool
Checks if flight is allowed.

Returns: True if flight is allowed, false otherwise.

script.zs
// MinecraftServer.isFlightAllowed() as bool;
myMinecraftServer.isFlightAllowed();

Return Type: bool

Getter
Checks if the server is hardcore.
script.zs
// MinecraftServer.isHardcore as bool
myMinecraftServer.isHardcore

Return Type: bool

isHardcore() as bool
Checks if the server is hardcore.

Returns: True if the server is hardcore, false otherwise.

script.zs
// MinecraftServer.isHardcore() as bool;
myMinecraftServer.isHardcore();

Return Type: bool

Getter
Checks if PvP is allowed.
script.zs
// MinecraftServer.isPvpAllowed as bool
myMinecraftServer.isPvpAllowed

Return Type: bool

isPvpAllowed() as bool
Checks if PvP is allowed.

Returns: True if PvP is allowed, false otherwise.

script.zs
// MinecraftServer.isPvpAllowed() as bool;
myMinecraftServer.isPvpAllowed();

Return Type: bool

Getter
Checks if the server is ready.
script.zs
// MinecraftServer.isReady as bool
myMinecraftServer.isReady

Return Type: bool

isReady() as bool
Checks if the server is ready.

Returns: True if the server is ready, false otherwise.

script.zs
// MinecraftServer.isReady() as bool;
myMinecraftServer.isReady();

Return Type: bool

Getter
Checks if the server is running.
script.zs
// MinecraftServer.isRunning as bool
myMinecraftServer.isRunning

Return Type: bool

isRunning() as bool
Checks if the server is running.

Returns: True if the server is running, false otherwise.

script.zs
// MinecraftServer.isRunning() as bool;
myMinecraftServer.isRunning();

Return Type: bool

Getter
Checks if the server is shutting down.
script.zs
// MinecraftServer.isShutdown as bool
myMinecraftServer.isShutdown

Return Type: bool

isShutdown() as bool
Checks if the server is shutting down.

Returns: True if the server is shutting down, false otherwise.

script.zs
// MinecraftServer.isShutdown() as bool;
myMinecraftServer.isShutdown();

Return Type: bool

Getter
Checks if the server is singleplayer.
script.zs
// MinecraftServer.isSingleplayer as bool
myMinecraftServer.isSingleplayer

Return Type: bool

isSingleplayer() as bool
Checks if the server is singleplayer.

Returns: True if the server is singleplayer, false otherwise.

script.zs
// MinecraftServer.isSingleplayer() as bool;
myMinecraftServer.isSingleplayer();

Return Type: bool

Getter
Checks if animals are spawning.
script.zs
// MinecraftServer.isSpawningAnimals as bool
myMinecraftServer.isSpawningAnimals

Return Type: bool

isSpawningAnimals() as bool
Checks if animals are spawning.

Returns: True if animals are spawning, false otherwise.

script.zs
// MinecraftServer.isSpawningAnimals() as bool;
myMinecraftServer.isSpawningAnimals();

Return Type: bool

Getter
Checks if monsters are spawning.
script.zs
// MinecraftServer.isSpawningMonsters as bool
myMinecraftServer.isSpawningMonsters

Return Type: bool

isSpawningMonsters() as bool
Checks if monsters are spawning.

Returns: True if monsters are spawning, false otherwise.

script.zs
// MinecraftServer.isSpawningMonsters() as bool;
myMinecraftServer.isSpawningMonsters();

Return Type: bool

Getter
Checks if the server is stopped.
script.zs
// MinecraftServer.isStopped as bool
myMinecraftServer.isStopped

Return Type: bool

isStopped() as bool
Checks if the server is stopped.

Returns: True if the server is stopped, false otherwise.

script.zs
// MinecraftServer.isStopped() as bool;
myMinecraftServer.isStopped();

Return Type: bool

isUnderSpawnProtection(level as ServerLevel, pos as BlockPos, player as Player) as bool
Checks if a position is under spawn protection.

Returns: True if the position is under spawn protection, false otherwise.

script.zs
// MinecraftServer.isUnderSpawnProtection(level as ServerLevel, pos as BlockPos, player as Player) as bool;
myMinecraftServer.isUnderSpawnProtection(myServerLevel, myBlockPos, myPlayer);

Parameters:

level Type: ServerLevel - The level.
pos Type: BlockPos - The position.
player Type: Player - The player.

Return Type: bool

Getter
Gets the keys of all levels.
script.zs
// MinecraftServer.levelKeys as List<ResourceLocation>
myMinecraftServer.levelKeys

Return Type: List<ResourceLocation>

levelKeys() as List<ResourceLocation>
Gets the keys of all levels.

Returns: The keys of all levels.

script.zs
// MinecraftServer.levelKeys() as List<ResourceLocation>;
myMinecraftServer.levelKeys();

Return Type: List<ResourceLocation>

Getter
Gets the maximum number of players.
script.zs
// MinecraftServer.maxPlayer as int
myMinecraftServer.maxPlayer

Return Type: int

maxPlayer() as int
Gets the maximum number of players.

Returns: The maximum number of players.

script.zs
// MinecraftServer.maxPlayer() as int;
myMinecraftServer.maxPlayer();

Return Type: int

Getter
Gets the modded status.
script.zs
// MinecraftServer.moddeStatus as string
myMinecraftServer.moddeStatus

Return Type: string

moddeStatus() as string
Gets the modded status.

Returns: The modded status.

script.zs
// MinecraftServer.moddeStatus() as string;
myMinecraftServer.moddeStatus();

Return Type: string

Getter
Gets the message of the day.
script.zs
// MinecraftServer.motd as string
myMinecraftServer.motd

Return Type: string

motd() as string
Gets the message of the day.

Returns: The message of the day.

script.zs
// MinecraftServer.motd() as string;
myMinecraftServer.motd();

Return Type: string

Getter
Gets the operator user permission level.
script.zs
// MinecraftServer.operatorUserPermissionLevel as int
myMinecraftServer.operatorUserPermissionLevel

Return Type: int

operatorUserPermissionLevel() as int
Gets the operator user permission level.

Returns: The operator user permission level.

script.zs
// MinecraftServer.operatorUserPermissionLevel() as int;
myMinecraftServer.operatorUserPermissionLevel();

Return Type: int

Getter
Gets the overworld.
script.zs
// MinecraftServer.overworld as ServerLevel
myMinecraftServer.overworld

Return Type: ServerLevel

overworld() as ServerLevel
Gets the overworld.

Returns: The overworld.

script.zs
// MinecraftServer.overworld() as ServerLevel;
myMinecraftServer.overworld();

Return Type: ServerLevel

Getter
Gets the custom data of the overworld.

The overworld is always loaded, so this can be used to store and access data no matter what level a player may be in.

script.zs
// MinecraftServer.overworldData as CraftTweakerSavedData
myMinecraftServer.overworldData

Return Type: CraftTweakerSavedData

overworldData() as CraftTweakerSavedData
Gets the custom data of the overworld.

The overworld is always loaded, so this can be used to store and access data no matter what level a player may be in.

Returns: The overworld's custom data.

script.zs
// MinecraftServer.overworldData() as CraftTweakerSavedData;
myMinecraftServer.overworldData();

Return Type: CraftTweakerSavedData

Getter
Gets the player count.
script.zs
// MinecraftServer.playerCount as int
myMinecraftServer.playerCount

Return Type: int

playerCount() as int
Gets the player count.

Returns: The player count.

script.zs
// MinecraftServer.playerCount() as int;
myMinecraftServer.playerCount();

Return Type: int

Getter
Gets the player list.
script.zs
// MinecraftServer.playerList as PlayerList
myMinecraftServer.playerList

Return Type: PlayerList

playerList() as PlayerList
Gets the player list.

Returns: The player list.

script.zs
// MinecraftServer.playerList() as PlayerList;
myMinecraftServer.playerList();

Return Type: PlayerList

Getter
Gets the player names.
script.zs
// MinecraftServer.playerNames as string[]
myMinecraftServer.playerNames

Return Type: string[]

playerNames() as string[]
Gets the player names.

Returns: The player names.

script.zs
// MinecraftServer.playerNames() as string[];
myMinecraftServer.playerNames();

Return Type: string[]

sendMessage(component as Component)
Sends a message to the command source.
script.zs
// MinecraftServer.sendMessage(component as Component);
myMinecraftServer.sendMessage(myComponent);

Parameters:

component Type: Component - The message to send.
Getter
Gets the server mod name.
script.zs
// MinecraftServer.serverModName as string
myMinecraftServer.serverModName

Return Type: string

serverModName() as string
Gets the server mod name.

Returns: The server mod name.

script.zs
// MinecraftServer.serverModName() as string;
myMinecraftServer.serverModName();

Return Type: string

Getter
Gets the server version.
script.zs
// MinecraftServer.serverVersion as string
myMinecraftServer.serverVersion

Return Type: string

serverVersion() as string
Gets the server version.

Returns: The server version.

script.zs
// MinecraftServer.serverVersion() as string;
myMinecraftServer.serverVersion();

Return Type: string

setDefaultGameType(gameType as GameType)
Sets the default game type.
script.zs
// MinecraftServer.setDefaultGameType(gameType as GameType);
myMinecraftServer.setDefaultGameType(myGameType);

Parameters:

gameType Type: GameType - The game type to set.
setDifficulty(difficulty as Difficulty, force as bool)
Sets the difficulty of the server.
script.zs
// MinecraftServer.setDifficulty(difficulty as Difficulty, force as bool);
myMinecraftServer.setDifficulty(myDifficulty, myBool);

Parameters:

difficulty Type: Difficulty - The difficulty to set.
force Type: bool - Whether to force the difficulty.
setDifficultyLocked(locked as bool)
Sets if the difficulty should be locked.
script.zs
// MinecraftServer.setDifficultyLocked(locked as bool);
myMinecraftServer.setDifficultyLocked(myBool);

Parameters:

locked Type: bool - Whether to lock the difficulty.
setEnforceWhitelist(enforceWhitelist as bool)
Sets if the whitelist is enforced.
script.zs
// MinecraftServer.setEnforceWhitelist(enforceWhitelist as bool);
myMinecraftServer.setEnforceWhitelist(myBool);

Parameters:

enforceWhitelist Type: bool - Whether to enforce the whitelist.
setFlightAllowed(flightAllowed as bool)
Sets if flight is allowed.
script.zs
// MinecraftServer.setFlightAllowed(flightAllowed as bool);
myMinecraftServer.setFlightAllowed(myBool);

Parameters:

flightAllowed Type: bool - Whether to allow flight.
setMotd(motd as string)
Sets the message of the day.
script.zs
// MinecraftServer.setMotd(motd as string);
myMinecraftServer.setMotd(myString);

Parameters:

motd Type: string - The message of the day.
setPvpAllowed(pvpAllowed as bool)
Sets if PvP is allowed.
script.zs
// MinecraftServer.setPvpAllowed(pvpAllowed as bool);
myMinecraftServer.setPvpAllowed(myBool);

Parameters:

pvpAllowed Type: bool - Whether to allow PvP.
Getter
Checks if the commands from this source should inform admins.
script.zs
// MinecraftServer.shouldInformAdmins as bool
myMinecraftServer.shouldInformAdmins

Return Type: bool

shouldInformAdmins() as bool
Checks if the commands from this source should inform admins.

Returns: True if the commands from this source should inform admins, false otherwise.

script.zs
// MinecraftServer.shouldInformAdmins() as bool;
myMinecraftServer.shouldInformAdmins();

Return Type: bool

Getter
Gets the spawn protection radius.
script.zs
// MinecraftServer.spawnProtectionRadius as int
myMinecraftServer.spawnProtectionRadius

Return Type: int

spawnProtectionRadius() as int
Gets the spawn protection radius.

Returns: The spawn protection radius.

script.zs
// MinecraftServer.spawnProtectionRadius() as int;
myMinecraftServer.spawnProtectionRadius();

Return Type: int

Getter
Gets the tick count.
script.zs
// MinecraftServer.tickCount as int
myMinecraftServer.tickCount

Return Type: int

tickCount() as int
Gets the tick count.

Returns: The tick count.

script.zs
// MinecraftServer.tickCount() as int;
myMinecraftServer.tickCount();

Return Type: int