Class MinecraftServer

java.lang.Object
net.minestom.server.MinecraftServer

public final class MinecraftServer extends 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 Details

  • Constructor Details

    • MinecraftServer

      public MinecraftServer()
  • Method Details

    • init

      public static MinecraftServer init()
    • updateProcess

      @Internal public static ServerProcess updateProcess()
    • getBrandName

      @NotNull public static @NotNull String getBrandName()
      Gets the current server brand name.
      Returns:
      the server brand name
    • setBrandName

      public static void setBrandName(@NotNull @NotNull String brandName)
      Changes the server brand name and send the change to all connected players.
      Parameters:
      brandName - the server brand name
      Throws:
      NullPointerException - if brandName is null
    • getDifficulty

      @NotNull public static @NotNull Difficulty getDifficulty()
      Gets the server difficulty showed in game option.
      Returns:
      the server difficulty
    • setDifficulty

      public static void setDifficulty(@NotNull @NotNull Difficulty difficulty)
      Changes the server difficulty and send the appropriate packet to all connected clients.
      Parameters:
      difficulty - the new server difficulty
    • process

      public static @UnknownNullability ServerProcess process()
    • getGlobalEventHandler

      @NotNull public static @NotNull GlobalEventHandler getGlobalEventHandler()
    • getPacketListenerManager

      @NotNull public static @NotNull PacketListenerManager getPacketListenerManager()
    • getInstanceManager

      @NotNull public static @NotNull InstanceManager getInstanceManager()
    • getBlockManager

      @NotNull public static @NotNull BlockManager getBlockManager()
    • getCommandManager

      @NotNull public static @NotNull CommandManager getCommandManager()
    • getRecipeManager

      @NotNull public static @NotNull RecipeManager getRecipeManager()
    • getTeamManager

      @NotNull public static @NotNull TeamManager getTeamManager()
    • getSchedulerManager

      @NotNull public static @NotNull SchedulerManager getSchedulerManager()
    • getBenchmarkManager

      @NotNull public static @NotNull BenchmarkManager getBenchmarkManager()
      Gets the manager handling server monitoring.
      Returns:
      the benchmark manager
    • getExceptionManager

      @NotNull public static @NotNull ExceptionManager getExceptionManager()
    • getConnectionManager

      @NotNull public static @NotNull ConnectionManager getConnectionManager()
    • getBossBarManager

      @NotNull public static @NotNull BossBarManager getBossBarManager()
    • getPacketParser

      @NotNull public static @NotNull PacketParser<ClientPacket> getPacketParser()
    • isStarted

      public static boolean isStarted()
    • isStopping

      public static boolean isStopping()
    • getChunkViewDistance

      @Deprecated public static int 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 public static int 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

      public static AdvancementManager getAdvancementManager()
    • getTagManager

      public static TagManager getTagManager()
    • getChatTypeRegistry

      @NotNull public static @NotNull DynamicRegistry<ChatType> getChatTypeRegistry()
    • getDimensionTypeRegistry

      @NotNull public static @NotNull DynamicRegistry<DimensionType> getDimensionTypeRegistry()
    • getBiomeRegistry

      @NotNull public static @NotNull DynamicRegistry<Biome> getBiomeRegistry()
    • getDamageTypeRegistry

      @NotNull public static @NotNull DynamicRegistry<DamageType> getDamageTypeRegistry()
    • getTrimMaterialRegistry

      @NotNull public static @NotNull DynamicRegistry<TrimMaterial> getTrimMaterialRegistry()
    • getTrimPatternRegistry

      @NotNull public static @NotNull DynamicRegistry<TrimPattern> getTrimPatternRegistry()
    • getBannerPatternRegistry

      @NotNull public static @NotNull DynamicRegistry<BannerPattern> getBannerPatternRegistry()
    • getWolfVariantRegistry

      @NotNull public static @NotNull DynamicRegistry<WolfMeta.Variant> getWolfVariantRegistry()
    • getEnchantmentRegistry

      @NotNull public static @NotNull DynamicRegistry<Enchantment> getEnchantmentRegistry()
    • getPaintingVariantRegistry

      @NotNull public static @NotNull DynamicRegistry<PaintingMeta.Variant> getPaintingVariantRegistry()
    • getJukeboxSongRegistry

      @NotNull public static @NotNull DynamicRegistry<JukeboxSong> getJukeboxSongRegistry()
    • enchantmentLevelBasedValues

      @NotNull public static @NotNull DynamicRegistry<BinaryTagSerializer<? extends LevelBasedValue>> enchantmentLevelBasedValues()
    • enchantmentValueEffects

      @NotNull public static @NotNull DynamicRegistry<BinaryTagSerializer<? extends ValueEffect>> enchantmentValueEffects()
    • enchantmentEntityEffects

      @NotNull public static @NotNull DynamicRegistry<BinaryTagSerializer<? extends EntityEffect>> enchantmentEntityEffects()
    • enchantmentLocationEffects

      @NotNull public static @NotNull DynamicRegistry<BinaryTagSerializer<? extends LocationEffect>> enchantmentLocationEffects()
    • getServer

      public static Server getServer()
    • start

      public void start(@NotNull @NotNull SocketAddress address)
      Starts the server.

      It should be called after init() and probably your own initialization code.

      Parameters:
      address - the server address
      Throws:
      IllegalStateException - if called before init() or if the server is already running
    • start

      public void start(@NotNull @NotNull String address, int port)
    • stopCleanly

      public static void stopCleanly()
      Stops this server properly (saves if needed, kicking players, etc.)