Package net.minecraft.server
Class MinecraftServer
java.lang.Object
net.minecraft.util.thread.BlockableEventLoop<R>
net.minecraft.util.thread.ReentrantBlockableEventLoop<TickTask>
net.minecraft.server.MinecraftServer
- All Implemented Interfaces:
- AutoCloseable,- Executor,- CommandSource,- ServerInfo,- ProfilerMeasured,- ProcessorHandle<TickTask>
- Direct Known Subclasses:
- DedicatedServer,- GameTestServer,- IntegratedServer
public abstract class MinecraftServer
extends ReentrantBlockableEventLoop<TickTask>
implements ServerInfo, CommandSource, AutoCloseable
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic final recordstatic final record(package private) static class
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intprivate booleanstatic final com.mojang.authlib.GameProfileprivate static final intprivate static final floatprivate floatprivate Stringprivate CommandStorageprivate final ServerConnectionListenerprivate final CustomBossEventsprivate MinecraftServer.TimeProfilerprivate booleanprivate static final longprivate longstatic final LevelSettingsprivate booleanprivate final Executorprivate final com.mojang.datafixers.DataFixerprivate final ServerFunctionManagerprivate static final com.google.gson.Gsonprivate booleanprivate booleanprivate booleanprivate KeyPairprivate longprivate longprivate final Map<ResourceKey<Level>,ServerLevel> private Stringprivate static final org.slf4j.Loggerprivate static final intprivate static final intprivate booleanprivate MetricsRecorderprivate Stringstatic final intprotected longprivate booleanprivate Consumer<ProfileResults>private static final intprivate static final intprivate final PackRepositoryprivate Map<ResourceKey<Level>,long[]> protected final PlayerDataStorageprivate intprivate PlayerListprivate intprivate booleanprivate ProfilerFillerprivate final ChunkProgressListenerFactoryprotected final Proxyprivate booleanprivate final RandomSourceprivate final LayeredRegistryAccess<RegistryLayer>private booleanprivate final ServerScoreboardprivate Stringprivate final Threadprotected final Servicesprivate com.mojang.authlib.GameProfilestatic final intprivate static final intprivate ServerStatusprivate static final longprivate ServerStatus.Faviconprivate booleanprotected final LevelStorageSource.LevelStorageAccessprivate final StructureTemplateManagerprivate static final intprivate intfinal long[]static final Stringprivate booleanprivate ServerLevel[]private intprivate intprotected final WorldDataFields inherited from interface net.minecraft.commands.CommandSourceNULL
- 
Constructor SummaryConstructorsConstructorDescriptionMinecraftServer(Thread p_236723_, LevelStorageSource.LevelStorageAccess p_236724_, PackRepository p_236725_, WorldStem p_236726_, Proxy p_236727_, com.mojang.datafixers.DataFixer p_236728_, Services p_236729_, ChunkProgressListenerFactory p_236730_) 
- 
Method SummaryModifier and TypeMethodDescriptionbooleanbooleanvoidaddTickable(Runnable p_129947_) booleanprivate ServerStatus.Playersprivate ServerStatusvoidvoidclose()static WorldDataConfigurationconfigurePackRepository(PackRepository p_248681_, DataPackConfig p_248920_, boolean p_249869_, FeatureFlagSet p_251243_) private static CrashReportconstructOrExtractCrashReport(Throwable p_206569_) createGameModeForPlayer(ServerPlayer p_177934_) protected voidcreateLevels(ChunkProgressListener p_129816_) createTextFilterForPlayer(ServerPlayer p_129814_) voidprivate voiddumpClasspath(Path p_129992_) private voiddumpGameRules(Path p_129984_) private voiddumpMiscStats(Path p_129951_) private voiddumpNativeModules(Path p_195522_) voiddumpServerProperties(Path p_177911_) private voiddumpThreads(Path p_129996_) private voidbooleanvoidexecuteIfPossible(Runnable p_202482_) abstract SystemReportfillServerSystemReport(SystemReport p_177901_) fillSystemReport(SystemReport p_177936_) voidprotected voidbooleanvoidDeprecated.intfloatintcom.mojang.datafixers.DataFixerabstract intgetLevel(ResourceKey<Level> p_129881_) intintgetMotd()longabstract intintintString[]intgetPort()booleanintgetProfilePermissions(com.mojang.authlib.GameProfile p_129945_) com.mojang.authlib.GameProfileRepositorygetProxy()abstract intintgetScaledTrackingDistance(int p_129935_) private static DataPackConfiggetSelectedPacks(PackRepository p_129818_) com.mojang.authlib.minecraft.MinecraftSessionServicecom.mojang.authlib.GameProfileintintgetSpawnRadius(ServerLevel p_129804_) intlong[]getTickTime(ResourceKey<Level> dim) private ServerLevel[]getWorldPath(LevelResource p_129844_) voidhalt(boolean p_129884_) booleanhasGui()private booleanhaveTime()booleanprotected voidprotected abstract booleanvoidabstract booleanbooleanabstract booleanbooleanisDemo()booleanabstract booleanbooleanbooleanbooleanabstract booleanbooleanbooleanisReady()booleanbooleanbooleanbooleanbooleanabstract booleanisSingleplayerOwner(com.mojang.authlib.GameProfile p_129840_) booleanbooleanbooleanbooleanbooleanisUnderSpawnProtection(ServerLevel p_129811_, BlockPos p_129812_, Player p_129813_) voidkickUnlistedPlayers(CommandSourceStack p_129850_) protected voidprivate Optional<ServerStatus.Favicon>voidlogChatMessage(Component p_241503_, ChatType.Bound p_241402_, String p_241481_) booleanlogIPs()protected voidlogTickTime(long p_298126_) voidDeprecated.voidonServerCrash(CrashReport p_129874_) voidfinal ServerLevelbooleanpollTask()private booleanprivate voidprepareLevels(ChunkProgressListener p_129941_) booleanpublishServer(GameType p_129833_, boolean p_129834_, int p_129835_) private voidreadScoreboard(DimensionDataStorage p_129842_) reloadResources(Collection<String> p_129862_) booleanprivate voidresetStatusCache(ServerStatus status) protected voidbooleansaveAllChunks(boolean p_129886_, boolean p_129887_, boolean p_129888_) private voidsaveDebugReport(Path p_129860_) booleansaveEverything(boolean p_195515_, boolean p_195516_, boolean p_195517_) booleanprivate voidsendDifficultyUpdate(ServerPlayer p_129939_) voidsendSystemMessage(Component p_236736_) voidsetDefaultGameType(GameType p_129832_) voidsetDemo(boolean p_129976_) voidsetDifficulty(Difficulty p_129828_, boolean p_129829_) voidsetDifficultyLocked(boolean p_129959_) voidsetEnforceWhitelist(boolean p_130005_) voidsetFlightAllowed(boolean p_130000_) protected voidprivate static voidsetInitialSpawn(ServerLevel p_177897_, ServerLevelData p_177898_, boolean p_177899_, boolean p_177900_) voidsetLocalIp(String p_129914_) voidvoidsetPlayerIdleTimeout(int p_129978_) voidsetPlayerList(PlayerList p_129824_) voidsetPort(int p_129802_) voidsetPreventProxyConnections(boolean p_129994_) voidsetPvpAllowed(boolean p_129998_) voidsetSingleplayerProfile(com.mojang.authlib.GameProfile p_236741_) private voidsetupDebugLevel(WorldData p_129848_) voidsetUsesAuthentication(boolean p_129986_) abstract booleanabstract booleanprotected booleanstatic <S extends MinecraftServer>
 Sprivate voidvoidstartRecordingMetrics(Consumer<ProfileResults> p_177924_, Consumer<Path> p_177925_) voidvoidvoidprivate voidsynchronizeTime(ServerLevel p_276371_) voidtickChildren(BooleanSupplier p_129954_) voidtickServer(BooleanSupplier p_129871_) private voidbooleanprotected voidprotected TickTaskwrapRunnable(Runnable p_129852_) Methods inherited from class net.minecraft.util.thread.ReentrantBlockableEventLooprunningTaskMethods inherited from class net.minecraft.util.thread.BlockableEventLoopdropAllTasks, execute, executeBlocking, getPendingTasksCount, isSameThread, managedBlock, name, profiledMetrics, runAllTasks, submit, submit, submitAsync, tell, waitForTasksMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.commands.CommandSourcealwaysAcceptsMethods inherited from interface net.minecraft.util.thread.ProcessorHandleask, askEither
