Skip to content

Class endstone::Server

ClassList > endstone > Server

Represents a server implementation.

  • #include <endstone/server.h>

Public Static Attributes

Type Name
const std::string BroadcastChannelAdmin = = "endstone.broadcast.admin"
Used for all administrative messages, such as an operator using a command.
const std::string BroadcastChannelUser = = "endstone.broadcast.user"
Used for all announcement messages, such as informing users that a player has joined.

Public Functions

Type Name
Server () = default
Server (const Server &) = delete
virtual void broadcast (const Message & message, const std::string & permission) const = 0
Broadcasts the specified message to every user with the given permission name.
virtual void broadcastMessage (const Message & message) const = 0
Broadcasts the specified message to every user with permission endstone.broadcast.user.
void broadcastMessage (const fmt::format_string< Args... > format, Args &&... args) const
virtual Result< std::shared_ptr< BlockData > > createBlockData (std::string type) const = 0
Creates a new BlockData instance for the specified block type, with all properties initialized to defaults.
virtual Result< std::shared_ptr< BlockData > > createBlockData (std::string type, BlockStates block_states) const = 0
Creates a new BlockData instance for the specified block type, with all properties initialized to defaults, except for those provided in data.
virtual std::unique_ptr< BossBar > createBossBar (std::string title, BarColor color, BarStyle style) const = 0
Creates a boss bar instance to display to players. The progress defaults to 1.0.
virtual std::unique_ptr< BossBar > createBossBar (std::string title, BarColor color, BarStyle style, std::vector< BarFlag > flags) const = 0
Creates a boss bar instance to display to players. The progress defaults to 1.0.
virtual std::shared_ptr< Scoreboard > createScoreboard () = 0
Creates a new Scoreboard to be tracked by the server.
virtual bool dispatchCommand (CommandSender & sender, std::string command_line) const = 0
Dispatches a command on this server, and executes it if found.
virtual float getAverageMillisecondsPerTick () = 0
Gets the average milliseconds per tick (MSPT).
virtual float getAverageTickUsage () = 0
Gets the average tick usage of the server.
virtual float getAverageTicksPerSecond () = 0
Gets the average ticks per second (TPS).
virtual PlayerBanList & getBanList () const = 0
virtual ConsoleCommandSender & getCommandSender () const = 0
Gets a CommandSender for this server.
virtual float getCurrentMillisecondsPerTick () = 0
Gets the current milliseconds per tick (MSPT).
virtual float getCurrentTickUsage () = 0
Gets the current tick usage of the server.
virtual float getCurrentTicksPerSecond () = 0
Gets the current ticks per second (TPS).
virtual IpBanList & getIpBanList () const = 0
virtual Language & getLanguage () const = 0
Gets the current language interface used by the server.
virtual Level * getLevel () const = 0
Gets the server level.
virtual Logger & getLogger () const = 0
Returns the primary logger associated with this server instance.
virtual int getMaxPlayers () const = 0
Get the maximum amount of players which can login to this server.
virtual std::string getMinecraftVersion () const = 0
Gets the Minecraft version that this server is running.
virtual std::string getName () const = 0
Gets the name of this server implementation.
virtual bool getOnlineMode () const = 0
Gets whether the Server is in online mode or not.
virtual std::vector< Player * > getOnlinePlayers () const = 0
Gets a list of all currently online players.
virtual Player * getPlayer (endstone::UUID id) const = 0
Gets the player with the given UUID .
virtual Player * getPlayer (std::string name) const = 0
Gets the player with the exact given name, case-insensitive.
virtual PluginCommand * getPluginCommand (std::string name) const = 0
Gets a PluginCommand with the given name or alias.
virtual PluginManager & getPluginManager () const = 0
Gets the plugin manager for interfacing with plugins.
virtual Scheduler & getScheduler () const = 0
Gets the scheduler for managing scheduled events.
virtual Scoreboard * getScoreboard () const = 0
Gets the primary Scoreboard controlled by the server.
virtual std::chrono::system_clock::time_point getStartTime () = 0
Gets the start time of the server.
virtual std::string getVersion () const = 0
Gets the version string of this server implementation.
virtual bool isPrimaryThread () const = 0
Checks the current thread against the expected primary server thread.
Server & operator= (const Server &) = delete
virtual void reload () = 0
Reloads the server configuration, functions, scripts and plugins.
virtual void reloadData () = 0
Reload only the Minecraft data for the server.
virtual Result< void > setMaxPlayers (int max_players) = 0
Set the maximum amount of players allowed to be logged in at once.
virtual void shutdown () = 0
Shutdowns the server, stopping everything.
virtual ~Server () = default

