Interface Server

    • Method Detail

      • isMultiWorldEnabled

        boolean isMultiWorldEnabled()
        Gets if multiple worlds will be loaded by the server.

        If false, no calls to loading worlds via the world manager or otherwise will load a world

        True if enabled, false if not
      • maxPlayers

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

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

        boolean isOnlineModeEnabled()
        Gets if incoming connections are authenticated against Mojang's servers.
        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
        The message of the day
      • resourcePack

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

        int playerIdleTimeout()
        Gets the player idle timeout, in minutes.

        A value of 0 means the timeout is disabled

        The player idle timeout
      • isHardcoreModeEnabled

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

        boolean isGameModeEnforced()
        Gets if players will have their game mode set to the default. gameMode()
        True if enforced, false if not
      • isPVPEnabled

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

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

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

        boolean isAnimalSpawnsEnabled()
        Gets if animals will naturally spawn.
        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.
        True if this is a dedicated server without a game client
      • player

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

        This only works for online players.

        Note: Do not use names for persistent storage, the Notch of today may not be the Notch of yesterday.

        name - The name to get the player from
        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.

        The server scoreboard may not be available if dimension 0 is not yet loaded. In Vanilla, this will only occur when the server is first starting, as dimension 0 is normally always loaded.

        the server scoreboard, if available.
      • chunkLayout

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

        Ticks runningTimeTicks()
        Gets the time, in ticks, since this server began running for the current session.

        This value is not persisted across server restarts, it is set to zero each time the server starts.

        The number of ticks since this server started running
      • broadcastAudience

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

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

        void setHasWhitelist​(boolean enabled)
        Sets whether the server is utilizing a whitelist.
        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.

        For the Sponge implementation on the client, this will trigger the Integrated Server to shutdown a tick later.

      • shutdown

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

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

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

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

        This is dependent on the implementation.

        The target tick per second rate.
      • setPlayerIdleTimeout

        void setPlayerIdleTimeout​(int timeout)
        Sets the player idle timeout, in minutes.

        A value of 0 disables the player idle timeout.

        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.

        The provider will not be available during plugin construction and will throw an IllegalStateException if there is an attempt to access this before the provider is ready.

        The service manager
      • mapStorage

        MapStorage mapStorage()
        Gets the map storage for this server

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