- 
Field Details- 
LOGGERprivate static final org.slf4j.Logger LOGGER
- 
VANILLA_BRAND- See Also:
 
- 
AVERAGE_TICK_TIME_SMOOTHINGprivate static final float AVERAGE_TICK_TIME_SMOOTHING- See Also:
 
- 
TICK_STATS_SPANprivate static final int TICK_STATS_SPAN- See Also:
 
- 
MS_PER_TICKpublic static final int MS_PER_TICK- See Also:
 
- 
OVERLOADED_THRESHOLDprivate static final int OVERLOADED_THRESHOLD- See Also:
 
- 
OVERLOADED_WARNING_INTERVALprivate static final int OVERLOADED_WARNING_INTERVAL- See Also:
 
- 
STATUS_EXPIRE_TIME_NSprivate static final long STATUS_EXPIRE_TIME_NS- See Also:
 
- 
MAX_STATUS_PLAYER_SAMPLEprivate static final int MAX_STATUS_PLAYER_SAMPLE- See Also:
 
- 
START_CHUNK_RADIUSpublic static final int START_CHUNK_RADIUS- See Also:
 
- 
START_TICKING_CHUNK_COUNTprivate static final int START_TICKING_CHUNK_COUNT- See Also:
 
- 
AUTOSAVE_INTERVALprivate static final int AUTOSAVE_INTERVAL- See Also:
 
