Interface Server
-
- All Superinterfaces:
PluginMessageRecipient
public interface Server extends PluginMessageRecipient
Represents a server implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classServer.Spigot
-
Field Summary
Fields Modifier and Type Field Description static StringBROADCAST_CHANNEL_ADMINISTRATIVEUsed for all administrative messages, such as an operator using a command.static StringBROADCAST_CHANNEL_USERSUsed for all announcement messages, such as informing users that a player has joined.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description booleanaddRecipe(Recipe recipe)Adds a recipe to the crafting manager.Iterator<Advancement>advancementIterator()Get an iterator through all advancements.voidbanIP(String address)Bans the specified address from the server.intbroadcast(String message, String permission)Broadcasts the specified message to every user with the given permission name.intbroadcastMessage(String message)Broadcast a message to all players.voidclearRecipes()Clears the list of crafting recipes.BlockDatacreateBlockData(String data)Creates a newBlockDatainstance with material and properties parsed from provided data.BlockDatacreateBlockData(Material material)Creates a newBlockDatainstance for the specified Material, with all properties initialized to unspecified defaults.BlockDatacreateBlockData(Material material, String data)Creates a newBlockDatainstance for the specified Material, with all properties initialized to unspecified defaults, except for those provided in data.BlockDatacreateBlockData(Material material, java.util.function.Consumer<BlockData> consumer)Creates a newBlockDatainstance for the specified Material, with all properties initialized to unspecified defaults.BossBarcreateBossBar(String title, BarColor color, BarStyle style, BarFlag... flags)Creates a boss bar instance to display to players.ChunkGenerator.ChunkDatacreateChunkData(World world)Create a ChunkData for use in a generator.InventorycreateInventory(InventoryHolder owner, int size)Creates an empty inventory of typeInventoryType.CHESTwith the specified size.InventorycreateInventory(InventoryHolder owner, int size, String title)Creates an empty inventory of typeInventoryType.CHESTwith the specified size and title.InventorycreateInventory(InventoryHolder owner, InventoryType type)Creates an empty inventory with the specified type and title.InventorycreateInventory(InventoryHolder owner, InventoryType type, String title)Creates an empty inventory with the specified type and title.MapViewcreateMap(World world)Create a new map with an automatically assigned ID.MerchantcreateMerchant(String title)Creates an empty merchant.WorldcreateWorld(WorldCreator creator)Creates or loads a world with the given name using the specified options.booleandispatchCommand(CommandSender sender, String commandLine)Dispatches a command on this server, and executes it if found.AdvancementgetAdvancement(NamespacedKey key)Get the advancement specified by this key.booleangetAllowEnd()Gets whether this server allows the End or not.booleangetAllowFlight()Gets whether this server allows flying or not.booleangetAllowNether()Gets whether this server allows the Nether or not.intgetAmbientSpawnLimit()Gets user-specified limit for number of ambient mobs that can spawn in a chunk.intgetAnimalSpawnLimit()Gets user-specified limit for number of animals that can spawn in a chunk.BanListgetBanList(BanList.Type type)Gets a ban list for the supplied type.Set<OfflinePlayer>getBannedPlayers()Gets a set containing all banned players.StringgetBukkitVersion()Gets the Bukkit version that this server is running.Map<String,String[]>getCommandAliases()Gets a list of command aliases defined in the server properties.longgetConnectionThrottle()Gets the value of the connection throttle setting.ConsoleCommandSendergetConsoleSender()Gets aConsoleCommandSenderthat may be used as an input source for this server.GameModegetDefaultGameMode()Gets the defaultGameModefor new players.EntitygetEntity(UUID uuid)Gets an entity on the server by its UUIDbooleangetGenerateStructures()Get generate-structures setting.HelpMapgetHelpMap()Gets theHelpMapproviding help topics for this server.intgetIdleTimeout()Gets the idle kick timeout.StringgetIp()Get the IP that this server is bound to, or empty string if not specified.Set<String>getIPBans()Gets a set containing all current IPs that are banned.ItemFactorygetItemFactory()Gets the instance of the item factory (forItemMeta).LoggergetLogger()Returns the primary logger associated with this server instance.LootTablegetLootTable(NamespacedKey key)Gets the specifiedLootTable.MapViewgetMap(short id)Deprecated.Magic valueintgetMaxPlayers()Get the maximum amount of players which can login to this server.MessengergetMessenger()Gets theMessengerresponsible for this server.intgetMonsterSpawnLimit()Gets user-specified limit for number of monsters that can spawn in a chunk.StringgetMotd()Gets the message that is displayed on the server list.StringgetName()Gets the name of this server implementation.OfflinePlayergetOfflinePlayer(String name)Deprecated.Persistent storage of users should be by UUID as names are no longer unique past a single session.OfflinePlayergetOfflinePlayer(UUID id)Gets the player by the given UUID, regardless if they are offline or online.OfflinePlayer[]getOfflinePlayers()Gets every player that has ever played on this server.booleangetOnlineMode()Gets whether the Server is in online mode or not.Collection<? extends Player>getOnlinePlayers()Gets a view of all currently logged in players.Set<OfflinePlayer>getOperators()Gets a set containing all player operators.PlayergetPlayer(String name)Gets a player object by the given username.PlayergetPlayer(UUID id)Gets the player with the given UUID.PlayergetPlayerExact(String name)Gets the player with the exact given name, case insensitive.PluginCommandgetPluginCommand(String name)Gets aPluginCommandwith the given name or alias.PluginManagergetPluginManager()Gets the plugin manager for interfacing with plugins.intgetPort()Get the game port that the server runs on.List<Recipe>getRecipesFor(ItemStack result)Get a list of all recipes for a given item.BukkitSchedulergetScheduler()Gets the scheduler for managing scheduled events.ScoreboardManagergetScoreboardManager()Gets the instance of the scoreboard manager.CachedServerIcongetServerIcon()Gets an instance of the server's default server-icon.StringgetServerId()Get an ID of this server.StringgetServerName()Get the name of this server.ServicesManagergetServicesManager()Gets a services manager.StringgetShutdownMessage()Gets the default message that is displayed when the server is stopped.intgetSpawnRadius()Gets the radius, in blocks, around each worlds spawn point to protect.<T extends Keyed>
Tag<T>getTag(String registry, NamespacedKey tag, Class<T> clazz)Gets a tag which has already been defined within the server.intgetTicksPerAnimalSpawns()Gets default ticks per animal spawns value.intgetTicksPerMonsterSpawns()Gets the default ticks per monster spawns value.UnsafeValuesgetUnsafe()Deprecated.StringgetUpdateFolder()Gets the name of the update folder.FilegetUpdateFolderFile()Gets the update folder.StringgetVersion()Gets the version string of this server implementation.intgetViewDistance()Get the view distance from this server.Warning.WarningStategetWarningState()Gets the current warning state for the server.intgetWaterAnimalSpawnLimit()Gets user-specified limit for number of water animals that can spawn in a chunk.Set<OfflinePlayer>getWhitelistedPlayers()Gets a list of whitelisted players.WorldgetWorld(String name)Gets the world with the given name.WorldgetWorld(UUID uid)Gets the world from the given Unique ID.FilegetWorldContainer()Gets the folder that contains all of the variousWorlds.List<World>getWorlds()Gets a list of all worlds on this server.StringgetWorldType()Get world type (level-type setting) for default world.booleanhasWhitelist()Gets whether this server has a whitelist or not.booleanisHardcore()Gets whether the server is in hardcore mode or not.booleanisPrimaryThread()Checks the current thread against the expected primary thread for the server.CachedServerIconloadServerIcon(BufferedImage image)Creates a cached server-icon for the specific image.CachedServerIconloadServerIcon(File file)Loads an image from a file, and returns a cached image for the specific server-icon.List<Player>matchPlayer(String name)Attempts to match any players with the given name, and returns a list of all possibly matches.Iterator<Recipe>recipeIterator()Get an iterator through the list of crafting recipes.voidreload()Reloads the server, refreshing settings and plugin information.voidreloadData()Reload only the Minecraft data for the server.voidreloadWhitelist()Reloads the whitelist from disk.voidresetRecipes()Resets the list of crafting recipes to the default.voidsavePlayers()Writes loaded players to disk.voidsetDefaultGameMode(GameMode mode)Sets the defaultGameModefor new players.voidsetIdleTimeout(int threshold)Set the idle kick timeout.voidsetSpawnRadius(int value)Sets the radius, in blocks, around each worlds spawn point to protect.voidsetWhitelist(boolean value)Sets if the server is whitelisted.voidshutdown()Shutdowns the server, stopping everything.Server.Spigotspigot()voidunbanIP(String address)Unbans the specified address from the server.booleanunloadWorld(String name, boolean save)Unloads a world with the given name.booleanunloadWorld(World world, boolean save)Unloads the given world.-
Methods inherited from interface org.bukkit.plugin.messaging.PluginMessageRecipient
getListeningPluginChannels, sendPluginMessage
-
-
-
-
Field Detail
-
BROADCAST_CHANNEL_ADMINISTRATIVE
static final String BROADCAST_CHANNEL_ADMINISTRATIVE
Used for all administrative messages, such as an operator using a command.For use in
broadcast(java.lang.String, java.lang.String).- See Also:
- Constant Field Values
-
BROADCAST_CHANNEL_USERS
static final String BROADCAST_CHANNEL_USERS
Used for all announcement messages, such as informing users that a player has joined.For use in
broadcast(java.lang.String, java.lang.String).- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
String getName()
Gets the name of this server implementation.- Returns:
- name of this server implementation
-
getVersion
String getVersion()
Gets the version string of this server implementation.- Returns:
- version of this server implementation
-
getBukkitVersion
String getBukkitVersion()
Gets the Bukkit version that this server is running.- Returns:
- version of Bukkit
-
getOnlinePlayers
Collection<? extends Player> 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
SerializableorList), 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, andkickingare 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
-
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
String 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
-
getServerName
String getServerName()
Get the name of this server.- Returns:
- the name of this server
-
getServerId
String getServerId()
Get an ID of this server. The ID is a simple generally alphanumeric ID that can be used for uniquely identifying this server.- Returns:
- the ID of this server
-
getWorldType
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
-
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
-
getWhitelistedPlayers
Set<OfflinePlayer> getWhitelistedPlayers()
Gets a list of whitelisted players.- Returns:
- a set containing all whitelisted players
-
reloadWhitelist
void reloadWhitelist()
Reloads the whitelist from disk.
-
broadcastMessage
int broadcastMessage(String message)
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
-
getUpdateFolder
String 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
File 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
-
getPlayer
Player getPlayer(String name)
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
Player getPlayerExact(String name)
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
List<Player> matchPlayer(String name)
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
Player getPlayer(UUID id)
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
-
getPluginManager
PluginManager getPluginManager()
Gets the plugin manager for interfacing with plugins.- Returns:
- a plugin manager for this Server instance
-
getScheduler
BukkitScheduler getScheduler()
Gets the scheduler for managing scheduled events.- Returns:
- a scheduling service for this server
-
getServicesManager
ServicesManager getServicesManager()
Gets a services manager.- Returns:
- s services manager
-
getWorlds
List<World> getWorlds()
Gets a list of all worlds on this server.- Returns:
- a list of worlds
-
createWorld
World createWorld(WorldCreator creator)
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
boolean unloadWorld(String name, boolean save)
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
boolean unloadWorld(World world, boolean save)
Unloads the given world.- Parameters:
world- the world to unloadsave- whether to save the chunks before unloading- Returns:
- true if successful, false otherwise
-
getWorld
World getWorld(String name)
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
World getWorld(UUID uid)
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
-
getMap
@Deprecated MapView getMap(short id)
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
MapView createMap(World world)
Create a new map with an automatically assigned ID.- Parameters:
world- the world the map will belong to- Returns:
- a newly created map view
-
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
Logger getLogger()
Returns the primary logger associated with this server instance.- Returns:
- Logger associated with this server
-
getPluginCommand
PluginCommand getPluginCommand(String name)
Gets aPluginCommandwith 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(CommandSender sender, String commandLine) throws CommandException
Dispatches 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
boolean addRecipe(Recipe recipe)
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
List<Recipe> getRecipesFor(ItemStack result)
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
-
recipeIterator
Iterator<Recipe> 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.
-
getCommandAliases
Map<String,String[]> 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
int broadcast(String message, String permission)
Broadcasts the specified message to every user with the given permission name.- Parameters:
message- message to broadcastpermission- the required permissionpermissiblesmust have to receive the broadcast- Returns:
- number of message recipients
-
getOfflinePlayer
@Deprecated OfflinePlayer getOfflinePlayer(String name)
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)
-
getOfflinePlayer
OfflinePlayer getOfflinePlayer(UUID id)
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
Set<String> getIPBans()
Gets a set containing all current IPs that are banned.- Returns:
- a set containing banned IP addresses
-
banIP
void banIP(String address)
Bans the specified address from the server.- Parameters:
address- the IP address to ban
-
unbanIP
void unbanIP(String address)
Unbans the specified address from the server.- Parameters:
address- the IP address to unban
-
getBannedPlayers
Set<OfflinePlayer> getBannedPlayers()
Gets a set containing all banned players.- Returns:
- a set containing banned players
-
getBanList
BanList getBanList(BanList.Type type)
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
Set<OfflinePlayer> getOperators()
Gets a set containing all player operators.- Returns:
- a set containing player operators
-
getDefaultGameMode
GameMode getDefaultGameMode()
Gets the defaultGameModefor new players.- Returns:
- the default game mode
-
setDefaultGameMode
void setDefaultGameMode(GameMode mode)
Sets the defaultGameModefor new players.- Parameters:
mode- the new game mode
-
getConsoleSender
ConsoleCommandSender getConsoleSender()
Gets aConsoleCommandSenderthat may be used as an input source for this server.- Returns:
- a console command sender
-
getWorldContainer
File getWorldContainer()
Gets the folder that contains all of the variousWorlds.- Returns:
- folder that contains all worlds
-
getOfflinePlayers
OfflinePlayer[] getOfflinePlayers()
Gets every player that has ever played on this server.- Returns:
- an array containing all previous players
-
getMessenger
Messenger getMessenger()
Gets theMessengerresponsible for this server.- Returns:
- messenger responsible for this server
-
getHelpMap
HelpMap getHelpMap()
Gets theHelpMapproviding help topics for this server.- Returns:
- a help map for this server
-
createInventory
Inventory createInventory(InventoryHolder owner, InventoryType type)
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.WORKBENCHwill not process crafting recipes if created with this method. UseHumanEntity.openWorkbench(Location, boolean)instead.
InventoryType.ENCHANTINGwill not processItemStacks 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 theInventoryTypecannot be viewed.- See Also:
InventoryType.isCreatable()
-
createInventory
Inventory createInventory(InventoryHolder owner, InventoryType type, String 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.WORKBENCHwill not process crafting recipes if created with this method. UseHumanEntity.openWorkbench(Location, boolean)instead.
InventoryType.ENCHANTINGwill not processItemStacks 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 theInventoryTypecannot be viewed.- See Also:
InventoryType.isCreatable()
-
createInventory
Inventory createInventory(InventoryHolder owner, int size) throws IllegalArgumentException
Creates an empty inventory of typeInventoryType.CHESTwith 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
Inventory createInventory(InventoryHolder owner, int size, String title) throws IllegalArgumentException
Creates an empty inventory of typeInventoryType.CHESTwith 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
Merchant createMerchant(String title)
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
-
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
-
getMotd
String getMotd()
Gets the message that is displayed on the server list.- Returns:
- the servers MOTD
-
getShutdownMessage
String getShutdownMessage()
Gets the default message that is displayed when the server is stopped.- Returns:
- the shutdown message
-
getWarningState
Warning.WarningState getWarningState()
Gets the current warning state for the server.- Returns:
- the configured warning state
-
getItemFactory
ItemFactory getItemFactory()
Gets the instance of the item factory (forItemMeta).- Returns:
- the item factory
- See Also:
ItemFactory
-
getScoreboardManager
ScoreboardManager 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
CachedServerIcon 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
CachedServerIcon loadServerIcon(File file) throws IllegalArgumentException, Exception
Loads 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
CachedServerIcon loadServerIcon(BufferedImage image) throws IllegalArgumentException, Exception
Creates 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
ChunkGenerator.ChunkData createChunkData(World world)
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
-
createBossBar
BossBar createBossBar(String title, BarColor color, BarStyle style, 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
-
getEntity
Entity getEntity(UUID uuid)
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
-
getAdvancement
Advancement getAdvancement(NamespacedKey key)
Get the advancement specified by this key.- Parameters:
key- unique advancement key- Returns:
- advancement or null if not exists
-
advancementIterator
Iterator<Advancement> advancementIterator()
Get an iterator through all advancements. Advancements cannot be removed from this iterator,- Returns:
- an advancement iterator
-
createBlockData
BlockData createBlockData(Material material)
Creates a newBlockDatainstance for the specified Material, with all properties initialized to unspecified defaults.- Parameters:
material- the material- Returns:
- new data instance
-
createBlockData
BlockData createBlockData(Material material, java.util.function.Consumer<BlockData> consumer)
Creates a newBlockDatainstance 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
BlockData createBlockData(String data) throws IllegalArgumentException
Creates a newBlockDatainstance 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
BlockData createBlockData(Material material, String data) throws IllegalArgumentException
Creates a newBlockDatainstance for the specified Material, with all properties initialized to unspecified defaults, except for those provided in data.
Ifmaterialis 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(String registry, NamespacedKey tag, Class<T> clazz)
Gets a tag which has already been defined within the server. Plugins are suggested to use the concrete tags inTagrather 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
-
getLootTable
LootTable getLootTable(NamespacedKey key)
Gets the specifiedLootTable.- Parameters:
key- the name of the LootTable- Returns:
- the LootTable, or null if no LootTable is found with that name
-
getUnsafe
@Deprecated UnsafeValues getUnsafe()
Deprecated.- Returns:
- the unsafe values instance
- See Also:
UnsafeValues
-
spigot
Server.Spigot spigot()
-
-