Table of Contents

Interface ICoreServerAPI

Namespace
Vintagestory.API.Server
Assembly
VintagestoryAPI.dll

The core api implemented by the server. The main interface for accessing the server. Contains all sub components and some miscellaneous methods.

public interface ICoreServerAPI : ICoreAPI, ICoreAPICommon
Inherited Members
Extension Methods

Properties

Event

API Component for registering to various Events

IServerEventAPI Event { get; }

Property Value

IServerEventAPI

Groups

Everything related to player groups

IGroupManager Groups { get; }

Property Value

IGroupManager

Network

API for sending/receiving network packets

IServerNetworkAPI Network { get; }

Property Value

IServerNetworkAPI

Permissions

Everything related to roles and privileges

IPermissionManager Permissions { get; }

Property Value

IPermissionManager

PlayerData

World-agnostic player data. You can query this information even when the player is offline

IPlayerDataManager PlayerData { get; }

Property Value

IPlayerDataManager

Server

API Component for accessing server related functionality

IServerAPI Server { get; }

Property Value

IServerAPI

World

API for accessing anything in the game world

IServerWorldAccessor World { get; }

Property Value

IServerWorldAccessor

WorldManager

API Component for access/modify everything game world related

IWorldManagerAPI WorldManager { get; }

Property Value

IWorldManagerAPI

Methods

BroadcastMessageToAllGroups(string, EnumChatType, string)

Sends a chat message to all online players in all of their channels

void BroadcastMessageToAllGroups(string message, EnumChatType chatType, string data = null)

Parameters

message string
chatType EnumChatType
data string

Custom data to a message to be received by the client

HandleCommand(IServerPlayer, string)

Calls a command as if given player called it

[Obsolete("Use ChatCommand subapi instead")]
void HandleCommand(IServerPlayer player, string message)

Parameters

player IServerPlayer
message string

InjectConsole(string)

Injects a message or command into the server console input processing system. This lets you run commands or chat as Admin.

void InjectConsole(string message)

Parameters

message string

RegisterBlock(Block)

Register a new Block. Must happen before server runphase LoadGame. These are sent to the client during connect, so only need to register them on the server side.

void RegisterBlock(Block block)

Parameters

block Block

BlockType to register. The Server assigns a block id and sets block.blockId

RegisterCommand(string, string, string, ServerChatCommandDelegate, string)

Registers a chat command. When registered on the client you access the command by prefixing a dot (.), on the server it's a slash (/)

[Obsolete("Use ChatCommand subapi instead")]
bool RegisterCommand(string command, string descriptionMsg, string syntaxMsg, ServerChatCommandDelegate handler, string requiredPrivilege = null)

Parameters

command string
descriptionMsg string
syntaxMsg string
handler ServerChatCommandDelegate
requiredPrivilege string

Returns

bool

RegisterCommand(ServerChatCommand)

Registers a chat command. When registered on the client you access the command by prefixing a dot (.), on the server it's a slash (/)

[Obsolete("Use ChatCommand subapi instead")]
bool RegisterCommand(ServerChatCommand chatcommand)

Parameters

chatcommand ServerChatCommand

Returns

bool

RegisterCraftingRecipe(GridRecipe)

Registers a new crafting recipe. These are sent to the client during connect, so only need to register them on the server side.

void RegisterCraftingRecipe(GridRecipe recipe)

Parameters

recipe GridRecipe

RegisterItem(Item)

Register a new item type

void RegisterItem(Item item)

Parameters

item Item

RegisterTreeGenerator(AssetLocation, GrowTreeDelegate)

Registers a new tree generator

void RegisterTreeGenerator(AssetLocation generatorCode, GrowTreeDelegate genhandler)

Parameters

generatorCode AssetLocation
genhandler GrowTreeDelegate

RegisterTreeGenerator(AssetLocation, ITreeGenerator)

Registers a new tree generator

void RegisterTreeGenerator(AssetLocation generatorCode, ITreeGenerator gen)

Parameters

generatorCode AssetLocation
gen ITreeGenerator

SendIngameDiscovery(IServerPlayer, string, string, params object[])

Shows a discovery text on the players screen. If text is null the client will try to find a language entry using supplied code prefixed with 'ingamediscovery-' (which is recommended so that the errors are translated to the users local language)

void SendIngameDiscovery(IServerPlayer player, string discoveryCode, string text = null, params object[] langparams)

Parameters

player IServerPlayer
discoveryCode string
text string
langparams object[]

If text is null, these are the arguments passed into the Language translation tool

SendIngameError(IServerPlayer, string, string, params object[])

Shows a vibrating red text in the players screen. If text is null the client will try to find a language entry using supplied code prefixed with 'ingameerror-' (which is recommended so that the errors are translated to the users local language)

void SendIngameError(IServerPlayer player, string errorCode, string text = null, params object[] langparams)

Parameters

player IServerPlayer
errorCode string
text string
langparams object[]

If text is null, these are the arguments passed into the Language translation tool

SendMessage(IPlayer, int, string, EnumChatType, string)

Sends a chat message only to given player in given groupId

void SendMessage(IPlayer player, int groupId, string message, EnumChatType chatType, string data = null)

Parameters

player IPlayer
groupId int
message string
chatType EnumChatType
data string

Custom data to a message to be received by the client

SendMessageToGroup(int, string, EnumChatType, string)

Sends a chat message to all online players in given player group

void SendMessageToGroup(int groupid, string message, EnumChatType chatType, string data = null)

Parameters

groupid int
message string
chatType EnumChatType
data string

Custom data to a message to be received by the client

TriggerOnAssetsFirstLoaded()

For internal use: used to remap block and item Ids, as soon as assets are loaded from disk, before recipes etc. are loaded or anything else which may occur in modsystem AssetsLoaded() methods

void TriggerOnAssetsFirstLoaded()