- 
MAX_TICK_LATENCYprivate static final int MAX_TICK_LATENCY- See Also:
 
- 
ABSOLUTE_MAX_WORLD_SIZEpublic static final int ABSOLUTE_MAX_WORLD_SIZE- See Also:
 
- 
DEMO_SETTINGS
- 
DELAYED_TASKS_TICK_EXTENSIONprivate static final long DELAYED_TASKS_TICK_EXTENSION- See Also:
 
- 
ANONYMOUS_PLAYER_PROFILEpublic static final com.mojang.authlib.GameProfile ANONYMOUS_PLAYER_PROFILE
- 
storageSource
- 
playerDataStorage
- 
tickables
- 
metricsRecorder
- 
profiler
- 
onMetricsRecordingStopped
- 
onMetricsRecordingFinished
- 
willStartRecordingMetricsprivate boolean willStartRecordingMetrics
- 
debugCommandProfiler
- 
debugCommandProfilerDelayStartprivate boolean debugCommandProfilerDelayStart
- 
connection
- 
progressListenerFactory
- 
status
- 
statusIcon
- 
random
- 
fixerUpperprivate final com.mojang.datafixers.DataFixer fixerUpper
- 
localIp
- 
portprivate int port
- 
registries
- 
levels
- 
playerList
- 
runningprivate volatile boolean running
- 
stoppedprivate boolean stopped
- 
tickCountprivate int tickCount
- 
proxy
- 
onlineModeprivate boolean onlineMode
- 
preventProxyConnectionsprivate boolean preventProxyConnections
- 
pvpprivate boolean pvp
- 
allowFlightprivate boolean allowFlight
- 
motd
- 
playerIdleTimeoutprivate int playerIdleTimeout
- 
tickTimespublic final long[] tickTimes
- 
keyPair
- 
singleplayerProfile@Nullable private com.mojang.authlib.GameProfile singleplayerProfile
- 
isDemoprivate boolean isDemo
- 
isReadyprivate volatile boolean isReady
- 
lastOverloadWarningprivate long lastOverloadWarning
- 
services
- 
lastServerStatusprivate long lastServerStatus
- 
serverThread
- 
nextTickTimeprotected long nextTickTime
- 
delayedTasksMaxNextTickTimeprivate long delayedTasksMaxNextTickTime
- 
mayHaveDelayedTasksprivate boolean mayHaveDelayedTasks
- 
packRepository
- 
scoreboard
- 
commandStorage
- 
customBossEvents
- 
functionManager
- 
enforceWhitelistprivate boolean enforceWhitelist
- 
averageTickTimeprivate float averageTickTime
- 
executor
- 
serverId
- 
resources
- 
structureTemplateManager
- 
worldData
- 
isSavingprivate volatile boolean isSaving
- 
GSONprivate static final com.google.gson.Gson GSON
- 
cachedServerStatus
- 
perWorldTickTimes
- 
worldArrayMarkerprivate int worldArrayMarker
- 
worldArrayLastprivate int worldArrayLast
- 
worldArray
 
