Package org.bukkit

Interface Server

All Superinterfaces:
Audience, ForwardingAudience, PluginMessageRecipient, Pointered

public interface Server extends PluginMessageRecipient, ForwardingAudience
Represents a server implementation.
  • Field Details

  • Method Details

    • getPluginsFolder

      @NotNull @NotNull File getPluginsFolder()
      Returns the de facto plugins directory, generally used for storing plugin jars to be loaded, as well as their data folders.

      Plugins should use Plugin.getDataFolder() rather than traversing this directory manually when determining the location in which to store their data and configuration files.

      Returns:
      plugins directory
    • getName

      Gets the name of this server implementation.
      Returns:
      name of this server implementation
    • getVersion

      @NotNull @NotNull String getVersion()
      Gets the version string of this server implementation.
      Returns:
      version of this server implementation
    • getBukkitVersion

      @NotNull @NotNull String getBukkitVersion()
      Gets the Bukkit version that this server is running.
      Returns:
      version of Bukkit
    • getMinecraftVersion

      @NotNull @NotNull String getMinecraftVersion()
      Gets the version of game this server implements
      Returns:
      version of game
    • getOnlinePlayers

      @NotNull @NotNull Collection<? extends Player> getOnlinePlayers()
      Gets a view of all currently logged in players. This view is a reused object, making some operations like 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.

      Returns:
      a view of currently online players.
    • getMaxPlayers

      int getMaxPlayers()
      Get the maximum amount of players which can login to this server.
      Returns:
      the amount of players this server allows
    • setMaxPlayers

      void setMaxPlayers(int maxPlayers)
      Set the maximum amount of players allowed to be logged in at once.
      Parameters:
      maxPlayers - The maximum amount of concurrent players
    • 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.
    • getSimulationDistance

      int getSimulationDistance()
      Get the simulation distance from this server.
      Returns:
      the simulation distance from this server.
    • getIp

      Get the IP that this server is bound to, or empty string if not specified.
      Returns:
      the IP string that this server is bound to, otherwise empty string
    • getWorldType

      @NotNull @NotNull String getWorldType()
      Get world type (level-type setting) for default world.
      Returns:
      the value of level-type (e.g. DEFAULT, FLAT, DEFAULT_1_1)
    • getGenerateStructures

      boolean getGenerateStructures()
      Get generate-structures setting.
      Returns:
      true if structure generation is enabled, false otherwise
    • getMaxWorldSize

      int getMaxWorldSize()
      Get max world size.
      Returns:
      the maximum world size as specified for the server
    • getAllowEnd

      boolean getAllowEnd()
      Gets whether this server allows the End or not.
      Returns:
      whether this server allows the End or not
    • getAllowNether

      boolean getAllowNether()
      Gets whether this server allows the Nether or not.
      Returns:
      whether this server allows the Nether or not
    • isLoggingIPs

      boolean isLoggingIPs()
      Gets whether the server is logging the IP addresses of players.
      Returns:
      whether the server is logging the IP addresses of players
    • getInitialEnabledPacks

      @NotNull @NotNull List<String> getInitialEnabledPacks()
      Gets a list of packs to be enabled.
      Returns:
      a list of packs names
    • getInitialDisabledPacks

      @NotNull @NotNull List<String> getInitialDisabledPacks()
      Gets a list of packs that will not be enabled automatically.
      Returns:
      a list of packs names
    • getDataPackManager

      @NotNull @Deprecated(forRemoval=true, since="1.20") @NotNull DataPackManager getDataPackManager()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the DataPack Manager.
      Returns:
      the manager
    • getServerTickManager

      @NotNull @NotNull ServerTickManager getServerTickManager()
      Get the ServerTick Manager.
      Returns:
      the manager
    • getServerResourcePack

      @Nullable @Nullable ResourcePack getServerResourcePack()
      Gets the resource pack configured to be sent to clients by the server.
      Returns:
      the resource pack
    • getResourcePack

      @NotNull @NotNull String getResourcePack()
      Gets the server resource pack uri, or empty string if not specified.
      Returns:
      the server resource pack uri, otherwise empty string
    • getResourcePackHash

      @NotNull @NotNull String getResourcePackHash()
      Gets the SHA-1 digest of the server resource pack, or empty string if not specified.
      Returns:
      the SHA-1 digest of the server resource pack, otherwise empty string
    • getResourcePackPrompt

      @NotNull @NotNull String getResourcePackPrompt()
      Gets the custom prompt message to be shown when the server resource pack is required, or empty string if not specified.
      Returns:
      the custom prompt message to be shown when the server resource, otherwise empty string
    • isResourcePackRequired

      boolean isResourcePackRequired()
      Gets whether the server resource pack is enforced.
      Returns:
      whether the server resource pack is enforced
    • hasWhitelist

      boolean hasWhitelist()
      Gets whether this server has a whitelist or not.
      Returns:
      whether this server has a whitelist or not
    • setWhitelist

      void setWhitelist(boolean value)
      Sets if the server is whitelisted.
      Parameters:
      value - true for whitelist on, false for off
    • isWhitelistEnforced

      boolean isWhitelistEnforced()
      Gets whether the server whitelist is enforced. If the whitelist is enforced, non-whitelisted players will be disconnected when the server whitelist is reloaded.
      Returns:
      whether the server whitelist is enforced
    • setWhitelistEnforced

      void setWhitelistEnforced(boolean value)
      Sets if the server whitelist is enforced. If the whitelist is enforced, non-whitelisted players will be disconnected when the server whitelist is reloaded.
      Parameters:
      value - true for enforced, false for not
    • getWhitelistedPlayers

      @NotNull @NotNull 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

      @Deprecated int broadcastMessage(@NotNull @NotNull String message)
      Broadcast a message to all players.

      This is the same as calling broadcast(java.lang.String, java.lang.String) to BROADCAST_CHANNEL_USERS

      Parameters:
      message - the message
      Returns:
      the number of players
    • broadcast

      @Deprecated default void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent component)
      Deprecated.
      use sendMessage methods that accept Component
      Sends the component to all online players.
      Parameters:
      component - the component to send
    • broadcast

      @Deprecated default void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent... components)
      Deprecated.
      use sendMessage methods that accept Component
      Sends an array of components as a single message to all online players.
      Parameters:
      components - the components to send
    • getUpdateFolder

      @NotNull @NotNull 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

      @NotNull @NotNull 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

      @Deprecated(since="1.18.1") int getTicksPerAnimalSpawns()
      Deprecated.
      Deprecated in favor of getTicksPerSpawns(SpawnCategory)
      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

      @Deprecated(since="1.18.1") int getTicksPerMonsterSpawns()
      Deprecated.
      Deprecated in favor of getTicksPerSpawns(SpawnCategory)
      Gets the default ticks per monster spawns value.

      Example Usage:

      • A value of 1 will mean the server will attempt to spawn monsters every tick.
      • A value of 400 will mean the server will attempt to spawn monsters every 400th tick.
      • A value below 0 will be reset back to Minecraft's default.

      Note: If set to 0, monsters spawning will be disabled. We recommend using spawn-monsters to control this instead.

      Minecraft default: 1.

      Returns:
      the default ticks per monsters spawn value
    • getTicksPerWaterSpawns

      @Deprecated(since="1.18.1") int getTicksPerWaterSpawns()
      Deprecated.
      Deprecated in favor of getTicksPerSpawns(SpawnCategory)
      Gets the default ticks per water mob spawns value.

      Example Usage:

      • A value of 1 will mean the server will attempt to spawn water mobs every tick.
      • A value of 400 will mean the server will attempt to spawn water mobs every 400th tick.
      • A value below 0 will be reset back to Minecraft's default.

      Note: If set to 0, water mobs spawning will be disabled.

      Minecraft default: 1.

      Returns:
      the default ticks per water mobs spawn value
    • getTicksPerWaterAmbientSpawns

      @Deprecated(since="1.18.1") int getTicksPerWaterAmbientSpawns()
      Deprecated.
      Deprecated in favor of getTicksPerSpawns(SpawnCategory)
      Gets the default ticks per water ambient mob spawns value.

      Example Usage:

      • A value of 1 will mean the server will attempt to spawn water ambient mobs every tick.
      • A value of 400 will mean the server will attempt to spawn water ambient mobs every 400th tick.
      • A value below 0 will be reset back to Minecraft's default.

      Note: If set to 0, ambient mobs spawning will be disabled.

      Minecraft default: 1.

      Returns:
      the default ticks per water ambient mobs spawn value
    • getTicksPerWaterUndergroundCreatureSpawns

      @Deprecated(since="1.18.1") int getTicksPerWaterUndergroundCreatureSpawns()
      Deprecated.
      Deprecated in favor of getTicksPerSpawns(SpawnCategory)
      Gets the default ticks per water underground creature spawns value.

      Example Usage:

      • A value of 1 will mean the server will attempt to spawn water underground creature every tick.
      • A value of 400 will mean the server will attempt to spawn water underground creature every 400th tick.
      • A value below 0 will be reset back to Minecraft's default.

      Note: If set to 0, water underground creature spawning will be disabled.

      Minecraft default: 1.

      Returns:
      the default ticks per water underground creature spawn value
    • getTicksPerAmbientSpawns

      @Deprecated(since="1.18.1") int getTicksPerAmbientSpawns()
      Deprecated.
      Deprecated in favor of getTicksPerSpawns(SpawnCategory)
      Gets the default ticks per ambient mob spawns value.

      Example Usage:

      • A value of 1 will mean the server will attempt to spawn ambient mobs every tick.
      • A value of 400 will mean the server will attempt to spawn ambient mobs every 400th tick.
      • A value below 0 will be reset back to Minecraft's default.

      Note: If set to 0, ambient mobs spawning will be disabled.

      Minecraft default: 1.

      Returns:
      the default ticks per ambient mobs spawn value
    • getTicksPerSpawns

      int getTicksPerSpawns(@NotNull @NotNull SpawnCategory spawnCategory)
      Gets the default ticks per SpawnCategory spawns value.

      Example Usage:

      • A value of 1 will mean the server will attempt to spawn SpawnCategory mobs every tick.
      • A value of 400 will mean the server will attempt to spawn SpawnCategory mobs every 400th tick.
      • A value below 0 will be reset back to Minecraft's default.

      Note: If set to 0, SpawnCategory mobs spawning will be disabled.

      Parameters:
      spawnCategory - the category of spawn
      Returns:
      the default ticks per SpawnCategory mobs spawn value
      Throws:
      IllegalArgumentException - if the category is SpawnCategory.MISC
    • getPlayer

      Gets a player whose name matches the given name closest.

      Use getPlayerExact(String) to get the player matching the input exactly and matchPlayer(String) if you want a list of all players matching the input.

      This method may not return objects for offline players.

      Parameters:
      name - the name to look up
      Returns:
      a player if one was found, null otherwise
    • getPlayerExact

      Gets the player with the exact given name, case insensitive.
      Parameters:
      name - Exact name of the player to retrieve
      Returns:
      a player object if one was found, null otherwise
    • matchPlayer

      Attempts to match any players with the given name, and returns a list of all possibly matches.

      This list is not sorted in any particular order. If an exact match is found, the returned list will only contain a single result.

      Parameters:
      name - the (partial) name to match
      Returns:
      list of all possible players
    • getPlayer

      Gets the player with the given UUID.
      Parameters:
      id - UUID of the player to retrieve
      Returns:
      a player object if one was found, null otherwise
    • getPlayerUniqueId

      @Nullable @Nullable UUID getPlayerUniqueId(@NotNull @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
      Parameters:
      playerName - the player name to look up the unique ID for
      Returns:
      A UUID, or null if that player name is not registered with Minecraft and the server is in online mode
    • getPluginManager

      @NotNull @NotNull PluginManager getPluginManager()
      Gets the plugin manager for interfacing with plugins.
      Returns:
      a plugin manager for this Server instance
    • getScheduler

      Gets the scheduler for managing scheduled events.
      Returns:
      a scheduling service for this server
    • getServicesManager

      @NotNull @NotNull ServicesManager getServicesManager()
      Gets a services manager.
      Returns:
      s services manager
    • getWorlds

      @NotNull @NotNull List<World> getWorlds()
      Gets a list of all worlds on this server.
      Returns:
      a list of worlds
    • isTickingWorlds

      boolean isTickingWorlds()
      Gets whether the worlds are being ticked right now.
      Returns:
      true if the worlds are being ticked, false otherwise.
    • createWorld

      Creates or loads a world with the given name using the specified options.

      If the world is already loaded, it will just return the equivalent of getWorld(creator.name()).

      Do note that un/loading worlds mid-tick may have potential side effects, we strongly recommend ensuring that you're not un/loading worlds midtick by checking Bukkit.isTickingWorlds()

      Parameters:
      creator - the options to use when creating the world
      Returns:
      newly created or loaded world
      Throws:
      IllegalStateException - when isTickingWorlds is true
    • unloadWorld

      boolean unloadWorld(@NotNull @NotNull String name, boolean save)
      Unloads a world with the given name.

      Do note that un/loading worlds mid-tick may have potential side effects, we strongly recommend ensuring that you're not un/loading worlds midtick by checking Bukkit.isTickingWorlds()

      Parameters:
      name - Name of the world to unload
      save - whether to save the chunks before unloading
      Returns:
      true if successful, false otherwise
      Throws:
      IllegalStateException - when isTickingWorlds is true
    • unloadWorld

      boolean unloadWorld(@NotNull @NotNull World world, boolean save)
      Unloads the given world.

      Do note that un/loading worlds mid-tick may have potential side effects, we strongly recommend ensuring that you're not un/loading worlds midtick by checking Bukkit.isTickingWorlds()

      Parameters:
      world - the world to unload
      save - whether to save the chunks before unloading
      Returns:
      true if successful, false otherwise
      Throws:
      IllegalStateException - when isTickingWorlds is true
    • getWorld

      Gets the world with the given name.
      Parameters:
      name - the name of the world to retrieve
      Returns:
      a world with the given name, or null if none exists
    • getWorld

      Gets the world from the given Unique ID.
      Parameters:
      uid - a unique-id of the world to retrieve
      Returns:
      a world with the given Unique ID, or null if none exists
    • getWorld

      @Nullable default @Nullable World getWorld(@NotNull @NotNull NamespacedKey worldKey)
      Gets the world from the given NamespacedKey
      Parameters:
      worldKey - the NamespacedKey of the world to retrieve
      Returns:
      a world with the given NamespacedKey, or null if none exists
    • getWorld

      @Nullable @Nullable World getWorld(@NotNull Key worldKey)
      Gets the world from the given Key
      Parameters:
      worldKey - the Key of the world to retrieve
      Returns:
      a world with the given Key, or null if none exists
    • createWorldBorder

      @NotNull @NotNull WorldBorder createWorldBorder()
      Create a new virtual WorldBorder.

      Note that world borders created by the server will not respect any world scaling effects (i.e. coordinates are not divided by 8 in the nether).

      Returns:
      the created world border instance
      See Also:
    • getMap

      @Nullable @Nullable MapView getMap(int id)
      Gets the map from the given item ID.
      Parameters:
      id - the id of the map to get
      Returns:
      a map view if it exists, or null otherwise
    • createMap

      Create a new map with an automatically assigned ID.
      Parameters:
      world - the world the map will belong to
      Returns:
      a newly created map view
    • createExplorerMap

      Create a new explorer map targeting the closest nearby structure of a given StructureType.
      This method uses implementation default values for radius and findUnexplored (usually 100, true).
      Parameters:
      world - the world the map will belong to
      location - the origin location to find the nearest structure
      structureType - the type of structure to find
      Returns:
      a newly created item stack
      See Also:
    • createExplorerMap

      @Deprecated @NotNull @NotNull ItemStack createExplorerMap(@NotNull @NotNull World world, @NotNull @NotNull Location location, @NotNull @NotNull StructureType structureType, int radius, boolean findUnexplored)
      Create a new explorer map targeting the closest nearby structure of a given StructureType.
      Parameters:
      world - the world the map will belong to
      location - the origin location to find the nearest structure
      structureType - the type of structure to find
      radius - radius to search, see World#locateNearestStructure for more information
      findUnexplored - whether to find unexplored structures
      Returns:
      the newly created item stack
      See Also:
    • createExplorerMap

      @Nullable default @Nullable ItemStack createExplorerMap(@NotNull @NotNull World world, @NotNull @NotNull Location location, @NotNull StructureType structureType, @NotNull MapCursor.Type mapIcon)
      Create a new explorer map targeting the closest nearby structure of a given StructureType.
      This method uses implementation default values for radius and findUnexplored (usually 100, true).
      Parameters:
      world - the world the map will belong to
      location - the origin location to find the nearest structure
      structureType - the type of structure to find
      mapIcon - the map icon to use on the map
      Returns:
      a newly created item stack or null if it can't find a location
      See Also:
    • createExplorerMap

      @Nullable @Nullable ItemStack createExplorerMap(@NotNull @NotNull World world, @NotNull @NotNull Location location, @NotNull StructureType structureType, @NotNull MapCursor.Type mapIcon, int radius, boolean findUnexplored)
      Create a new explorer map targeting the closest nearby structure of a given StructureType.
      Parameters:
      world - the world the map will belong to
      location - the origin location to find the nearest structure
      structureType - the type of structure to find
      mapIcon - the map icon to use on the map
      radius - radius to search, see World#locateNearestStructure for more information
      findUnexplored - whether to find unexplored structures
      Returns:
      the newly created item stack or null if it can't find a location
      See Also:
    • 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.
    • updateResources

      void updateResources()
      Updates all advancement, tag, and recipe data to all connected clients. Useful for updating clients to new advancements/recipes/tags.
      See Also:
    • updateRecipes

      void updateRecipes()
      Updates recipe data and the recipe book to each player. Useful for updating clients to new recipes.
      See Also:
    • getLogger

      Returns the primary logger associated with this server instance.
      Returns:
      Logger associated with this server
      See Also:
      API Note:
      This logger is for the Minecraft server software, not for specific plugins. You should use a logger for a specific plugin, either via Plugin.getSLF4JLogger() or Plugin.getLogger() or create a specific logger for a class via slf4j. That way, log messages contain contextual information about the source of the message.
    • getPluginCommand

      Gets a PluginCommand with the given name or alias.
      Parameters:
      name - the name of the command to retrieve
      Returns:
      a plugin command if found, null otherwise
    • savePlayers

      void savePlayers()
      Writes loaded players to disk.
    • dispatchCommand

      boolean dispatchCommand(@NotNull @NotNull CommandSender sender, @NotNull @NotNull String commandLine) throws CommandException
      Dispatches a command on this server, and executes it if found.
      Parameters:
      sender - the apparent sender of the command
      commandLine - 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

      @Contract("null -> false") boolean addRecipe(@Nullable @Nullable Recipe recipe)
      Adds a recipe to the crafting manager. Recipes added with this method won't be sent to the client automatically. Use updateRecipes() or updateResources() to update clients to new recipes added.

      Player's still have to discover recipes via HumanEntity.discoverRecipe(NamespacedKey) before seeing them in their recipe book.

      Parameters:
      recipe - the recipe to add
      Returns:
      true if the recipe was added, false if it wasn't for some reason
      See Also:
    • addRecipe

      @Contract("null, _ -> false") boolean addRecipe(@Nullable @Nullable Recipe recipe, boolean resendRecipes)
      Adds a recipe to the crafting manager.
      Parameters:
      recipe - the recipe to add
      resendRecipes - true to update the client with the full set of recipes
      Returns:
      true if the recipe was added, false if it wasn't for some reason
    • getRecipesFor

      Get a list of all recipes for a given item. The stack size is ignored in comparisons. If the durability is -1, it will match any data value.
      Parameters:
      result - the item to match against recipe results
      Returns:
      a list of recipes with the given result
    • getRecipe

      Get the Recipe for the given key.
      Parameters:
      recipeKey - the key of the recipe to return
      Returns:
      the recipe for the given key or null.
    • getCraftingRecipe

      @Nullable @Nullable Recipe getCraftingRecipe(@NotNull @NotNull ItemStack[] craftingMatrix, @NotNull @NotNull World world)
      Get the Recipe for the list of ItemStacks provided.

      The list is formatted as a crafting matrix where the index follow the pattern below:

       [ 0 1 2 ]
       [ 3 4 5 ]
       [ 6 7 8 ]
       

      NOTE: This method will not modify the provided ItemStack array, for that, use craftItem(ItemStack[], World, Player).

      Parameters:
      craftingMatrix - list of items to be crafted from. Must not contain more than 9 items.
      world - The world the crafting takes place in.
      Returns:
      the Recipe resulting from the given crafting matrix.
    • craftItem

      Get the crafted item using the list of ItemStack provided.

      The list is formatted as a crafting matrix where the index follow the pattern below:

       [ 0 1 2 ]
       [ 3 4 5 ]
       [ 6 7 8 ]
       

      The World and Player arguments are required to fulfill the Bukkit Crafting events.

      Calls PrepareItemCraftEvent to imitate the Player initiating the crafting event.

      Parameters:
      craftingMatrix - list of items to be crafted from. Must not contain more than 9 items.
      world - The world the crafting takes place in.
      player - The player to imitate the crafting event on.
      Returns:
      the ItemStack resulting from the given crafting matrix, if no recipe is found an ItemStack of Material.AIR is returned.
    • craftItem

      Get the crafted item using the list of ItemStack provided.

      The list is formatted as a crafting matrix where the index follow the pattern below:

       [ 0 1 2 ]
       [ 3 4 5 ]
       [ 6 7 8 ]
       
      Parameters:
      craftingMatrix - list of items to be crafted from. Must not contain more than 9 items.
      world - The world the crafting takes place in.
      Returns:
      the ItemStack resulting from the given crafting matrix, if no recipe is found an ItemStack of Material.AIR is returned.
    • craftItemResult

      Get the crafted item using the list of ItemStack provided.

      The list is formatted as a crafting matrix where the index follow the pattern below:

       [ 0 1 2 ]
       [ 3 4 5 ]
       [ 6 7 8 ]
       

      The World and Player arguments are required to fulfill the Bukkit Crafting events.

      Calls PrepareItemCraftEvent to imitate the Player initiating the crafting event.

      Parameters:
      craftingMatrix - list of items to be crafted from. Must not contain more than 9 items.
      world - The world the crafting takes place in.
      player - The player to imitate the crafting event on.
      Returns:
      resulting ItemCraftResult containing the resulting item, matrix and any overflow items.
    • craftItemResult

      @NotNull @NotNull ItemCraftResult craftItemResult(@NotNull @NotNull ItemStack[] craftingMatrix, @NotNull @NotNull World world)
      Get the crafted item using the list of ItemStack provided.

      The list is formatted as a crafting matrix where the index follow the pattern below:

       [ 0 1 2 ]
       [ 3 4 5 ]
       [ 6 7 8 ]
       
      Parameters:
      craftingMatrix - list of items to be crafted from. Must not contain more than 9 items.
      world - The world the crafting takes place in.
      Returns:
      resulting ItemCraftResult containing the resulting item, matrix and any overflow items.
    • recipeIterator

      @NotNull @NotNull 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.
    • removeRecipe

      boolean removeRecipe(@NotNull @NotNull NamespacedKey key)
      Remove a recipe from the server. Note that removing a recipe may cause permanent loss of data associated with that recipe (eg whether it has been discovered by players).
      Parameters:
      key - NamespacedKey of recipe to remove.
      Returns:
      True if recipe was removed
    • removeRecipe

      boolean removeRecipe(@NotNull @NotNull NamespacedKey key, boolean resendRecipes)
      Remove a recipe from the server.

      Note that removing a recipe may cause permanent loss of data associated with that recipe (eg whether it has been discovered by players).

      Parameters:
      key - NamespacedKey of recipe to remove.
      resendRecipes - true to update all clients on the new recipe list. Will only update if a recipe was actually removed
      Returns:
      True if recipe was removed
    • getCommandAliases

      @NotNull @NotNull 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
    • shouldSendChatPreviews

      @Deprecated(since="1.19.3") boolean shouldSendChatPreviews()
      Deprecated.
      chat previews have been removed
      Gets whether the server should send a preview of the player's chat message to the client when the player types a message
      Returns:
      true if the server should send a preview, false otherwise
    • isEnforcingSecureProfiles

      boolean isEnforcingSecureProfiles()
      Gets whether the server only allow players with Mojang-signed public key to join
      Returns:
      true if only Mojang-signed players can join, false otherwise
    • isAcceptingTransfers

      boolean isAcceptingTransfers()
      Gets whether this server is allowing connections transferred from other servers.
      Returns:
      true if the server accepts transfers, false otherwise
    • getHideOnlinePlayers

      boolean getHideOnlinePlayers()
      Gets whether the Server hide online players in server status.
      Returns:
      true if the server hide online players, false otherwise
    • getOnlineMode

      boolean getOnlineMode()
      Gets whether the Server is in online mode or not.
      Returns:
      true if the server authenticates clients, false otherwise
    • getAllowFlight

      boolean getAllowFlight()
      Gets whether this server allows flying or not.
      Returns:
      true if the server allows flight, false otherwise
    • isHardcore

      boolean isHardcore()
      Gets whether the server is in hardcore mode or not.
      Returns:
      true if the server mode is hardcore, false otherwise
    • shutdown

      void shutdown()
      Shutdowns the server, stopping everything.
    • broadcast

      @Deprecated int broadcast(@NotNull @NotNull String message, @NotNull @NotNull String permission)
      Broadcasts the specified message to every user with the given permission name.
      Parameters:
      message - message to broadcast
      permission - the required permission permissibles must have to receive the broadcast
      Returns:
      number of message recipients
    • broadcast

      int broadcast(@NotNull Component message)
      Broadcast a message to all players.

      This is the same as calling broadcast(net.kyori.adventure.text.Component, java.lang.String) with the BROADCAST_CHANNEL_USERS permission.

      Parameters:
      message - the message
      Returns:
      the number of players
    • broadcast

      int broadcast(@NotNull Component message, @NotNull @NotNull String permission)
      Broadcasts the specified message to every user with the given permission name.
      Parameters:
      message - message to broadcast
      permission - the required permission permissibles must have to receive the broadcast
      Returns:
      number of message recipients
    • getOfflinePlayer

      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:
    • getOfflinePlayerIfCached

      @Nullable @Nullable OfflinePlayer getOfflinePlayerIfCached(@NotNull @NotNull String name)
      Gets the player by the given name, regardless if they are offline or online.

      This will not make a web request to get the UUID for the given name, thus this method will not block. However this method will return null if the player is not cached.

      Parameters:
      name - the name of the player to retrieve
      Returns:
      an offline player if cached, null otherwise
      See Also:
    • getOfflinePlayer

      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
    • createPlayerProfile

      Creates a new PlayerProfile.
      Parameters:
      uniqueId - the unique id
      name - the name
      Returns:
      the new PlayerProfile
      Throws:
      IllegalArgumentException - if both the unique id is null and the name is null or blank
    • createPlayerProfile

      @NotNull @Deprecated(since="1.18.1") @NotNull PlayerProfile createPlayerProfile(@NotNull @NotNull UUID uniqueId)
      Deprecated.
      Creates a new PlayerProfile.
      Parameters:
      uniqueId - the unique id
      Returns:
      the new PlayerProfile
      Throws:
      IllegalArgumentException - if the unique id is null
    • createPlayerProfile

      @NotNull @Deprecated(since="1.18.1") @NotNull PlayerProfile createPlayerProfile(@NotNull @NotNull String name)
      Deprecated.
      Creates a new PlayerProfile.
      Parameters:
      name - the name
      Returns:
      the new PlayerProfile
      Throws:
      IllegalArgumentException - if the name is null or blank
    • getIPBans

      @NotNull @NotNull Set<String> getIPBans()
      Gets a set containing all current IPs that are banned.
      Returns:
      a set containing banned IP addresses
    • banIP

      @Deprecated(since="1.20.1") void banIP(@NotNull @NotNull String address)
      Deprecated.
      Bans the specified address from the server.
      Parameters:
      address - the IP address to ban
    • unbanIP

      @Deprecated(since="1.20.1") void unbanIP(@NotNull @NotNull String address)
      Deprecated.
      Unbans the specified address from the server.
      Parameters:
      address - the IP address to unban
    • banIP

      void banIP(@NotNull @NotNull InetAddress address)
      Bans the specified address from the server.
      Parameters:
      address - the IP address to ban
    • unbanIP

      void unbanIP(@NotNull @NotNull InetAddress address)
      Unbans the specified address from the server.
      Parameters:
      address - the IP address to unban
    • getBannedPlayers

      @NotNull @NotNull Set<OfflinePlayer> getBannedPlayers()
      Gets a set containing all banned players.
      Returns:
      a set containing banned players
    • getBanList

      @Deprecated @NotNull <T extends BanList<?>> T getBanList(@NotNull BanList.Type type)
      Deprecated.
      use getBanList(io.papermc.paper.ban.BanListType) to enforce the correct return value at compile time.
      Gets a ban list for the supplied type.
      Type Parameters:
      T - The ban target
      Parameters:
      type - the type of list to fetch, cannot be null
      Returns:
      a ban list of the specified type
    • getBanList

      @NotNull <B extends BanList<E>, E> B getBanList(@NotNull BanListType<B> type)
      Gets a ban list for the supplied type.
      Type Parameters:
      B - The ban target
      Parameters:
      type - the type of list to fetch, cannot be null
      Returns:
      a ban list of the specified type
    • getOperators

      Gets a set containing all player operators.
      Returns:
      a set containing player operators
    • getDefaultGameMode

      @NotNull @NotNull GameMode getDefaultGameMode()
      Gets the default GameMode for new players.
      Returns:
      the default game mode
    • setDefaultGameMode

      void setDefaultGameMode(@NotNull @NotNull GameMode mode)
      Sets the default GameMode for new players.
      Parameters:
      mode - the new game mode
    • getConsoleSender

      Gets a ConsoleCommandSender that may be used as an input source for this server.
      Returns:
      a console command sender
    • createCommandSender

      @NotNull @NotNull CommandSender createCommandSender(@NotNull Consumer<? super Component> feedback)
      Creates a special CommandSender which redirects command feedback (in the form of chat messages) to the specified listener. The returned sender will have the same effective permissions as getConsoleSender().
      Parameters:
      feedback - feedback listener
      Returns:
      a command sender
    • getWorldContainer

      @NotNull @NotNull File getWorldContainer()
      Gets the folder that contains all of the various Worlds.
      Returns:
      folder that contains all worlds
    • getOfflinePlayers

      @NotNull @NotNull OfflinePlayer[] getOfflinePlayers()
      Gets every player that has ever played on this server.

      This method can be expensive as it loads all the player data files from the disk.

      Returns:
      an array containing all previous players
    • getMessenger

      @NotNull @NotNull Messenger getMessenger()
      Gets the Messenger responsible for this server.
      Returns:
      messenger responsible for this server
    • getHelpMap

      @NotNull @NotNull HelpMap getHelpMap()
      Gets the HelpMap providing help topics for this server.
      Returns:
      a help map for this server
    • createInventory

      Creates an empty inventory with the specified type. If the type is 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 ItemStacks for possible enchanting results. Use HumanEntity.openEnchanting(Location, boolean) instead.
      Parameters:
      owner - the holder of the inventory, or null to indicate no holder
      type - the type of inventory to create
      Returns:
      a new inventory
      Throws:
      IllegalArgumentException - if the InventoryType cannot be viewed.
      See Also:
    • createInventory

      Creates an empty inventory with the specified type and title. If the type is InventoryType.CHEST, the new inventory has a size of 27; otherwise the new inventory has the normal size for its type.
      It should be noted that some inventory types do not support titles and may not render with said titles on the Minecraft client.
      InventoryType.WORKBENCH will not process crafting recipes if created with this method. Use HumanEntity.openWorkbench(Location, boolean) instead.
      InventoryType.ENCHANTING will not process ItemStacks for possible enchanting results. Use HumanEntity.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 the InventoryType cannot be viewed.
      See Also:
    • createInventory

      Creates an empty inventory with the specified type and title. If the type is InventoryType.CHEST, the new inventory has a size of 27; otherwise the new inventory has the normal size for its type.
      It should be noted that some inventory types do not support titles and may not render with said titles on the Minecraft client.
      InventoryType.WORKBENCH will not process crafting recipes if created with this method. Use HumanEntity.openWorkbench(Location, boolean) instead.
      InventoryType.ENCHANTING will not process ItemStacks for possible enchanting results. Use HumanEntity.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 the InventoryType cannot be viewed.
      See Also:
    • createInventory

      Creates an empty inventory of type InventoryType.CHEST with the specified size.
      Parameters:
      owner - the holder of the inventory, or null to indicate no holder
      size - 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

      Creates an empty inventory of type InventoryType.CHEST with the specified size and title.
      Parameters:
      owner - the holder of the inventory, or null to indicate no holder
      size - a multiple of 9 as the size of inventory to create
      title - the title of the inventory, displayed when inventory is viewed
      Returns:
      a new inventory
      Throws:
      IllegalArgumentException - if the size is not a multiple of 9
    • createInventory

      Creates an empty inventory of type InventoryType.CHEST with the specified size and title.
      Parameters:
      owner - the holder of the inventory, or null to indicate no holder
      size - a multiple of 9 as the size of inventory to create
      title - 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

      @NotNull @NotNull Merchant createMerchant(@Nullable Component 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
    • createMerchant

      Creates an empty merchant.
      Parameters:
      title - the title of the corresponding merchant inventory, displayed when the merchant inventory is viewed
      Returns:
      a new merchant
    • getMaxChainedNeighborUpdates

      int getMaxChainedNeighborUpdates()
      Gets the amount of consecutive neighbor updates before skipping additional ones.
      Returns:
      the amount of consecutive neighbor updates, if the value is negative then the limit it's not used
    • getMonsterSpawnLimit

      @Deprecated(since="1.18.1") int getMonsterSpawnLimit()
      Deprecated.
      Deprecated in favor of getSpawnLimit(SpawnCategory)
      Gets user-specified limit for number of monsters that can spawn in a chunk.
      Returns:
      the monster spawn limit
    • getAnimalSpawnLimit

      @Deprecated(since="1.18.1") int getAnimalSpawnLimit()
      Deprecated.
      Deprecated in favor of getSpawnLimit(SpawnCategory)
      Gets user-specified limit for number of animals that can spawn in a chunk.
      Returns:
      the animal spawn limit
    • getWaterAnimalSpawnLimit

      @Deprecated(since="1.18.1") int getWaterAnimalSpawnLimit()
      Deprecated.
      Deprecated in favor of getSpawnLimit(SpawnCategory)
      Gets user-specified limit for number of water animals that can spawn in a chunk.
      Returns:
      the water animal spawn limit
    • getWaterAmbientSpawnLimit

      @Deprecated(since="1.18.1") int getWaterAmbientSpawnLimit()
      Deprecated.
      Deprecated in favor of getSpawnLimit(SpawnCategory)
      Gets user-specified limit for number of water ambient mobs that can spawn in a chunk.
      Returns:
      the water ambient spawn limit
    • getWaterUndergroundCreatureSpawnLimit

      @Deprecated(since="1.18.1") int getWaterUndergroundCreatureSpawnLimit()
      Deprecated.
      Deprecated in favor of getSpawnLimit(SpawnCategory)
      Get user-specified limit for number of water creature underground that can spawn in a chunk.
      Returns:
      the water underground creature limit
    • getAmbientSpawnLimit

      @Deprecated(since="1.18.1") int getAmbientSpawnLimit()
      Deprecated.
      Deprecated in favor of getSpawnLimit(SpawnCategory)
      Gets user-specified limit for number of ambient mobs that can spawn in a chunk.
      Returns:
      the ambient spawn limit
    • getSpawnLimit

      int getSpawnLimit(@NotNull @NotNull SpawnCategory spawnCategory)
      Gets user-specified limit for number of SpawnCategory mobs that can spawn in a chunk. Note: the SpawnCategory.MISC are not consider.
      Parameters:
      spawnCategory - the category spawn
      Returns:
      the SpawnCategory spawn limit
    • isPrimaryThread

      boolean isPrimaryThread()
      Checks the current thread against the expected primary thread for the server.

      Note: this method should not be used to indicate the current synchronized state of the runtime. A current thread matching the main thread indicates that it is synchronized, but a mismatch does not preclude the same assumption.

      Returns:
      true if the current thread matches the expected primary thread, false otherwise
    • motd

      Gets the message that is displayed on the server list.
      Returns:
      the server's MOTD
    • motd

      void motd(@NotNull Component motd)
      Set the message that is displayed on the server list.
      Parameters:
      motd - The message to be displayed
    • shutdownMessage

      @Nullable Component shutdownMessage()
      Gets the default message that is displayed when the server is stopped.
      Returns:
      the shutdown message
    • getMotd

      Deprecated.
      in favour of motd()
      Gets the message that is displayed on the server list.
      Returns:
      the servers MOTD
    • setMotd

      @Deprecated void setMotd(@NotNull @NotNull String motd)
      Set the message that is displayed on the server list.
      Parameters:
      motd - The message to be displayed
    • getServerLinks

      Gets the server links which will be sent to clients
      Returns:
      the server's links
    • getShutdownMessage

      @Nullable @Deprecated @Nullable String getShutdownMessage()
      Deprecated.
      in favour of shutdownMessage()
      Gets the default message that is displayed when the server is stopped.
      Returns:
      the shutdown message
    • getWarningState

      Gets the current warning state for the server.
      Returns:
      the configured warning state
    • getItemFactory

      @NotNull @NotNull ItemFactory getItemFactory()
      Gets the instance of the item factory (for ItemMeta).
      Returns:
      the item factory
      See Also:
    • getEntityFactory

      @NotNull @NotNull EntityFactory getEntityFactory()
      Gets the instance of the entity factory (for EntitySnapshot).
      Returns:
      the entity factory
      See Also:
    • getScoreboardManager

      @NotNull @NotNull 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.
    • getScoreboardCriteria

      @NotNull @NotNull Criteria getScoreboardCriteria(@NotNull @NotNull String name)
      Get (or create) a new Criteria by its name.
      Parameters:
      name - the criteria name
      Returns:
      the criteria
      See Also:
    • 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

      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 null
      Exception - if the image does not meet current server server-icon specifications
    • loadServerIcon

      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 null
      Exception - 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
    • getPauseWhenEmptyTime

      int getPauseWhenEmptyTime()
      Gets the pause when empty threshold seconds. To save resources, the pause most functions after this time if there are no players online.
      Returns:
      the pause threshold in seconds
    • setPauseWhenEmptyTime

      void setPauseWhenEmptyTime(int seconds)
      Sets the pause when empty threshold seconds. To save resources, the pause most functions after this time if there are no players online.

      A value of less than 1 will disable the setting

      Parameters:
      seconds - the pause threshold in seconds
    • createChunkData

      Parameters:
      world - the world to create the ChunkData for
      Returns:
      a new ChunkData for the world
    • createBossBar

      Creates a boss bar instance to display to players. The progress defaults to 1.0
      Parameters:
      title - the title of the boss bar
      color - the color of the boss bar
      style - the style of the boss bar
      flags - an optional list of flags to set on the boss bar
      Returns:
      the created boss bar
    • createBossBar

      Creates a boss bar instance to display to players. The progress defaults to 1.0.
      This instance is added to the persistent storage of the server and will be editable by commands and restored after restart.
      Parameters:
      key - the key of the boss bar that is used to access the boss bar
      title - the title of the boss bar
      color - the color of the boss bar
      style - the style of the boss bar
      flags - an optional list of flags to set on the boss bar
      Returns:
      the created boss bar
    • getBossBars

      Gets an unmodifiable iterator through all persistent bossbars. e.g. bossbars created using the bossbar command
      Returns:
      a bossbar iterator
    • getBossBar

      Gets the KeyedBossBar specified by this key. e.g. bossbars created using the bossbar command
      Parameters:
      key - unique bossbar key
      Returns:
      bossbar or null if not exists
    • removeBossBar

      boolean removeBossBar(@NotNull @NotNull NamespacedKey key)
      Removes a KeyedBossBar specified by this key. e.g. bossbars created using the bossbar command
      Parameters:
      key - unique bossbar key
      Returns:
      true if removal succeeded or false
    • getEntity

      Gets an entity on the server by its UUID
      Parameters:
      uuid - the UUID of the entity
      Returns:
      the entity with the given UUID, or null if it isn't found
    • getTPS

      @NotNull @org.jetbrains.annotations.NotNull double[] getTPS()
      Gets the current server TPS
      Returns:
      current server TPS (1m, 5m, 15m in Paper-Server)
    • getTickTimes

      @NotNull @org.jetbrains.annotations.NotNull long[] getTickTimes()
      Get a sample of the servers last tick times (in nanos)
      Returns:
      A sample of the servers last tick times (in nanos)
    • getAverageTickTime

      double getAverageTickTime()
      Get the average tick time (in millis)
      Returns:
      Average tick time (in millis)
    • getCommandMap

      @NotNull CommandMap getCommandMap()
      Gets the active CommandMap
      Returns:
      the active command map
    • getAdvancement

      Get the advancement specified by this key.
      Parameters:
      key - unique advancement key
      Returns:
      advancement or null if not exists
    • advancementIterator

      @NotNull @NotNull Iterator<Advancement> advancementIterator()
      Get an iterator through all advancements. Advancements cannot be removed from this iterator,
      Returns:
      an advancement iterator
    • createBlockData

      @NotNull @NotNull BlockData createBlockData(@NotNull @NotNull Material material)
      Creates a new BlockData instance for the specified Material, with all properties initialized to unspecified defaults.
      Parameters:
      material - the material
      Returns:
      new data instance
    • createBlockData

      @NotNull @NotNull BlockData createBlockData(@NotNull @NotNull Material material, @Nullable @Nullable Consumer<? super BlockData> consumer)
      Creates a new BlockData instance for the specified Material, with all properties initialized to unspecified defaults.
      Parameters:
      material - the material
      consumer - consumer to run on new instance before returning
      Returns:
      new data instance
    • createBlockData

      Creates a new BlockData instance with material and properties parsed from provided data.
      Parameters:
      data - data string
      Returns:
      new data instance
      Throws:
      IllegalArgumentException - if the specified data is not valid
    • createBlockData

      @NotNull @Contract("null, null -> fail") @NotNull BlockData createBlockData(@Nullable @Nullable Material material, @Nullable @Nullable String data) throws IllegalArgumentException
      Creates a new BlockData instance for the specified Material, with all properties initialized to unspecified defaults, except for those provided in data.
      If material is specified, then the data string must not also contain the material.
      Parameters:
      material - the material
      data - data string
      Returns:
      new data instance
      Throws:
      IllegalArgumentException - if the specified data is not valid
    • getTag

      Gets a tag which has already been defined within the server. Plugins are suggested to use the concrete tags in 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.
      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 in Tag.
      Type Parameters:
      T - type of the tag
      Parameters:
      registry - the tag registry to look at
      tag - the name of the tag
      clazz - the class of the tag entries
      Returns:
      the tag or null
    • getTags

      @NotNull <T extends Keyed> @NotNull Iterable<Tag<T>> getTags(@NotNull @NotNull String registry, @NotNull @NotNull Class<T> clazz)
      Gets a all tags which have been defined within the server.
      Server implementations are allowed to handle only the registries indicated in Tag.
      No guarantees are made about the mutability of the returned iterator.
      Type Parameters:
      T - type of the tag
      Parameters:
      registry - the tag registry to look at
      clazz - the class of the tag entries
      Returns:
      all defined tags
    • getLootTable

      Gets the specified LootTable.
      Parameters:
      key - the name of the LootTable
      Returns:
      the LootTable, or null if no LootTable is found with that name
    • selectEntities

      Selects entities using the given Vanilla selector.
      No guarantees are made about the selector format, other than they match the Vanilla format for the active Minecraft version.
      Usually a selector will start with '@', unless selecting a Player in which case it may simply be the Player's name or UUID.
      Note that in Vanilla, elevated permissions are usually required to use '@' selectors, but this method should not check such permissions from the sender.
      Parameters:
      sender - the sender to execute as, must be provided
      selector - the selection string
      Returns:
      a list of the selected entities. The list will not be null, but no further guarantees are made.
      Throws:
      IllegalArgumentException - if the selector is malformed in any way or a parameter is null
    • getStructureManager

      @NotNull @NotNull StructureManager getStructureManager()
      Gets the structure manager for loading and saving structures.
      Returns:
      the structure manager
    • getRegistry

      @Nullable @Deprecated(since="1.20.6") <T extends Keyed> @Nullable Registry<T> getRegistry(@NotNull @NotNull Class<T> tClass)
      Returns the registry for the given class.
      If no registry is present for the given class null will be returned.
      Depending on the implementation not every registry present in Registry will be returned by this method.
      Type Parameters:
      T - type of the registry
      Parameters:
      tClass - of the registry to get
      Returns:
      the corresponding registry or null if not present
    • getUnsafe

      Deprecated.
      Returns:
      the unsafe values instance
      See Also:
    • spigot

    • reloadPermissions

      void reloadPermissions()
    • reloadCommandAliases

      boolean reloadCommandAliases()
    • suggestPlayerNamesWhenNullTabCompletions

      boolean suggestPlayerNamesWhenNullTabCompletions()
      Checks if player names should be suggested when a command returns null as their tab completion result.
      Returns:
      true if player names should be suggested
    • getPermissionMessage

      @NotNull @Deprecated @NotNull String getPermissionMessage()
      Deprecated.
      Gets the default no permission message used on the server
      Returns:
      the default message
    • permissionMessage

      @NotNull Component permissionMessage()
      Gets the default no permission message used on the server
      Returns:
      the default message
    • createProfile

      Creates a PlayerProfile for the specified uuid, with name as null. If a player with the passed uuid exists on the server at the time of creation, the returned player profile will be populated with the properties of said player (including their uuid and name).
      Parameters:
      uuid - UUID to create profile for
      Returns:
      A PlayerProfile object
    • createProfile

      Creates a PlayerProfile for the specified name, with UUID as null. If a player with the passed name exists on the server at the time of creation, the returned player profile will be populated with the properties of said player (including their uuid and name).

      E.g. if the player 'jeb_' is currently playing on the server, calling createProfile("JEB_") will yield a profile with the name 'jeb_', their uuid and their textures. To bypass this pre-population on a case-insensitive name match, see createProfileExact(UUID, String).

      Parameters:
      name - Name to create profile for
      Returns:
      A PlayerProfile object
      Throws:
      IllegalArgumentException - if the name is longer than 16 characters
      IllegalArgumentException - if the name contains invalid characters
    • createProfile

      Creates a PlayerProfile for the specified name/uuid Both UUID and Name can not be null at same time. One must be supplied. If a player with the passed uuid or name exists on the server at the time of creation, the returned player profile will be populated with the properties of said player (including their uuid and name).

      E.g. if the player 'jeb_' is currently playing on the server, calling createProfile(null, "JEB_") will yield a profile with the name 'jeb_', their uuid and their textures. To bypass this pre-population on an case-insensitive name match, see createProfileExact(UUID, String).

      The name comparison will compare the String.toLowerCase() version of both the passed name parameter and a players name to honour the case-insensitive nature of a mojang profile lookup.

      Parameters:
      uuid - UUID to create profile for
      name - Name to create profile for
      Returns:
      A PlayerProfile object
      Throws:
      IllegalArgumentException - if the name is longer than 16 characters
      IllegalArgumentException - if the name contains invalid characters
    • createProfileExact

      Creates an exact PlayerProfile for the specified name/uuid Both UUID and Name can not be null at same time. One must be supplied. If a player with the passed uuid or name exists on the server at the time of creation, the returned player profile will be populated with the properties of said player.

      Compared to createProfile(UUID, String), this method will never mutate the passed uuid or name. If a player with either the same uuid or a matching name (case-insensitive) is found on the server, their properties, such as textures, will be pre-populated in the profile, however the passed uuid and name stay intact.

      Parameters:
      uuid - UUID to create profile for
      name - Name to create profile for
      Returns:
      A PlayerProfile object
      Throws:
      IllegalArgumentException - if the name is longer than 16 characters
      IllegalArgumentException - if the name contains invalid characters
    • getCurrentTick

      int getCurrentTick()
      Get the current internal server tick
      Returns:
      Current tick
    • isStopping

      boolean isStopping()
      Checks if the server is in the process of being shutdown.
      Returns:
      true if server is in the process of being shutdown
    • getMobGoals

      @NotNull MobGoals getMobGoals()
      Returns the MobGoals manager
      Returns:
      the mob goals manager
    • getDatapackManager

      @NotNull DatapackManager getDatapackManager()
      Returns:
      the datapack manager
    • getPotionBrewer

      @NotNull PotionBrewer getPotionBrewer()
      Gets the potion brewer.
      Returns:
      the potion brewer
    • getRegionScheduler

      @NotNull RegionScheduler getRegionScheduler()
      Returns the Folia region task scheduler. The region task scheduler can be used to schedule tasks by location to be executed on the region which owns the location.

      Note: It is entirely inappropriate to use the region scheduler to schedule tasks for entities. If you wish to schedule tasks to perform actions on entities, you should be using Entity.getScheduler() as the entity scheduler will "follow" an entity if it is teleported, whereas the region task scheduler will not.

      If you do not need/want to make your plugin run on Folia, use getScheduler() instead.

      Returns:
      the region task scheduler
    • getAsyncScheduler

      @NotNull AsyncScheduler getAsyncScheduler()
      Returns the Folia async task scheduler. The async task scheduler can be used to schedule tasks that execute asynchronously from the server tick process.
      Returns:
      the async task scheduler
    • getGlobalRegionScheduler

      @NotNull GlobalRegionScheduler getGlobalRegionScheduler()
      Returns the Folia global region task scheduler. The global task scheduler can be used to schedule tasks to execute on the global region.

      The global region is responsible for maintaining world day time, world game time, weather cycle, sleep night skipping, executing commands for console, and other misc. tasks that do not belong to any specific region.

      If you do not need/want to make your plugin run on Folia, use getScheduler() instead.

      Returns:
      the global region scheduler
    • isOwnedByCurrentRegion

      boolean isOwnedByCurrentRegion(@NotNull @NotNull World world, @NotNull Position position)
      Returns whether the current thread is ticking a region and that the region being ticked owns the chunk at the specified world and block position.
      Parameters:
      world - Specified world.
      position - Specified block position.
    • isOwnedByCurrentRegion

      boolean isOwnedByCurrentRegion(@NotNull @NotNull World world, @NotNull Position position, int squareRadiusChunks)
      Returns whether the current thread is ticking a region and that the region being ticked owns the chunks centered at the specified block position within the specified square radius. Specifically, this function checks that every chunk with position x in [centerX - radius, centerX + radius] and position z in [centerZ - radius, centerZ + radius] is owned by the current ticking region.
      Parameters:
      world - Specified world.
      position - Specified block position.
      squareRadiusChunks - Specified square radius. Must be >= 0. Note that this parameter is not a squared radius, but rather a Chebyshev Distance.
    • isOwnedByCurrentRegion

      boolean isOwnedByCurrentRegion(@NotNull @NotNull Location location)
      Returns whether the current thread is ticking a region and that the region being ticked owns the chunk at the specified world and block position as included in the specified location.
      Parameters:
      location - Specified location, must have a non-null world.
    • isOwnedByCurrentRegion

      boolean isOwnedByCurrentRegion(@NotNull @NotNull Location location, int squareRadiusChunks)
      Returns whether the current thread is ticking a region and that the region being ticked owns the chunks centered at the specified world and block position as included in the specified location within the specified square radius. Specifically, this function checks that every chunk with position x in [centerX - radius, centerX + radius] and position z in [centerZ - radius, centerZ + radius] is owned by the current ticking region.
      Parameters:
      location - Specified location, must have a non-null world.
      squareRadiusChunks - Specified square radius. Must be >= 0. Note that this parameter is not a squared radius, but rather a Chebyshev Distance.
    • isOwnedByCurrentRegion

      default boolean isOwnedByCurrentRegion(@NotNull Block block)
      Returns whether the current thread is ticking a region and that the region being ticked owns the chunk at the specified block position.
      Parameters:
      block - Specified block position.
    • isOwnedByCurrentRegion

      boolean isOwnedByCurrentRegion(@NotNull @NotNull World world, int chunkX, int chunkZ)
      Returns whether the current thread is ticking a region and that the region being ticked owns the chunk at the specified world and chunk position.
      Parameters:
      world - Specified world.
      chunkX - Specified x-coordinate of the chunk position.
      chunkZ - Specified z-coordinate of the chunk position.
    • isOwnedByCurrentRegion

      boolean isOwnedByCurrentRegion(@NotNull @NotNull World world, int chunkX, int chunkZ, int squareRadiusChunks)
      Returns whether the current thread is ticking a region and that the region being ticked owns the chunks centered at the specified world and chunk position within the specified square radius. Specifically, this function checks that every chunk with position x in [centerX - radius, centerX + radius] and position z in [centerZ - radius, centerZ + radius] is owned by the current ticking region.
      Parameters:
      world - Specified world.
      chunkX - Specified x-coordinate of the chunk position.
      chunkZ - Specified z-coordinate of the chunk position.
      squareRadiusChunks - Specified square radius. Must be >= 0. Note that this parameter is not a squared radius, but rather a Chebyshev Distance.
    • isOwnedByCurrentRegion

      boolean isOwnedByCurrentRegion(@NotNull @NotNull World world, int minChunkX, int minChunkZ, int maxChunkX, int maxChunkZ)
      Returns whether the current thread is ticking a region and that the region being ticked owns the chunks in the rectangle specified by the min and max parameters. Specifically, this function checks that every chunk with position x in [minChunkX, maxChunkX] and position z in [minChunkZ, maxChunkZ] is owned by the current ticking region.
      Parameters:
      world - Specified world.
      minChunkX - Specified x-coordinate of the minimum chunk position.
      minChunkZ - Specified z-coordinate of the minimum chunk position.
      maxChunkX - Specified x-coordinate of the maximum chunk position.
      maxChunkZ - Specified z-coordinate of the maximum chunk position.
    • isOwnedByCurrentRegion

      boolean isOwnedByCurrentRegion(@NotNull @NotNull Entity entity)
      Returns whether the current thread is ticking a region and that the region being ticked owns the specified entity. Note that this function is the only appropriate method of checking for ownership of an entity, as retrieving the entity's location is undefined unless the entity is owned by the current region.
      Parameters:
      entity - Specified entity.
    • isGlobalTickThread

      boolean isGlobalTickThread()
      Returns whether the current thread is ticking the global region.
      See Also:
    • isPaused

      boolean isPaused()
      Returns whether the server is sleeping/paused.
    • allowPausing

      void allowPausing(@NotNull Plugin plugin, boolean value)
      Allows or disallows the server to sleep/pause. If any plugin disallows pausing, the server will never pause.
      Parameters:
      plugin - The Plugin that's allowing or disallowing pausing.
      value - Whether to allow sleeping of the server (defaults to true).