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
FieldsModifier and TypeFieldDescriptionstatic final MajorMinorVersionstatic final intstatic final net.kyori.adventure.text.logger.slf4j.ComponentLoggerstatic final intstatic final MajorMinorVersionstatic final Stringstatic final Stringstatic final Stringstatic final intstatic final intDeprecated.static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DynamicRegistry<StructCodec<? extends EntityEffect>> static DynamicRegistry<StructCodec<? extends LevelBasedValue>> static DynamicRegistry<StructCodec<? extends LocationEffect>> static DynamicRegistry<StructCodec<? extends ValueEffect>> static AdvancementManagerstatic DynamicRegistry<BannerPattern> static BenchmarkManagerGets the manager handling server monitoring.static DynamicRegistry<Biome> static BlockManagerstatic BossBarManagerstatic StringGets the current server brand name.static DynamicRegistry<ChatType> static intDeprecated.static CommandManagerstatic intGets the compression threshold of the server.static ConnectionManagerstatic DynamicRegistry<DamageType> static DynamicRegistry<Dialog> static DifficultyGets the server difficulty showed in game option.static DynamicRegistry<DimensionType> static DynamicRegistry<Enchantment> static intDeprecated.static ExceptionManagerstatic GlobalEventHandlerstatic InstanceManagerstatic DynamicRegistry<Instrument> static DynamicRegistry<JukeboxSong> static PacketListenerManagerstatic PacketParser<ClientPacket> static DynamicRegistry<PaintingVariant> static RecipeManagerstatic SchedulerManagerstatic Serverstatic TeamManagerstatic DynamicRegistry<TrimMaterial> static DynamicRegistry<TrimPattern> static DynamicRegistry<WolfVariant> static MinecraftServerinit()static MinecraftServerstatic booleanstatic booleanstatic @UnknownNullability ServerProcessprocess()static voidsetBrandName(String brandName) Changes the server brand name and send the change to all connected players.static voidsetCompressionThreshold(int compressionThreshold) Changes the compression threshold of the server.static voidsetDifficulty(Difficulty difficulty) Changes the server difficulty and send the appropriate packet to all connected clients.voidvoidstart(SocketAddress address) Starts the server.static voidStops this server properly (saves if needed, kicking players, etc.)static ServerProcessstatic ServerProcessupdateProcess(Auth auth)
-
Field Details
-
LOGGER
public static final net.kyori.adventure.text.logger.slf4j.ComponentLogger LOGGER -
THREAD_NAME_BENCHMARK
- See Also:
-
THREAD_NAME_TICK_SCHEDULER
- See Also:
-
THREAD_NAME_TICK
- See Also:
-
TICK_PER_SECOND
Deprecated. -
TICK_MS
public static final int TICK_MS -
VERSION_NAME
- See Also:
-
PROTOCOL_VERSION
static final int PROTOCOL_VERSION- See Also:
-
DATA_VERSION
static final int DATA_VERSION- See Also:
-
RESOURCE_PACK_VERSION
-
DATA_PACK_VERSION
-
-
Constructor Details
-
MinecraftServer
public MinecraftServer()
-
-
Method Details
-
init
-
init
-
updateProcess
-
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- ifbrandNameis 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
-
getPacketParser
-
isStarted
public static boolean isStarted() -
isStopping
public static boolean isStopping() -
getChunkViewDistance
Deprecated.Gets the chunk view distance of the server.Deprecated in favor of
ServerFlag.CHUNK_VIEW_DISTANCE- Returns:
- the chunk view distance
-
getEntityViewDistance
Deprecated.Gets the entity view distance of the server.Deprecated in favor of
ServerFlag.ENTITY_VIEW_DISTANCE- Returns:
- the entity view distance
-
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
-
getAdvancementManager
-
getChatTypeRegistry
-
getDialogRegistry
-
getDimensionTypeRegistry
-
getBiomeRegistry
-
getDamageTypeRegistry
-
getTrimMaterialRegistry
-
getTrimPatternRegistry
-
getBannerPatternRegistry
-
getWolfVariantRegistry
-
getEnchantmentRegistry
-
getPaintingVariantRegistry
-
getJukeboxSongRegistry
-
getInstrumentRegistry
-
enchantmentLevelBasedValues
-
enchantmentValueEffects
-
enchantmentEntityEffects
-
enchantmentLocationEffects
-
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.)
-