- 
- 
Constructor Details- 
MinecraftServerpublic MinecraftServer(Thread p_236723_, LevelStorageSource.LevelStorageAccess p_236724_, PackRepository p_236725_, WorldStem p_236726_, Proxy p_236727_, com.mojang.datafixers.DataFixer p_236728_, Services p_236729_, ChunkProgressListenerFactory p_236730_) 
 
- 
- 
Method Details- 
spin
- 
readScoreboard
- 
initServer- Throws:
- IOException
 
- 
loadLevelprotected void loadLevel()
- 
forceDifficultyprotected void forceDifficulty()
- 
createLevels
- 
setInitialSpawnprivate static void setInitialSpawn(ServerLevel p_177897_, ServerLevelData p_177898_, boolean p_177899_, boolean p_177900_) 
- 
setupDebugLevel
- 
prepareLevels
- 
getDefaultGameType
- 
isHardcorepublic boolean isHardcore()
- 
getOperatorUserPermissionLevelpublic abstract int getOperatorUserPermissionLevel()
- 
getFunctionCompilationLevelpublic abstract int getFunctionCompilationLevel()
- 
shouldRconBroadcastpublic abstract boolean shouldRconBroadcast()
- 
saveAllChunkspublic boolean saveAllChunks(boolean p_129886_, boolean p_129887_, boolean p_129888_) 
- 
saveEverythingpublic boolean saveEverything(boolean p_195515_, boolean p_195516_, boolean p_195517_) 
- 
closepublic void close()- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- ProcessorHandle<TickTask>
 
- 
stopServerpublic void stopServer()
- 
getLocalIp
- 
setLocalIp
- 
isRunningpublic boolean isRunning()
- 
haltpublic void halt(boolean p_129884_) 
- 
runServerprotected void runServer()
- 
constructOrExtractCrashReport
- 
haveTimeprivate boolean haveTime()
- 
waitUntilNextTickprotected void waitUntilNextTick()
- 
wrapRunnable- Specified by:
- wrapRunnablein class- BlockableEventLoop<TickTask>
 
- 
shouldRun- Specified by:
- shouldRunin class- BlockableEventLoop<TickTask>
 
- 
pollTaskpublic boolean pollTask()- Overrides:
- pollTaskin class- BlockableEventLoop<TickTask>
 
- 
pollTaskInternalprivate boolean pollTaskInternal()
- 
doRunTask- Overrides:
- doRunTaskin class- ReentrantBlockableEventLoop<TickTask>
 
- 
loadStatusIcon
- 
getWorldScreenshotFile
- 
getServerDirectory
- 
onServerCrash
- 
onServerExitpublic void onServerExit()
- 
tickServer
- 
resetStatusCache
- 
getStatusJson
- 
logTickTimeprotected void logTickTime(long p_298126_) 
- 
buildServerStatus
- 
buildPlayerStatus
- 
tickChildren
- 
synchronizeTime
- 
forceTimeSynchronizationpublic void forceTimeSynchronization()
- 
isNetherEnabledpublic boolean isNetherEnabled()
- 
addTickable
- 
setId
- 
isShutdownpublic boolean isShutdown()
- 
getFile
- 
overworld
- 
getLevel
- 
levelKeys
- 
getAllLevels
- 
getServerVersion- Specified by:
- getServerVersionin interface- ServerInfo
 
- 
getPlayerCountpublic int getPlayerCount()- Specified by:
- getPlayerCountin interface- ServerInfo
 
