public final class Bukkit extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
addRecipe(Recipe recipe)
Adds a recipe to the crafting manager.
|
static Iterator<Advancement> |
advancementIterator()
Get an iterator through all advancements.
|
static void |
banIP(String address)
Bans the specified address from the server.
|
static void |
broadcast(net.md_5.bungee.api.chat.BaseComponent... components)
Sends an array of components as a single message to all online players.
|
static void |
broadcast(net.md_5.bungee.api.chat.BaseComponent component)
Sends the component to all online players.
|
static int |
broadcast(String message,
String permission)
Broadcasts the specified message to every user with the given
permission name.
|
static int |
broadcastMessage(String message)
Broadcast a message to all players.
|
static void |
clearRecipes()
Clears the list of crafting recipes.
|
static BossBar |
createBossBar(String title,
BarColor color,
BarStyle style,
BarFlag... flags)
Creates a boss bar instance to display to players.
|
static ChunkGenerator.ChunkData |
createChunkData(World world)
Create a ChunkData for use in a generator.
|
static Inventory |
createInventory(InventoryHolder owner,
int size)
Creates an empty inventory of type
InventoryType.CHEST with the
specified size. |
static Inventory |
createInventory(InventoryHolder owner,
int size,
String title)
Creates an empty inventory of type
InventoryType.CHEST with the
specified size and title. |
static Inventory |
createInventory(InventoryHolder owner,
InventoryType type)
Creates an empty inventory of the specified type.
|
static Inventory |
createInventory(InventoryHolder owner,
InventoryType type,
String title)
Creates an empty inventory with the specified type and title.
|
static MapView |
createMap(World world)
Create a new map with an automatically assigned ID.
|
static Merchant |
createMerchant(String title)
Creates an empty merchant.
|
static PlayerProfile |
createProfile(String name)
Creates a PlayerProfile for the specified name, with UUID as null
|
static PlayerProfile |
createProfile(UUID uuid)
Creates a PlayerProfile for the specified uuid, with name as null
|
static PlayerProfile |
createProfile(UUID uuid,
String name)
Creates a PlayerProfile for the specified name/uuid
Both UUID and Name can not be null at same time.
|
static World |
createWorld(WorldCreator creator)
Creates or loads a world with the given name using the specified
options.
|
static boolean |
dispatchCommand(CommandSender sender,
String commandLine)
Dispatches a command on this server, and executes it if found.
|
static Advancement |
getAdvancement(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 BanList |
getBanList(BanList.Type type)
Gets a ban list for the supplied type.
|
static Set<OfflinePlayer> |
getBannedPlayers()
Gets a set containing all banned players.
|
static String |
getBukkitVersion()
Gets the Bukkit version that this server is running.
|
static 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 ConsoleCommandSender |
getConsoleSender()
Gets a
ConsoleCommandSender that may be used as an input source
for this server. |
static GameMode |
getDefaultGameMode()
Gets the default
GameMode for new players. |
static Entity |
getEntity(UUID uuid)
Gets an entity on the server by its UUID
|
static boolean |
getGenerateStructures()
Get generate-structures setting.
|
static HelpMap |
getHelpMap()
Gets the
HelpMap providing help topics for this server. |
static int |
getIdleTimeout()
Gets the idle kick timeout.
|
static String |
getIp()
Get the IP that this server is bound to, or empty string if not
specified.
|
static Set<String> |
getIPBans()
Gets a set containing all current IPs that are banned.
|
static ItemFactory |
getItemFactory()
Gets the instance of the item factory (for
ItemMeta ). |
static Logger |
getLogger()
Returns the primary logger associated with this server instance.
|
static MapView |
getMap(short id)
Deprecated.
Magic value
|
static int |
getMaxPlayers()
Get the maximum amount of players which can login to this server.
|
static Messenger |
getMessenger()
Gets the
Messenger responsible for this server. |
static int |
getMonsterSpawnLimit()
Gets user-specified limit for number of monsters that can spawn in a
chunk.
|
static String |
getMotd()
Gets the message that is displayed on the server list.
|
static String |
getName()
Gets the name of this server implementation.
|
static OfflinePlayer |
getOfflinePlayer(String name)
Deprecated.
Persistent storage of users should be by UUID as names are no longer
unique past a single session.
|
static OfflinePlayer |
getOfflinePlayer(UUID id)
Gets the player by the given UUID, regardless if they are offline or
online.
|
static 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 Collection<? extends Player> |
getOnlinePlayers()
Gets a view of all currently logged in players.
|
static Set<OfflinePlayer> |
getOperators()
Gets a set containing all player operators.
|
static Player |
getPlayer(String name)
Gets a player object by the given username.
|
static Player |
getPlayer(UUID id)
Gets the player with the given UUID.
|
static Player |
getPlayerExact(String name)
Gets the player with the exact given name, case insensitive.
|
static UUID |
getPlayerUniqueId(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 PluginCommand |
getPluginCommand(String name)
Gets a
PluginCommand with the given name or alias. |
static PluginManager |
getPluginManager()
Gets the plugin manager for interfacing with plugins.
|
static int |
getPort()
Get the game port that the server runs on.
|
static List<Recipe> |
getRecipesFor(ItemStack result)
Get a list of all recipes for a given item.
|
static BukkitScheduler |
getScheduler()
Gets the scheduler for managing scheduled events.
|
static ScoreboardManager |
getScoreboardManager()
Gets the instance of the scoreboard manager.
|
static Server |
getServer()
Gets the current
Server singleton |
static CachedServerIcon |
getServerIcon()
Gets an instance of the server's default server-icon.
|
static String |
getServerId()
Get an ID of this server.
|
static String |
getServerName()
Get the name of this server.
|
static ServicesManager |
getServicesManager()
Gets a services manager.
|
static String |
getShutdownMessage()
Gets the default message that is displayed when the server is stopped.
|
static int |
getSpawnRadius()
Gets the radius, in blocks, around each worlds spawn point to protect.
|
static int |
getTicksPerAnimalSpawns()
Gets default ticks per animal spawns value.
|
static int |
getTicksPerMonsterSpawns()
Gets the default ticks per monster spawns value.
|
static double[] |
getTPS()
Gets the current server TPS
|
static UnsafeValues |
getUnsafe()
Deprecated.
|
static String |
getUpdateFolder()
Gets the name of the update folder.
|
static File |
getUpdateFolderFile()
Gets the update folder.
|
static String |
getVersion()
Gets the version string of this server implementation.
|
static int |
getViewDistance()
Get the view distance from this server.
|
static Warning.WarningState |
getWarningState()
Gets the current warning state for the server.
|
static int |
getWaterAnimalSpawnLimit()
Gets user-specified limit for number of water animals that can spawn in
a chunk.
|
static Set<OfflinePlayer> |
getWhitelistedPlayers()
Gets a list of whitelisted players.
|
static World |
getWorld(String name)
Gets the world with the given name.
|
static World |
getWorld(UUID uid)
Gets the world from the given Unique ID.
|
static File |
getWorldContainer()
Gets the folder that contains all of the various
World s. |
static List<World> |
getWorlds()
Gets a list of all worlds on this server.
|
static 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 CachedServerIcon |
loadServerIcon(BufferedImage image)
Creates a cached server-icon for the specific image.
|
static CachedServerIcon |
loadServerIcon(File file)
Loads an image from a file, and returns a cached image for the specific
server-icon.
|
static List<Player> |
matchPlayer(String name)
Attempts to match any players with the given name, and returns a list
of all possibly matches.
|
static 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 void |
resetRecipes()
Resets the list of crafting recipes to the default.
|
static void |
savePlayers()
Writes loaded players to disk.
|
static void |
setDefaultGameMode(GameMode mode)
Sets the default
GameMode for new players. |
static void |
setIdleTimeout(int threshold)
Set the idle kick timeout.
|
static void |
setServer(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 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(String address)
Unbans the specified address from the server.
|
static boolean |
unloadWorld(String name,
boolean save)
Unloads a world with the given name.
|
static boolean |
unloadWorld(World world,
boolean save)
Unloads the given world.
|
public static Server getServer()
Server
singletonpublic static void setServer(Server server)
Server
singleton.
This cannot be done if the Server is already set.
server
- Server instancepublic static String getName()
public static String getVersion()
public static String getBukkitVersion()
public static 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 int getPort()
public static int getViewDistance()
public static String getIp()
public static String getServerName()
public static String getServerId()
public static String getWorldType()
public static boolean getGenerateStructures()
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 offpublic static Set<OfflinePlayer> getWhitelistedPlayers()
public static void reloadWhitelist()
public static int broadcastMessage(String message)
This is the same as calling broadcast(java.lang.String,
java.lang.String)
to Server.BROADCAST_CHANNEL_USERS
message
- the messagepublic static void broadcast(net.md_5.bungee.api.chat.BaseComponent component)
component
- the component to sendpublic static void broadcast(net.md_5.bungee.api.chat.BaseComponent... components)
components
- the components to sendpublic static String getUpdateFolder()
The update folder name is relative to the plugins folder.
public static 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 Player getPlayer(String name)
This method may not return objects for offline players.
name
- the name to look uppublic static Player getPlayerExact(String name)
name
- Exact name of the player to retrievepublic static List<Player> matchPlayer(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 matchpublic static Player getPlayer(UUID id)
id
- UUID of the player to retrieve@Nullable public static UUID getPlayerUniqueId(String playerName)
playerName
- the player name to look up the unique ID forpublic static PluginManager getPluginManager()
public static BukkitScheduler getScheduler()
public static ServicesManager getServicesManager()
public static List<World> getWorlds()
public static World createWorld(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(String name, boolean save)
name
- Name of the world to unloadsave
- whether to save the chunks before unloadingpublic static boolean unloadWorld(World world, boolean save)
world
- the world to unloadsave
- whether to save the chunks before unloadingpublic static World getWorld(String name)
name
- the name of the world to retrievepublic static World getWorld(UUID uid)
uid
- a unique-id of the world to retrieve@Deprecated public static MapView getMap(short id)
id
- the id of the map to getpublic static MapView createMap(World world)
world
- the world the map will belong topublic static void reload()
public static void reloadData()
public static Logger getLogger()
public static PluginCommand getPluginCommand(String name)
PluginCommand
with the given name or alias.name
- the name of the command to retrievepublic static void savePlayers()
public static boolean dispatchCommand(CommandSender sender, 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 exceptionpublic static boolean addRecipe(Recipe recipe)
recipe
- the recipe to addpublic static List<Recipe> getRecipesFor(ItemStack result)
result
- the item to match against recipe resultspublic static Iterator<Recipe> recipeIterator()
public static void clearRecipes()
public static void resetRecipes()
public static 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(String message, String permission)
message
- message to broadcastpermission
- the required permission permissibles
must have to receive the broadcast@Deprecated public static OfflinePlayer getOfflinePlayer(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)
public static OfflinePlayer getOfflinePlayer(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 retrievepublic static Set<String> getIPBans()
public static void banIP(String address)
address
- the IP address to banpublic static void unbanIP(String address)
address
- the IP address to unbanpublic static Set<OfflinePlayer> getBannedPlayers()
public static BanList getBanList(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 nullpublic static Set<OfflinePlayer> getOperators()
public static GameMode getDefaultGameMode()
GameMode
for new players.public static void setDefaultGameMode(GameMode mode)
GameMode
for new players.mode
- the new game modepublic static ConsoleCommandSender getConsoleSender()
ConsoleCommandSender
that may be used as an input source
for this server.public static File getWorldContainer()
World
s.public static OfflinePlayer[] getOfflinePlayers()
public static Messenger getMessenger()
Messenger
responsible for this server.public static HelpMap getHelpMap()
HelpMap
providing help topics for this server.public static Inventory createInventory(InventoryHolder owner, InventoryType type)
InventoryType.CHEST
, the new inventory has a size of 27; otherwise the
new inventory has the normal size for its type.owner
- the holder of the inventory, or null to indicate no holdertype
- the type of inventory to createpublic static Inventory createInventory(InventoryHolder owner, InventoryType type, String title)
InventoryType.CHEST
, the new inventory has a size of 27;
otherwise the new inventory has the normal size for its type.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.public static Inventory createInventory(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 9public static Inventory createInventory(InventoryHolder owner, int size, String 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 9public static Merchant createMerchant(String title)
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 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.
public static String getMotd()
public static String getShutdownMessage()
public static Warning.WarningState getWarningState()
public static ItemFactory getItemFactory()
ItemMeta
).ItemFactory
public static ScoreboardManager getScoreboardManager()
This will only exist after the first world has loaded.
public static CachedServerIcon getServerIcon()
public static CachedServerIcon loadServerIcon(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
specificationspublic static CachedServerIcon loadServerIcon(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()
public static ChunkGenerator.ChunkData createChunkData(World world)
ChunkGenerator.generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)
world
- the world to create the ChunkData forpublic static BossBar createBossBar(String title, BarColor color, BarStyle style, 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 barpublic static Entity getEntity(UUID uuid)
uuid
- the UUID of the entitypublic static double[] getTPS()
public static Advancement getAdvancement(NamespacedKey key)
key
- unique advancement keypublic static Iterator<Advancement> advancementIterator()
@Deprecated public static UnsafeValues getUnsafe()
UnsafeValues
public static CommandMap getCommandMap()
CommandMap
public static void reloadPermissions()
public static boolean reloadCommandAliases()
public static boolean suggestPlayerNamesWhenNullTabCompletions()
null
as
their tab completion result.public static PlayerProfile createProfile(@Nonnull UUID uuid)
uuid
- UUID to create profile forpublic static PlayerProfile createProfile(@Nonnull String name)
name
- Name to create profile forpublic static PlayerProfile createProfile(@Nullable UUID uuid, @Nullable String name)
uuid
- UUID to create profile forname
- Name to create profile forpublic static Server.Spigot spigot()
Copyright © 2021. All rights reserved.