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,ProfilerMeasured,ProcessorHandle<TickTask>
- Direct Known Subclasses:
DedicatedServer,GameTestServer,IntegratedServer
public abstract class MinecraftServer
extends ReentrantBlockableEventLoop<TickTask>
implements CommandSource, AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intprivate booleanstatic final com.mojang.authlib.GameProfileprivate static final intprivate static final floatprivate floatprivate CommandStorageprivate final ServerConnectionListenerprivate final CustomBossEventsprivate MinecraftServer.TimeProfilerprivate booleanprivate static final longprivate longstatic final LevelSettingsprivate booleanprivate final Executorprivate final com.mojang.datafixers.DataFixerprivate final FrameTimerprivate final ServerFunctionManagerprivate booleanprivate booleanprivate booleanprivate KeyPairprivate longprivate longstatic final Stringstatic final Stringprivate final Map<ResourceKey<Level>,ServerLevel> private Stringprivate static final org.slf4j.Loggerstatic final Stringprivate 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 final GameProfileCacheprivate ProfilerFillerprivate final com.mojang.authlib.GameProfileRepositoryprivate final ChunkProgressListenerFactoryprotected final Proxyprivate booleanprivate final Randomprivate final RegistryAccess.Frozenprivate Stringprivate Stringprivate booleanprivate final ServerScoreboardprivate Stringprivate final Threadprivate final com.mojang.authlib.minecraft.MinecraftSessionServiceprivate Stringstatic final intprivate static final intprivate final ServerStatusprivate static final longprivate booleanprotected final LevelStorageSource.LevelStorageAccessprivate final StructureManagerprivate static final intprivate intfinal long[]static final Filestatic final Stringprivate booleanprivate ServerLevel[]private intprivate intprotected final WorldDataFields inherited from interface net.minecraft.commands.CommandSource
NULL -
Constructor Summary
ConstructorsConstructorDescriptionMinecraftServer(Thread p_206546_, LevelStorageSource.LevelStorageAccess p_206547_, PackRepository p_206548_, WorldStem p_206549_, Proxy p_206550_, com.mojang.datafixers.DataFixer p_206551_, com.mojang.authlib.minecraft.MinecraftSessionService p_206552_, com.mojang.authlib.GameProfileRepository p_206553_, GameProfileCache p_206554_, ChunkProgressListenerFactory p_206555_) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanvoidaddTickable(Runnable p_129947_) booleanvoidclose()static DataPackConfigconfigurePackRepository(PackRepository p_129820_, DataPackConfig p_129821_, boolean p_129822_) private static CrashReportconstructOrExtractCrashReport(Throwable p_206569_) createGameModeForPlayer(ServerPlayer p_177934_) protected voidcreateLevels(ChunkProgressListener p_129816_) createTextFilterForPlayer(ServerPlayer p_129814_) protected voidvoidprivate 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 voidvoidexecuteIfPossible(Runnable p_202482_) abstract SystemReportfillServerSystemReport(SystemReport p_177901_) fillSystemReport(SystemReport p_177936_) voidprotected voidbooleanDeprecated.intfloatintcom.mojang.datafixers.DataFixerabstract intgetLevel(ResourceKey<Level> p_129881_) intgetMotd()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.MinecraftSessionServiceintintgetSpawnRadius(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 voidvoidDeprecated.protected 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_) booleanprotected 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_) voidsendMessage(Component p_129876_, UUID p_129877_) 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_) voidsetResourcePack(String p_129854_, String p_129855_) voidsetSingleplayerName(String p_129982_) 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_) voidvoidvoidvoidtickChildren(BooleanSupplier p_129954_) voidtickServer(BooleanSupplier p_129871_) private voidprivate voidupdateStatusIcon(ServerStatus p_129879_) booleanprotected voidprotected TickTaskwrapRunnable(Runnable p_129852_) Methods inherited from class net.minecraft.util.thread.ReentrantBlockableEventLoop
runningTaskMethods inherited from class net.minecraft.util.thread.BlockableEventLoop
dropAllTasks, execute, executeBlocking, getPendingTasksCount, isSameThread, managedBlock, name, profiledMetrics, runAllTasks, submit, submit, submitAsync, tell, waitForTasksMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.commands.CommandSource
alwaysAcceptsMethods inherited from interface net.minecraft.util.thread.ProcessorHandle
ask, askEither
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
VANILLA_BRAND
- See Also:
-
AVERAGE_TICK_TIME_SMOOTHING
private static final float AVERAGE_TICK_TIME_SMOOTHING- See Also:
-
TICK_STATS_SPAN
private static final int TICK_STATS_SPAN- See Also:
-
MS_PER_TICK
public static final int MS_PER_TICK- See Also:
-
OVERLOADED_THRESHOLD
private static final int OVERLOADED_THRESHOLD- See Also:
-
OVERLOADED_WARNING_INTERVAL
private static final int OVERLOADED_WARNING_INTERVAL- See Also:
-
LEVEL_STORAGE_PROTOCOL
- See Also:
-
LEVEL_STORAGE_SCHEMA
- See Also:
-
STATUS_EXPIRE_TIME_NS
private static final long STATUS_EXPIRE_TIME_NS- See Also:
-
MAX_STATUS_PLAYER_SAMPLE
private static final int MAX_STATUS_PLAYER_SAMPLE- See Also:
-
MAP_RESOURCE_FILE
- See Also:
-
USERID_CACHE_FILE
-
START_CHUNK_RADIUS
public static final int START_CHUNK_RADIUS- See Also:
-
START_TICKING_CHUNK_COUNT
private static final int START_TICKING_CHUNK_COUNT- See Also:
-
AUTOSAVE_INTERVAL
private static final int AUTOSAVE_INTERVAL- See Also:
-
MAX_TICK_LATENCY
private static final int MAX_TICK_LATENCY- See Also:
-
ABSOLUTE_MAX_WORLD_SIZE
public static final int ABSOLUTE_MAX_WORLD_SIZE- See Also:
-
DEMO_SETTINGS
-
DELAYED_TASKS_TICK_EXTENSION
private static final long DELAYED_TASKS_TICK_EXTENSION- See Also:
-
ANONYMOUS_PLAYER_PROFILE
public static final com.mojang.authlib.GameProfile ANONYMOUS_PLAYER_PROFILE -
storageSource
-
playerDataStorage
-
tickables
-
metricsRecorder
-
profiler
-
onMetricsRecordingStopped
-
onMetricsRecordingFinished
-
willStartRecordingMetrics
private boolean willStartRecordingMetrics -
debugCommandProfiler
-
debugCommandProfilerDelayStart
private boolean debugCommandProfilerDelayStart -
connection
-
progressListenerFactory
-
status
-
random
-
fixerUpper
private final com.mojang.datafixers.DataFixer fixerUpper -
localIp
-
port
private int port -
registryHolder
-
levels
-
playerList
-
running
private volatile boolean running -
stopped
private boolean stopped -
tickCount
private int tickCount -
proxy
-
onlineMode
private boolean onlineMode -
preventProxyConnections
private boolean preventProxyConnections -
pvp
private boolean pvp -
allowFlight
private boolean allowFlight -
motd
-
playerIdleTimeout
private int playerIdleTimeout -
tickTimes
public final long[] tickTimes -
keyPair
-
singleplayerName
-
isDemo
private boolean isDemo -
resourcePack
-
resourcePackHash
-
isReady
private volatile boolean isReady -
lastOverloadWarning
private long lastOverloadWarning -
sessionService
private final com.mojang.authlib.minecraft.MinecraftSessionService sessionService -
profileRepository
@Nullable private final com.mojang.authlib.GameProfileRepository profileRepository -
profileCache
-
lastServerStatus
private long lastServerStatus -
serverThread
-
nextTickTime
protected long nextTickTime -
delayedTasksMaxNextTickTime
private long delayedTasksMaxNextTickTime -
mayHaveDelayedTasks
private boolean mayHaveDelayedTasks -
packRepository
-
scoreboard
-
commandStorage
-
customBossEvents
-
functionManager
-
frameTimer
-
enforceWhitelist
private boolean enforceWhitelist -
averageTickTime
private float averageTickTime -
executor
-
serverId
-
resources
-
structureManager
-
worldData
-
isSaving
private volatile boolean isSaving -
perWorldTickTimes
-
worldArrayMarker
private int worldArrayMarker -
worldArrayLast
private int worldArrayLast -
worldArray
-
-
Constructor Details
-
MinecraftServer
public MinecraftServer(Thread p_206546_, LevelStorageSource.LevelStorageAccess p_206547_, PackRepository p_206548_, WorldStem p_206549_, Proxy p_206550_, com.mojang.datafixers.DataFixer p_206551_, @Nullable com.mojang.authlib.minecraft.MinecraftSessionService p_206552_, @Nullable com.mojang.authlib.GameProfileRepository p_206553_, @Nullable GameProfileCache p_206554_, ChunkProgressListenerFactory p_206555_)
-
-
Method Details
-
spin
-
readScoreboard
-
initServer
- Throws:
IOException
-
loadLevel
protected void loadLevel() -
forceDifficulty
protected void forceDifficulty() -
createLevels
-
setInitialSpawn
private static void setInitialSpawn(ServerLevel p_177897_, ServerLevelData p_177898_, boolean p_177899_, boolean p_177900_) -
setupDebugLevel
-
prepareLevels
-
detectBundledResources
protected void detectBundledResources() -
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_129886_, boolean p_129887_, boolean p_129888_) -
saveEverything
public boolean saveEverything(boolean p_195515_, boolean p_195516_, boolean p_195517_) -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceProcessorHandle<TickTask>
-
stopServer
public void stopServer() -
getLocalIp
-
setLocalIp
-
isRunning
public boolean isRunning() -
halt
public void halt(boolean p_129884_) -
runServer
protected void runServer() -
constructOrExtractCrashReport
-
haveTime
private boolean haveTime() -
waitUntilNextTick
protected void waitUntilNextTick() -
wrapRunnable
- Specified by:
wrapRunnablein classBlockableEventLoop<TickTask>
-
shouldRun
- Specified by:
shouldRunin classBlockableEventLoop<TickTask>
-
pollTask
public boolean pollTask()- Overrides:
pollTaskin classBlockableEventLoop<TickTask>
-
pollTaskInternal
private boolean pollTaskInternal() -
doRunTask
- Overrides:
doRunTaskin classReentrantBlockableEventLoop<TickTask>
-
updateStatusIcon
-
getWorldScreenshotFile
-
getServerDirectory
-
onServerCrash
-
onServerExit
public void onServerExit() -
tickServer
-
tickChildren
-
isNetherEnabled
public boolean isNetherEnabled() -
addTickable
-
setId
-
isShutdown
public boolean isShutdown() -
getFile
-
overworld
-
getLevel
-
levelKeys
-
getAllLevels
-
getServerVersion
-
getPlayerCount
public int getPlayerCount() -
getMaxPlayers
public int getMaxPlayers() -
getPlayerNames
-
getServerModName
-
fillSystemReport
-
fillServerSystemReport
-
getModdedStatus
-
sendMessage
- Specified by:
sendMessagein interfaceCommandSource
-
getKeyPair
-
getPort
public int getPort() -
setPort
public void setPort(int p_129802_) -
getSingleplayerName
-
setSingleplayerName
-
isSingleplayer
public boolean isSingleplayer() -
initializeKeyPair
protected void initializeKeyPair() -
setDifficulty
-
getScaledTrackingDistance
public int getScaledTrackingDistance(int p_129935_) -
updateMobSpawningFlags
private void updateMobSpawningFlags() -
setDifficultyLocked
public void setDifficultyLocked(boolean p_129959_) -
sendDifficultyUpdate
-
isSpawningMonsters
public boolean isSpawningMonsters() -
isDemo
public boolean isDemo() -
setDemo
public void setDemo(boolean p_129976_) -
getResourcePack
-
getResourcePackHash
-
setResourcePack
-
isDedicatedServer
public abstract boolean isDedicatedServer() -
getRateLimitPacketsPerSecond
public abstract int getRateLimitPacketsPerSecond() -
usesAuthentication
public boolean usesAuthentication() -
setUsesAuthentication
public void setUsesAuthentication(boolean p_129986_) -
getPreventProxyConnections
public boolean getPreventProxyConnections() -
setPreventProxyConnections
public void setPreventProxyConnections(boolean p_129994_) -
isSpawningAnimals
public boolean isSpawningAnimals() -
areNpcsEnabled
public boolean areNpcsEnabled() -
isEpollEnabled
public abstract boolean isEpollEnabled() -
isPvpAllowed
public boolean isPvpAllowed() -
setPvpAllowed
public void setPvpAllowed(boolean p_129998_) -
isFlightAllowed
public boolean isFlightAllowed() -
setFlightAllowed
public void setFlightAllowed(boolean p_130000_) -
isCommandBlockEnabled
public abstract boolean isCommandBlockEnabled() -
getMotd
-
setMotd
-
isStopped
public boolean isStopped() -
getPlayerList
-
setPlayerList
-
isPublished
public abstract boolean isPublished() -
setDefaultGameType
-
getConnection
-
isReady
public boolean isReady() -
hasGui
public boolean hasGui() -
publishServer
-
getTickCount
public int getTickCount() -
getSpawnProtectionRadius
public int getSpawnProtectionRadius() -
isUnderSpawnProtection
-
repliesToStatus
public boolean repliesToStatus() -
hidesOnlinePlayers
public boolean hidesOnlinePlayers() -
getProxy
-
getPlayerIdleTimeout
public int getPlayerIdleTimeout() -
setPlayerIdleTimeout
public void setPlayerIdleTimeout(int p_129978_) -
getSessionService
public com.mojang.authlib.minecraft.MinecraftSessionService getSessionService() -
getProfileRepository
public com.mojang.authlib.GameProfileRepository getProfileRepository() -
getProfileCache
-
getStatus
-
invalidateStatus
public void invalidateStatus() -
getAbsoluteMaxWorldSize
public int getAbsoluteMaxWorldSize() -
scheduleExecutables
public boolean scheduleExecutables()- Overrides:
scheduleExecutablesin classReentrantBlockableEventLoop<TickTask>
-
executeIfPossible
- Overrides:
executeIfPossiblein classBlockableEventLoop<TickTask>
-
getRunningThread
- Specified by:
getRunningThreadin classBlockableEventLoop<TickTask>
-
getCompressionThreshold
public int getCompressionThreshold() -
getNextTickTime
public long getNextTickTime() -
getFixerUpper
public com.mojang.datafixers.DataFixer getFixerUpper() -
getSpawnRadius
-
getAdvancements
-
getFunctions
-
reloadResources
-
configurePackRepository
public static DataPackConfig configurePackRepository(PackRepository p_129820_, DataPackConfig p_129821_, boolean p_129822_) -
getSelectedPacks
-
kickUnlistedPlayers
-
getPackRepository
-
getCommands
-
createCommandSourceStack
-
acceptsSuccess
public boolean acceptsSuccess()- Specified by:
acceptsSuccessin interfaceCommandSource
-
acceptsFailure
public boolean acceptsFailure()- Specified by:
acceptsFailurein interfaceCommandSource
-
shouldInformAdmins
public abstract boolean shouldInformAdmins()- Specified by:
shouldInformAdminsin interfaceCommandSource
-
getRecipeManager
-
getScoreboard
-
getCommandStorage
-
getLootTables
-
getPredicateManager
-
getItemModifierManager
-
getGameRules
-
getCustomBossEvents
-
isEnforceWhitelist
public boolean isEnforceWhitelist() -
setEnforceWhitelist
public void setEnforceWhitelist(boolean p_130005_) -
getAverageTickTime
public float getAverageTickTime() -
getProfilePermissions
public int getProfilePermissions(com.mojang.authlib.GameProfile p_129945_) -
getFrameTimer
-
getProfiler
-
isSingleplayerOwner
public abstract boolean isSingleplayerOwner(com.mojang.authlib.GameProfile p_129840_) -
getTickTime
-
forgeGetWorldMap
Deprecated. -
markWorldsDirty
Deprecated. -
getWorldArray
-
dumpServerProperties
- Throws:
IOException
-
saveDebugReport
-
dumpMiscStats
- Throws:
IOException
-
dumpGameRules
- Throws:
IOException
-
dumpClasspath
- Throws:
IOException
-
dumpThreads
- Throws:
IOException
-
dumpNativeModules
- Throws:
IOException
-
startMetricsRecordingTick
private void startMetricsRecordingTick() -
endMetricsRecordingTick
private void endMetricsRecordingTick() -
isRecordingMetrics
public boolean isRecordingMetrics() -
startRecordingMetrics
-
stopRecordingMetrics
public void stopRecordingMetrics() -
finishRecordingMetrics
public void finishRecordingMetrics() -
getWorldPath
-
forceSynchronousWrites
public boolean forceSynchronousWrites() -
getStructureManager
-
getWorldData
-
getServerResources
-
registryAccess
-
createTextFilterForPlayer
-
isResourcePackRequired
public boolean isResourcePackRequired() -
createGameModeForPlayer
-
getForcedGameType
-
getResourceManager
-
getResourcePackPrompt
-
isCurrentlySaving
public boolean isCurrentlySaving() -
isTimeProfilerRunning
public boolean isTimeProfilerRunning() -
startTimeProfiler
public void startTimeProfiler() -
stopTimeProfiler
-