Public Static Attributes Documentation

variable BroadcastChannelAdmin

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

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


variable BroadcastChannelUser

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

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


Public Functions Documentation

function Server [½]

endstone::Server::Server () = default

function Server [2/2]

endstone::Server::Server (
    const Server &
) = delete

function broadcast

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

virtual void endstone::Server::broadcast (
    const Message & message,
    const std::string & permission
) const = 0

Parameters:

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

function broadcastMessage [½]

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

virtual void endstone::Server::broadcastMessage (
    const Message & message
) const = 0

Parameters:

  • message the message

function broadcastMessage [2/2]

template<typename... Args>
inline void endstone::Server::broadcastMessage (
    const fmt::format_string< Args... > format,
    Args &&... args
) const

function createBlockData [½]

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

virtual Result< std::shared_ptr< BlockData > > endstone::Server::createBlockData (
    std::string type
) const = 0

Parameters:

  • type the block type

Returns:

new data instance


function createBlockData [2/2]

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

virtual Result< std::shared_ptr< BlockData > > endstone::Server::createBlockData (
    std::string type,
    BlockStates block_states
) const = 0

Parameters:

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

Returns:

new data instance


function createBossBar [½]

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

virtual std::unique_ptr< BossBar > endstone::Server::createBossBar (
    std::string title,
    BarColor color,
    BarStyle style
) const = 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


function createBossBar [2/2]

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

virtual std::unique_ptr< BossBar > endstone::Server::createBossBar (
    std::string title,
    BarColor color,
    BarStyle style,
    std::vector< BarFlag > flags
) const = 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


function createScoreboard

Creates a new Scoreboard to be tracked by the server.

virtual std::shared_ptr< Scoreboard > endstone::Server::createScoreboard () = 0

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

Returns:

the newly created Scoreboard


function dispatchCommand

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

virtual bool endstone::Server::dispatchCommand (
    CommandSender & sender,
    std::string command_line
) const = 0

Parameters:

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

Returns:

true if execution is successful, false otherwise


function getAverageMillisecondsPerTick

Gets the average milliseconds per tick (MSPT).

virtual float endstone::Server::getAverageMillisecondsPerTick () = 0

Returns:

The average number of milliseconds per tick.


function getAverageTickUsage

Gets the average tick usage of the server.

virtual float endstone::Server::getAverageTickUsage () = 0

Returns:

The average tick usage in percentage.


function getAverageTicksPerSecond

Gets the average ticks per second (TPS).

virtual float endstone::Server::getAverageTicksPerSecond () = 0

Returns:

The average ticks per second


function getBanList

virtual PlayerBanList & endstone::Server::getBanList () const = 0

Gets the player ban list.

Returns:

The player ban list


function getCommandSender

Gets a CommandSender for this server.

virtual ConsoleCommandSender & endstone::Server::getCommandSender () const = 0

Returns:

a console command sender


function getCurrentMillisecondsPerTick

Gets the current milliseconds per tick (MSPT).

virtual float endstone::Server::getCurrentMillisecondsPerTick () = 0

Returns:

The average current of milliseconds per tick.


function getCurrentTickUsage

Gets the current tick usage of the server.

virtual float endstone::Server::getCurrentTickUsage () = 0

Returns:

The current tick usage in percentage.


function getCurrentTicksPerSecond

