public final class Bukkit extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
addRecipe(@Nullable Recipe recipe)
Adds a recipe to the crafting manager.
|
static @NotNull Iterator<Advancement> |
advancementIterator()
Get an iterator through all advancements.
|
static void |
banIP(@NotNull String address)
Bans the specified address from the server.
|
static void |
broadcast(BaseComponent... components)
Deprecated.
use
sendMessage methods on getServer() that accept Component |
static void |
broadcast(BaseComponent component)
Deprecated.
use
sendMessage methods on getServer() that accept Component |
static int |
broadcast(net.kyori.adventure.text.Component message,
@NotNull String permission)
Broadcasts the specified message to every user with the given
permission name.
|
static int |
broadcast(@NotNull String message,
@NotNull String permission)
Deprecated.
|
static int |
broadcastMessage(@NotNull String message)
Deprecated.
in favour of
Audience.sendMessage(net.kyori.adventure.text.Component) |
static void |
clearRecipes()
Clears the list of crafting recipes.
|
static @NotNull BlockData |
createBlockData(@NotNull Material material)
Creates a new
BlockData instance for the specified Material, with
all properties initialized to unspecified defaults. |
static @NotNull BlockData |
createBlockData(@NotNull Material material,
@Nullable Consumer<BlockData> consumer)
Creates a new
BlockData instance for the specified Material, with
all properties initialized to unspecified defaults. |
static @NotNull BlockData |
createBlockData(@Nullable Material material,
@Nullable String data)
Creates a new
BlockData instance for the specified Material, with
all properties initialized to unspecified defaults, except for those
provided in data. |
static @NotNull BlockData |
createBlockData(@NotNull String data)
Creates a new
BlockData instance with material and properties
parsed from provided data. |
static @NotNull KeyedBossBar |
createBossBar(@NotNull NamespacedKey key,
@Nullable String title,
@NotNull BarColor color,
@NotNull BarStyle style,
BarFlag... flags)
Creates a boss bar instance to display to players.
|
static @NotNull BossBar |
createBossBar(@Nullable String title,
@NotNull BarColor color,
@NotNull BarStyle style,
BarFlag... flags)
Creates a boss bar instance to display to players.
|
static ChunkGenerator.ChunkData |
createChunkData(@NotNull World world)
Create a ChunkData for use in a generator.
|
static @NotNull ItemStack |
createExplorerMap(@NotNull World world,
@NotNull Location location,
@NotNull StructureType structureType)
Create a new explorer map targeting the closest nearby structure of a
given
StructureType . |
static @NotNull ItemStack |
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
given
StructureType . |
static @NotNull Inventory |
createInventory(@Nullable InventoryHolder owner,
int size)
Creates an empty inventory of type
InventoryType.CHEST with the
specified size. |
static @NotNull Inventory |
createInventory(@Nullable InventoryHolder owner,
int size,
net.kyori.adventure.text.Component title)
Creates an empty inventory of type
InventoryType.CHEST with the
specified size and title. |
static @NotNull Inventory |
createInventory(@Nullable InventoryHolder owner,
int size,
@NotNull String title)
Deprecated.
|
static @NotNull Inventory |
createInventory(@Nullable InventoryHolder owner,
@NotNull InventoryType type)
Creates an empty inventory with the specified type.
|
static @NotNull Inventory |
createInventory(@Nullable InventoryHolder owner,
@NotNull InventoryType type,
net.kyori.adventure.text.Component title)
Creates an empty inventory with the specified type and title.
|
static @NotNull Inventory |
createInventory(@Nullable InventoryHolder owner,
@NotNull InventoryType type,
@NotNull String title)
Deprecated.
|
static @NotNull MapView |
createMap(@NotNull World world)
Create a new map with an automatically assigned ID.
|
static @NotNull Merchant |
createMerchant(net.kyori.adventure.text.Component title)
Creates an empty merchant.
|
static @NotNull Merchant |
createMerchant(@Nullable String title)
Deprecated.
in favour of
createMerchant(net.kyori.adventure.text.Component) |
static PlayerProfile |
createProfile(@NotNull String name)
Creates a PlayerProfile for the specified name, with UUID as null
|
static PlayerProfile |
createProfile(@NotNull UUID uuid)
Creates a PlayerProfile for the specified uuid, with name as null
|
static PlayerProfile |
createProfile(@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.
|
static ChunkGenerator.ChunkData |
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 world
|
static @Nullable World |
createWorld(@NotNull WorldCreator creator)
Creates or loads a world with the given name using the specified
options.
|
static boolean |
dispatchCommand(@NotNull CommandSender sender,
@NotNull String commandLine)
Dispatches a command on this server, and executes it if found.
|
static @Nullable Advancement |
getAdvancement(@NotNull NamespacedKey key)
Get the advancement specified by this key.
|
static boolean |
getAllowEnd()
Gets whether this server allows the End or not.
|
static boolean |
getAllowFlight()
Gets whether this server allows flying or not.
|
static boolean |
getAllowNether()
Gets whether this server allows the Nether or not.
|
static int |
getAmbientSpawnLimit()
Gets user-specified limit for number of ambient mobs that can spawn in
a chunk.
|
static int |
getAnimalSpawnLimit()
Gets user-specified limit for number of animals that can spawn in a
chunk.
|
static double |
getAverageTickTime()
Get the average tick time (in millis)
|
static @NotNull BanList |
getBanList(BanList.Type type)
Gets a ban list for the supplied type.
|
static @NotNull Set<OfflinePlayer> |
getBannedPlayers()
Gets a set containing all banned players.
|
static @Nullable KeyedBossBar |
getBossBar(@NotNull NamespacedKey key)
Gets the
KeyedBossBar specified by this key. |
static @NotNull Iterator<KeyedBossBar> |
getBossBars()
Gets an unmodifiable iterator through all persistent bossbars.
|
static @NotNull String |
getBukkitVersion()
Gets the Bukkit version that this server is running.
|
static @NotNull Map<String,String[]> |
getCommandAliases()
Gets a list of command aliases defined in the server properties.
|
static CommandMap |
getCommandMap()
Gets the active
CommandMap |
static long |
getConnectionThrottle()
Gets the value of the connection throttle setting.
|
static @NotNull ConsoleCommandSender |
getConsoleSender()
Gets a
ConsoleCommandSender that may be used as an input source
for this server. |
static int |
getCurrentTick() |
static DatapackManager |
getDatapackManager() |
static @NotNull GameMode |
getDefaultGameMode()
Gets the default
GameMode for new players. |
static @Nullable Entity |
getEntity(@NotNull UUID uuid)
Gets an entity on the server by its UUID
|
static boolean |
getGenerateStructures()
Get generate-structures setting.
|
static @NotNull HelpMap |
getHelpMap()
Gets the
HelpMap providing help topics for this server. |
static int |
getIdleTimeout()
Gets the idle kick timeout.
|
static @NotNull String |
getIp()
Get the IP that this server is bound to, or empty string if not
specified.
|
static @NotNull Set<String> |
getIPBans()
Gets a set containing all current IPs that are banned.
|
static @NotNull ItemFactory |
getItemFactory()
Gets the instance of the item factory (for
ItemMeta ). |
static @NotNull Logger |
getLogger()
Returns the primary logger associated with this server instance.
|
static @Nullable LootTable |
getLootTable(@NotNull NamespacedKey key)
Gets the specified
LootTable . |
static @Nullable MapView |
getMap(int id)
Deprecated.
Magic value
|
static int |
getMaxPlayers()
Get the maximum amount of players which can login to this server.
|
static int |
getMaxWorldSize()
Get max world size.
|
static @NotNull Messenger |
getMessenger()
Gets the
Messenger responsible for this server. |
static @NotNull String |
getMinecraftVersion()
Gets the version of game this server implements
|
static MobGoals |
getMobGoals()
Returns the
MobGoals manager |
static int |
getMonsterSpawnLimit()
Gets user-specified limit for number of monsters that can spawn in a
chunk.
|
static @NotNull String |
getMotd()
Deprecated.
in favour of
motd() |
static @NotNull String |
getName()
Gets the name of this server implementation.
|
static @NotNull OfflinePlayer |
getOfflinePlayer(@NotNull String name)
Deprecated.
Persistent storage of users should be by UUID as names are no longer
unique past a single session.
|
static @NotNull OfflinePlayer |
getOfflinePlayer(@NotNull UUID id)
Gets the player by the given UUID, regardless if they are offline or
online.
|
static @Nullable OfflinePlayer |
getOfflinePlayerIfCached(@NotNull String name)
Gets the player by the given name, regardless if they are offline or
online.
|
static @NotNull OfflinePlayer[] |
getOfflinePlayers()
Gets every player that has ever played on this server.
|
static boolean |
getOnlineMode()
Gets whether the Server is in online mode or not.
|
static @NotNull Collection<? extends Player> |
getOnlinePlayers()
Gets a view of all currently logged in players.
|
static @NotNull Set<OfflinePlayer> |
getOperators()
Gets a set containing all player operators.
|
static @NotNull String |
getPermissionMessage() |
static @Nullable Player |
getPlayer(@NotNull String name)
Gets a player object by the given username.
|
static @Nullable Player |
getPlayer(@NotNull UUID id)
Gets the player with the given UUID.
|
static @Nullable Player |
getPlayerExact(@NotNull String name)
Gets the player with the exact given name, case insensitive.
|
static @Nullable UUID |
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 UUID
|
static @Nullable PluginCommand |
getPluginCommand(@NotNull String name)
Gets a
PluginCommand with the given name or alias. |
static @NotNull PluginManager |
getPluginManager()
Gets the plugin manager for interfacing with plugins.
|
static int |
getPort()
Get the game port that the server runs on.
|
static @Nullable Recipe |
getRecipe(@NotNull NamespacedKey recipeKey)
Get the
Recipe for the given key. |
static @NotNull List<Recipe> |
getRecipesFor(@NotNull ItemStack result)
Get a list of all recipes for a given item.
|
static @NotNull BukkitScheduler |
getScheduler()
Gets the scheduler for managing scheduled events.
|
static @NotNull ScoreboardManager |
getScoreboardManager()
Gets the instance of the scoreboard manager.
|
static @NotNull Server |
getServer()
Gets the current
Server singleton |
static @Nullable CachedServerIcon |
getServerIcon()
Gets an instance of the server's default server-icon.
|
static @NotNull ServicesManager |
getServicesManager()
Gets a services manager.
|
static @Nullable String |
getShutdownMessage()
Deprecated.
in favour of
shutdownMessage() |
static int |
getSpawnRadius()
Gets the radius, in blocks, around each worlds spawn point to protect.
|
static <T extends Keyed> |
getTag(@NotNull String registry,
@NotNull NamespacedKey tag,
@NotNull Class<T> clazz)
Gets a tag which has already been defined within the server.
|
static <T extends Keyed> |
getTags(@NotNull String registry,
@NotNull Class<T> clazz)
Gets a all tags which have been defined within the server.
|
static int |
getTicksPerAmbientSpawns()
Gets the default ticks per ambient mob spawns value.
|
static int |
getTicksPerAnimalSpawns()
Gets default ticks per animal spawns value.
|
static int |
getTicksPerMonsterSpawns()
Gets the default ticks per monster spawns value.
|
static int |
getTicksPerWaterAmbientSpawns()
Gets the default ticks per water ambient mob spawns value.
|
static int |
getTicksPerWaterSpawns()
Gets the default ticks per water mob spawns value.
|
static @NotNull long[] |
getTickTimes()
Get a sample of the servers last tick times (in nanos)
|
static @NotNull double[] |
getTPS()
Gets the current server TPS
|
static @NotNull UnsafeValues |
getUnsafe()
Deprecated.
|
static @NotNull String |
getUpdateFolder()
Gets the name of the update folder.
|
static @NotNull File |
getUpdateFolderFile()
Gets the update folder.
|
static @NotNull String |
getVersion()
Gets the version string of this server implementation.
|
static int |
getViewDistance()
Get the view distance from this server.
|
static @NotNull Warning.WarningState |
getWarningState()
Gets the current warning state for the server.
|
static int |
getWaterAmbientSpawnLimit()
Gets user-specified limit for number of water ambient mobs that can spawn
in a chunk.
|
static int |
getWaterAnimalSpawnLimit()
Gets user-specified limit for number of water animals that can spawn in
a chunk.
|
static @NotNull Set<OfflinePlayer> |
getWhitelistedPlayers()
Gets a list of whitelisted players.
|
static @Nullable World |
getWorld(@NotNull NamespacedKey worldKey)
Gets the world from the given NamespacedKey
|
static @Nullable World |
getWorld(@NotNull String name)
Gets the world with the given name.
|
static @Nullable World |
getWorld(@NotNull UUID uid)
Gets the world from the given Unique ID.
|
static @NotNull File |
getWorldContainer()
Gets the folder that contains all of the various
World s. |
static @NotNull List<World> |
getWorlds()
Gets a list of all worlds on this server.
|
static @NotNull String |
getWorldType()
Get world type (level-type setting) for default world.
|
static boolean |
hasWhitelist()
Gets whether this server has a whitelist or not.
|
static boolean |
isHardcore()
Gets whether the server is in hardcore mode or not.
|
static boolean |
isPrimaryThread()
Checks the current thread against the expected primary thread for the
server.
|
static boolean |
isStopping()
Checks if the server is in the process of being shutdown.
|
static @NotNull CachedServerIcon |
loadServerIcon(@NotNull BufferedImage image)
Creates a cached server-icon for the specific image.
|
static @NotNull CachedServerIcon |
loadServerIcon(@NotNull File file)
Loads an image from a file, and returns a cached image for the specific
server-icon.
|
static @NotNull List<Player> |
matchPlayer(@NotNull String name)
Attempts to match any players with the given name, and returns a list
of all possibly matches.
|
static net.kyori.adventure.text.Component |
motd()
Gets the message that is displayed on the server list.
|
static @NotNull Iterator<Recipe> |
recipeIterator()
Get an iterator through the list of crafting recipes.
|
static void |
reload()
Reloads the server, refreshing settings and plugin information.
|
static boolean |
reloadCommandAliases()
Reload the Command Aliases in commands.yml
|
static void |
reloadData()
Reload only the Minecraft data for the server.
|
static void |
reloadPermissions()
Reload the Permissions in permissions.yml
|
static void |
reloadWhitelist()
Reloads the whitelist from disk.
|
static boolean |
removeBossBar(@NotNull NamespacedKey key)
Removes a
KeyedBossBar specified by this key. |
static boolean |
removeRecipe(@NotNull NamespacedKey key)
Remove a recipe from the server.
|
static void |
resetRecipes()
Resets the list of crafting recipes to the default.
|
static void |
savePlayers()
Writes loaded players to disk.
|
static @NotNull List<Entity> |
selectEntities(@NotNull CommandSender sender,
@NotNull String selector)
Selects entities using the given Vanilla selector.
|
static void |
setDefaultGameMode(@NotNull GameMode mode)
Sets the default
GameMode for new players. |
static void |
setIdleTimeout(int threshold)
Set the idle kick timeout.
|
static void |
setMaxPlayers(int maxPlayers)
Set the maximum amount of players which can login to this server.
|
static void |
setServer(@NotNull Server server)
Attempts to set the
Server singleton. |
static void |
setSpawnRadius(int value)
Sets the radius, in blocks, around each worlds spawn point to protect.
|
static void |
setWhitelist(boolean value)
Sets if the server is whitelisted.
|
static void |
shutdown()
Shutdowns the server, stopping everything.
|
static net.kyori.adventure.text.Component |
shutdownMessage()
Gets the default message that is displayed when the server is stopped.
|
static Server.Spigot |
spigot() |
static boolean |
suggestPlayerNamesWhenNullTabCompletions()
Checks if player names should be suggested when a command returns
null as
their tab completion result. |
static void |
unbanIP(@NotNull String address)
Unbans the specified address from the server.
|
static boolean |
unloadWorld(@NotNull String name,
boolean save)
Unloads a world with the given name.
|
static boolean |
unloadWorld(@NotNull World world,
boolean save)
Unloads the given world.
|
@NotNull public static @NotNull Server getServer()
Server
singletonpublic static void setServer(@NotNull @NotNull Server server)
Server
singleton.
This cannot be done if the Server is already set.
server
- Server instance@NotNull public static @NotNull String getName()
@NotNull public static @NotNull String getVersion()
@NotNull public static @NotNull String getBukkitVersion()
@NotNull public static @NotNull String getMinecraftVersion()
@NotNull public static @NotNull Collection<? extends Player> getOnlinePlayers()
Collection.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
or List
), 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
, and kicking
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.
public static int getMaxPlayers()
public static void setMaxPlayers(int maxPlayers)
maxPlayers
- the amount of players this server allowspublic static int getPort()
public static int getViewDistance()
@NotNull public static @NotNull String getIp()
@NotNull public static @NotNull String getWorldType()
public static boolean getGenerateStructures()
public static int getMaxWorldSize()
public static boolean getAllowEnd()
public static boolean getAllowNether()
public static boolean hasWhitelist()
public static void setWhitelist(boolean value)
value
- true for whitelist on, false for off@NotNull public static @NotNull Set<OfflinePlayer> getWhitelistedPlayers()
public static void reloadWhitelist()
@Deprecated public static int broadcastMessage(@NotNull @NotNull String message)
Audience.sendMessage(net.kyori.adventure.text.Component)
This is the same as calling broadcast(java.lang.String,
java.lang.String)
to Server.BROADCAST_CHANNEL_USERS
message
- the message@Deprecated public static void broadcast(@NotNull BaseComponent component)
sendMessage
methods on getServer()
that accept Component
component
- the component to send@Deprecated public static void broadcast(@NotNull BaseComponent... components)
sendMessage
methods on getServer()
that accept Component
components
- the components to send@NotNull public static @NotNull String getUpdateFolder()
The update folder name is relative to the plugins folder.
@NotNull public static @NotNull File getUpdateFolderFile()
public static long getConnectionThrottle()
public static int getTicksPerAnimalSpawns()
Example Usage:
Note: If set to 0, animal spawning will be disabled. We recommend using spawn-animals to control this instead.
Minecraft default: 400.
public static int getTicksPerMonsterSpawns()
Example Usage:
Note: If set to 0, monsters spawning will be disabled. We recommend using spawn-monsters to control this instead.
Minecraft default: 1.
public static int getTicksPerWaterSpawns()
Example Usage:
Note: If set to 0, water mobs spawning will be disabled.
Minecraft default: 1.
public static int getTicksPerAmbientSpawns()
Example Usage:
Note: If set to 0, ambient mobs spawning will be disabled.
Minecraft default: 1.
public static int getTicksPerWaterAmbientSpawns()
Example Usage:
Note: If set to 0, ambient mobs spawning will be disabled.
Minecraft default: 1.
@Nullable public static @Nullable Player getPlayer(@NotNull @NotNull String name)
This method may not return objects for offline players.
name
- the name to look up@Nullable public static @Nullable Player getPlayerExact(@NotNull @NotNull String name)
name
- Exact name of the player to retrieve@NotNull public static @NotNull List<Player> matchPlayer(@NotNull @NotNull String name)
This list is not sorted in any particular order. If an exact match is found, the returned list will only contain a single result.
name
- the (partial) name to match@Nullable public static @Nullable Player getPlayer(@NotNull @NotNull UUID id)
id
- UUID of the player to retrieve@Nullable public static @Nullable UUID getPlayerUniqueId(@NotNull @NotNull String playerName)
playerName
- the player name to look up the unique ID for@NotNull public static @NotNull PluginManager getPluginManager()
@NotNull public static @NotNull BukkitScheduler getScheduler()
@NotNull public static @NotNull ServicesManager getServicesManager()
@NotNull public static @NotNull List<World> getWorlds()
@Nullable public static @Nullable World createWorld(@NotNull @NotNull WorldCreator creator)
If the world is already loaded, it will just return the equivalent of getWorld(creator.name()).
creator
- the options to use when creating the worldpublic static boolean unloadWorld(@NotNull @NotNull String name, boolean save)
name
- Name of the world to unloadsave
- whether to save the chunks before unloadingpublic static boolean unloadWorld(@NotNull @NotNull World world, boolean save)
world
- the world to unloadsave
- whether to save the chunks before unloading@Nullable public static @Nullable World getWorld(@NotNull @NotNull String name)
name
- the name of the world to retrieve@Nullable public static @Nullable World getWorld(@NotNull @NotNull UUID uid)
uid
- a unique-id of the world to retrieve@Nullable public static @Nullable World getWorld(@NotNull @NotNull NamespacedKey worldKey)
worldKey
- the NamespacedKey of the world to retrieve@Deprecated @Nullable public static @Nullable MapView getMap(int id)
id
- the id of the map to get@NotNull public static @NotNull MapView createMap(@NotNull @NotNull World world)
world
- the world the map will belong to@NotNull public static @NotNull ItemStack createExplorerMap(@NotNull @NotNull World world, @NotNull @NotNull Location location, @NotNull @NotNull StructureType structureType)
StructureType
.
world
- the world the map will belong tolocation
- the origin location to find the nearest structurestructureType
- the type of structure to findWorld.locateNearestStructure(org.bukkit.Location,
org.bukkit.StructureType, int, boolean)
@NotNull public static @NotNull ItemStack createExplorerMap(@NotNull @NotNull World world, @NotNull @NotNull Location location, @NotNull @NotNull StructureType structureType, int radius, boolean findUnexplored)
StructureType
.
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 structuresWorld.locateNearestStructure(org.bukkit.Location,
org.bukkit.StructureType, int, boolean)
public static void reload()
public static void reloadData()
@NotNull public static @NotNull Logger getLogger()
@Nullable public static @Nullable PluginCommand getPluginCommand(@NotNull @NotNull String name)
PluginCommand
with the given name or alias.name
- the name of the command to retrievepublic static void savePlayers()
public static boolean dispatchCommand(@NotNull @NotNull CommandSender sender, @NotNull @NotNull String commandLine) throws CommandException
sender
- the apparent sender of the commandcommandLine
- the command + arguments. Example: test abc
123
CommandException
- thrown when the executor for the given command
fails with an unhandled exception@Contract(value="null -> false") public static boolean addRecipe(@Nullable @Nullable Recipe recipe)
recipe
- the recipe to add@NotNull public static @NotNull List<Recipe> getRecipesFor(@NotNull @NotNull ItemStack result)
result
- the item to match against recipe results@Nullable public static @Nullable Recipe getRecipe(@NotNull @NotNull NamespacedKey recipeKey)
Recipe
for the given key.recipeKey
- the key of the recipe to return@NotNull public static @NotNull Iterator<Recipe> recipeIterator()
public static void clearRecipes()
public static void resetRecipes()
public static boolean removeRecipe(@NotNull @NotNull NamespacedKey key)
key
- NamespacedKey of recipe to remove.@NotNull public static @NotNull Map<String,String[]> getCommandAliases()
public static int getSpawnRadius()
public static void setSpawnRadius(int value)
value
- new spawn radius, or 0 if nonepublic static boolean getOnlineMode()
public static boolean getAllowFlight()
public static boolean isHardcore()
public static void shutdown()
public static int broadcast(@NotNull net.kyori.adventure.text.Component message, @NotNull @NotNull String permission)
message
- message to broadcastpermission
- the required permission permissibles
must have to receive the broadcast@Deprecated public static int broadcast(@NotNull @NotNull String message, @NotNull @NotNull String permission)
broadcast(net.kyori.adventure.text.Component, String)
message
- message to broadcastpermission
- the required permission permissibles
must have to receive the broadcast@Deprecated @NotNull public static @NotNull OfflinePlayer getOfflinePlayer(@NotNull @NotNull String name)
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.
name
- the name the player to retrievegetOfflinePlayer(java.util.UUID)
@Nullable public static @Nullable OfflinePlayer getOfflinePlayerIfCached(@NotNull @NotNull String name)
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.
name
- the name of the player to retrievenull
otherwisegetOfflinePlayer(String)
,
getOfflinePlayer(java.util.UUID)
@NotNull public static @NotNull OfflinePlayer getOfflinePlayer(@NotNull @NotNull UUID id)
This will return an object even if the player does not exist. To this method, all players will exist.
id
- the UUID of the player to retrieve@NotNull public static @NotNull Set<String> getIPBans()
public static void banIP(@NotNull @NotNull String address)
address
- the IP address to banpublic static void unbanIP(@NotNull @NotNull String address)
address
- the IP address to unban@NotNull public static @NotNull Set<OfflinePlayer> getBannedPlayers()
@NotNull public static @NotNull BanList getBanList(@NotNull BanList.Type 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.
type
- the type of list to fetch, cannot be null@NotNull public static @NotNull Set<OfflinePlayer> getOperators()
@NotNull public static @NotNull GameMode getDefaultGameMode()
GameMode
for new players.public static void setDefaultGameMode(@NotNull @NotNull GameMode mode)
GameMode
for new players.mode
- the new game mode@NotNull public static @NotNull ConsoleCommandSender getConsoleSender()
ConsoleCommandSender
that may be used as an input source
for this server.@NotNull public static @NotNull File getWorldContainer()
World
s.@NotNull public static @NotNull OfflinePlayer[] getOfflinePlayers()
@NotNull public static @NotNull Messenger getMessenger()
Messenger
responsible for this server.@NotNull public static @NotNull HelpMap getHelpMap()
HelpMap
providing help topics for this server.@NotNull public static @NotNull Inventory createInventory(@Nullable @Nullable InventoryHolder owner, @NotNull @NotNull InventoryType type)
InventoryType.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. Use
HumanEntity.openWorkbench(Location, boolean)
instead.
InventoryType.ENCHANTING
will not process ItemStack
s
for possible enchanting results. Use
HumanEntity.openEnchanting(Location, boolean)
instead.owner
- the holder of the inventory, or null to indicate no holdertype
- the type of inventory to createIllegalArgumentException
- if the InventoryType
cannot be
viewed.InventoryType.isCreatable()
@NotNull public static @NotNull Inventory createInventory(@Nullable @Nullable InventoryHolder owner, @NotNull @NotNull InventoryType type, @NotNull net.kyori.adventure.text.Component title)
InventoryType.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. Use
HumanEntity.openWorkbench(Location, boolean)
instead.
InventoryType.ENCHANTING
will not process ItemStack
s
for possible enchanting results. Use
HumanEntity.openEnchanting(Location, boolean)
instead.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.IllegalArgumentException
- if the InventoryType
cannot be
viewed.InventoryType.isCreatable()
@Deprecated @NotNull public static @NotNull Inventory createInventory(@Nullable @Nullable InventoryHolder owner, @NotNull @NotNull InventoryType type, @NotNull @NotNull String title)
createInventory(InventoryHolder, InventoryType, net.kyori.adventure.text.Component)
InventoryType.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. Use
HumanEntity.openWorkbench(Location, boolean)
instead.
InventoryType.ENCHANTING
will not process ItemStack
s
for possible enchanting results. Use
HumanEntity.openEnchanting(Location, boolean)
instead.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.IllegalArgumentException
- if the InventoryType
cannot be
viewed.InventoryType.isCreatable()
@NotNull public static @NotNull Inventory createInventory(@Nullable @Nullable InventoryHolder owner, int size) throws IllegalArgumentException
InventoryType.CHEST
with the
specified size.owner
- the holder of the inventory, or null to indicate no holdersize
- a multiple of 9 as the size of inventory to createIllegalArgumentException
- if the size is not a multiple of 9@NotNull public static @NotNull Inventory createInventory(@Nullable @Nullable InventoryHolder owner, int size, @NotNull net.kyori.adventure.text.Component title) throws IllegalArgumentException
InventoryType.CHEST
with the
specified size and title.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
viewedIllegalArgumentException
- if the size is not a multiple of 9@Deprecated @NotNull public static @NotNull Inventory createInventory(@Nullable @Nullable InventoryHolder owner, int size, @NotNull @NotNull String title) throws IllegalArgumentException
createInventory(InventoryHolder, InventoryType, net.kyori.adventure.text.Component)
InventoryType.CHEST
with the
specified size and title.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
viewedIllegalArgumentException
- if the size is not a multiple of 9@NotNull public static @NotNull Merchant createMerchant(@Nullable net.kyori.adventure.text.Component title)
title
- the title of the corresponding merchant inventory, displayed
when the merchant inventory is viewed@NotNull @Deprecated public static @NotNull Merchant createMerchant(@Nullable @Nullable String title)
createMerchant(net.kyori.adventure.text.Component)
title
- the title of the corresponding merchant inventory, displayed
when the merchant inventory is viewedpublic static int getMonsterSpawnLimit()
public static int getAnimalSpawnLimit()
public static int getWaterAnimalSpawnLimit()
public static int getWaterAmbientSpawnLimit()
public static int getAmbientSpawnLimit()
public static boolean isPrimaryThread()
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.
@NotNull public static net.kyori.adventure.text.Component motd()
@NotNull @Deprecated public static @NotNull String getMotd()
motd()
@Nullable public static net.kyori.adventure.text.Component shutdownMessage()
@Nullable @Deprecated public static @Nullable String getShutdownMessage()
shutdownMessage()
@NotNull public static @NotNull Warning.WarningState getWarningState()
@NotNull public static @NotNull ItemFactory getItemFactory()
ItemMeta
).ItemFactory
@NotNull public static @NotNull ScoreboardManager getScoreboardManager()
This will only exist after the first world has loaded.
@Nullable public static @Nullable CachedServerIcon getServerIcon()
@NotNull public static @NotNull CachedServerIcon loadServerIcon(@NotNull @NotNull File file) throws IllegalArgumentException, Exception
Size and type are implementation defined. An incompatible file is
guaranteed to throw an implementation-defined Exception
.
file
- the file to load the fromServerListPingEvent.setServerIcon(CachedServerIcon)
IllegalArgumentException
- if image is nullException
- if the image does not meet current server server-icon
specifications@NotNull public static @NotNull CachedServerIcon loadServerIcon(@NotNull @NotNull BufferedImage image) throws IllegalArgumentException, Exception
Size and type are implementation defined. An incompatible file is
guaranteed to throw an implementation-defined Exception
.
image
- the image to useServerListPingEvent.setServerIcon(CachedServerIcon)
IllegalArgumentException
- if image is nullException
- if the image does not meet current server
server-icon specificationspublic static void setIdleTimeout(int threshold)
A value of 0 will disable the idle kick timeout.
threshold
- the idle timeout in minutespublic static int getIdleTimeout()
@NotNull public static ChunkGenerator.ChunkData createChunkData(@NotNull @NotNull World world)
ChunkGenerator.generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)
world
- the world to create the ChunkData for@NotNull public static ChunkGenerator.ChunkData createVanillaChunkData(@NotNull @NotNull World world, int x, int z)
world
- the world to create the ChunkData forx
- the x coordinate of the chunkz
- the z coordinate of the chunk@NotNull public static @NotNull BossBar createBossBar(@Nullable @Nullable String title, @NotNull @NotNull BarColor color, @NotNull @NotNull BarStyle style, @NotNull BarFlag... flags)
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@NotNull public static @NotNull KeyedBossBar createBossBar(@NotNull @NotNull NamespacedKey key, @Nullable @Nullable String title, @NotNull @NotNull BarColor color, @NotNull @NotNull BarStyle style, @NotNull BarFlag... flags)
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@NotNull public static @NotNull Iterator<KeyedBossBar> getBossBars()
Boss
createBossBar(String, BarColor, BarStyle, BarFlag...)
@Nullable public static @Nullable KeyedBossBar getBossBar(@NotNull @NotNull NamespacedKey key)
KeyedBossBar
specified by this key.
Boss
createBossBar(String, BarColor, BarStyle, BarFlag...)
key
- unique bossbar keypublic static boolean removeBossBar(@NotNull @NotNull NamespacedKey key)
KeyedBossBar
specified by this key.
Boss
createBossBar(String, BarColor, BarStyle, BarFlag...)
key
- unique bossbar key@Nullable public static @Nullable Entity getEntity(@NotNull @NotNull UUID uuid)
uuid
- the UUID of the entity@NotNull public static @NotNull double[] getTPS()
@NotNull public static @NotNull long[] getTickTimes()
public static double getAverageTickTime()
@Nullable public static @Nullable Advancement getAdvancement(@NotNull @NotNull NamespacedKey key)
key
- unique advancement key@NotNull public static @NotNull Iterator<Advancement> advancementIterator()
@NotNull public static @NotNull BlockData createBlockData(@NotNull @NotNull Material material)
BlockData
instance for the specified Material, with
all properties initialized to unspecified defaults.material
- the material@NotNull public static @NotNull BlockData createBlockData(@NotNull @NotNull Material material, @Nullable @Nullable Consumer<BlockData> consumer)
BlockData
instance for the specified Material, with
all properties initialized to unspecified defaults.material
- the materialconsumer
- consumer to run on new instance before returning@NotNull public static @NotNull BlockData createBlockData(@NotNull @NotNull String data) throws IllegalArgumentException
BlockData
instance with material and properties
parsed from provided data.data
- data stringIllegalArgumentException
- if the specified data is not valid@NotNull @Contract(value="null, null -> fail") public static @NotNull BlockData createBlockData(@Nullable @Nullable Material material, @Nullable @Nullable String data) throws IllegalArgumentException
BlockData
instance for the specified Material, with
all properties initialized to unspecified defaults, except for those
provided in data.material
- the materialdata
- data stringIllegalArgumentException
- if the specified data is not validpublic static <T extends Keyed> Tag<T> getTag(@NotNull @NotNull String registry, @NotNull @NotNull NamespacedKey tag, @NotNull @NotNull Class<T> clazz)
Tag
rather than this method
which makes no guarantees about which tags are available, and may also be
less performant due to lack of caching.
Tag
.T
- type of the tagregistry
- the tag registry to look attag
- the name of the tagclazz
- the class of the tag entries@NotNull public static <T extends Keyed> @NotNull Iterable<Tag<T>> getTags(@NotNull @NotNull String registry, @NotNull @NotNull Class<T> clazz)
Tag
.
T
- type of the tagregistry
- the tag registry to look atclazz
- the class of the tag entries@Nullable public static @Nullable LootTable getLootTable(@NotNull @NotNull NamespacedKey key)
LootTable
.key
- the name of the LootTable@NotNull public static @NotNull List<Entity> selectEntities(@NotNull @NotNull CommandSender sender, @NotNull @NotNull String selector) throws IllegalArgumentException
sender
- the sender to execute as, must be providedselector
- the selection stringIllegalArgumentException
- if the selector is malformed in any way
or a parameter is null@Deprecated @NotNull public static @NotNull UnsafeValues getUnsafe()
UnsafeValues
@NotNull public static CommandMap getCommandMap()
CommandMap
public static void reloadPermissions()
public static boolean reloadCommandAliases()
public static boolean suggestPlayerNamesWhenNullTabCompletions()
null
as
their tab completion result.@NotNull public static @NotNull String getPermissionMessage()
@NotNull public static PlayerProfile createProfile(@NotNull @NotNull UUID uuid)
uuid
- UUID to create profile for@NotNull public static PlayerProfile createProfile(@NotNull @NotNull String name)
name
- Name to create profile for@NotNull public static PlayerProfile createProfile(@Nullable @Nullable UUID uuid, @Nullable @Nullable String name)
uuid
- UUID to create profile forname
- Name to create profile forpublic static int getCurrentTick()
public static boolean isStopping()
@NotNull public static MobGoals getMobGoals()
MobGoals
manager@NotNull public static DatapackManager getDatapackManager()
@NotNull public static Server.Spigot spigot()
Copyright © 2021. All rights reserved.