- 
getMaxPlayerspublic int getMaxPlayers()- Specified by:
- getMaxPlayersin interface- ServerInfo
 
- 
getPlayerNames
- 
getServerModName
- 
fillSystemReport
- 
fillServerSystemReport
- 
getModdedStatus
- 
sendSystemMessage- Specified by:
- sendSystemMessagein interface- CommandSource
 
- 
getKeyPair
- 
getPortpublic int getPort()
- 
setPortpublic void setPort(int p_129802_) 
- 
getSingleplayerProfile@Nullable public com.mojang.authlib.GameProfile getSingleplayerProfile()
- 
setSingleplayerProfilepublic void setSingleplayerProfile(@Nullable com.mojang.authlib.GameProfile p_236741_) 
- 
isSingleplayerpublic boolean isSingleplayer()
- 
initializeKeyPairprotected void initializeKeyPair()
- 
setDifficulty
- 
getScaledTrackingDistancepublic int getScaledTrackingDistance(int p_129935_) 
- 
updateMobSpawningFlagsprivate void updateMobSpawningFlags()
- 
setDifficultyLockedpublic void setDifficultyLocked(boolean p_129959_) 
- 
sendDifficultyUpdate
- 
isSpawningMonsterspublic boolean isSpawningMonsters()
- 
isDemopublic boolean isDemo()
- 
setDemopublic void setDemo(boolean p_129976_) 
- 
getServerResourcePack
- 
isResourcePackRequiredpublic boolean isResourcePackRequired()
- 
isDedicatedServerpublic abstract boolean isDedicatedServer()
- 
getRateLimitPacketsPerSecondpublic abstract int getRateLimitPacketsPerSecond()
- 
usesAuthenticationpublic boolean usesAuthentication()
- 
setUsesAuthenticationpublic void setUsesAuthentication(boolean p_129986_) 
- 
getPreventProxyConnectionspublic boolean getPreventProxyConnections()
- 
setPreventProxyConnectionspublic void setPreventProxyConnections(boolean p_129994_) 
- 
isSpawningAnimalspublic boolean isSpawningAnimals()
- 
areNpcsEnabledpublic boolean areNpcsEnabled()
- 
isEpollEnabledpublic abstract boolean isEpollEnabled()
- 
isPvpAllowedpublic boolean isPvpAllowed()
- 
setPvpAllowedpublic void setPvpAllowed(boolean p_129998_) 
- 
isFlightAllowedpublic boolean isFlightAllowed()
- 
setFlightAllowedpublic void setFlightAllowed(boolean p_130000_) 
- 
isCommandBlockEnabledpublic abstract boolean isCommandBlockEnabled()
- 
getMotd- Specified by:
- getMotdin interface- ServerInfo
 
- 
setMotd
- 
isStoppedpublic boolean isStopped()
- 
getPlayerList
- 
setPlayerList
- 
isPublishedpublic abstract boolean isPublished()
- 
setDefaultGameType
- 
getConnection
- 
isReadypublic boolean isReady()
- 
hasGuipublic boolean hasGui()
- 
publishServer
- 
getTickCountpublic int getTickCount()
- 
getSpawnProtectionRadiuspublic int getSpawnProtectionRadius()
- 
isUnderSpawnProtection
- 
repliesToStatuspublic boolean repliesToStatus()
- 
hidesOnlinePlayerspublic boolean hidesOnlinePlayers()
- 
getProxy
- 
getPlayerIdleTimeoutpublic int getPlayerIdleTimeout()
- 
setPlayerIdleTimeoutpublic void setPlayerIdleTimeout(int p_129978_) 
- 
getSessionServicepublic com.mojang.authlib.minecraft.MinecraftSessionService getSessionService()
- 
getProfileKeySignatureValidator
- 
getProfileRepositorypublic com.mojang.authlib.GameProfileRepository getProfileRepository()
- 
getProfileCache
- 
getStatus
- 
invalidateStatuspublic void invalidateStatus()
- 
getAbsoluteMaxWorldSizepublic int getAbsoluteMaxWorldSize()
- 
scheduleExecutablespublic boolean scheduleExecutables()- Overrides:
- scheduleExecutablesin class- ReentrantBlockableEventLoop<TickTask>
 
