Interface Server
- All Superinterfaces:
net.kyori.adventure.audience.Audience
,net.kyori.adventure.audience.ForwardingAudience
,PluginMessageRecipient
,net.kyori.adventure.pointer.Pointered
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.kyori.adventure.audience.ForwardingAudience
net.kyori.adventure.audience.ForwardingAudience.Single
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds a recipe to the crafting manager.Get an iterator through all advancements.void
Bans the specified address from the server.int
Deprecated.default void
broadcast(@NotNull BaseComponent... components)
Deprecated.usesendMessage
methods that acceptComponent
int
broadcast(net.kyori.adventure.text.Component message)
Broadcast a message to all players.int
Broadcasts the specified message to every user with the given permission name.default void
broadcast(BaseComponent component)
Deprecated.usesendMessage
methods that acceptComponent
int
broadcastMessage(@NotNull String message)
Deprecated.void
Clears the list of crafting recipes.createBlockData(@NotNull String data)
Creates a newBlockData
instance with material and properties parsed from provided data.createBlockData(@NotNull Material material)
Creates a newBlockData
instance for the specified Material, with all properties initialized to unspecified defaults.Creates a newBlockData
instance for the specified Material, with all properties initialized to unspecified defaults.createBlockData(@Nullable Material material, @Nullable String data)
Creates a newBlockData
instance for the specified Material, with all properties initialized to unspecified defaults, except for those provided in data.createBossBar(@NotNull NamespacedKey key, @Nullable String title, @NotNull BarColor color, @NotNull BarStyle style, @NotNull BarFlag... flags)
Creates a boss bar instance to display to players.createBossBar(@Nullable String title, @NotNull BarColor color, @NotNull BarStyle style, @NotNull BarFlag... flags)
Creates a boss bar instance to display to players.createChunkData(@NotNull World world)
Create a ChunkData for use in a generator.createExplorerMap(@NotNull World world, @NotNull Location location, @NotNull StructureType structureType)
Create a new explorer map targeting the closest nearby structure of a givenStructureType
.createExplorerMap(@NotNull World world, @NotNull Location location, @NotNull StructureType structureType, int radius, boolean findUnexplored)
Create a new explorer map targeting the closest nearby structure of a givenStructureType
.createInventory(@Nullable InventoryHolder owner, int size)
Creates an empty inventory of typeInventoryType.CHEST
with the specified size.createInventory(@Nullable InventoryHolder owner, int size, @NotNull String title)
Deprecated.createInventory(@Nullable InventoryHolder owner, int size, net.kyori.adventure.text.Component title)
Creates an empty inventory of typeInventoryType.CHEST
with the specified size and title.createInventory(@Nullable InventoryHolder owner, @NotNull InventoryType type)
Creates an empty inventory with the specified type.createInventory(@Nullable InventoryHolder owner, @NotNull InventoryType type, @NotNull String title)
Deprecated.createInventory(@Nullable InventoryHolder owner, @NotNull InventoryType type, net.kyori.adventure.text.Component title)
Creates an empty inventory with the specified type and title.Create a new map with an automatically assigned ID.createMerchant(@Nullable String title)
Deprecated.in favour ofcreateMerchant(net.kyori.adventure.text.Component)
createMerchant(net.kyori.adventure.text.Component title)
Creates an empty merchant.createProfile(@NotNull String name)
Creates a PlayerProfile for the specified name, with UUID as nullcreateProfile(@NotNull UUID uuid)
Creates a PlayerProfile for the specified uuid, with name as nullcreateProfile(@Nullable UUID uuid, @Nullable String name)
Creates a PlayerProfile for the specified name/uuid Both UUID and Name can not be null at same time.createVanillaChunkData(@NotNull World world, int x, int z)
Create a ChunkData for use in a generator, that is populated by the vanilla generator for that worldcreateWorld(@NotNull WorldCreator creator)
Creates or loads a world with the given name using the specified options.boolean
dispatchCommand(@NotNull CommandSender sender, @NotNull String commandLine)
Dispatches a command on this server, and executes it if found.Get the advancement specified by this key.boolean
Gets whether this server allows the End or not.boolean
Gets whether this server allows flying or not.boolean
Gets whether this server allows the Nether or not.int
Gets user-specified limit for number of ambient mobs that can spawn in a chunk.int
Gets user-specified limit for number of animals that can spawn in a chunk.double
Get the average tick time (in millis)getBanList(BanList.Type type)
Gets a ban list for the supplied type.Gets a set containing all banned players.getBossBar(@NotNull NamespacedKey key)
Gets theKeyedBossBar
specified by this key.Gets an unmodifiable iterator through all persistent bossbars.Gets the Bukkit version that this server is running.Gets a list of command aliases defined in the server properties.Gets the activeCommandMap
long
Gets the value of the connection throttle setting.Gets aConsoleCommandSender
that may be used as an input source for this server.int
Get the current internal server tickGets the defaultGameMode
for new players.Gets an entity on the server by its UUIDboolean
Get generate-structures setting.Gets theHelpMap
providing help topics for this server.int
Gets the idle kick timeout.getIp()
Get the IP that this server is bound to, or empty string if not specified.Gets a set containing all current IPs that are banned.Gets the instance of the item factory (forItemMeta
).Returns the primary logger associated with this server instance.Gets the specifiedLootTable
.getMap(int id)
Deprecated.Magic valueint
Get the maximum amount of players which can login to this server.int
Get max world size.Gets theMessenger
responsible for this server.Gets the version of game this server implementsReturns theMobGoals
managerint
Gets user-specified limit for number of monsters that can spawn in a chunk.getMotd()
Deprecated.in favour ofmotd()
getName()
Gets the name of this server implementation.getOfflinePlayer(@NotNull String name)
Deprecated.Persistent storage of users should be by UUID as names are no longer unique past a single session.getOfflinePlayer(@NotNull UUID id)
Gets the player by the given UUID, regardless if they are offline or online.Gets the player by the given name, regardless if they are offline or online.Gets every player that has ever played on this server.boolean
Gets whether the Server is in online mode or not.@NotNull Collection<? extends Player>
Gets a view of all currently logged in players.Gets a set containing all player operators.Gets a player object by the given username.Gets the player with the given UUID.getPlayerExact(@NotNull String name)
Gets the player with the exact given name, case insensitive.getPlayerUniqueId(@NotNull String playerName)
Gets the unique ID of the player currently known as the specified player name In Offline Mode, will return an Offline UUIDgetPluginCommand(@NotNull String name)
Gets aPluginCommand
with the given name or alias.Gets the plugin manager for interfacing with plugins.int
getPort()
Get the game port that the server runs on.getRecipe(@NotNull NamespacedKey recipeKey)
Get theRecipe
for the given key.getRecipesFor(@NotNull ItemStack result)
Get a list of all recipes for a given item.Gets the scheduler for managing scheduled events.Gets the instance of the scoreboard manager.Gets an instance of the server's default server-icon.Gets a services manager.Deprecated.in favour ofshutdownMessage()
int
Gets the radius, in blocks, around each worlds spawn point to protect.Gets a tag which has already been defined within the server.Gets a all tags which have been defined within the server.int
Gets the default ticks per ambient mob spawns value.int
Gets default ticks per animal spawns value.int
Gets the default ticks per monster spawns value.int
Gets the default ticks per water ambient mob spawns value.int
Gets the default ticks per water mob spawns value.@org.jetbrains.annotations.NotNull long[]
Get a sample of the servers last tick times (in nanos)@org.jetbrains.annotations.NotNull double[]
getTPS()
Gets the current server TPSDeprecated.Gets the name of the update folder.Gets the update folder.Gets the version string of this server implementation.int
Get the view distance from this server.Gets the current warning state for the server.int
Gets user-specified limit for number of water ambient mobs that can spawn in a chunk.int
Gets user-specified limit for number of water animals that can spawn in a chunk.Gets a list of whitelisted players.Gets the world with the given name.Gets the world from the given Unique ID.getWorld(@NotNull NamespacedKey worldKey)
Gets the world from the given NamespacedKeyGets the folder that contains all of the variousWorld
s.Gets a list of all worlds on this server.Get world type (level-type setting) for default world.boolean
Gets whether this server has a whitelist or not.boolean
Gets whether the server is in hardcore mode or not.boolean
Checks the current thread against the expected primary thread for the server.boolean
Checks if the server is in the process of being shutdown.boolean
Gets whether the server whitelist is enforced.loadServerIcon(@NotNull BufferedImage image)
Creates a cached server-icon for the specific image.loadServerIcon(@NotNull File file)
Loads an image from a file, and returns a cached image for the specific server-icon.matchPlayer(@NotNull String name)
Attempts to match any players with the given name, and returns a list of all possibly matches.net.kyori.adventure.text.Component
motd()
Gets the message that is displayed on the server list.Get an iterator through the list of crafting recipes.void
reload()
Reloads the server, refreshing settings and plugin information.boolean
void
Reload only the Minecraft data for the server.void
void
Reloads the whitelist from disk.boolean
Removes aKeyedBossBar
specified by this key.boolean
Remove a recipe from the server.void
Resets the list of crafting recipes to the default.void
Writes loaded players to disk.selectEntities(@NotNull CommandSender sender, @NotNull String selector)
Selects entities using the given Vanilla selector.void
setDefaultGameMode(@NotNull GameMode mode)
Sets the defaultGameMode
for new players.void
setIdleTimeout(int threshold)
Set the idle kick timeout.void
setMaxPlayers(int maxPlayers)
Set the maximum amount of players which can login to this server.void
setSpawnRadius(int value)
Sets the radius, in blocks, around each worlds spawn point to protect.void
setWhitelist(boolean value)
Sets if the server is whitelisted.void
setWhitelistEnforced(boolean value)
Sets if the server whitelist is enforced.void
shutdown()
Shutdowns the server, stopping everything.net.kyori.adventure.text.Component
Gets the default message that is displayed when the server is stopped.spigot()
boolean
Checks if player names should be suggested when a command returnsnull
as their tab completion result.void
Unbans the specified address from the server.boolean
unloadWorld(@NotNull String name, boolean save)
Unloads a world with the given name.boolean
unloadWorld(@NotNull World world, boolean save)
Unloads the given world.Methods inherited from interface net.kyori.adventure.audience.Audience
openBook, sendActionBar, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeaderAndFooter, stopSound
Methods inherited from interface net.kyori.adventure.audience.ForwardingAudience
audiences, clearTitle, get, getOrDefault, getOrDefaultFrom, hideBossBar, openBook, playSound, playSound, playSound, resetTitle, sendActionBar, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeaderAndFooter, showBossBar, showTitle, stopSound
Methods inherited from interface org.bukkit.plugin.messaging.PluginMessageRecipient
getListeningPluginChannels, sendPluginMessage
Methods inherited from interface net.kyori.adventure.pointer.Pointered
pointers
-
Field Details
-
BROADCAST_CHANNEL_ADMINISTRATIVE
Used for all administrative messages, such as an operator using a command.For use in
broadcast(net.kyori.adventure.text.Component, java.lang.String)
.- See Also:
- Constant Field Values
-
BROADCAST_CHANNEL_USERS
Used for all announcement messages, such as informing users that a player has joined.For use in
broadcast(net.kyori.adventure.text.Component, java.lang.String)
.- See Also:
- Constant Field Values
-
-
Method Details
-
getName
Gets the name of this server implementation.- Returns:
- name of this server implementation
-
getVersion
Gets the version string of this server implementation.- Returns:
- version of this server implementation
-
getBukkitVersion
Gets the Bukkit version that this server is running.- Returns:
- version of Bukkit
-
getMinecraftVersion
Gets the version of game this server implements- Returns:
- version of game
-
getOnlinePlayers
Gets a view of all currently logged in players. This view is a reused object, making some operations likeCollection.size()
zero-allocation.The collection is a view backed by the internal representation, such that, changes to the internal state of the server will be reflected immediately. However, the reuse of the returned collection (identity) is not strictly guaranteed for future or all implementations. Casting the collection, or relying on interface implementations (like
Serializable
orList
), is deprecated.Iteration behavior is undefined outside of self-contained main-thread uses. Normal and immediate iterator use without consequences that affect the collection are fully supported. The effects following (non-exhaustive)
teleportation
,death
, andkicking
are undefined. Any use of this collection from asynchronous threads is unsafe.For safe consequential iteration or mimicking the old array behavior, using
Collection.toArray(Object[])
is recommended. For making snapshots,ImmutableList.copyOf(Collection)
is recommended.- Returns:
- a view of currently online players.
-
getMaxPlayers
int getMaxPlayers()Get the maximum amount of players which can login to this server.- Returns:
- the amount of players this server allows
-
setMaxPlayers
void setMaxPlayers(int maxPlayers)Set the maximum amount of players which can login to this server.- Parameters:
maxPlayers
- the amount of players this server allows
-
getPort
int getPort()Get the game port that the server runs on.- Returns:
- the port number of this server
-
getViewDistance
int getViewDistance()Get the view distance from this server.- Returns:
- the view distance from this server.
-
getIp
Get the IP that this server is bound to, or empty string if not specified.- Returns:
- the IP string that this server is bound to, otherwise empty string
-
getWorldType
Get world type (level-type setting) for default world.- Returns:
- the value of level-type (e.g. DEFAULT, FLAT, DEFAULT_1_1)
-
getGenerateStructures
boolean getGenerateStructures()Get generate-structures setting.- Returns:
- true if structure generation is enabled, false otherwise
-
getMaxWorldSize
int getMaxWorldSize()Get max world size.- Returns:
- the maximum world size as specified for the server
-
getAllowEnd
boolean getAllowEnd()Gets whether this server allows the End or not.- Returns:
- whether this server allows the End or not
-
getAllowNether
boolean getAllowNether()Gets whether this server allows the Nether or not.- Returns:
- whether this server allows the Nether or not
-
hasWhitelist
boolean hasWhitelist()Gets whether this server has a whitelist or not.- Returns:
- whether this server has a whitelist or not
-
setWhitelist
void setWhitelist(boolean value)Sets if the server is whitelisted.- Parameters:
value
- true for whitelist on, false for off
-
isWhitelistEnforced
boolean isWhitelistEnforced()Gets whether the server whitelist is enforced. If the whitelist is enforced, non-whitelisted players will be disconnected when the server whitelist is reloaded.- Returns:
- whether the server whitelist is enforced
-
setWhitelistEnforced
void setWhitelistEnforced(boolean value)Sets if the server whitelist is enforced. If the whitelist is enforced, non-whitelisted players will be disconnected when the server whitelist is reloaded.- Parameters:
value
- true for enforced, false for not
-
getWhitelistedPlayers
Gets a list of whitelisted players.- Returns:
- a set containing all whitelisted players
-
reloadWhitelist
void reloadWhitelist()Reloads the whitelist from disk. -
broadcastMessage
Deprecated.Broadcast a message to all players.This is the same as calling
broadcast(java.lang.String, java.lang.String)
toBROADCAST_CHANNEL_USERS
- Parameters:
message
- the message- Returns:
- the number of players
-
broadcast
Deprecated.usesendMessage
methods that acceptComponent
Sends the component to all online players.- Parameters:
component
- the component to send
-
broadcast
Deprecated.usesendMessage
methods that acceptComponent
Sends an array of components as a single message to all online players.- Parameters:
components
- the components to send
-
getUpdateFolder
Gets the name of the update folder. The update folder is used to safely update plugins at the right moment on a plugin load.The update folder name is relative to the plugins folder.
- Returns:
- the name of the update folder
-
getUpdateFolderFile
Gets the update folder. The update folder is used to safely update plugins at the right moment on a plugin load.- Returns:
- the update folder
-
getConnectionThrottle
long getConnectionThrottle()Gets the value of the connection throttle setting.- Returns:
- the value of the connection throttle setting
-
getTicksPerAnimalSpawns
int getTicksPerAnimalSpawns()Gets default ticks per animal spawns value.Example Usage:
- A value of 1 will mean the server will attempt to spawn monsters every tick.
- A value of 400 will mean the server will attempt to spawn monsters every 400th tick.
- A value below 0 will be reset back to Minecraft's default.
Note: If set to 0, animal spawning will be disabled. We recommend using spawn-animals to control this instead.
Minecraft default: 400.
- Returns:
- the default ticks per animal spawns value
-
getTicksPerMonsterSpawns
int getTicksPerMonsterSpawns()Gets the default ticks per monster spawns value.Example Usage:
- A value of 1 will mean the server will attempt to spawn monsters every tick.
- A value of 400 will mean the server will attempt to spawn monsters every 400th tick.
- A value below 0 will be reset back to Minecraft's default.
Note: If set to 0, monsters spawning will be disabled. We recommend using spawn-monsters to control this instead.
Minecraft default: 1.
- Returns:
- the default ticks per monsters spawn value
-
getTicksPerWaterSpawns
int getTicksPerWaterSpawns()Gets the default ticks per water mob spawns value.Example Usage:
- A value of 1 will mean the server will attempt to spawn water mobs every tick.
- A value of 400 will mean the server will attempt to spawn water mobs every 400th tick.
- A value below 0 will be reset back to Minecraft's default.
Note: If set to 0, water mobs spawning will be disabled.
Minecraft default: 1.
- Returns:
- the default ticks per water mobs spawn value
-
getTicksPerWaterAmbientSpawns
int getTicksPerWaterAmbientSpawns()Gets the default ticks per water ambient mob spawns value.Example Usage:
- A value of 1 will mean the server will attempt to spawn water ambient mobs every tick.
- A value of 400 will mean the server will attempt to spawn water ambient mobs every 400th tick.
- A value below 0 will be reset back to Minecraft's default.
Note: If set to 0, ambient mobs spawning will be disabled.
Minecraft default: 1.
- Returns:
- the default ticks per water ambient mobs spawn value
-
getTicksPerAmbientSpawns
int getTicksPerAmbientSpawns()Gets the default ticks per ambient mob spawns value.Example Usage:
- A value of 1 will mean the server will attempt to spawn ambient mobs every tick.
- A value of 400 will mean the server will attempt to spawn ambient mobs every 400th tick.
- A value below 0 will be reset back to Minecraft's default.
Note: If set to 0, ambient mobs spawning will be disabled.
Minecraft default: 1.
- Returns:
- the default ticks per ambient mobs spawn value
-
getPlayer
Gets a player object by the given username.This method may not return objects for offline players.
- Parameters:
name
- the name to look up- Returns:
- a player if one was found, null otherwise
-
getPlayerExact
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
-
matchPlayer
Attempts to match any players with the given name, and returns a list of all possibly matches.This list is not sorted in any particular order. If an exact match is found, the returned list will only contain a single result.
- Parameters:
name
- the (partial) name to match- Returns:
- list of all possible players
-
getPlayer
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
-
getPlayerUniqueId
Gets the unique ID of the player currently known as the specified player name In Offline Mode, will return an Offline UUID- Parameters:
playerName
- the player name to look up the unique ID for- Returns:
- A UUID, or null if that player name is not registered with Minecraft and the server is in online mode
-
getPluginManager
Gets the plugin manager for interfacing with plugins.- Returns:
- a plugin manager for this Server instance
-
getScheduler
Gets the scheduler for managing scheduled events.- Returns:
- a scheduling service for this server
-
getServicesManager
Gets a services manager.- Returns:
- s services manager
-
getWorlds
Gets a list of all worlds on this server.- Returns:
- a list of worlds
-
createWorld
Creates or loads a world with the given name using the specified options.If the world is already loaded, it will just return the equivalent of getWorld(creator.name()).
- Parameters:
creator
- the options to use when creating the world- Returns:
- newly created or loaded world
-
unloadWorld
Unloads a world with the given name.- Parameters:
name
- Name of the world to unloadsave
- whether to save the chunks before unloading- Returns:
- true if successful, false otherwise
-
unloadWorld
Unloads the given world.- Parameters:
world
- the world to unloadsave
- whether to save the chunks before unloading- Returns:
- true if successful, false otherwise
-
getWorld
Gets the world with the given name.- Parameters:
name
- the name of the world to retrieve- Returns:
- a world with the given name, or null if none exists
-
getWorld
Gets the world from the given Unique ID.- Parameters:
uid
- a unique-id of the world to retrieve- Returns:
- a world with the given Unique ID, or null if none exists
-
getWorld
Gets the world from the given NamespacedKey- Parameters:
worldKey
- the NamespacedKey of the world to retrieve- Returns:
- a world with the given NamespacedKey, or null if none exists
-
getMap
Deprecated.Magic valueGets the map from the given item ID.- Parameters:
id
- the id of the map to get- Returns:
- a map view if it exists, or null otherwise
-
createMap
Create a new map with an automatically assigned ID.- Parameters:
world
- the world the map will belong to- Returns:
- a newly created map view
-
createExplorerMap
@NotNull @NotNull ItemStack createExplorerMap(@NotNull @NotNull World world, @NotNull @NotNull Location location, @NotNull @NotNull StructureType structureType)Create a new explorer map targeting the closest nearby structure of a givenStructureType
.
This method uses implementation default values for radius and findUnexplored (usually 100, true).- Parameters:
world
- the world the map will belong tolocation
- the origin location to find the nearest structurestructureType
- the type of structure to find- Returns:
- a newly created item stack
- See Also:
World.locateNearestStructure(org.bukkit.Location, org.bukkit.StructureType, int, boolean)
-
createExplorerMap
@NotNull @NotNull ItemStack createExplorerMap(@NotNull @NotNull World world, @NotNull @NotNull Location location, @NotNull @NotNull StructureType structureType, int radius, boolean findUnexplored)Create a new explorer map targeting the closest nearby structure of a givenStructureType
.
This method uses implementation default values for radius and findUnexplored (usually 100, true).- Parameters:
world
- the world the map will belong tolocation
- the origin location to find the nearest structurestructureType
- the type of structure to findradius
- radius to search, see World#locateNearestStructure for more informationfindUnexplored
- whether to find unexplored structures- Returns:
- the newly created item stack
- See Also:
World.locateNearestStructure(org.bukkit.Location, org.bukkit.StructureType, int, boolean)
-
reload
void reload()Reloads the server, refreshing settings and plugin information. -
reloadData
void reloadData()Reload only the Minecraft data for the server. This includes custom advancements and loot tables. -
getLogger
Returns the primary logger associated with this server instance.- Returns:
- Logger associated with this server
-
getPluginCommand
Gets aPluginCommand
with the given name or alias.- Parameters:
name
- the name of the command to retrieve- Returns:
- a plugin command if found, null otherwise
-
savePlayers
void savePlayers()Writes loaded players to disk. -
dispatchCommand
boolean dispatchCommand(@NotNull @NotNull CommandSender sender, @NotNull @NotNull String commandLine) throws CommandExceptionDispatches a command on this server, and executes it if found.- Parameters:
sender
- the apparent sender of the commandcommandLine
- the command + arguments. Example:test abc 123
- Returns:
- returns false if no target is found
- Throws:
CommandException
- thrown when the executor for the given command fails with an unhandled exception
-
addRecipe
Adds a recipe to the crafting manager.- Parameters:
recipe
- the recipe to add- Returns:
- true if the recipe was added, false if it wasn't for some reason
-
getRecipesFor
Get a list of all recipes for a given item. The stack size is ignored in comparisons. If the durability is -1, it will match any data value.- Parameters:
result
- the item to match against recipe results- Returns:
- a list of recipes with the given result
-
getRecipe
Get theRecipe
for the given key.- Parameters:
recipeKey
- the key of the recipe to return- Returns:
- the recipe for the given key or null.
-
recipeIterator
Get an iterator through the list of crafting recipes.- Returns:
- an iterator
-
clearRecipes
void clearRecipes()Clears the list of crafting recipes. -
resetRecipes
void resetRecipes()Resets the list of crafting recipes to the default. -
removeRecipe
Remove a recipe from the server. Note that removing a recipe may cause permanent loss of data associated with that recipe (eg whether it has been discovered by players).- Parameters:
key
- NamespacedKey of recipe to remove.- Returns:
- True if recipe was removed
-
getCommandAliases
Gets a list of command aliases defined in the server properties.- Returns:
- a map of aliases to command names
-
getSpawnRadius
int getSpawnRadius()Gets the radius, in blocks, around each worlds spawn point to protect.- Returns:
- spawn radius, or 0 if none
-
setSpawnRadius
void setSpawnRadius(int value)Sets the radius, in blocks, around each worlds spawn point to protect.- Parameters:
value
- new spawn radius, or 0 if none
-
getOnlineMode
boolean getOnlineMode()Gets whether the Server is in online mode or not.- Returns:
- true if the server authenticates clients, false otherwise
-
getAllowFlight
boolean getAllowFlight()Gets whether this server allows flying or not.- Returns:
- true if the server allows flight, false otherwise
-
isHardcore
boolean isHardcore()Gets whether the server is in hardcore mode or not.- Returns:
- true if the server mode is hardcore, false otherwise
-
shutdown
void shutdown()Shutdowns the server, stopping everything. -
broadcast
Deprecated.Broadcasts the specified message to every user with the given permission name.- Parameters:
message
- message to broadcastpermission
- the required permissionpermissibles
must have to receive the broadcast- Returns:
- number of message recipients
-
broadcast
Broadcast a message to all players.This is the same as calling
broadcast(net.kyori.adventure.text.Component, java.lang.String)
with theBROADCAST_CHANNEL_USERS
permission.- Parameters:
message
- the message- Returns:
- the number of players
-
broadcast
int broadcast(@NotNull net.kyori.adventure.text.Component message, @NotNull @NotNull String permission)Broadcasts the specified message to every user with the given permission name.- Parameters:
message
- message to broadcastpermission
- the required permissionpermissibles
must have to receive the broadcast- Returns:
- number of message recipients
-
getOfflinePlayer
Deprecated.Persistent storage of users should be by UUID as names are no longer unique past a single session.Gets the player by the given name, regardless if they are offline or online.This method may involve a blocking web request to get the UUID for the given name.
This will return an object even if the player does not exist. To this method, all players will exist.
- Parameters:
name
- the name the player to retrieve- Returns:
- an offline player
- See Also:
getOfflinePlayer(java.util.UUID)
-
getOfflinePlayerIfCached
Gets the player by the given name, regardless if they are offline or online.This will not make a web request to get the UUID for the given name, thus this method will not block. However this method will return
null
if the player is not cached.- Parameters:
name
- the name of the player to retrieve- Returns:
- an offline player if cached,
null
otherwise - See Also:
getOfflinePlayer(String)
,getOfflinePlayer(java.util.UUID)
-
getOfflinePlayer
Gets the player by the given UUID, regardless if they are offline or online.This will return an object even if the player does not exist. To this method, all players will exist.
- Parameters:
id
- the UUID of the player to retrieve- Returns:
- an offline player
-
getIPBans
Gets a set containing all current IPs that are banned.- Returns:
- a set containing banned IP addresses
-
banIP
Bans the specified address from the server.- Parameters:
address
- the IP address to ban
-
unbanIP
Unbans the specified address from the server.- Parameters:
address
- the IP address to unban
-
getBannedPlayers
Gets a set containing all banned players.- Returns:
- a set containing banned players
-
getBanList
Gets a ban list for the supplied type.Bans by name are no longer supported and this method will return null when trying to request them. The replacement is bans by UUID.
- Parameters:
type
- the type of list to fetch, cannot be null- Returns:
- a ban list of the specified type
-
getOperators
Gets a set containing all player operators.- Returns:
- a set containing player operators
-
getDefaultGameMode
Gets the defaultGameMode
for new players.- Returns:
- the default game mode
-
setDefaultGameMode
Sets the defaultGameMode
for new players.- Parameters:
mode
- the new game mode
-
getConsoleSender
Gets aConsoleCommandSender
that may be used as an input source for this server.- Returns:
- a console command sender
-
getWorldContainer
Gets the folder that contains all of the variousWorld
s.- Returns:
- folder that contains all worlds
-
getOfflinePlayers
Gets every player that has ever played on this server.- Returns:
- an array containing all previous players
-
getMessenger
Gets theMessenger
responsible for this server.- Returns:
- messenger responsible for this server
-
getHelpMap
Gets theHelpMap
providing help topics for this server.- Returns:
- a help map for this server
-
createInventory
@NotNull @NotNull Inventory createInventory(@Nullable @Nullable InventoryHolder owner, @NotNull @NotNull InventoryType type)Creates an empty inventory with the specified type. If the type isInventoryType.CHEST
, the new inventory has a size of 27; otherwise the new inventory has the normal size for its type.
InventoryType.WORKBENCH
will not process crafting recipes if created with this method. UseHumanEntity.openWorkbench(Location, boolean)
instead.
InventoryType.ENCHANTING
will not processItemStack
s for possible enchanting results. UseHumanEntity.openEnchanting(Location, boolean)
instead.- Parameters:
owner
- the holder of the inventory, or null to indicate no holdertype
- the type of inventory to create- Returns:
- a new inventory
- Throws:
IllegalArgumentException
- if theInventoryType
cannot be viewed.- See Also:
InventoryType.isCreatable()
-
createInventory
@NotNull @NotNull Inventory createInventory(@Nullable @Nullable InventoryHolder owner, @NotNull @NotNull InventoryType type, @NotNull net.kyori.adventure.text.Component title)Creates an empty inventory with the specified type and title. If the type isInventoryType.CHEST
, the new inventory has a size of 27; otherwise the new inventory has the normal size for its type.
It should be noted that some inventory types do not support titles and may not render with said titles on the Minecraft client.
InventoryType.WORKBENCH
will not process crafting recipes if created with this method. UseHumanEntity.openWorkbench(Location, boolean)
instead.
InventoryType.ENCHANTING
will not processItemStack
s for possible enchanting results. UseHumanEntity.openEnchanting(Location, boolean)
instead.- Parameters:
owner
- The holder of the inventory; can be null if there's no holder.type
- The type of inventory to create.title
- The title of the inventory, to be displayed when it is viewed.- Returns:
- The new inventory.
- Throws:
IllegalArgumentException
- if theInventoryType
cannot be viewed.- See Also:
InventoryType.isCreatable()
-
createInventory
@Deprecated @NotNull @NotNull Inventory createInventory(@Nullable @Nullable InventoryHolder owner, @NotNull @NotNull InventoryType type, @NotNull @NotNull String title)Deprecated.Creates an empty inventory with the specified type and title. If the type isInventoryType.CHEST
, the new inventory has a size of 27; otherwise the new inventory has the normal size for its type.
It should be noted that some inventory types do not support titles and may not render with said titles on the Minecraft client.
InventoryType.WORKBENCH
will not process crafting recipes if created with this method. UseHumanEntity.openWorkbench(Location, boolean)
instead.
InventoryType.ENCHANTING
will not processItemStack
s for possible enchanting results. UseHumanEntity.openEnchanting(Location, boolean)
instead.- Parameters:
owner
- The holder of the inventory; can be null if there's no holder.type
- The type of inventory to create.title
- The title of the inventory, to be displayed when it is viewed.- Returns:
- The new inventory.
- Throws:
IllegalArgumentException
- if theInventoryType
cannot be viewed.- See Also:
InventoryType.isCreatable()
-
createInventory
@NotNull @NotNull Inventory createInventory(@Nullable @Nullable InventoryHolder owner, int size) throws IllegalArgumentExceptionCreates an empty inventory of typeInventoryType.CHEST
with the specified size.- Parameters:
owner
- the holder of the inventory, or null to indicate no holdersize
- a multiple of 9 as the size of inventory to create- Returns:
- a new inventory
- Throws:
IllegalArgumentException
- if the size is not a multiple of 9
-
createInventory
@NotNull @NotNull Inventory createInventory(@Nullable @Nullable InventoryHolder owner, int size, @NotNull net.kyori.adventure.text.Component title) throws IllegalArgumentExceptionCreates an empty inventory of typeInventoryType.CHEST
with the specified size and title.- Parameters:
owner
- the holder of the inventory, or null to indicate no holdersize
- a multiple of 9 as the size of inventory to createtitle
- the title of the inventory, displayed when inventory is viewed- Returns:
- a new inventory
- Throws:
IllegalArgumentException
- if the size is not a multiple of 9
-
createInventory
@Deprecated @NotNull @NotNull Inventory createInventory(@Nullable @Nullable InventoryHolder owner, int size, @NotNull @NotNull String title) throws IllegalArgumentExceptionDeprecated.Creates an empty inventory of typeInventoryType.CHEST
with the specified size and title.- Parameters:
owner
- the holder of the inventory, or null to indicate no holdersize
- a multiple of 9 as the size of inventory to createtitle
- the title of the inventory, displayed when inventory is viewed- Returns:
- a new inventory
- Throws:
IllegalArgumentException
- if the size is not a multiple of 9
-
createMerchant
Creates an empty merchant.- Parameters:
title
- the title of the corresponding merchant inventory, displayed when the merchant inventory is viewed- Returns:
- a new merchant
-
createMerchant
Deprecated.in favour ofcreateMerchant(net.kyori.adventure.text.Component)
Creates an empty merchant.- Parameters:
title
- the title of the corresponding merchant inventory, displayed when the merchant inventory is viewed- Returns:
- a new merchant
-
getMonsterSpawnLimit
int getMonsterSpawnLimit()Gets user-specified limit for number of monsters that can spawn in a chunk.- Returns:
- the monster spawn limit
-
getAnimalSpawnLimit
int getAnimalSpawnLimit()Gets user-specified limit for number of animals that can spawn in a chunk.- Returns:
- the animal spawn limit
-
getWaterAnimalSpawnLimit
int getWaterAnimalSpawnLimit()Gets user-specified limit for number of water animals that can spawn in a chunk.- Returns:
- the water animal spawn limit
-
getWaterAmbientSpawnLimit
int getWaterAmbientSpawnLimit()Gets user-specified limit for number of water ambient mobs that can spawn in a chunk.- Returns:
- the water ambient spawn limit
-
getAmbientSpawnLimit
int getAmbientSpawnLimit()Gets user-specified limit for number of ambient mobs that can spawn in a chunk.- Returns:
- the ambient spawn limit
-
isPrimaryThread
boolean isPrimaryThread()Checks the current thread against the expected primary thread for the server.Note: this method should not be used to indicate the current synchronized state of the runtime. A current thread matching the main thread indicates that it is synchronized, but a mismatch does not preclude the same assumption.
- Returns:
- true if the current thread matches the expected primary thread, false otherwise
-
motd
Gets the message that is displayed on the server list.- Returns:
- the server's MOTD
-
getMotd
Deprecated.in favour ofmotd()
Gets the message that is displayed on the server list.- Returns:
- the servers MOTD
-
shutdownMessage
Gets the default message that is displayed when the server is stopped.- Returns:
- the shutdown message
-
getShutdownMessage
Deprecated.in favour ofshutdownMessage()
Gets the default message that is displayed when the server is stopped.- Returns:
- the shutdown message
-
getWarningState
Gets the current warning state for the server.- Returns:
- the configured warning state
-
getItemFactory
Gets the instance of the item factory (forItemMeta
).- Returns:
- the item factory
- See Also:
ItemFactory
-
getScoreboardManager
Gets the instance of the scoreboard manager.This will only exist after the first world has loaded.
- Returns:
- the scoreboard manager or null if no worlds are loaded.
-
getServerIcon
Gets an instance of the server's default server-icon.- Returns:
- the default server-icon; null values may be used by the implementation to indicate no defined icon, but this behavior is not guaranteed
-
loadServerIcon
@NotNull @NotNull CachedServerIcon loadServerIcon(@NotNull @NotNull File file) throws IllegalArgumentException, ExceptionLoads an image from a file, and returns a cached image for the specific server-icon.Size and type are implementation defined. An incompatible file is guaranteed to throw an implementation-defined
Exception
.- Parameters:
file
- the file to load the from- Returns:
- a cached server-icon that can be used for a
ServerListPingEvent.setServerIcon(CachedServerIcon)
- Throws:
IllegalArgumentException
- if image is nullException
- if the image does not meet current server server-icon specifications
-
loadServerIcon
@NotNull @NotNull CachedServerIcon loadServerIcon(@NotNull @NotNull BufferedImage image) throws IllegalArgumentException, ExceptionCreates a cached server-icon for the specific image.Size and type are implementation defined. An incompatible file is guaranteed to throw an implementation-defined
Exception
.- Parameters:
image
- the image to use- Returns:
- a cached server-icon that can be used for a
ServerListPingEvent.setServerIcon(CachedServerIcon)
- Throws:
IllegalArgumentException
- if image is nullException
- if the image does not meet current server server-icon specifications
-
setIdleTimeout
void setIdleTimeout(int threshold)Set the idle kick timeout. Any players idle for the specified amount of time will be automatically kicked.A value of 0 will disable the idle kick timeout.
- Parameters:
threshold
- the idle timeout in minutes
-
getIdleTimeout
int getIdleTimeout()Gets the idle kick timeout.- Returns:
- the idle timeout in minutes
-
createChunkData
Create a ChunkData for use in a generator. SeeChunkGenerator.generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)
- Parameters:
world
- the world to create the ChunkData for- Returns:
- a new ChunkData for the world
-
createVanillaChunkData
@NotNull ChunkGenerator.ChunkData createVanillaChunkData(@NotNull @NotNull World world, int x, int z)Create a ChunkData for use in a generator, that is populated by the vanilla generator for that world- Parameters:
world
- the world to create the ChunkData forx
- the x coordinate of the chunkz
- the z coordinate of the chunk- Returns:
- a new ChunkData for the world
-
createBossBar
@NotNull @NotNull BossBar createBossBar(@Nullable @Nullable String title, @NotNull @NotNull BarColor color, @NotNull @NotNull BarStyle style, @NotNull @NotNull BarFlag... flags)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
- an optional list of flags to set on the boss bar- Returns:
- the created boss bar
-
createBossBar
@NotNull @NotNull KeyedBossBar createBossBar(@NotNull @NotNull NamespacedKey key, @Nullable @Nullable String title, @NotNull @NotNull BarColor color, @NotNull @NotNull BarStyle style, @NotNull @NotNull BarFlag... flags)Creates a boss bar instance to display to players. The progress defaults to 1.0.
This instance is added to the persistent storage of the server and will be editable by commands and restored after restart.- Parameters:
key
- the key of the boss bar that is used to access the boss bartitle
- the title of the boss barcolor
- the color of the boss barstyle
- the style of the boss barflags
- an optional list of flags to set on the boss bar- Returns:
- the created boss bar
-
getBossBars
Gets an unmodifiable iterator through all persistent bossbars.- not bound to a
Boss
-
not created using
createBossBar(String, BarColor, BarStyle, BarFlag...)
- Returns:
- a bossbar iterator
- not bound to a
-
getBossBar
Gets theKeyedBossBar
specified by this key.- not bound to a
Boss
-
not created using
createBossBar(String, BarColor, BarStyle, BarFlag...)
- Parameters:
key
- unique bossbar key- Returns:
- bossbar or null if not exists
- not bound to a
-
removeBossBar
Removes aKeyedBossBar
specified by this key.- not bound to a
Boss
-
not created using
createBossBar(String, BarColor, BarStyle, BarFlag...)
- Parameters:
key
- unique bossbar key- Returns:
- true if removal succeeded or false
- not bound to a
-
getEntity
Gets an entity on the server by its UUID- Parameters:
uuid
- the UUID of the entity- Returns:
- the entity with the given UUID, or null if it isn't found
-
getTPS
Gets the current server TPS- Returns:
- current server TPS (1m, 5m, 15m in Paper-Server)
-
getTickTimes
Get a sample of the servers last tick times (in nanos)- Returns:
- A sample of the servers last tick times (in nanos)
-
getAverageTickTime
double getAverageTickTime()Get the average tick time (in millis)- Returns:
- Average tick time (in millis)
-
getCommandMap
Gets the activeCommandMap
- Returns:
- the active command map
-
getAdvancement
Get the advancement specified by this key.- Parameters:
key
- unique advancement key- Returns:
- advancement or null if not exists
-
advancementIterator
Get an iterator through all advancements. Advancements cannot be removed from this iterator,- Returns:
- an advancement iterator
-
createBlockData
Creates a newBlockData
instance for the specified Material, with all properties initialized to unspecified defaults.- Parameters:
material
- the material- Returns:
- new data instance
-
createBlockData
@NotNull @NotNull BlockData createBlockData(@NotNull @NotNull Material material, @Nullable @Nullable Consumer<BlockData> consumer)Creates a newBlockData
instance for the specified Material, with all properties initialized to unspecified defaults.- Parameters:
material
- the materialconsumer
- consumer to run on new instance before returning- Returns:
- new data instance
-
createBlockData
@NotNull @NotNull BlockData createBlockData(@NotNull @NotNull String data) throws IllegalArgumentExceptionCreates a newBlockData
instance with material and properties parsed from provided data.- Parameters:
data
- data string- Returns:
- new data instance
- Throws:
IllegalArgumentException
- if the specified data is not valid
-
createBlockData
@NotNull @Contract("null, null -> fail") @NotNull BlockData createBlockData(@Nullable @Nullable Material material, @Nullable @Nullable String data) throws IllegalArgumentExceptionCreates a newBlockData
instance for the specified Material, with all properties initialized to unspecified defaults, except for those provided in data.
Ifmaterial
is specified, then the data string must not also contain the material.- Parameters:
material
- the materialdata
- data string- Returns:
- new data instance
- Throws:
IllegalArgumentException
- if the specified data is not valid
-
getTag
<T extends Keyed> Tag<T> getTag(@NotNull @NotNull String registry, @NotNull @NotNull NamespacedKey tag, @NotNull @NotNull Class<T> clazz)Gets a tag which has already been defined within the server. Plugins are suggested to use the concrete tags inTag
rather than this method which makes no guarantees about which tags are available, and may also be less performant due to lack of caching.
Tags will be searched for in an implementation specific manner, but a path consisting of namespace/tags/registry/key is expected.
Server implementations are allowed to handle only the registries indicated inTag
.- Type Parameters:
T
- type of the tag- Parameters:
registry
- the tag registry to look attag
- the name of the tagclazz
- the class of the tag entries- Returns:
- the tag or null
-
getTags
@NotNull <T extends Keyed> @NotNull Iterable<Tag<T>> getTags(@NotNull @NotNull String registry, @NotNull @NotNull Class<T> clazz)Gets a all tags which have been defined within the server.
Server implementations are allowed to handle only the registries indicated inTag
.
No guarantees are made about the mutability of the returned iterator.- Type Parameters:
T
- type of the tag- Parameters:
registry
- the tag registry to look atclazz
- the class of the tag entries- Returns:
- all defined tags
-
getLootTable
Gets the specifiedLootTable
.- Parameters:
key
- the name of the LootTable- Returns:
- the LootTable, or null if no LootTable is found with that name
-
selectEntities
@NotNull @NotNull List<Entity> selectEntities(@NotNull @NotNull CommandSender sender, @NotNull @NotNull String selector) throws IllegalArgumentExceptionSelects entities using the given Vanilla selector.
No guarantees are made about the selector format, other than they match the Vanilla format for the active Minecraft version.
Usually a selector will start with '@', unless selecting a Player in which case it may simply be the Player's name or UUID.
Note that in Vanilla, elevated permissions are usually required to use '@' selectors, but this method should not check such permissions from the sender.- Parameters:
sender
- the sender to execute as, must be providedselector
- the selection string- Returns:
- a list of the selected entities. The list will not be null, but no further guarantees are made.
- Throws:
IllegalArgumentException
- if the selector is malformed in any way or a parameter is null
-
getUnsafe
Deprecated.- Returns:
- the unsafe values instance
- See Also:
UnsafeValues
-
spigot
-
reloadPermissions
void reloadPermissions() -
reloadCommandAliases
boolean reloadCommandAliases() -
suggestPlayerNamesWhenNullTabCompletions
boolean suggestPlayerNamesWhenNullTabCompletions()Checks if player names should be suggested when a command returnsnull
as their tab completion result.- Returns:
- true if player names should be suggested
-
getPermissionMessage
- Returns:
- the default no permission message used on the server
-
createProfile
Creates a PlayerProfile for the specified uuid, with name as null- Parameters:
uuid
- UUID to create profile for- Returns:
- A PlayerProfile object
-
createProfile
Creates a PlayerProfile for the specified name, with UUID as null- Parameters:
name
- Name to create profile for- Returns:
- A PlayerProfile object
-
createProfile
@NotNull PlayerProfile createProfile(@Nullable @Nullable UUID uuid, @Nullable @Nullable String name)Creates a PlayerProfile for the specified name/uuid Both UUID and Name can not be null at same time. One must be supplied.- Parameters:
uuid
- UUID to create profile forname
- Name to create profile for- Returns:
- A PlayerProfile object
-
getCurrentTick
int getCurrentTick()Get the current internal server tick- Returns:
- Current tick
-
isStopping
boolean isStopping()Checks if the server is in the process of being shutdown.- Returns:
- true if server is in the process of being shutdown
-
getMobGoals
Returns theMobGoals
manager- Returns:
- the mob goals manager
-
getDatapackManager
- Returns:
- the datapack manager
-
broadcast(net.kyori.adventure.text.Component, String)