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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.kyori.adventure.audience.ForwardingAudience
ForwardingAudience.Single
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
areCommandBlocksEnabled()
Gets ifcommand blocks
will run commands.double
averageTickTime()
Gets the current average milliseconds per tick.java.util.Optional<java.net.InetSocketAddress>
boundAddress()
Gets the boundInetSocketAddress
from where this server is accepting connections.Audience
broadcastAudience()
Gets the message channel that server-wide messages are sent through.ChunkLayout
chunkLayout()
Returns information about the chunk layout used by this server implementation.CommandManager
commandManager()
Gets theCommandManager
for executing and inspecting commands.Difficulty
difficulty()
Gets theDifficulty
.GameMode
gameMode()
Gets theGameMode
.GameProfileManager
gameProfileManager()
Gets theGameProfileManager
for resolving game profiles.boolean
isAnimalSpawnsEnabled()
Gets ifanimals
will naturally spawn.boolean
isDedicatedServer()
Gets whether this server is dedicated to being a global server, or whether this server is local to a game client where aClient
instance may be available.boolean
isGameModeEnforced()
boolean
isHardcoreModeEnabled()
Gets if hardcode mode has been enabled.boolean
isMonsterSpawnsEnabled()
Gets ifmonsters
will naturally spawn.boolean
isMultiWorldEnabled()
Gets if multipleworlds
will be loaded by the server.boolean
isOnlineModeEnabled()
Gets if incomingconnections
are authenticated against Mojang's servers.boolean
isPVPEnabled()
Gets if pvp is enabled.boolean
isWhitelistEnabled()
Gets if the whitelist is currently enforced.MapStorage
mapStorage()
Gets the map storage for this serverint
maxPlayers()
Gets the maxplayers
allowed to join.Component
motd()
Gets the "message of the day" presented to clients who have this server saved as a connection profile in the multiplayer menujava.util.Collection<ServerPlayer>
onlinePlayers()
Gets theServerPlayer
s currently online.java.util.Optional<ServerPlayer>
player(java.lang.String name)
Gets aServerPlayer
by their name.java.util.Optional<ServerPlayer>
player(java.util.UUID uniqueId)
Gets aServerPlayer
by their UUID.int
playerIdleTimeout()
Gets the player idle timeout, in minutes.RecipeManager
recipeManager()
Retrieves theRecipeManager
.java.util.Optional<ResourcePack>
resourcePack()
Gets thepack
sent to clients when they join.Ticks
runningTimeTicks()
Gets the time, in ticks, since this server began running for the current session.java.util.Optional<? extends Scoreboard>
serverScoreboard()
Gets the 'server' scoreboard.ServiceProvider.ServerScoped
serviceProvider()
Gets theServiceProvider.ServerScoped
, used to provide Sponge services that plugins may provide.void
setBroadcastAudience(Audience channel)
Sets the channel that server-wide messages should be sent through.void
setHasWhitelist(boolean enabled)
Sets whether the server is utilizing a whitelist.void
setPlayerIdleTimeout(int timeout)
Sets the player idle timeout, in minutes.void
shutdown()
Shuts down the server, and kicks all players with the default kick message.void
shutdown(Component kickMessage)
Shuts down the server, and kicks all players with the given message.int
targetTicksPerSecond()
Gets the target ticks per second for this server.TeleportHelper
teleportHelper()
Gets theTeleportHelper
, used to find safeServerLocation
s.double
ticksPerSecond()
Gets the current ticks per second.UserManager
userManager()
Gets theUserManager
.WorldGenerationConfig
worldGenerationConfig()
Gets theWorldGenerationConfig
.WorldManager
worldManager()
Gets theWorldManager
.-
Methods inherited from interface net.kyori.adventure.audience.Audience
deleteMessage, openBook, sendActionBar, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeaderAndFooter, showTitle, stopSound
-
Methods inherited from interface org.spongepowered.api.Engine
causeStackManager, game, onMainThread, packRepository, reloadResources, resourceManager, scheduler
-
Methods inherited from interface net.kyori.adventure.audience.ForwardingAudience
audiences, clearTitle, deleteMessage, filterAudience, forEachAudience, hideBossBar, openBook, playSound, playSound, playSound, pointers, resetTitle, sendActionBar, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendTitlePart, showBossBar, stopSound
-
Methods inherited from interface org.spongepowered.api.util.locale.LocaleSource
locale
-
Methods inherited from interface net.kyori.adventure.pointer.Pointered
get, getOrDefault, getOrDefaultFrom
-
Methods inherited from interface org.spongepowered.api.registry.RegistryHolder
findRegistry, registry, streamRegistries
-
-
-
-
Method Detail
-
worldManager
WorldManager worldManager()
Gets theWorldManager
.- Returns:
- The world manager
-
recipeManager
RecipeManager recipeManager()
Retrieves theRecipeManager
.- Returns:
- The recipe manager
-
isMultiWorldEnabled
boolean isMultiWorldEnabled()
Gets if multipleworlds
will be loaded by the server.If false, no calls to loading worlds via the
world manager
or otherwise will load a world- Returns:
- True if enabled, false if not
-
worldGenerationConfig
WorldGenerationConfig worldGenerationConfig()
Gets theWorldGenerationConfig
.- Returns:
- The world generator config
-
maxPlayers
int maxPlayers()
Gets the maxplayers
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 incomingconnections
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
java.util.Optional<ResourcePack> resourcePack()
Gets thepack
sent to clients when they join.- Returns:
- The resource pack
-
playerIdleTimeout
int playerIdleTimeout()
Gets the player idle timeout, in minutes.A value of
0
means the timeout is disabled- 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 theDifficulty
.- Returns:
- The difficulty
-
isGameModeEnforced
boolean isGameModeEnforced()
- 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 ifcommand blocks
will run commands.- Returns:
- True if enabled, false if not
-
isMonsterSpawnsEnabled
boolean isMonsterSpawnsEnabled()
Gets ifmonsters
will naturally spawn.- Returns:
- True if enabled, false if not
-
isAnimalSpawnsEnabled
boolean isAnimalSpawnsEnabled()
Gets ifanimals
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 aClient
instance may be available.- Returns:
- True if this is a dedicated server without a game client
-
userManager
UserManager userManager()
Gets theUserManager
.- Returns:
- The user manager
-
teleportHelper
TeleportHelper teleportHelper()
Gets theTeleportHelper
, used to find safeServerLocation
s.- Returns:
- The teleport helper
-
onlinePlayers
java.util.Collection<ServerPlayer> onlinePlayers()
Gets theServerPlayer
s currently online.- Returns:
- A
Collection
of online players
-
player
java.util.Optional<ServerPlayer> player(java.util.UUID uniqueId)
Gets aServerPlayer
by their UUID.- Parameters:
uniqueId
- The UUID to get the player from- Returns:
- The
ServerPlayer
or empty if not found
-
player
java.util.Optional<ServerPlayer> player(java.lang.String name)
Gets aServerPlayer
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.
- Parameters:
name
- The name to get the player from- Returns:
- The
ServerPlayer
or empty if not found
-
serverScoreboard
java.util.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.
- 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.This value is not persisted across server restarts, it is set to zero each time the server starts.
- 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
java.util.Optional<java.net.InetSocketAddress> boundAddress()
Gets the boundInetSocketAddress
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.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.- Parameters:
kickMessage
- The message to kick players with
-
gameProfileManager
GameProfileManager gameProfileManager()
Gets theGameProfileManager
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.A value of
0
disables the player idle timeout.- Parameters:
timeout
- The player idle timeout
-
serviceProvider
ServiceProvider.ServerScoped serviceProvider()
Gets theServiceProvider.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.- Returns:
- The service manager
-
commandManager
CommandManager commandManager()
Gets theCommandManager
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 serverThis allows for control over the server's maps, including obtaining and creating them
- Returns:
- MapStorage
-
-