- 
executeIfPossible- Overrides:
- executeIfPossiblein class- BlockableEventLoop<TickTask>
 
- 
getRunningThread- Specified by:
- getRunningThreadin class- BlockableEventLoop<TickTask>
 
- 
getCompressionThresholdpublic int getCompressionThreshold()
- 
enforceSecureProfilepublic boolean enforceSecureProfile()
- 
getNextTickTimepublic long getNextTickTime()
- 
getFixerUpperpublic com.mojang.datafixers.DataFixer getFixerUpper()
- 
getSpawnRadius
- 
getAdvancements
- 
getFunctions
- 
reloadResources
- 
configurePackRepositorypublic static WorldDataConfiguration configurePackRepository(PackRepository p_248681_, DataPackConfig p_248920_, boolean p_249869_, FeatureFlagSet p_251243_) 
- 
getSelectedPacks
- 
kickUnlistedPlayers
- 
getPackRepository
- 
getCommands
- 
createCommandSourceStack
- 
acceptsSuccesspublic boolean acceptsSuccess()- Specified by:
- acceptsSuccessin interface- CommandSource
 
- 
acceptsFailurepublic boolean acceptsFailure()- Specified by:
- acceptsFailurein interface- CommandSource
 
- 
shouldInformAdminspublic abstract boolean shouldInformAdmins()- Specified by:
- shouldInformAdminsin interface- CommandSource
 
- 
getRecipeManager
- 
getScoreboard
- 
getCommandStorage
- 
getLootData
- 
getGameRules
- 
getCustomBossEvents
- 
isEnforceWhitelistpublic boolean isEnforceWhitelist()
- 
setEnforceWhitelistpublic void setEnforceWhitelist(boolean p_130005_) 
- 
getAverageTickTimepublic float getAverageTickTime()
- 
getProfilePermissionspublic int getProfilePermissions(com.mojang.authlib.GameProfile p_129945_) 
- 
getProfiler
- 
isSingleplayerOwnerpublic abstract boolean isSingleplayerOwner(com.mojang.authlib.GameProfile p_129840_) 
- 
getTickTime
- 
forgeGetWorldMapDeprecated.
- 
markWorldsDirtyDeprecated.
- 
getWorldArray
- 
dumpServerProperties- Throws:
- IOException
 
- 
saveDebugReport
- 
dumpMiscStats- Throws:
- IOException
 
- 
dumpGameRules- Throws:
- IOException
 
- 
dumpClasspath- Throws:
- IOException
 
- 
dumpThreads- Throws:
- IOException
 
- 
dumpNativeModules- Throws:
- IOException
 
- 
startMetricsRecordingTickprivate void startMetricsRecordingTick()
- 
endMetricsRecordingTickprivate void endMetricsRecordingTick()
- 
isRecordingMetricspublic boolean isRecordingMetrics()
- 
startRecordingMetrics
- 
stopRecordingMetricspublic void stopRecordingMetrics()
- 
finishRecordingMetricspublic void finishRecordingMetrics()
- 
cancelRecordingMetricspublic void cancelRecordingMetrics()
- 
getWorldPath
- 
forceSynchronousWritespublic boolean forceSynchronousWrites()
- 
getStructureManager
- 
getWorldData
- 
getServerResources
- 
registryAccess
- 
registries
- 
createTextFilterForPlayer
- 
createGameModeForPlayer
- 
getForcedGameType
- 
getResourceManager
- 
isCurrentlySavingpublic boolean isCurrentlySaving()
- 
isTimeProfilerRunningpublic boolean isTimeProfilerRunning()
- 
startTimeProfilerpublic void startTimeProfiler()
- 
stopTimeProfiler
- 
getMaxChainedNeighborUpdatespublic int getMaxChainedNeighborUpdates()
- 
logChatMessagepublic void logChatMessage(Component p_241503_, ChatType.Bound p_241402_, @Nullable String p_241481_) 
- 
getChatDecorator
- 
logIPspublic boolean logIPs()
 
-