Interface Server

All Superinterfaces:
Audience, Engine, ForwardingAudience, LocaleSource, Pointered, RegistryHolder
All Known Subinterfaces:
LocalServer

public interface Server extends ForwardingAudience, Engine, LocaleSource
Represents a typical Minecraft Server.
  • Method Details

    • worldManager

      WorldManager worldManager()
      Gets the WorldManager.
      Returns:
      The world manager
    • dataPackManager

      DataPackManager dataPackManager()
      Returns the DataPackManager
      Returns:
      The datapack manager
    • recipeManager

      RecipeManager recipeManager()
      Retrieves the RecipeManager.
      Returns:
      The recipe manager
    • isMultiWorldEnabled

      boolean isMultiWorldEnabled()
      Gets if multiple worlds will be loaded by the server.
      Returns:
      True if enabled, false if not
    • worldGenerationConfig

      WorldGenerationConfig worldGenerationConfig()
      Returns:
      The world generator config
    • maxPlayers

      int maxPlayers()
      Gets the max players allowed to join.
      Returns:
      The max players
    • isWhitelistEnabled

      boolean isWhitelistEnabled()
      Gets if the whitelist is currently enforced.
      Returns:
      True if enabled, false if not
    • isOnlineModeEnabled

      boolean isOnlineModeEnabled()
      Gets if incoming connections are authenticated against Mojang's servers.
      Returns:
      True if enabled, false if not
    • motd

      Component motd()
      Gets the "message of the day" presented to clients who have this server saved as a connection profile in the multiplayer menu
      Returns:
      The message of the day
    • resourcePack

      Optional<ResourcePackRequest> resourcePack()
      Gets the pack sent to clients when they join.
      Returns:
      The resource pack
    • playerIdleTimeout

      int playerIdleTimeout()
      Gets the player idle timeout, in minutes.
      Returns:
      The player idle timeout
    • isHardcoreModeEnabled

      boolean isHardcoreModeEnabled()
      Gets if hardcode mode has been enabled.
      Returns:
      True if enabled, false if not
    • difficulty

      Difficulty difficulty()
      Gets the Difficulty.
      Returns:
      The difficulty
    • gameMode

      GameMode gameMode()
      Gets the GameMode.
      Returns:
      The gamemode
    • isGameModeEnforced

      boolean isGameModeEnforced()
      Gets if players will have their game mode set to the default.

      gameMode()

      Returns:
      True if enforced, false if not
    • isPVPEnabled

      boolean isPVPEnabled()
      Gets if pvp is enabled.
      Returns:
      True if enabled, false if not
    • areCommandBlocksEnabled

      boolean areCommandBlocksEnabled()
      Gets if command blocks will run commands.
      Returns:
      True if enabled, false if not
    • isMonsterSpawnsEnabled

      boolean isMonsterSpawnsEnabled()
      Gets if monsters will naturally spawn.
      Returns:
      True if enabled, false if not
    • isAnimalSpawnsEnabled

      boolean isAnimalSpawnsEnabled()
      Gets if animals will naturally spawn.
      Returns:
      True if enabled, false if not
    • isDedicatedServer

      boolean isDedicatedServer()
      Gets whether this server is dedicated to being a global server, or whether this server is local to a game client where a Client instance may be available.
      Returns:
      True if this is a dedicated server without a game client
    • userManager

      UserManager userManager()
      Gets the UserManager.
      Returns:
      The user manager
    • teleportHelper

      TeleportHelper teleportHelper()
      Gets the TeleportHelper, used to find safe ServerLocations.
      Returns:
      The teleport helper
    • streamOnlinePlayers

      Stream<ServerPlayer> streamOnlinePlayers()
      Gets a Stream of all the ServerPlayers currently online.
      Returns:
      The stream of online players
    • onlinePlayers

      Collection<ServerPlayer> onlinePlayers()
      Gets the ServerPlayers currently online.
      Returns:
      A Collection of online players
    • player

      Optional<ServerPlayer> player(UUID uniqueId)
      Gets a ServerPlayer by their UUID.
      Parameters:
      uniqueId - The UUID to get the player from
      Returns:
      The ServerPlayer or empty if not found
    • player

      Optional<ServerPlayer> player(String name)
      Gets a ServerPlayer by their name.

      This only works for online players.

      Parameters:
      name - The name to get the player from
      Returns:
      The ServerPlayer or empty if not found
    • serverScoreboard

      Optional<? extends Scoreboard> serverScoreboard()
      Gets the 'server' scoreboard. In Vanilla, this is the scoreboard of dimension 0 (the overworld).

      The server scoreboard is used with the Vanilla /scoreboard command, automatic score updating through criteria, and other things.

      Returns:
      the server scoreboard, if available.
    • chunkLayout

      ChunkLayout chunkLayout()
      Returns information about the chunk layout used by this server implementation.
      Returns:
      The chunk layout used by the implementation
    • runningTimeTicks

      Ticks runningTimeTicks()
      Gets the time, in ticks, since this server began running for the current session.
      Returns:
      The number of ticks since this server started running
    • broadcastAudience

      Audience broadcastAudience()
      Gets the message channel that server-wide messages are sent through.
      Returns:
      The server-wide broadcast channel
    • setBroadcastAudience

      void setBroadcastAudience(Audience channel)
      Sets the channel that server-wide messages should be sent through.
      Parameters:
      channel - The broadcast channel
    • boundAddress

      Optional<InetSocketAddress> boundAddress()
      Gets the bound InetSocketAddress from where this server is accepting connections.
      Returns:
      The address or Optional.empty() if not found
    • setHasWhitelist

      void setHasWhitelist(boolean enabled)
      Sets whether the server is utilizing a whitelist.
      Parameters:
      enabled - True to enable the whitelist, false to disable
    • shutdown

      void shutdown()
      Shuts down the server, and kicks all players with the default kick message.
    • shutdown

      void shutdown(Component kickMessage)
      Shuts down the server, and kicks all players with the given message.
      Parameters:
      kickMessage - The message to kick players with
    • gameProfileManager

      GameProfileManager gameProfileManager()
      Gets the GameProfileManager for resolving game profiles.
      Returns:
      This server's game profile manager
    • ticksPerSecond

      double ticksPerSecond()
      Gets the current ticks per second. A tick represents one cycle of the game loop.
      Returns:
      The current ticks per second
    • averageTickTime

      double averageTickTime()
      Gets the current average milliseconds per tick.
      Returns:
      The current average tick time.
    • targetTicksPerSecond

      int targetTicksPerSecond()
      Gets the target ticks per second for this server.

      This is dependent on the implementation.

      Returns:
      The target tick per second rate.
    • setPlayerIdleTimeout

      void setPlayerIdleTimeout(int timeout)
      Sets the player idle timeout, in minutes.
      Parameters:
      timeout - The player idle timeout
    • serviceProvider

      ServiceProvider.ServerScoped serviceProvider()
      Gets the ServiceProvider.ServerScoped, used to provide Sponge services that plugins may provide. Services provided here are scoped to the lifetime of this Server.
      Returns:
      The service manager
    • commandManager

      CommandManager commandManager()
      Gets the CommandManager for executing and inspecting commands.

      Commands must be registered by listening to the RegisterCommandEvent instead.

      Returns:
      The CommandManager instance.
    • mapStorage

      MapStorage mapStorage()
      Gets the map storage for this server

      This allows for control over the server's maps, including obtaining and creating them

      Returns:
      MapStorage