Interface Server
- All Superinterfaces:
Audience, ForwardingAudience, Pointered
A plugin obtains it through PluginContext.server(). As a
ForwardingAudience, the server forwards anything sent to it to every
online player.
- Since:
- 0.1.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface ForwardingAudience
ForwardingAudience.Single -
Method Summary
Modifier and TypeMethodDescriptionbans()Gets the service holding the players who are not allowed to connect.biomes()Gets the server-wide biome registry.Gets the server brand name.Gets the server-wide chat type registry.commands()Gets the registry of Brigadier commands.createWorld(WorldSpec spec) Creates a new world from the given specification.default WorldcreateWorld(Key key, WorldGenerator generator) Creates a new world driven by the given generator, with a seed of0.Returns the key of the world currently preferred as the server's default, or Optional.empty() if none is configured.voiddefaultWorld(@Nullable Key key) Sets the world that should be preferred as the server's default when resolving a fallback world for players and commands with no other context.Gets the server description shown in the status ping.voiddescription(Component description) Sets the server description shown in the status ping.dialogs()Gets the server-wide dialog registry.Gets the server-wide dimension type registry.events()Gets the server-wide event bus.favicon()Gets the server's favicon shown in the status ping.voidSets the server's favicon shown in the status ping.The base game rules of the server: the overworld's, which every world follows unless it overrides them throughWorld.gameRules().booleanChecks whether the server is running.items()Gets the server-wide item registry.intGets the maximum player count shown in the status ping.voidmaxPlayers(int maxPlayers) Sets the maximum player count shown in the status ping.Gets the version of Minecraft this server implements.mobs()Gets the server-wide mob registry.Gets the directory of every identity the server knows of, connected or not.Collection<? extends Player> Gets the players currently connected.Gets the server-wide permission registry.Looks up an online player by name, ignoring case.Looks up an online player by identity.intGets the current online player count.plugins()Gets the plugin loader.intGets the network protocol version this server speaks.Gets the scheduler running tasks on the region threads.services()Gets the registry of services, through which plugins replace the default server behaviour.voidshutdown()Stops the server: firesServerStoppingEvent, kicks every player, disables the plugins and saves the worlds.Datapack structures: packs of<world>/datapacks, templates, jigsaw structures, placement and/locate-style search.Gets the store rendering translatable components for a given locale.booleanunloadWorld(Key key, boolean save) Unloads the world identified bykey, optionally saving it to disk first.Gets the service holding the players allowed to connect while the whitelist is enforced.Looks up a loaded world.Collection<? extends World> worlds()Gets the worlds currently loaded.Methods inherited from interface Audience
deleteMessage, openBook, openBook, removeResourcePacks, removeResourcePacks, removeResourcePacks, sendActionBar, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendResourcePacks, sendResourcePacks, showTitle, stopSoundMethods inherited from interface ForwardingAudience
audiences, clearResourcePacks, clearTitle, closeDialog, deleteMessage, filterAudience, forEachAudience, hideBossBar, openBook, playSound, playSound, playSound, pointers, removeResourcePacks, removeResourcePacks, resetTitle, sendActionBar, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendResourcePacks, sendTitlePart, showBossBar, showDialog, stopSoundMethods inherited from interface Pointered
get, getOrDefault, getOrDefaultFrom
-
Method Details
-
brandName
-
minecraftVersion
-
protocolVersion
-
isRunning
boolean isRunning()Checks whether the server is running.- Returns:
trueuntilshutdown()has been requested- Since:
- 0.1.0
-
shutdown
void shutdown()Stops the server: firesServerStoppingEvent, kicks every player, disables the plugins and saves the worlds.Calling it again once the shutdown has started does nothing.
- Since:
- 0.1.0
-
favicon
-
favicon
-
description
-
description
-
maxPlayers
-
maxPlayers
-
playerCount
-
onlinePlayers
Collection<? extends Player> onlinePlayers()Gets the players currently connected.- Returns:
- the online players
- Since:
- 0.1.0
-
player
-
player
-
offlinePlayers
Gets the directory of every identity the server knows of, connected or not.- Returns:
- the offline player directory
- Since:
- 0.1.0
-
bans
Gets the service holding the players who are not allowed to connect.- Returns:
- the ban service
- Since:
- 0.1.0
-
whitelist
Gets the service holding the players allowed to connect while the whitelist is enforced.- Returns:
- the whitelist service
- Since:
- 0.1.0
-
worlds
Collection<? extends World> worlds()Gets the worlds currently loaded.- Returns:
- the loaded worlds
- Since:
- 0.1.0
-
world
-
createWorld
Creates a new world from the given specification.If a world is already registered under the spec's key, that existing world is returned unchanged and the rest of the spec (seed, generator) is ignored; this call is therefore idempotent with respect to the world key. Otherwise a new world is registered using the spec's generator, or the server's built-in default generator when the spec supplies none.
The returned world is immediately usable: it participates in ticking and its chunks are generated on demand through the configured generator.
- Parameters:
spec- the description of the world to create- Returns:
- the newly created world, or the existing world sharing the same key
- Since:
- 0.1.0
-
createWorld
Creates a new world driven by the given generator, with a seed of0.- Parameters:
key- the world keygenerator- the chunk generator to drive the new world- Returns:
- the newly created world, or the existing world sharing the same key
- Since:
- 0.1.0
- See Also:
-
unloadWorld
Unloads the world identified bykey, optionally saving it to disk first.Unloading removes the world from
worlds()and stops it being ticked; entities it held are released. The call is refused, returningfalsewithout side effects, when:- no world is registered under
key; - the world is the only one currently loaded; at least one world must always remain; or
- players are still present in the world; relocate them with another world first.
- Parameters:
key- the key of the world to unloadsave- whether to save the world before unloading it- Returns:
trueif the world was unloaded,falseif the call was refused- Since:
- 0.1.0
- no world is registered under
-
defaultWorld
Returns the key of the world currently preferred as the server's default, or Optional.empty() if none is configured.- Returns:
- the key of the world currently preferred as the server's default, or Optional.empty() if none is configured
- Since:
- 0.1.0
-
defaultWorld
Sets the world that should be preferred as the server's default when resolving a fallback world for players and commands with no other context.- Parameters:
key- the key of the preferred world, ornullto clear the preference- Since:
- 0.1.0
-
gameRules
GameRules gameRules()The base game rules of the server: the overworld's, which every world follows unless it overrides them throughWorld.gameRules().- Returns:
- the base game rules, as changed by
/gamerule <rule> <value> - Since:
- 0.1.0
-
structures
StructureManager structures()Datapack structures: packs of<world>/datapacks, templates, jigsaw structures, placement and/locate-style search.- Returns:
- the structure manager of the server
- Since:
- 0.1.0
-
scheduler
Gets the scheduler running tasks on the region threads.- Returns:
- the regionized scheduler
- Since:
- 0.1.0
-
events
Gets the server-wide event bus.Plugins should prefer
PluginContext.events(), whose subscriptions are released automatically when the plugin is disabled.- Returns:
- the event bus
- Since:
- 0.1.0
-
services
Gets the registry of services, through which plugins replace the default server behaviour.- Returns:
- the service registry
- Since:
- 0.1.0
-
plugins
Gets the plugin loader.- Returns:
- the plugin manager
- Since:
- 0.1.0
-
commands
Gets the registry of Brigadier commands.- Returns:
- the command registry
- Since:
- 0.1.0
-
permissions
Gets the server-wide permission registry.- Returns:
- the permission registry
- Since:
- 0.1.0
-
translationStore
TranslationStore translationStore()Gets the store rendering translatable components for a given locale.- Returns:
- the active translation store
- Since:
- 0.1.0
-
dialogs
Gets the server-wide dialog registry.- Returns:
- the dialog registry
- Since:
- 0.1.0
-
biomes
Gets the server-wide biome registry.Biomes registered there are sent to every client, and may be referenced by
generatorsthroughGeneratedChunk.setBiome(int, int, int, Key).- Returns:
- the biome registry
- Since:
- 0.1.0
-
dimensionTypes
Gets the server-wide dimension type registry.Dimension types registered there are sent to every client, and may be returned by
generatorsto shape the worlds they drive.- Returns:
- the dimension type registry
- Since:
- 0.1.0
-
chatTypes
Gets the server-wide chat type registry.- Returns:
- the chat type registry
- Since:
- 0.1.0
-
mobs
Gets the server-wide mob registry.Where plugins attach behaviours to the built-in mobs, and register mobs of their own.
- Returns:
- the mob registry
- Since:
- 0.1.0
-
items
Gets the server-wide item registry.Where plugins register items of their own, rendered client-side as the vanilla item they name.
- Returns:
- the item registry
- Since:
- 0.1.0
-