Package net.minestom.server
Class MinecraftServer
java.lang.Object
net.minestom.server.MinecraftServer
The main server class used to start the server and retrieve all the managers.
The server needs to be initialized with init()
and started with start(String, int)
.
You should register all of your dimensions, biomes, commands, events, etc... in-between.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AdvancementManager
static @NotNull BenchmarkManager
Gets the manager handling server monitoring.static BiomeManager
static @NotNull BlockManager
static @NotNull BossBarManager
static @NotNull String
Gets the current server brand name.static int
Gets the chunk view distance of the server.static @NotNull CommandManager
static int
Gets the compression threshold of the server.static @NotNull ConnectionManager
static @NotNull Difficulty
Gets the server difficulty showed in game option.static DimensionTypeManager
static int
Gets the entity view distance of the server.static @NotNull ExceptionManager
static ExtensionManager
static @NotNull GlobalEventHandler
static @NotNull InstanceManager
static @NotNull PacketListenerManager
static @NotNull PacketProcessor
static @NotNull RecipeManager
static @NotNull SchedulerManager
static Server
static TagManager
static @NotNull TeamManager
static MinecraftServer
init()
static boolean
static boolean
static boolean
Gets if the built in Minestom terminal is enabled.static @UnknownNullability ServerProcess
process()
static void
setBrandName
(@NotNull String brandName) Changes the server brand name and send the change to all connected players.static void
setChunkViewDistance
(int chunkViewDistance) Deprecated.should instead be defined with a java propertystatic void
setCompressionThreshold
(int compressionThreshold) Changes the compression threshold of the server.static void
setDifficulty
(@NotNull Difficulty difficulty) Changes the server difficulty and send the appropriate packet to all connected clients.static void
setEntityViewDistance
(int entityViewDistance) Deprecated.should instead be defined with a java propertystatic void
setTerminalEnabled
(boolean enabled) Enabled/disables the built in Minestom terminal.void
void
start
(@NotNull SocketAddress address) Starts the server.static void
Stops this server properly (saves if needed, kicking players, etc.)static ServerProcess
-
Field Details
-
LOGGER
public static final net.kyori.adventure.text.logger.slf4j.ComponentLogger LOGGER -
VERSION_NAME
- See Also:
-
PROTOCOL_VERSION
public static final int PROTOCOL_VERSION- See Also:
-
THREAD_NAME_BENCHMARK
- See Also:
-
THREAD_NAME_TICK_SCHEDULER
- See Also:
-
THREAD_NAME_TICK
- See Also:
-
TICK_PER_SECOND
public static final int TICK_PER_SECOND -
TICK_MS
public static final int TICK_MS
-
-
Constructor Details
-
MinecraftServer
public MinecraftServer()
-
-
Method Details
-
init
-
updateProcess
-
getBrandName
Gets the current server brand name.- Returns:
- the server brand name
-
setBrandName
Changes the server brand name and send the change to all connected players.- Parameters:
brandName
- the server brand name- Throws:
NullPointerException
- ifbrandName
is null
-
getDifficulty
Gets the server difficulty showed in game option.- Returns:
- the server difficulty
-
setDifficulty
Changes the server difficulty and send the appropriate packet to all connected clients.- Parameters:
difficulty
- the new server difficulty
-
process
-
getGlobalEventHandler
-
getPacketListenerManager
-
getInstanceManager
-
getBlockManager
-
getCommandManager
-
getRecipeManager
-
getTeamManager
-
getSchedulerManager
-
getBenchmarkManager
Gets the manager handling server monitoring.- Returns:
- the benchmark manager
-
getExceptionManager
-
getConnectionManager
-
getBossBarManager
-
getPacketProcessor
-
isStarted
public static boolean isStarted() -
isStopping
public static boolean isStopping() -
getChunkViewDistance
public static int getChunkViewDistance()Gets the chunk view distance of the server.- Returns:
- the chunk view distance
-
setChunkViewDistance
Deprecated.should instead be defined with a java propertyChanges the chunk view distance of the server.- Parameters:
chunkViewDistance
- the new chunk view distance- Throws:
IllegalArgumentException
- ifchunkViewDistance
is not between 2 and 32
-
getEntityViewDistance
public static int getEntityViewDistance()Gets the entity view distance of the server.- Returns:
- the entity view distance
-
setEntityViewDistance
Deprecated.should instead be defined with a java propertyChanges the entity view distance of the server.- Parameters:
entityViewDistance
- the new entity view distance- Throws:
IllegalArgumentException
- ifentityViewDistance
is not between 0 and 32
-
getCompressionThreshold
public static int getCompressionThreshold()Gets the compression threshold of the server.- Returns:
- the compression threshold, 0 means that compression is disabled
-
setCompressionThreshold
public static void setCompressionThreshold(int compressionThreshold) Changes the compression threshold of the server.WARNING: this need to be called before
start(SocketAddress)
.- Parameters:
compressionThreshold
- the new compression threshold, 0 to disable compression- Throws:
IllegalStateException
- if this is called after the server started
-
isTerminalEnabled
public static boolean isTerminalEnabled()Gets if the built in Minestom terminal is enabled.- Returns:
- true if the terminal is enabled
-
setTerminalEnabled
public static void setTerminalEnabled(boolean enabled) Enabled/disables the built in Minestom terminal.- Parameters:
enabled
- true to enable, false to disable
-
getDimensionTypeManager
-
getBiomeManager
-
getAdvancementManager
-
getExtensionManager
-
getTagManager
-
getServer
-
start
Starts the server.It should be called after
init()
and probably your own initialization code.- Parameters:
address
- the server address- Throws:
IllegalStateException
- if called beforeinit()
or if the server is already running
-
start
-
stopCleanly
public static void stopCleanly()Stops this server properly (saves if needed, kicking players, etc.)
-