Skip to Content
⚠ Under Construction
ReferenceC++ APIServer

endstone::Server

Represents a server implementation.

Attributes:

NameDescription
BroadcastChannelAdminUsed for all administrative messages, such as an operator using a command.
BroadcastChannelUserUsed for all announcement messages, such as informing users that a player has joined.

Functions:

NameDescription
Server
Server
broadcastBroadcasts the specified message to every user with the given permission name.
broadcastMessageBroadcasts the specified message to every user with permission endstone.broadcast.user.
broadcastMessage
createBlockDataCreates a new BlockData instance for the specified block type, with all properties initialized to defaults.
createBlockDataCreates a new BlockData instance for the specified block type, with all properties initialized to defaults, except for those provided in data.
createBossBarCreates a boss bar instance to display to players. The progress defaults to 1.0.
createBossBarCreates a boss bar instance to display to players. The progress defaults to 1.0.
createScoreboardCreates a new Scoreboard to be tracked by the server.
dispatchCommandDispatches a command on this server, and executes it if found.
getAverageMillisecondsPerTickGets the average milliseconds per tick (MSPT).
getAverageTickUsageGets the average tick usage of the server.
getAverageTicksPerSecondGets the average ticks per second (TPS).
getBanList
getCommandSenderGets a CommandSender for this server.
getCurrentMillisecondsPerTickGets the current milliseconds per tick (MSPT).
getCurrentTickUsageGets the current tick usage of the server.
getCurrentTicksPerSecondGets the current ticks per second (TPS).
getEnchantmentRegistry
getIpBanList
getItemFactory
getItemRegistry
getLanguageGets the current language interface used by the server.
getLevelGets the server level.
getLoggerReturns the primary logger associated with this server instance.
getMaxPlayersGet the maximum amount of players which can login to this server.
getMinecraftVersionGets the Minecraft version that this server is running.
getNameGets the name of this server implementation.
getOnlineModeGets whether the Server is in online mode or not.
getOnlinePlayersGets a list of all currently online players.
getPlayerGets the player with the given UUID .
getPlayerGets the player with the exact given name, case-insensitive.
getPluginCommandGets a PluginCommand with the given name or alias.
getPluginManagerGets the plugin manager for interfacing with plugins.
getPortGet the game port that the server runs on.
getPortV6Get the game port (IPv6) that the server runs on.
getProtocolVersionGets the network protocol version that this server supports.
getSchedulerGets the scheduler for managing scheduled events.
getScoreboardGets the primary Scoreboard controlled by the server.
getServiceManager
getStartTimeGets the start time of the server.
getVersionGets the version string of this server implementation.
isPrimaryThreadChecks the current thread against the expected primary server thread.
reloadReloads the server configuration, functions, scripts and plugins.
reloadDataReload only the Minecraft data for the server.
setMaxPlayersSet the maximum amount of players allowed to be logged in at once.
shutdownShutdowns the server, stopping everything.

BroadcastChannelAdmin

const std::string endstone::Server::BroadcastChannelAdmin;

Used for all administrative messages, such as an operator using a command.

BroadcastChannelUser

const std::string endstone::Server::BroadcastChannelUser;

Used for all announcement messages, such as informing users that a player has joined.

Server

Server() = default
Server(const Server &) = delete

broadcast

void broadcast(const Message &message, const std::string &permission) const

Broadcasts the specified message to every user with the given permission name.

Parameters:

  • message message to broadcast
  • permission the required permission Permissibles must have to receive the broadcast

broadcastMessage

void broadcastMessage(const Message &message) const

Broadcasts the specified message to every user with permission endstone.broadcast.user.

Parameters:

  • message the message
template <typename... Args> void broadcastMessage(const fmt::format_string<Args...> format, Args &&...args) const

createBlockData

Result<std::unique_ptr<BlockData>> createBlockData(std::string type) const

Creates a new BlockData instance for the specified block type, with all properties initialized to defaults.

Parameters:

  • type the block type

Returns:

new data instance

Result<std::unique_ptr<BlockData>> createBlockData(std::string type, BlockStates block_states) const

Creates a new BlockData instance for the specified block type, with all properties initialized to defaults, except for those provided in data.

Parameters:

  • type the block type
  • block_states block states, for example {"old_leaf_type":"birch", "persistent_bit":true}

Returns:

new data instance

createBossBar

std::unique_ptr<BossBar> createBossBar(std::string title, BarColor color, BarStyle style) const

Creates a boss bar instance to display to players. The progress defaults to 1.0.

Parameters:

  • title the title of the boss bar
  • color the color of the boss bar
  • style the style of the boss bar

Returns:

the created boss bar

std::unique_ptr<BossBar> createBossBar(std::string title, BarColor color, BarStyle style, std::vector<BarFlag> flags) const

Creates a boss bar instance to display to players. The progress defaults to 1.0.

Parameters:

  • title the title of the boss bar
  • color the color of the boss bar
  • style the style of the boss bar
  • flags a list of flags to set on the boss bar

Returns:

the created boss bar

createScoreboard

std::shared_ptr<Scoreboard> createScoreboard()

Creates a new Scoreboard to be tracked by the server.

This will not be saved by the server and is not affected by the /scoreboard command.

Returns:

the newly created Scoreboard

dispatchCommand

bool dispatchCommand(CommandSender &sender, std::string command_line) const

