Class MinecraftServer

All Implemented Interfaces:
AutoCloseable, Executor, ICommandSource, ISnooperInfo, ITaskExecutor<TickDelayedTask>
Direct Known Subclasses:
DedicatedServer, IntegratedServer

public abstract class MinecraftServer extends RecursiveEventLoop<TickDelayedTask> implements ISnooperInfo, ICommandSource, AutoCloseable
  • Field Details

    • LOGGER

      private static final org.apache.logging.log4j.Logger LOGGER
    • USERID_CACHE_FILE

      public static final File USERID_CACHE_FILE
    • DEMO_SETTINGS

      public static final WorldSettings DEMO_SETTINGS
    • storageSource

      protected final SaveFormat.LevelSave storageSource
    • playerDataStorage

      protected final PlayerData playerDataStorage
    • snooper

      private final Snooper snooper
    • tickables

      private final List<Runnable> tickables
    • continousProfiler

      private final TimeTracker continousProfiler
    • profiler

      private IProfiler profiler
    • connection

      private final NetworkSystem connection
    • progressListenerFactory

      private final IChunkStatusListenerFactory progressListenerFactory
    • status

      private final ServerStatusResponse status
    • random

      private final Random random
    • fixerUpper

      private final com.mojang.datafixers.DataFixer fixerUpper
    • localIp

      private String localIp
    • port

      private int port
    • registryHolder

      protected final DynamicRegistries.Impl registryHolder
    • levels

      private final Map<RegistryKey<World>,ServerWorld> levels
    • playerList

      private PlayerList playerList
    • running

      private volatile boolean running
    • stopped

      private boolean stopped
    • tickCount

      private int tickCount
    • proxy

      protected final Proxy proxy
    • onlineMode

      private boolean onlineMode
    • preventProxyConnections

      private boolean preventProxyConnections
    • pvp

      private boolean pvp
    • allowFlight

      private boolean allowFlight
    • motd

      @Nullable private String motd
    • maxBuildHeight

      private int maxBuildHeight
    • playerIdleTimeout

      private int playerIdleTimeout
    • tickTimes

      public final long[] tickTimes
    • keyPair

      @Nullable private KeyPair keyPair
    • singleplayerName

      @Nullable private String singleplayerName
    • isDemo

      private boolean isDemo
    • resourcePack

      private String resourcePack
    • resourcePackHash

      private String resourcePackHash
    • isReady

      private volatile boolean isReady
    • lastOverloadWarning

      private long lastOverloadWarning
    • delayProfilerStart

      private boolean delayProfilerStart
    • forceGameType

      private boolean forceGameType
    • sessionService

      private final com.mojang.authlib.minecraft.MinecraftSessionService sessionService
    • profileRepository

      private final com.mojang.authlib.GameProfileRepository profileRepository
    • profileCache

      private final PlayerProfileCache profileCache
    • lastServerStatus

      private long lastServerStatus
    • serverThread

      private final Thread serverThread
    • nextTickTime

      protected long nextTickTime
    • delayedTasksMaxNextTickTime

      private long delayedTasksMaxNextTickTime
    • mayHaveDelayedTasks

      private boolean mayHaveDelayedTasks
    • hasWorldScreenshot

      private boolean hasWorldScreenshot
    • packRepository

      private final ResourcePackList packRepository
    • scoreboard

      private final ServerScoreboard scoreboard
    • commandStorage

      @Nullable private CommandStorage commandStorage
    • customBossEvents

      private final CustomServerBossInfoManager customBossEvents
    • functionManager

      private final FunctionManager functionManager
    • frameTimer

      private final FrameTimer frameTimer
    • enforceWhitelist

      private boolean enforceWhitelist
    • averageTickTime

      private float averageTickTime
    • executor

      private final Executor executor
    • serverId

      @Nullable private String serverId
    • resources

      private DataPackRegistries resources
    • structureManager

      private final TemplateManager structureManager
    • worldData

      protected final IServerConfiguration worldData
    • perWorldTickTimes

      private Map<RegistryKey<World>,long[]> perWorldTickTimes
    • worldArrayMarker

      private int worldArrayMarker
    • worldArrayLast

      private int worldArrayLast
    • worldArray

      private ServerWorld[] worldArray
  • Constructor Details

  • Method Details

    • spin

      public static <S extends MinecraftServer> S spin(Function<Thread,S> p_240784_0_)
    • readScoreboard

      private void readScoreboard(DimensionSavedDataManager p_213204_1_)
    • initServer

      protected abstract boolean initServer() throws IOException
      Throws:
      IOException
    • convertFromRegionFormatIfNeeded

      public static void convertFromRegionFormatIfNeeded(SaveFormat.LevelSave p_240777_0_)
    • loadLevel

      protected void loadLevel()
    • forceDifficulty

      protected void forceDifficulty()
    • createLevels

      protected void createLevels(IChunkStatusListener p_240787_1_)
    • setInitialSpawn

      private static void setInitialSpawn(ServerWorld p_240786_0_, IServerWorldInfo p_240786_1_, boolean p_240786_2_, boolean p_240786_3_, boolean p_240786_4_)
    • setupDebugLevel

      private void setupDebugLevel(IServerConfiguration p_240778_1_)
    • prepareLevels

      private void prepareLevels(IChunkStatusListener p_213186_1_)
    • detectBundledResources

      protected void detectBundledResources()
    • getDefaultGameType

      public GameType getDefaultGameType()
    • isHardcore

      public boolean isHardcore()
    • getOperatorUserPermissionLevel

      public abstract int getOperatorUserPermissionLevel()
    • getFunctionCompilationLevel

      public abstract int getFunctionCompilationLevel()
    • shouldRconBroadcast

      public abstract boolean shouldRconBroadcast()
    • saveAllChunks

      public boolean saveAllChunks(boolean p_213211_1_, boolean p_213211_2_, boolean p_213211_3_)
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface ITaskExecutor<TickDelayedTask>
    • stopServer

      protected void stopServer()
    • getLocalIp

      public String getLocalIp()
    • setLocalIp

      public void setLocalIp(String p_71189_1_)
    • isRunning

      public boolean isRunning()
    • halt

      public void halt(boolean p_71263_1_)
    • runServer

      protected void runServer()
    • haveTime

      private boolean haveTime()
    • waitUntilNextTick

      protected void waitUntilNextTick()
    • wrapRunnable

      protected TickDelayedTask wrapRunnable(Runnable p_212875_1_)
      Specified by:
      wrapRunnable in class ThreadTaskExecutor<TickDelayedTask>
    • shouldRun

      protected boolean shouldRun(TickDelayedTask p_212874_1_)
      Specified by:
      shouldRun in class ThreadTaskExecutor<TickDelayedTask>
    • pollTask

      public boolean pollTask()
      Overrides:
      pollTask in class ThreadTaskExecutor<TickDelayedTask>
    • pollTaskInternal

      private boolean pollTaskInternal()
    • doRunTask

      protected void doRunTask(TickDelayedTask p_213166_1_)
      Overrides:
      doRunTask in class RecursiveEventLoop<TickDelayedTask>
    • updateStatusIcon

      private void updateStatusIcon(ServerStatusResponse p_184107_1_)
    • hasWorldScreenshot

      public boolean hasWorldScreenshot()
    • getWorldScreenshotFile

      public File getWorldScreenshotFile()
    • getServerDirectory

      public File getServerDirectory()
    • onServerCrash

      protected void onServerCrash(CrashReport p_71228_1_)
    • onServerExit

      protected void onServerExit()
    • tickServer

      protected void tickServer(BooleanSupplier p_71217_1_)
    • tickChildren

      protected void tickChildren(BooleanSupplier p_71190_1_)
    • isNetherEnabled

      public boolean isNetherEnabled()
    • addTickable

      public void addTickable(Runnable p_82010_1_)
    • setId

      protected void setId(String p_213208_1_)
    • isShutdown

      public boolean isShutdown()
    • getFile

      public File getFile(String p_71209_1_)
    • overworld

      public final ServerWorld overworld()
    • getLevel

      @Nullable public ServerWorld getLevel(RegistryKey<World> p_71218_1_)
    • levelKeys

      public Set<RegistryKey<World>> levelKeys()
    • getAllLevels

      public Iterable<ServerWorld> getAllLevels()
    • getServerVersion

      public String getServerVersion()
    • getPlayerCount

      public int getPlayerCount()
    • getMaxPlayers

      public int getMaxPlayers()
    • getPlayerNames

      public String[] getPlayerNames()
    • getServerModName

      public String getServerModName()
    • fillReport

      public CrashReport fillReport(CrashReport p_71230_1_)
    • getModdedStatus

      public abstract Optional<String> getModdedStatus()
    • sendMessage

      public void sendMessage(ITextComponent p_145747_1_, UUID p_145747_2_)
      Specified by:
      sendMessage in interface ICommandSource
    • getKeyPair

      public KeyPair getKeyPair()
    • getPort

      public int getPort()
    • setPort

      public void setPort(int p_71208_1_)
    • getSingleplayerName

      public String getSingleplayerName()
    • setSingleplayerName

      public void setSingleplayerName(String p_71224_1_)
    • isSingleplayer

      public boolean isSingleplayer()
    • initializeKeyPair

      protected void initializeKeyPair()
    • setDifficulty

      public void setDifficulty(Difficulty p_147139_1_, boolean p_147139_2_)
    • getScaledTrackingDistance

      public int getScaledTrackingDistance(int p_230512_1_)
    • updateMobSpawningFlags

      private void updateMobSpawningFlags()
    • setDifficultyLocked

      public void setDifficultyLocked(boolean p_213209_1_)
    • sendDifficultyUpdate

      private void sendDifficultyUpdate(ServerPlayerEntity p_213189_1_)
    • isSpawningMonsters

      protected boolean isSpawningMonsters()
    • isDemo

      public boolean isDemo()
    • setDemo

      public void setDemo(boolean p_71204_1_)
    • getResourcePack

      public String getResourcePack()
    • getResourcePackHash

      public String getResourcePackHash()
    • setResourcePack

      public void setResourcePack(String p_180507_1_, String p_180507_2_)
    • populateSnooper

      public void populateSnooper(Snooper p_70000_1_)
      Specified by:
      populateSnooper in interface ISnooperInfo
    • isDedicatedServer

      public abstract boolean isDedicatedServer()
    • getRateLimitPacketsPerSecond

      public abstract int getRateLimitPacketsPerSecond()
    • usesAuthentication

      public boolean usesAuthentication()
    • setUsesAuthentication

      public void setUsesAuthentication(boolean p_71229_1_)
    • getPreventProxyConnections

      public boolean getPreventProxyConnections()
    • setPreventProxyConnections

      public void setPreventProxyConnections(boolean p_190517_1_)
    • isSpawningAnimals

      public boolean isSpawningAnimals()
    • areNpcsEnabled

      public boolean areNpcsEnabled()
    • isEpollEnabled

      public abstract boolean isEpollEnabled()
    • isPvpAllowed

      public boolean isPvpAllowed()
    • setPvpAllowed

      public void setPvpAllowed(boolean p_71188_1_)
    • isFlightAllowed

      public boolean isFlightAllowed()
    • setFlightAllowed

      public void setFlightAllowed(boolean p_71245_1_)
    • isCommandBlockEnabled

      public abstract boolean isCommandBlockEnabled()
    • getMotd

      public String getMotd()
    • setMotd

      public void setMotd(String p_71205_1_)
    • getMaxBuildHeight

      public int getMaxBuildHeight()
    • setMaxBuildHeight

      public void setMaxBuildHeight(int p_71191_1_)
    • isStopped

      public boolean isStopped()
    • getPlayerList

      public PlayerList getPlayerList()
    • setPlayerList

      public void setPlayerList(PlayerList p_184105_1_)
    • isPublished

      public abstract boolean isPublished()
    • setDefaultGameType

      public void setDefaultGameType(GameType p_71235_1_)
    • getConnection

      @Nullable public NetworkSystem getConnection()
    • isReady

      public boolean isReady()
    • hasGui

      public boolean hasGui()
    • publishServer

      public abstract boolean publishServer(GameType p_195565_1_, boolean p_195565_2_, int p_195565_3_)
    • getTickCount

      public int getTickCount()
    • getSnooper

      public Snooper getSnooper()
    • getSpawnProtectionRadius

      public int getSpawnProtectionRadius()
    • isUnderSpawnProtection

      public boolean isUnderSpawnProtection(ServerWorld p_175579_1_, BlockPos p_175579_2_, PlayerEntity p_175579_3_)
    • setForceGameType

      public void setForceGameType(boolean p_104055_1_)
    • getForceGameType

      public boolean getForceGameType()
    • repliesToStatus

      public boolean repliesToStatus()
    • getPlayerIdleTimeout

      public int getPlayerIdleTimeout()
    • setPlayerIdleTimeout

      public void setPlayerIdleTimeout(int p_143006_1_)
    • getSessionService

      public com.mojang.authlib.minecraft.MinecraftSessionService getSessionService()
    • getProfileRepository

      public com.mojang.authlib.GameProfileRepository getProfileRepository()
    • getProfileCache

      public PlayerProfileCache getProfileCache()
    • getStatus

      public ServerStatusResponse getStatus()
    • invalidateStatus

      public void invalidateStatus()
    • getAbsoluteMaxWorldSize

      public int getAbsoluteMaxWorldSize()
    • scheduleExecutables

      public boolean scheduleExecutables()
      Overrides:
      scheduleExecutables in class RecursiveEventLoop<TickDelayedTask>
    • getRunningThread

      public Thread getRunningThread()
      Specified by:
      getRunningThread in class ThreadTaskExecutor<TickDelayedTask>
    • getCompressionThreshold

      public int getCompressionThreshold()
    • getNextTickTime

      public long getNextTickTime()
    • getFixerUpper

      public com.mojang.datafixers.DataFixer getFixerUpper()
    • getSpawnRadius

      public int getSpawnRadius(@Nullable ServerWorld p_184108_1_)
    • getAdvancements

      public AdvancementManager getAdvancements()
    • getFunctions

      public FunctionManager getFunctions()
    • reloadResources

      public CompletableFuture<Void> reloadResources(Collection<String> p_240780_1_)
    • configurePackRepository

      public static DatapackCodec configurePackRepository(ResourcePackList p_240772_0_, DatapackCodec p_240772_1_, boolean p_240772_2_)
    • getSelectedPacks

      private static DatapackCodec getSelectedPacks(ResourcePackList p_240771_0_)
    • kickUnlistedPlayers

      public void kickUnlistedPlayers(CommandSource p_205743_1_)
    • getPackRepository

      public ResourcePackList getPackRepository()
    • getCommands

      public Commands getCommands()
    • createCommandSourceStack

      public CommandSource createCommandSourceStack()
    • acceptsSuccess

      public boolean acceptsSuccess()
      Specified by:
      acceptsSuccess in interface ICommandSource
    • acceptsFailure

      public boolean acceptsFailure()
      Specified by:
      acceptsFailure in interface ICommandSource
    • getRecipeManager

      public RecipeManager getRecipeManager()
    • getTags

      public ITagCollectionSupplier getTags()
    • getScoreboard

      public ServerScoreboard getScoreboard()
    • getCommandStorage

      public CommandStorage getCommandStorage()
    • getLootTables

      public LootTableManager getLootTables()
    • getPredicateManager

      public LootPredicateManager getPredicateManager()
    • getGameRules

      public GameRules getGameRules()
    • getCustomBossEvents

      public CustomServerBossInfoManager getCustomBossEvents()
    • isEnforceWhitelist

      public boolean isEnforceWhitelist()
    • setEnforceWhitelist

      public void setEnforceWhitelist(boolean p_205741_1_)
    • getAverageTickTime

      public float getAverageTickTime()
    • getProfilePermissions

      public int getProfilePermissions(com.mojang.authlib.GameProfile p_211833_1_)
    • getFrameTimer

      public FrameTimer getFrameTimer()
    • getProfiler

      public IProfiler getProfiler()
    • isSingleplayerOwner

      public abstract boolean isSingleplayerOwner(com.mojang.authlib.GameProfile p_213199_1_)
    • getTickTime

      @Nullable public long[] getTickTime(RegistryKey<World> dim)
    • forgeGetWorldMap

      @Deprecated public Map<RegistryKey<World>,ServerWorld> forgeGetWorldMap()
      Deprecated.
    • markWorldsDirty

      @Deprecated public void markWorldsDirty()
      Deprecated.
    • getWorldArray

      private ServerWorld[] getWorldArray()
    • saveDebugReport

      public void saveDebugReport(Path p_223711_1_) throws IOException
      Throws:
      IOException
    • dumpMiscStats

      private void dumpMiscStats(Path p_223710_1_) throws IOException
      Throws:
      IOException
    • dumpCrashCategory

      private void dumpCrashCategory(Path p_223709_1_) throws IOException
      Throws:
      IOException
    • dumpGameRules

      private void dumpGameRules(Path p_223708_1_) throws IOException
      Throws:
      IOException
    • dumpClasspath

      private void dumpClasspath(Path p_223706_1_) throws IOException
      Throws:
      IOException
    • dumpThreads

      private void dumpThreads(Path p_223712_1_) throws IOException
      Throws:
      IOException
    • startProfilerTick

      private void startProfilerTick(@Nullable LongTickDetector p_240773_1_)
    • endProfilerTick

      private void endProfilerTick(@Nullable LongTickDetector p_240795_1_)
    • isProfiling

      public boolean isProfiling()
    • startProfiling

      public void startProfiling()
    • finishProfiling

      public IProfileResult finishProfiling()
    • getWorldPath

      public Path getWorldPath(FolderName p_240776_1_)
    • forceSynchronousWrites

      public boolean forceSynchronousWrites()
    • getStructureManager

      public TemplateManager getStructureManager()
    • getWorldData

      public IServerConfiguration getWorldData()
    • getDataPackRegistries

      public DataPackRegistries getDataPackRegistries()
    • registryAccess

      public DynamicRegistries registryAccess()
    • createTextFilterForPlayer

      @Nullable public IChatFilter createTextFilterForPlayer(ServerPlayerEntity p_244435_1_)