public interface Server extends ChannelRegistrar
Modifier and Type | Method and Description |
---|---|
ListenableFuture<Optional<WorldProperties>> |
copyWorld(WorldProperties worldProperties,
String copyName)
Creates a world copy asynchronously using the new name given and returns
the new world properties if the copy was possible.
|
Optional<WorldProperties> |
createWorld(WorldCreationSettings settings)
Creates a new world from the given
WorldCreationSettings . |
ListenableFuture<Boolean> |
deleteWorld(WorldProperties worldProperties)
Deletes the provided world's files asynchronously from the disk.
|
Collection<WorldProperties> |
getAllWorldProperties()
Gets the properties of all worlds, loaded or otherwise.
|
Optional<InetSocketAddress> |
getBoundAddress()
Gets the bound
InetSocketAddress from where this server is accepting
connections. |
MessageSink |
getBroadcastSink()
Get the sink that messages to be broadcast across the whole server
should be sent to.
|
ChunkLayout |
getChunkLayout()
Returns information about the chunk layout used by this server
implementation.
|
ChunkLoadService |
getChunkLoadService()
Gets the ChunkLoadService used for requesting tickets to force load chunks.
|
ConsoleSource |
getConsole()
Gets the command source used for commands coming from this server's console.
|
Optional<WorldProperties> |
getDefaultWorld()
Gets the properties of default world.
|
int |
getMaxPlayers()
Gets the max players allowed on this server.
|
Text |
getMotd()
Gets the default message that is displayed in the server list of the
client.
|
boolean |
getOnlineMode()
Tests if this server is set to online mode.
|
Collection<Player> |
getOnlinePlayers()
Gets the
Player s currently online. |
Optional<Player> |
getPlayer(String name)
Gets a
Player by their name |
Optional<Player> |
getPlayer(UUID uniqueId)
Gets a
Player by their unique id |
int |
getRunningTimeTicks()
Gets the time, in ticks, since this server began running for the current
session.
|
double |
getTicksPerSecond()
Gets the current ticks per second.
|
Collection<WorldProperties> |
getUnloadedWorlds()
Gets the properties of all unloaded worlds.
|
Optional<World> |
getWorld(String worldName)
Gets a loaded
World by name, if it exists. |
Optional<World> |
getWorld(UUID uniqueId)
|
Optional<WorldProperties> |
getWorldProperties(String worldName)
Gets the
WorldProperties of a world. |
Optional<WorldProperties> |
getWorldProperties(UUID uniqueId)
Gets the
WorldProperties of a world. |
Collection<World> |
getWorlds()
Gets all currently loaded
World s. |
boolean |
hasWhitelist()
Tests if the server has a whitelist enabled.
|
Optional<World> |
loadWorld(String worldName)
Loads a
World from the default storage container. |
Optional<World> |
loadWorld(UUID uniqueId)
Loads a
World from the default storage container. |
Optional<World> |
loadWorld(WorldProperties properties)
Loads a
World from the default storage container. |
Optional<WorldProperties> |
renameWorld(WorldProperties worldProperties,
String newName)
Renames an unloaded world.
|
boolean |
saveWorldProperties(WorldProperties properties)
Persists the given
WorldProperties to the world storage for it,
updating any modified values. |
void |
setHasWhitelist(boolean enabled)
Sets whether the server is utilizing a whitelist.
|
void |
shutdown()
Shuts down the server, and kicks all players with the default kick
message.
|
void |
shutdown(Text kickMessage)
Shuts down the server, and kicks all players with the given message.
|
boolean |
unloadWorld(World world)
Unloads a
World , if there are any connected players in the given
world then no operation will occur. |
getRegisteredChannels, registerChannel
Collection<Player> getOnlinePlayers()
Player
s currently online.Collection
of online playersint getMaxPlayers()
Optional<Player> getPlayer(UUID uniqueId)
Player
by their unique iduniqueId
- The UUID to get the player fromPlayer
or Optional.absent() if not foundOptional<Player> getPlayer(String name)
Player
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 fromPlayer
or Optional.absent() if not foundCollection<World> getWorlds()
World
s.Collection<WorldProperties> getUnloadedWorlds()
Collection<WorldProperties> getAllWorldProperties()
Optional<World> getWorld(UUID uniqueId)
uniqueId
- UUID to lookupOptional<World> getWorld(String worldName)
World
by name, if it exists.worldName
- Name to lookupOptional<WorldProperties> getDefaultWorld()
Optional<World> loadWorld(String worldName)
World
from the default storage container. If a world with
the given name is already loaded then it is returned instead.worldName
- The name to lookupOptional<World> loadWorld(UUID uniqueId)
World
from the default storage container. If a world with
the given UUID is already loaded then it is returned instead.uniqueId
- The UUID to lookupOptional<World> loadWorld(WorldProperties properties)
World
from the default storage container. If the world
associated with the given properties is already loaded then it is
returned instead.properties
- The properties of the world to loadOptional<WorldProperties> getWorldProperties(String worldName)
WorldProperties
of a world. If a world with the given
name is loaded then this is equivalent to calling
World.getProperties()
. However, if no loaded world is found then
an attempt will be made to match unloaded worlds.worldName
- The name to lookupOptional<WorldProperties> getWorldProperties(UUID uniqueId)
WorldProperties
of a world. If a world with the given
UUID is loaded then this is equivalent to calling
World.getProperties()
. However, if no loaded world is found then
an attempt will be made to match unloaded worlds.uniqueId
- The UUID to lookupboolean unloadWorld(World world)
World
, if there are any connected players in the given
world then no operation will occur.
A world which is unloaded will be removed from memory. However if it
is still enabled according to WorldProperties.isEnabled()
then it
will be loaded again if the server is restarted or an attempt is made by
a plugin to transfer an entity to the world using
Entity.transferToWorld(String, Vector3d)
.
world
- The world to unloadOptional<WorldProperties> createWorld(WorldCreationSettings settings)
WorldCreationSettings
. For the
creation of the WorldCreationSettings please see
WorldBuilder
.
If the world already exists then the existing WorldProperties
are returned else a new world is created and the new WorldProperties
returned.
Although the world is created it is not loaded at this time. Please see one of the following methods for loading the world.
settings
- The settings for creationListenableFuture<Optional<WorldProperties>> copyWorld(WorldProperties worldProperties, String copyName)
If the world is already loaded then the following will occur:
worldProperties
- The world properties to copycopyName
- The name for copied worldOptional
containing the properties of the new world
instance, if the copy was successfulOptional<WorldProperties> renameWorld(WorldProperties worldProperties, String newName)
worldProperties
- The world properties to renamenewName
- The name that should be used as a replacement for the
current world nameOptional
containing the new WorldProperties
if the rename was successfulListenableFuture<Boolean> deleteWorld(WorldProperties worldProperties)
worldProperties
- The world properties to deleteboolean saveWorldProperties(WorldProperties properties)
WorldProperties
to the world storage for it,
updating any modified values.properties
- The world properties to saveChunkLayout getChunkLayout()
int getRunningTimeTicks()
This value is not persisted across server restarts, it is set to zero each time the server starts.
MessageSink getBroadcastSink()
Optional<InetSocketAddress> getBoundAddress()
InetSocketAddress
from where this server is accepting
connections.boolean hasWhitelist()
void setHasWhitelist(boolean enabled)
enabled
- True to enable the whitelist, false to disableboolean getOnlineMode()
Text getMotd()
void shutdown()
void shutdown(Text kickMessage)
kickMessage
- The message to kick players withConsoleSource getConsole()
ChunkLoadService getChunkLoadService()
double getTicksPerSecond()
Note: The server aims to limit itself at 20 ticks per second. Lower ticks per second may elude to the server taking more time to process information per tick. Examples of overburdening the server per tick include spawning 10,000 cows in a small area.