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() = 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 broadcastpermission
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 typeblock_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 barcolor
the color of the boss barstyle
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 barcolor
the color of the boss barstyle
the style of the boss barflags
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 commandcommand_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.