endstone::Server
Represents a server implementation.
Attributes:
| Name | Description |
|---|---|
BroadcastChannelAdmin | Used for all administrative messages, such as an operator using a command. |
BroadcastChannelUser | Used for all announcement messages, such as informing users that a player has joined. |
Functions:
| Name | Description |
|---|---|
Server | |
Server | |
broadcast | Broadcasts the specified message to every user with the given permission name. |
broadcastMessage | Broadcasts the specified message to every user with permission endstone.broadcast.user. |
broadcastMessage | |
createBlockData | Creates a new BlockData instance for the specified block type, with all properties initialized to defaults. |
createBlockData | Creates a new BlockData instance for the specified block type, with all properties initialized to defaults, except for those provided in data. |
createBossBar | Creates a boss bar instance to display to players. The progress defaults to 1.0. |
createBossBar | Creates a boss bar instance to display to players. The progress defaults to 1.0. |
createScoreboard | Creates a new Scoreboard to be tracked by the server. |
dispatchCommand | Dispatches a command on this server, and executes it if found. |
getAverageMillisecondsPerTick | Gets the average milliseconds per tick (MSPT). |
getAverageTickUsage | Gets the average tick usage of the server. |
getAverageTicksPerSecond | Gets the average ticks per second (TPS). |
getBanList | |
getCommandSender | Gets a CommandSender for this server. |
getCurrentMillisecondsPerTick | Gets the current milliseconds per tick (MSPT). |
getCurrentTickUsage | Gets the current tick usage of the server. |
getCurrentTicksPerSecond | Gets the current ticks per second (TPS). |
getEnchantmentRegistry | |
getIpBanList | |
getItemFactory | |
getItemRegistry | |
getLanguage | Gets the current language interface used by the server. |
getLevel | Gets the server level. |
getLogger | Returns the primary logger associated with this server instance. |
getMaxPlayers | Get the maximum amount of players which can login to this server. |
getMinecraftVersion | Gets the Minecraft version that this server is running. |
getName | Gets the name of this server implementation. |
getOnlineMode | Gets whether the Server is in online mode or not. |
getOnlinePlayers | Gets a list of all currently online players. |
getPlayer | Gets the player with the given UUID . |
getPlayer | Gets the player with the exact given name, case-insensitive. |
getPluginCommand | Gets a PluginCommand with the given name or alias. |
getPluginManager | Gets the plugin manager for interfacing with plugins. |
getPort | Get the game port that the server runs on. |
getPortV6 | Get the game port (IPv6) that the server runs on. |
getProtocolVersion | Gets the network protocol version that this server supports. |
getScheduler | Gets the scheduler for managing scheduled events. |
getScoreboard | Gets the primary Scoreboard controlled by the server. |
getServiceManager | |
getStartTime | Gets the start time of the server. |
getVersion | Gets the version string of this server implementation. |
isPrimaryThread | Checks the current thread against the expected primary server thread. |
reload | Reloads the server configuration, functions, scripts and plugins. |
reloadData | Reload only the Minecraft data for the server. |
setMaxPlayers | Set the maximum amount of players allowed to be logged in at once. |
shutdown | Shutdowns 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() = defaultServer(const Server &) = delete broadcast
void broadcast(const Message &message, const std::string &permission) constBroadcasts the specified message to every user with the given permission name.
Parameters:
messagemessage to broadcastpermissionthe required permission Permissibles must have to receive the broadcast
broadcastMessage
void broadcastMessage(const Message &message) constBroadcasts the specified message to every user with permission endstone.broadcast.user.
Parameters:
messagethe 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) constCreates a new BlockData instance for the specified block type, with all properties initialized to defaults.
Parameters:
typethe block type
Returns:
new data instance
Result<std::unique_ptr<BlockData>>
createBlockData(std::string type, BlockStates block_states) constCreates a new BlockData instance for the specified block type, with all properties initialized to defaults, except for those provided in data.
Parameters:
typethe block typeblock_statesblock 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) constCreates a boss bar instance to display to players. The progress defaults to 1.0.
Parameters:
titlethe title of the boss barcolorthe color of the boss barstylethe 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) constCreates a boss bar instance to display to players. The progress defaults to 1.0.
Parameters:
titlethe title of the boss barcolorthe color of the boss barstylethe style of the boss barflagsa 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) constDispatches a command on this server, and executes it if found.
Parameters:
senderthe apparent sender of the commandcommand_linethe 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() constGets the player ban list.
Returns:
The player ban list
getCommandSender
ConsoleCommandSender &getCommandSender() constGets 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() constReturns the registry for all the enchantments.
Returns:
the enchantment registry.
getIpBanList
IpBanList &getIpBanList() constGets the IP ban list.
Returns:
The IP ban list
getItemFactory
ItemFactory &getItemFactory() constGets the instance of the item factory (for ItemMeta).
Returns:
the item factory
See also: ItemFactory
getItemRegistry
Registry<ItemType> &getItemRegistry() constReturns the registry for all the item types.
Returns:
the item registry.
getLanguage
Language &getLanguage() constGets the current language interface used by the server.
Returns:
Language interface used by the server for translations.
getLevel
Level *getLevel() constGets the server level.
Returns:
the server level
getLogger
Logger &getLogger() constReturns the primary logger associated with this server instance.
Returns:
Logger associated with this server
getMaxPlayers
int getMaxPlayers() constGet the maximum amount of players which can login to this server.
Returns:
the amount of players this server allows
getMinecraftVersion
std::string getMinecraftVersion() constGets the Minecraft version that this server is running.
Returns:
version of Minecraft
getName
std::string getName() constGets the name of this server implementation.
Returns:
name of this server implementation
getOnlineMode
bool getOnlineMode() constGets whether the Server is in online mode or not.
Returns:
true if the server authenticates clients, false otherwise
getOnlinePlayers
std::vector<Player *> getOnlinePlayers() constGets a list of all currently online players.
Returns:
a list of currently online players.
getPlayer
Player *getPlayer(endstone::UUID id) constGets the player with the given UUID .
Parameters:
idUUID of the player to retrieve
Returns:
a player object if one was found, null otherwise
Player *getPlayer(std::string name) constGets the player with the exact given name, case-insensitive.
Parameters:
nameExact name of the player to retrieve
Returns:
a player object if one was found, null otherwise
getPluginCommand
PluginCommand *getPluginCommand(std::string name) constGets a PluginCommand with the given name or alias.
Parameters:
namethe name of the command to retrieve
Returns:
a plugin command if found, null otherwise
getPluginManager
PluginManager &getPluginManager() constGets the plugin manager for interfacing with plugins.
Returns:
a plugin manager for this Server instance
getPort
int getPort() constGet the game port that the server runs on.
Returns:
the port number of this server
getPortV6
int getPortV6() constGet the game port (IPv6) that the server runs on.
Returns:
the port number of this server
getProtocolVersion
int getProtocolVersion() constGets the network protocol version that this server supports.
Returns:
version of network protocol
getScheduler
Scheduler &getScheduler() constGets the scheduler for managing scheduled events.
Returns:
a scheduling service for this server
getScoreboard
Scoreboard *getScoreboard() constGets 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() constGets 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() constGets the version string of this server implementation.
Returns:
version of this server implementation
isPrimaryThread
bool isPrimaryThread() constChecks 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_playersThe maximum amount of concurrent players
shutdown
void shutdown()Shutdowns the server, stopping everything.