Table of Contents

Interface IServerAPI

Namespace
Vintagestory.API.Server
Assembly
VintagestoryAPI.dll

API for general Server features

public interface IServerAPI

Properties

Config

The servers current configuration as configured in the serverconfig.json. You can set the values but you need to call MarkDirty() to have them saved

IServerConfig Config { get; }

Property Value

IServerConfig

CurrentRunPhase

Returns the servers current run phase

EnumServerRunPhase CurrentRunPhase { get; }

Property Value

EnumServerRunPhase

IsDedicated

Returns whether the current server a dedicated server

bool IsDedicated { get; }

Property Value

bool

IsShuttingDown

Determines if the server process has been asked to terminate. Use this when you need to save data in a method registered using RegisterOnSave() before server quits.

bool IsShuttingDown { get; }

Property Value

bool

true if server is about to shutdown

Logger

Returns a logging interface to log any log level message

ILogger Logger { get; }

Property Value

ILogger

Players

All players known to the server (which joined at least once)

IServerPlayer[] Players { get; }

Property Value

IServerPlayer[]

ServerIp

The ip adress the server is listening at

string ServerIp { get; }

Property Value

string

ServerUptimeMilliseconds

Server uptime in milliseconds

long ServerUptimeMilliseconds { get; }

Property Value

long

ServerUptimeSeconds

Returns the number of seconds the server has been running since last restart

int ServerUptimeSeconds { get; }

Property Value

int

Server uptime in seconds

TotalReceivedBytes

long TotalReceivedBytes { get; }

Property Value

long

TotalSentBytes

long TotalSentBytes { get; }

Property Value

long

TotalWorldPlayTime

Returns the number of seconds the current world has been running. This is the playtime displayed on the singleplayer world list.

int TotalWorldPlayTime { get; }

Property Value

int

Methods

AddServerThread(string, IAsyncServerSystem)

Allows mods to add a ServerThread. Useful for off-thread tasks which must be run continuously (at specified intervals) while the server is running. Calling code simply needs to implement IAsyncServerSystem

void AddServerThread(string threadname, IAsyncServerSystem system)

Parameters

threadname string
system IAsyncServerSystem

LoadMiniDimension(IMiniDimension)

Add the specified dimension to the LoadedMiniDimensions, and return its index.
A mini dimension is a small set of blocks up to 4096x4096x4096 used for schematic previews, vehicles etc

int LoadMiniDimension(IMiniDimension blocks)

Parameters

blocks IMiniDimension

Returns

int

LogBuild(string, params object[])

Log given message with type = EnumLogType.Build

void LogBuild(string message, params object[] args)

Parameters

message string
args object[]

LogChat(string, params object[])

Log given message with type = EnumLogType.Chat

void LogChat(string message, params object[] args)

Parameters

message string
args object[]

LogDebug(string, params object[])

Log given message with type = EnumLogType.Debug

void LogDebug(string message, params object[] args)

Parameters

message string
args object[]

LogError(string, params object[])

Log given message with type = EnumLogType.Error

void LogError(string message, params object[] args)

Parameters

message string
args object[]

LogEvent(string, params object[])

void LogEvent(string message, params object[] args)

Parameters

message string
args object[]

LogFatal(string, params object[])

Log given message with type = EnumLogType.Fatal

void LogFatal(string message, params object[] args)

Parameters

message string
args object[]

LogNotification(string, params object[])

Log given message with type = EnumLogType.Notification

void LogNotification(string message, params object[] args)

Parameters

message string
args object[]

LogVerboseDebug(string, params object[])

Log given message with type = EnumLogType.VerboseDebug

void LogVerboseDebug(string message, params object[] args)

Parameters

message string
args object[]

LogWarning(string, params object[])

Log given message with type = EnumLogType.Warning

void LogWarning(string message, params object[] args)

Parameters

message string
args object[]

MarkConfigDirty()

Marks the config dirty for saving

void MarkConfigDirty()

PauseThread(string, int)

Does a blocking wait until given thread is paused. Returns true if the thread was paused within given time

bool PauseThread(string threadname, int waitTimeoutMs = 5000)

Parameters

threadname string
waitTimeoutMs int

Returns

bool

ResumeThread(string)

Resumes a previously paused thread

void ResumeThread(string threadname)

Parameters

threadname string

SetMiniDimension(IMiniDimension, int)

Set the specified dimension at the specified LoadedMiniDimensions index, and return its index
A mini dimension is a small set of blocks up to 4096x4096x4096 used for schematic previews, vehicles etc

int SetMiniDimension(IMiniDimension miniDimension, int index)

Parameters

miniDimension IMiniDimension
index int

Returns

int

ShutDown()

Gracefully shuts down the server

void ShutDown()