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>
,SnooperPopulator
- Direct Known Subclasses:
DedicatedServer
,GameTestServer
,IntegratedServer
public abstract class MinecraftServer
extends ReentrantBlockableEventLoop<TickTask>
implements SnooperPopulator, CommandSource, AutoCloseable
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic int
private boolean
private static int
private static float
private float
private CommandStorage
private ServerConnectionListener
private CustomBossEvents
private MinecraftServer.TimeProfiler
private boolean
private static long
private long
static LevelSettings
private boolean
private Executor
private com.mojang.datafixers.DataFixer
private FrameTimer
private ServerFunctionManager
private boolean
private boolean
private KeyPair
private long
private long
static String
static String
private Map<ResourceKey<Level>,ServerLevel>
private String
(package private) static org.apache.logging.log4j.Logger
static String
private static int
private static int
private boolean
private MetricsRecorder
private String
static int
protected long
private boolean
private Consumer<ProfileResults>
private static int
private static int
private PackRepository
private Map<ResourceKey<Level>,long[]>
protected PlayerDataStorage
private int
private PlayerList
private int
private boolean
private GameProfileCache
private ProfilerFiller
private com.mojang.authlib.GameProfileRepository
private ChunkProgressListenerFactory
protected Proxy
private boolean
private Random
protected RegistryAccess.RegistryHolder
private String
private String
private ServerResources
private boolean
private ServerScoreboard
private String
private Thread
private com.mojang.authlib.minecraft.MinecraftSessionService
private String
private Snooper
private static int
static int
private static int
private ServerStatus
private static long
private boolean
protected LevelStorageSource.LevelStorageAccess
private StructureManager
private static int
private int
long[]
static File
private boolean
private ServerLevel[]
private int
private int
protected WorldData
Fields inherited from interface net.minecraft.commands.CommandSource
NULL
-
Constructor Summary
ConstructorDescriptionMinecraftServer(Thread p_129769_, RegistryAccess.RegistryHolder p_129770_, LevelStorageSource.LevelStorageAccess p_129771_, WorldData p_129772_, PackRepository p_129773_, Proxy p_129774_, com.mojang.datafixers.DataFixer p_129775_, ServerResources p_129776_, com.mojang.authlib.minecraft.MinecraftSessionService p_129777_, com.mojang.authlib.GameProfileRepository p_129778_, GameProfileCache p_129779_, ChunkProgressListenerFactory p_129780_)
-
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
void
addTickable(Runnable p_129947_)
boolean
void
close()
static DataPackConfig
configurePackRepository(PackRepository p_129820_, DataPackConfig p_129821_, boolean p_129822_)
static void
createGameModeForPlayer(ServerPlayer p_177934_)
protected void
createLevels(ChunkProgressListener p_129816_)
createTextFilterForPlayer(ServerPlayer p_129814_)
protected void
void
private void
dumpClasspath(Path p_129992_)
private void
dumpGameRules(Path p_129984_)
private void
dumpMiscStats(Path p_129951_)
void
dumpServerProperties(Path p_177911_)
private void
dumpThreads(Path p_129996_)
private void
abstract SystemReport
fillServerSystemReport(SystemReport p_177901_)
fillSystemReport(SystemReport p_177936_)
void
protected void
boolean
Deprecated.int
float
int
com.mojang.datafixers.DataFixer
abstract int
getLevel(ResourceKey<Level> p_129881_)
int
getMotd()
long
abstract int
int
int
String[]
int
getPort()
boolean
int
getProfilePermissions(com.mojang.authlib.GameProfile p_129945_)
com.mojang.authlib.GameProfileRepository
getProxy()
abstract int
int
getScaledTrackingDistance(int p_129935_)
private static DataPackConfig
getSelectedPacks(PackRepository p_129818_)
com.mojang.authlib.minecraft.MinecraftSessionService
int
int
getSpawnRadius(ServerLevel p_129804_)
getTags()
int
long[]
getTickTime(ResourceKey<Level> dim)
private ServerLevel[]
getWorldPath(LevelResource p_129844_)
void
halt(boolean p_129884_)
boolean
hasGui()
private boolean
haveTime()
protected void
protected abstract boolean
void
abstract boolean
abstract boolean
boolean
isDemo()
boolean
abstract boolean
boolean
boolean
boolean
abstract boolean
boolean
boolean
isReady()
boolean
boolean
boolean
boolean
boolean
abstract boolean
isSingleplayerOwner(com.mojang.authlib.GameProfile p_129840_)
boolean
boolean
boolean
boolean
boolean
boolean
isUnderSpawnProtection(ServerLevel p_129811_, BlockPos p_129812_, Player p_129813_)
void
kickUnlistedPlayers(CommandSourceStack p_129850_)
protected void
void
Deprecated.protected void
onServerCrash(CrashReport p_129874_)
void
boolean
pollTask()
private boolean
void
populateSnooper(Snooper p_129831_)
void
populateSnooperInitial(Snooper p_177938_)
private void
prepareLevels(ChunkProgressListener p_129941_)
boolean
publishServer(GameType p_129833_, boolean p_129834_, int p_129835_)
private void
readScoreboard(DimensionDataStorage p_129842_)
reloadResources(Collection<String> p_129862_)
boolean
protected void
boolean
saveAllChunks(boolean p_129886_, boolean p_129887_, boolean p_129888_)
private void
saveDebugReport(Path p_129860_)
boolean
private void
sendDifficultyUpdate(ServerPlayer p_129939_)
void
sendMessage(Component p_129876_, UUID p_129877_)
void
setDefaultGameType(GameType p_129832_)
void
setDemo(boolean p_129976_)
void
setDifficulty(Difficulty p_129828_, boolean p_129829_)
void
setDifficultyLocked(boolean p_129959_)
void
setEnforceWhitelist(boolean p_130005_)
void
setFlightAllowed(boolean p_130000_)
protected void
private static void
setInitialSpawn(ServerLevel p_177897_, ServerLevelData p_177898_, boolean p_177899_, boolean p_177900_)
void
setLocalIp(String p_129914_)
void
void
setPlayerIdleTimeout(int p_129978_)
void
setPlayerList(PlayerList p_129824_)
void
setPort(int p_129802_)
void
setPreventProxyConnections(boolean p_129994_)
void
setPvpAllowed(boolean p_129998_)
void
setResourcePack(String p_129854_, String p_129855_)
void
setSingleplayerName(String p_129982_)
private void
setupDebugLevel(WorldData p_129848_)
void
setUsesAuthentication(boolean p_129986_)
abstract boolean
abstract boolean
protected boolean
static <S extends MinecraftServer>
Sprivate void
void
startRecordingMetrics(Consumer<ProfileResults> p_177924_, Consumer<Path> p_177925_)
void
void
void
void
tickChildren(BooleanSupplier p_129954_)
void
tickServer(BooleanSupplier p_129871_)
private void
private void
updateStatusIcon(ServerStatus p_129879_)
boolean
protected void
protected TickTask
wrapRunnable(Runnable p_129852_)
Methods inherited from class net.minecraft.util.thread.ReentrantBlockableEventLoop
runningTask
Methods inherited from class net.minecraft.util.thread.BlockableEventLoop
dropAllTasks, execute, executeBlocking, getPendingTasksCount, isSameThread, managedBlock, name, profiledMetrics, runAllTasks, submit, submit, submitAsync, tell, waitForTasks
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraft.commands.CommandSource
alwaysAccepts
Methods inherited from interface net.minecraft.util.thread.ProcessorHandle
ask, askEither
-
Field Details
-
LOGGER
static final org.apache.logging.log4j.Logger LOGGER -
AVERAGE_TICK_TIME_SMOOTHING
private static final float AVERAGE_TICK_TIME_SMOOTHING- See Also:
- Constant Field Values
-
TICK_STATS_SPAN
private static final int TICK_STATS_SPAN- See Also:
- Constant Field Values
-
MS_PER_TICK
public static final int MS_PER_TICK- See Also:
- Constant Field Values
-
SNOOPER_UPDATE_INTERVAL
private static final int SNOOPER_UPDATE_INTERVAL- See Also:
- Constant Field Values
-
OVERLOADED_THRESHOLD
private static final int OVERLOADED_THRESHOLD- See Also:
- Constant Field Values
-
OVERLOADED_WARNING_INTERVAL
private static final int OVERLOADED_WARNING_INTERVAL- See Also:
- Constant Field Values
-
LEVEL_STORAGE_PROTOCOL
- See Also:
- Constant Field Values
-
LEVEL_STORAGE_SCHEMA
- See Also:
- Constant Field Values
-
STATUS_EXPIRE_TIME_NS
private static final long STATUS_EXPIRE_TIME_NS- See Also:
- Constant Field Values
-
MAX_STATUS_PLAYER_SAMPLE
private static final int MAX_STATUS_PLAYER_SAMPLE- See Also:
- Constant Field Values
-
MAP_RESOURCE_FILE
- See Also:
- Constant Field Values
-
USERID_CACHE_FILE
-
START_CHUNK_RADIUS
public static final int START_CHUNK_RADIUS- See Also:
- Constant Field Values
-
START_TICKING_CHUNK_COUNT
private static final int START_TICKING_CHUNK_COUNT- See Also:
- Constant Field Values
-
AUTOSAVE_INTERVAL
private static final int AUTOSAVE_INTERVAL- See Also:
- Constant Field Values
-
MAX_TICK_LATENCY
private static final int MAX_TICK_LATENCY- See Also:
- Constant Field Values
-
ABSOLUTE_MAX_WORLD_SIZE
public static final int ABSOLUTE_MAX_WORLD_SIZE- See Also:
- Constant Field Values
-
DEMO_SETTINGS
-
DELAYED_TASKS_TICK_EXTENSION
private static final long DELAYED_TASKS_TICK_EXTENSION- See Also:
- Constant Field Values
-
storageSource
-
playerDataStorage
-
snooper
-
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
-
perWorldTickTimes
-
worldArrayMarker
private int worldArrayMarker -
worldArrayLast
private int worldArrayLast -
worldArray
-
-
Constructor Details
-
MinecraftServer
public MinecraftServer(Thread p_129769_, RegistryAccess.RegistryHolder p_129770_, LevelStorageSource.LevelStorageAccess p_129771_, WorldData p_129772_, PackRepository p_129773_, Proxy p_129774_, com.mojang.datafixers.DataFixer p_129775_, ServerResources p_129776_, @Nullable com.mojang.authlib.minecraft.MinecraftSessionService p_129777_, @Nullable com.mojang.authlib.GameProfileRepository p_129778_, @Nullable GameProfileCache p_129779_, ChunkProgressListenerFactory p_129780_)
-
-
Method Details
-
spin
-
readScoreboard
-
initServer
- Throws:
IOException
-
convertFromRegionFormatIfNeeded
public static void convertFromRegionFormatIfNeeded(LevelStorageSource.LevelStorageAccess p_129846_) -
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_) -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceProcessorHandle<TickTask>
-
stopServer
public void stopServer() -
getLocalIp
-
setLocalIp
-
isRunning
public boolean isRunning() -
halt
public void halt(boolean p_129884_) -
runServer
protected void runServer() -
haveTime
private boolean haveTime() -
waitUntilNextTick
protected void waitUntilNextTick() -
wrapRunnable
- Specified by:
wrapRunnable
in classBlockableEventLoop<TickTask>
-
shouldRun
- Specified by:
shouldRun
in classBlockableEventLoop<TickTask>
-
pollTask
public boolean pollTask()- Overrides:
pollTask
in classBlockableEventLoop<TickTask>
-
pollTaskInternal
private boolean pollTaskInternal() -
doRunTask
- Overrides:
doRunTask
in 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:
sendMessage
in 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
-
populateSnooper
- Specified by:
populateSnooper
in interfaceSnooperPopulator
-
populateSnooperInitial
- Specified by:
populateSnooperInitial
in interfaceSnooperPopulator
-
isSnooperEnabled
public boolean isSnooperEnabled()- Specified by:
isSnooperEnabled
in interfaceSnooperPopulator
-
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() -
getSnooper
-
getSpawnProtectionRadius
public int getSpawnProtectionRadius() -
isUnderSpawnProtection
-
repliesToStatus
public boolean repliesToStatus() -
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:
scheduleExecutables
in classReentrantBlockableEventLoop<TickTask>
-
getRunningThread
- Specified by:
getRunningThread
in 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:
acceptsSuccess
in interfaceCommandSource
-
acceptsFailure
public boolean acceptsFailure()- Specified by:
acceptsFailure
in interfaceCommandSource
-
shouldInformAdmins
public abstract boolean shouldInformAdmins()- Specified by:
shouldInformAdmins
in interfaceCommandSource
-
getRecipeManager
-
getTags
-
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
-
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
-
isTimeProfilerRunning
public boolean isTimeProfilerRunning() -
startTimeProfiler
public void startTimeProfiler() -
stopTimeProfiler
-