Package net.minestom.server
Class MinecraftServer
java.lang.Object
net.minestom.server.MinecraftServer
public final class MinecraftServer
extends java.lang.Object
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 Modifier and Type Field Description static int
PROTOCOL_VERSION
static int
THREAD_COUNT_BLOCK_BATCH
static int
THREAD_COUNT_PARALLEL_CHUNK_SAVING
static int
THREAD_COUNT_SCHEDULER
static java.lang.String
THREAD_NAME_BENCHMARK
static java.lang.String
THREAD_NAME_BLOCK_BATCH
static java.lang.String
THREAD_NAME_MAIN_UPDATE
static java.lang.String
THREAD_NAME_PARALLEL_CHUNK_SAVING
static java.lang.String
THREAD_NAME_SCHEDULER
static java.lang.String
THREAD_NAME_TICK
static int
TICK_MS
static int
TICK_PER_SECOND
static java.lang.String
VERSION_NAME
-
Constructor Summary
Constructors Constructor Description MinecraftServer()
-
Method Summary
Modifier and Type Method Description static AdvancementManager
getAdvancementManager()
Gets the manager handling advancements.static BenchmarkManager
getBenchmarkManager()
Gets the manager handling server monitoring.static BiomeManager
getBiomeManager()
Gets the manager handling biomes.static BlockManager
getBlockManager()
Gets the manager handlingCustomBlock
andBlockPlacementRule
.static java.lang.String
getBrandName()
Gets the current server brand name.static int
getChunkViewDistance()
Gets the chunk view distance of the server.static CommandManager
getCommandManager()
Gets the manager handling commands.static int
getCompressionThreshold()
Gets the compression threshold of the server.static ConnectionManager
getConnectionManager()
Gets the manager handling server connections.static DataManager
getDataManager()
Gets the manager handlingDataType
used bySerializableData
.static Difficulty
getDifficulty()
Gets the server difficulty showed in game option.static DimensionTypeManager
getDimensionTypeManager()
Gets the manager handling dimensions.static EntityManager
getEntityManager()
Gets the manager handling waiting players.static int
getEntityViewDistance()
Gets the entity view distance of the server.static ExtensionManager
getExtensionManager()
Get the manager handlingExtension
.static InstanceManager
getInstanceManager()
Gets the manager handling all registered instances.static LootTableManager
getLootTableManager()
Gets the manager handling loot tables.static int
getMaxPacketSize()
Gets the maximum packet size (in bytes) that a client can send without getting disconnected.static NettyServer
getNettyServer()
Gets the netty server.static PacketListenerManager
getPacketListenerManager()
Gets the manager handling all incoming packetsstatic PacketProcessor
getPacketProcessor()
Gets the object handling the client packets processing.static int
getRateLimit()
Gets the maximum number of packets a client can send over 1 second.static RecipeManager
getRecipeManager()
Gets the manager handling recipes show to the clients.static ResponseDataConsumer
getResponseDataConsumer()
Gets the consumer executed to show server-list data.static SchedulerManager
getSchedulerManager()
Gets the manager handling scheduled tasks.static StorageManager
getStorageManager()
Gets the manager handling storage.static TagManager
getTagManager()
Gets the manager handling tags.static TeamManager
getTeamManager()
Gets the manager handling teams.static UpdateManager
getUpdateManager()
Gets the manager handling the server ticks.static MinecraftServer
init()
static boolean
isStarted()
Gets if the server is up and running.static void
setBrandName(java.lang.String brandName)
Changes the server brand name and send the change to all connected players.static void
setChunkViewDistance(int chunkViewDistance)
Changes the chunk view distance of the server.static void
setCompressionThreshold(int compressionThreshold)
Changes the compression threshold of the server.static void
setDifficulty(Difficulty difficulty)
Changes the server difficulty and send the appropriate packet to all connected clients.static void
setEntityViewDistance(int entityViewDistance)
Changes the entity view distance of the server.static void
setMaxPacketSize(int maxPacketSize)
Changes the maximum packet size (in bytes) that a client can send without getting disconnected.static void
setRateLimit(int rateLimit)
Changes the number of packet a client can send over 1 second without being disconnected.void
start(java.lang.String address, int port)
Starts the server.void
start(java.lang.String address, int port, ResponseDataConsumer responseDataConsumer)
Starts the server.static void
stopCleanly()
Stops this server properly (saves if needed, kicking players, etc.)
-
Field Details
-
VERSION_NAME
public static final java.lang.String VERSION_NAME- See Also:
- Constant Field Values
-
PROTOCOL_VERSION
public static final int PROTOCOL_VERSION- See Also:
- Constant Field Values
-
THREAD_NAME_BENCHMARK
public static final java.lang.String THREAD_NAME_BENCHMARK- See Also:
- Constant Field Values
-
THREAD_NAME_MAIN_UPDATE
public static final java.lang.String THREAD_NAME_MAIN_UPDATE- See Also:
- Constant Field Values
-
THREAD_NAME_TICK
public static final java.lang.String THREAD_NAME_TICK- See Also:
- Constant Field Values
-
THREAD_NAME_BLOCK_BATCH
public static final java.lang.String THREAD_NAME_BLOCK_BATCH- See Also:
- Constant Field Values
-
THREAD_COUNT_BLOCK_BATCH
public static final int THREAD_COUNT_BLOCK_BATCH- See Also:
- Constant Field Values
-
THREAD_NAME_SCHEDULER
public static final java.lang.String THREAD_NAME_SCHEDULER- See Also:
- Constant Field Values
-
THREAD_COUNT_SCHEDULER
public static final int THREAD_COUNT_SCHEDULER- See Also:
- Constant Field Values
-
THREAD_NAME_PARALLEL_CHUNK_SAVING
public static final java.lang.String THREAD_NAME_PARALLEL_CHUNK_SAVING- See Also:
- Constant Field Values
-
THREAD_COUNT_PARALLEL_CHUNK_SAVING
public static final int THREAD_COUNT_PARALLEL_CHUNK_SAVING- See Also:
- Constant Field Values
-
TICK_PER_SECOND
public static final int TICK_PER_SECOND- See Also:
- Constant Field Values
-
TICK_MS
public static final int TICK_MS- See Also:
- Constant Field Values
-
-
Constructor Details
-
MinecraftServer
public MinecraftServer()
-
-
Method Details
-
init
-
getBrandName
@NotNull public static java.lang.String getBrandName()Gets the current server brand name.- Returns:
- the server brand name
-
setBrandName
public static void setBrandName(@NotNull java.lang.String brandName)Changes the server brand name and send the change to all connected players.- Parameters:
brandName
- the server brand name- Throws:
java.lang.NullPointerException
- ifbrandName
is null
-
getRateLimit
public static int getRateLimit()Gets the maximum number of packets a client can send over 1 second.- Returns:
- the packet count limit over 1 second, 0 if not enabled
-
setRateLimit
public static void setRateLimit(int rateLimit)Changes the number of packet a client can send over 1 second without being disconnected.- Parameters:
rateLimit
- the number of packet, 0 to disable
-
getMaxPacketSize
public static int getMaxPacketSize()Gets the maximum packet size (in bytes) that a client can send without getting disconnected.- Returns:
- the maximum packet size
-
setMaxPacketSize
public static void setMaxPacketSize(int maxPacketSize)Changes the maximum packet size (in bytes) that a client can send without getting disconnected.- Parameters:
maxPacketSize
- the new max packet size
-
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
-
getPacketListenerManager
Gets the manager handling all incoming packets- Returns:
- the packet listener manager
-
getNettyServer
Gets the netty server.- Returns:
- the netty server
-
getInstanceManager
Gets the manager handling all registered instances.- Returns:
- the instance manager
-
getBlockManager
Gets the manager handlingCustomBlock
andBlockPlacementRule
.- Returns:
- the block manager
-
getEntityManager
Gets the manager handling waiting players.- Returns:
- the entity manager
-
getCommandManager
Gets the manager handling commands.- Returns:
- the command manager
-
getRecipeManager
Gets the manager handling recipes show to the clients.- Returns:
- the recipe manager
-
getStorageManager
Gets the manager handling storage.- Returns:
- the storage manager
-
getDataManager
Gets the manager handlingDataType
used bySerializableData
.- Returns:
- the data manager
-
getTeamManager
Gets the manager handling teams.- Returns:
- the team manager
-
getSchedulerManager
Gets the manager handling scheduled tasks.- Returns:
- the scheduler manager
-
getBenchmarkManager
Gets the manager handling server monitoring.- Returns:
- the benchmark manager
-
getConnectionManager
Gets the manager handling server connections.- Returns:
- the connection manager
-
getPacketProcessor
Gets the object handling the client packets processing.Can be used if you want to convert a buffer to a client packet object.
- Returns:
- the packet processor
-
isStarted
public static boolean isStarted()Gets if the server is up and running.- Returns:
- true if the server is started
-
getChunkViewDistance
public static int getChunkViewDistance()Gets the chunk view distance of the server.- Returns:
- the chunk view distance
-
setChunkViewDistance
public static void setChunkViewDistance(int chunkViewDistance)Changes the chunk view distance of the server.- Parameters:
chunkViewDistance
- the new chunk view distance- Throws:
java.lang.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
public static void setEntityViewDistance(int entityViewDistance)Changes the entity view distance of the server.- Parameters:
entityViewDistance
- the new entity view distance- Throws:
java.lang.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(String, int, ResponseDataConsumer)
.- Parameters:
compressionThreshold
- the new compression threshold, 0 to disable compression- Throws:
java.lang.IllegalStateException
- if this is called after the server started
-
getResponseDataConsumer
Gets the consumer executed to show server-list data.- Returns:
- the response data consumer
-
getLootTableManager
Gets the manager handling loot tables.- Returns:
- the loot table manager
-
getDimensionTypeManager
Gets the manager handling dimensions.- Returns:
- the dimension manager
-
getBiomeManager
Gets the manager handling biomes.- Returns:
- the biome manager
-
getAdvancementManager
Gets the manager handling advancements.- Returns:
- the advancement manager
-
getExtensionManager
Get the manager handlingExtension
.- Returns:
- the extension manager
-
getTagManager
Gets the manager handling tags.- Returns:
- the tag manager
-
getUpdateManager
Gets the manager handling the server ticks.- Returns:
- the update manager
-
start
public void start(@NotNull java.lang.String address, int port, @Nullable ResponseDataConsumer responseDataConsumer)Starts the server.It should be called after
init()
and probably your own initialization code.- Parameters:
address
- the server addressport
- the server portresponseDataConsumer
- the response data consumer, can be null- Throws:
java.lang.IllegalStateException
- if called beforeinit()
or if the server is already running
-
start
public void start(@NotNull java.lang.String address, int port)Starts the server.- Parameters:
address
- the server addressport
- the server port- See Also:
start(String, int, ResponseDataConsumer)
-
stopCleanly
public static void stopCleanly()Stops this server properly (saves if needed, kicking players, etc.)
-