Gets the current ticks per second (TPS).

virtual float endstone::Server::getCurrentTicksPerSecond () = 0

Returns:

The current ticks per second


function getIpBanList

virtual IpBanList & endstone::Server::getIpBanList () const = 0

Gets the IP ban list.

Returns:

The IP ban list


function getLanguage

Gets the current language interface used by the server.

virtual Language & endstone::Server::getLanguage () const = 0

Returns:

Language interface used by the server for translations.


function getLevel

Gets the server level.

virtual Level * endstone::Server::getLevel () const = 0

Returns:

the server level


function getLogger

Returns the primary logger associated with this server instance.

virtual Logger & endstone::Server::getLogger () const = 0

Returns:

Logger associated with this server


function getMaxPlayers

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

virtual int endstone::Server::getMaxPlayers () const = 0

Returns:

the amount of players this server allows


function getMinecraftVersion

Gets the Minecraft version that this server is running.

virtual std::string endstone::Server::getMinecraftVersion () const = 0

Returns:

version of Minecraft


function getName

Gets the name of this server implementation.

virtual std::string endstone::Server::getName () const = 0

Returns:

name of this server implementation


function getOnlineMode

Gets whether the Server is in online mode or not.

virtual bool endstone::Server::getOnlineMode () const = 0

Returns:

true if the server authenticates clients, false otherwise


function getOnlinePlayers

Gets a list of all currently online players.

virtual std::vector< Player * > endstone::Server::getOnlinePlayers () const = 0

Returns:

a list of currently online players.


function getPlayer [½]

Gets the player with the given UUID .

virtual Player * endstone::Server::getPlayer (
    endstone::UUID id
) const = 0

Parameters:

  • id UUID of the player to retrieve

Returns:

a player object if one was found, null otherwise


function getPlayer [2/2]

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

virtual Player * endstone::Server::getPlayer (
    std::string name
) const = 0

Parameters:

  • name Exact name of the player to retrieve

Returns:

a player object if one was found, null otherwise


function getPluginCommand

Gets a PluginCommand with the given name or alias.

virtual PluginCommand * endstone::Server::getPluginCommand (
    std::string name
) const = 0

Parameters:

  • name the name of the command to retrieve

Returns:

a plugin command if found, null otherwise


function getPluginManager

Gets the plugin manager for interfacing with plugins.

virtual PluginManager & endstone::Server::getPluginManager () const = 0

Returns:

a plugin manager for this Server instance


function getScheduler

Gets the scheduler for managing scheduled events.

virtual Scheduler & endstone::Server::getScheduler () const = 0

Returns:

a scheduling service for this server


function getScoreboard

Gets the primary Scoreboard controlled by the server.

virtual Scoreboard * endstone::Server::getScoreboard () const = 0

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


function getStartTime

Gets the start time of the server.

virtual std::chrono::system_clock::time_point endstone::Server::getStartTime () = 0

Returns:

The start time of the server。


function getVersion

Gets the version string of this server implementation.

virtual std::string endstone::Server::getVersion () const = 0

Returns:

version of this server implementation


function isPrimaryThread

Checks the current thread against the expected primary server thread.

virtual bool endstone::Server::isPrimaryThread () const = 0

Returns:

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


function operator=

Server & endstone::Server::operator= (
    const Server &
) = delete

function reload

Reloads the server configuration, functions, scripts and plugins.

virtual void endstone::Server::reload () = 0


function reloadData

Reload only the Minecraft data for the server.

virtual void endstone::Server::reloadData () = 0

This includes functions and script files from all behaviour packs.


function setMaxPlayers

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

virtual Result< void > endstone::Server::setMaxPlayers (
    int max_players
) = 0

Parameters:

  • max_players The maximum amount of concurrent players

function shutdown

Shutdowns the server, stopping everything.

virtual void endstone::Server::shutdown () = 0


function ~Server

virtual endstone::Server::~Server () = default


The documentation for this class was generated from the following file include/endstone/server.h