Dispatches a command on this server, and executes it if found.

Parameters:

  • sender the apparent sender of the command
  • command_line the command + arguments.

Returns:

true if execution is successful, false otherwise

getAverageMillisecondsPerTick

float getAverageMillisecondsPerTick()

Gets the average milliseconds per tick (MSPT).

Returns:

The average number of milliseconds per tick.

getAverageTickUsage

float getAverageTickUsage()

Gets the average tick usage of the server.

Returns:

The average tick usage in percentage.

getAverageTicksPerSecond

float getAverageTicksPerSecond()

Gets the average ticks per second (TPS).

Returns:

The average ticks per second

getBanList

PlayerBanList &getBanList() const

Gets the player ban list.

Returns:

The player ban list

getCommandSender

ConsoleCommandSender &getCommandSender() const

Gets a CommandSender for this server.

Returns:

a console command sender

getCurrentMillisecondsPerTick

float getCurrentMillisecondsPerTick()

Gets the current milliseconds per tick (MSPT).

Returns:

The average current of milliseconds per tick.

getCurrentTickUsage

float getCurrentTickUsage()

Gets the current tick usage of the server.

Returns:

The current tick usage in percentage.

getCurrentTicksPerSecond

float getCurrentTicksPerSecond()

Gets the current ticks per second (TPS).

Returns:

The current ticks per second

getEnchantmentRegistry

Registry<Enchantment> &getEnchantmentRegistry() const

Returns the registry for all the enchantments.

Returns:

the enchantment registry.

getIpBanList

IpBanList &getIpBanList() const

Gets the IP ban list.

Returns:

The IP ban list

getItemFactory

ItemFactory &getItemFactory() const

Gets the instance of the item factory (for ItemMeta).

Returns:

the item factory

See also: ItemFactory

getItemRegistry

Registry<ItemType> &getItemRegistry() const

Returns the registry for all the item types.

Returns:

the item registry.

getLanguage

Language &getLanguage() const

Gets the current language interface used by the server.

Returns:

Language interface used by the server for translations.

getLevel

Level *getLevel() const

Gets the server level.

Returns:

the server level

getLogger

Logger &getLogger() const

Returns the primary logger associated with this server instance.

Returns:

Logger associated with this server

getMaxPlayers

int getMaxPlayers() const

Get the maximum amount of players which can login to this server.

Returns:

the amount of players this server allows

getMinecraftVersion

std::string getMinecraftVersion() const

Gets the Minecraft version that this server is running.

Returns:

version of Minecraft

getName

std::string getName() const

Gets the name of this server implementation.

Returns:

name of this server implementation

getOnlineMode

bool getOnlineMode() const

Gets whether the Server is in online mode or not.

Returns:

true if the server authenticates clients, false otherwise

getOnlinePlayers

std::vector<Player *> getOnlinePlayers() const

Gets a list of all currently online players.

Returns:

a list of currently online players.

getPlayer

Player *getPlayer(endstone::UUID id) const

Gets the player with the given UUID .

Parameters:

  • id UUID of the player to retrieve

Returns:

a player object if one was found, null otherwise

Player *getPlayer(std::string name) const

Gets the player with the exact given name, case-insensitive.

Parameters:

  • name Exact name of the player to retrieve

Returns:

a player object if one was found, null otherwise

getPluginCommand

PluginCommand *getPluginCommand(std::string name) const

Gets a PluginCommand with the given name or alias.

Parameters:

  • name the name of the command to retrieve

Returns:

a plugin command if found, null otherwise

getPluginManager

PluginManager &getPluginManager() const

Gets the plugin manager for interfacing with plugins.

Returns:

a plugin manager for this Server instance

getPort

int getPort() const

Get the game port that the server runs on.

Returns:

the port number of this server

getPortV6

int getPortV6() const

Get the game port (IPv6) that the server runs on.

Returns:

the port number of this server

getProtocolVersion

int getProtocolVersion() const

Gets the network protocol version that this server supports.

Returns:

version of network protocol

getScheduler

Scheduler &getScheduler() const

Gets the scheduler for managing scheduled events.

Returns:

a scheduling service for this server

getScoreboard

Scoreboard *getScoreboard() const

Gets the primary Scoreboard controlled by the server.

This Scoreboard is saved by the server, is affected by the /scoreboard command, and is the scoreboard shown by default to players. This will only exist after the level has been loaded.

Returns:

the default server scoreboard

getServiceManager

ServiceManager &getServiceManager() const

Gets the service manager.

Returns:

The service manager

getStartTime

std::chrono::system_clock::time_point getStartTime()

Gets the start time of the server.

Returns:

The start time of the server.

getVersion

std::string getVersion() const

Gets the version string of this server implementation.

Returns:

version of this server implementation

isPrimaryThread

bool isPrimaryThread() const

Checks the current thread against the expected primary server thread.

Returns:

true if the current thread matches the expected primary thread, false otherwise

reload

void reload()

Reloads the server configuration, functions, scripts and plugins.

reloadData

void reloadData()

Reload only the Minecraft data for the server.

This includes functions and script files from all behaviour packs.

setMaxPlayers

Result<void> setMaxPlayers(int max_players)

Set the maximum amount of players allowed to be logged in at once.

Parameters:

  • max_players The maximum amount of concurrent players

shutdown

void shutdown()

Shutdowns the server, stopping everything.

Last updated on