Interface Server

All Superinterfaces:
Audience, ForwardingAudience, Pointered

public interface Server extends ForwardingAudience
The running Fidorial server, entry point to every subsystem a plugin can reach.

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
  • Method Details

    • brandName

      @Contract(pure=true) String brandName()
      Gets the server brand name.
      Returns:
      server brand name
      Since:
      0.1.0
    • minecraftVersion

      @Contract(pure=true) String minecraftVersion()
      Gets the version of Minecraft this server implements.
      Returns:
      the Minecraft version, for instance 26.3
      Since:
      0.1.0
    • protocolVersion

      @Contract(pure=true) int protocolVersion()
      Gets the network protocol version this server speaks.
      Returns:
      the protocol version clients must use to join
      Since:
      0.1.0
    • isRunning

      boolean isRunning()
      Checks whether the server is running.
      Returns:
      true until shutdown() has been requested
      Since:
      0.1.0
    • shutdown

      void shutdown()
      Stops the server: fires ServerStoppingEvent, 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

      @Contract(pure=true) Optional<Favicon> favicon()
      Gets the server's favicon shown in the status ping.
      Returns:
      the server favicon
      Since:
      0.1.0
    • favicon

      @Contract(mutates="this") void favicon(Favicon favicon)
      Sets the server's favicon shown in the status ping.
      Parameters:
      favicon - the server favicon
      Since:
      0.1.0
    • description

      @Contract(pure=true) Component description()
      Gets the server description shown in the status ping.
      Returns:
      server description
      Since:
      0.1.0
    • description

      @Contract(mutates="this") void description(Component description)
      Sets the server description shown in the status ping.
      Parameters:
      description - server description
      Since:
      0.1.0
    • maxPlayers

      @Contract(pure=true) int maxPlayers()
      Gets the maximum player count shown in the status ping.
      Returns:
      maximum player count
      Since:
      0.1.0
    • maxPlayers

      @Contract(mutates="this") void maxPlayers(int maxPlayers)
      Sets the maximum player count shown in the status ping.
      Parameters:
      maxPlayers - maximum player count
      Since:
      0.1.0
    • playerCount

      @Contract(pure=true) int playerCount()
      Gets the current online player count.
      Returns:
      online player count
      Since:
      0.1.0
    • onlinePlayers

      Collection<? extends Player> onlinePlayers()
      Gets the players currently connected.
      Returns:
      the online players
      Since:
      0.1.0
    • player

      Optional<? extends Player> player(UUID uuid)
      Looks up an online player by identity.
      Parameters:
      uuid - the player identity
      Returns:
      the player, or empty if no player with that identity is connected
      Since:
      0.1.0
    • player

      Optional<? extends Player> player(String name)
      Looks up an online player by name, ignoring case.
      Parameters:
      name - the player name
      Returns:
      the player, or empty if no player with that name is connected
      Since:
      0.1.0
    • offlinePlayers

      @Contract(pure=true) OfflinePlayers offlinePlayers()
      Gets the directory of every identity the server knows of, connected or not.
      Returns:
      the offline player directory
      Since:
      0.1.0
    • bans

      @Contract(pure=true) BanManager bans()
      Gets the service holding the players who are not allowed to connect.
      Returns:
      the ban service
      Since:
      0.1.0
    • whitelist

      @Contract(pure=true) WhitelistManager 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

      Optional<? extends World> world(Key key)
      Looks up a loaded world.
      Parameters:
      key - the world key
      Returns:
      the world, or empty if no world is loaded under that key
      Since:
      0.1.0
    • createWorld

      @Contract(mutates="this") World createWorld(WorldSpec spec)
      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

      @Contract(mutates="this") default World createWorld(Key key, WorldGenerator generator)
      Creates a new world driven by the given generator, with a seed of 0.
      Parameters:
      key - the world key
      generator - 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

      @Contract(mutates="this") boolean unloadWorld(Key key, boolean save)
      Unloads the world identified by key, 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, returning false without 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 unload
      save - whether to save the world before unloading it
      Returns:
      true if the world was unloaded, false if the call was refused
      Since:
      0.1.0
    • defaultWorld

      @Contract(pure=true) Optional<Key> 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

      @Contract(mutates="this") void defaultWorld(@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.
      Parameters:
      key - the key of the preferred world, or null to 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 through World.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

      @Contract(pure=true) EventBus 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

      @Contract(pure=true) ServiceRegistry services()
      Gets the registry of services, through which plugins replace the default server behaviour.
      Returns:
      the service registry
      Since:
      0.1.0
    • plugins

      @Contract(pure=true) PluginManager plugins()
      Gets the plugin loader.
      Returns:
      the plugin manager
      Since:
      0.1.0
    • commands

      @Contract(pure=true) CommandRegistry commands()
      Gets the registry of Brigadier commands.
      Returns:
      the command registry
      Since:
      0.1.0
    • permissions

      @Contract(pure=true) PermissionRegistry 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

      @Contract(pure=true) DialogRegistry dialogs()
      Gets the server-wide dialog registry.
      Returns:
      the dialog registry
      Since:
      0.1.0
    • biomes

      @Contract(pure=true) BiomeRegistry biomes()
      Gets the server-wide biome registry.

      Biomes registered there are sent to every client, and may be referenced by generators through GeneratedChunk.setBiome(int, int, int, Key).

      Returns:
      the biome registry
      Since:
      0.1.0
    • dimensionTypes

      @Contract(pure=true) DimensionTypeRegistry dimensionTypes()
      Gets the server-wide dimension type registry.

      Dimension types registered there are sent to every client, and may be returned by generators to shape the worlds they drive.

      Returns:
      the dimension type registry
      Since:
      0.1.0
    • chatTypes

      @Contract(pure=true) ChatTypeRegistry chatTypes()
      Gets the server-wide chat type registry.
      Returns:
      the chat type registry
      Since:
      0.1.0
    • mobs

      @Contract(pure=true) MobRegistry 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

      @Contract(pure=true) ItemRegistry 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