Package net.minecraft.server
Class MinecraftServer
- All Implemented Interfaces:
AutoCloseable
,Executor
,CommandOutput
,SnooperListener
,MessageListener<ServerTask>
- Direct Known Subclasses:
IntegratedServer
,MinecraftDedicatedServer
public abstract class MinecraftServer extends ReentrantThreadExecutor<ServerTask> implements SnooperListener, CommandOutput, AutoCloseable
-
Field Summary
Fields inherited from interface net.minecraft.server.command.CommandOutput
DUMMY
-
Constructor Summary
Constructors Constructor Description MinecraftServer(Thread thread, DynamicRegistryManager.Impl impl, LevelStorage.Session session, SaveProperties saveProperties, ResourcePackManager resourcePackManager, Proxy proxy, com.mojang.datafixers.DataFixer dataFixer, ServerResourceManager serverResourceManager, com.mojang.authlib.minecraft.MinecraftSessionService minecraftSessionService, com.mojang.authlib.GameProfileRepository gameProfileRepository, UserCache userCache, WorldGenerationProgressListenerFactory worldGenerationProgressListenerFactory)
-
Method Summary
Methods inherited from class net.minecraft.util.thread.ReentrantThreadExecutor
hasRunningTasks
Methods inherited from class net.minecraft.util.thread.ThreadExecutor
cancelTasks, execute, getName, getTaskCount, isOnThread, runTasks, runTasks, send, submit, submit, submitAndJoin, 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.server.command.CommandOutput
shouldBroadcastConsoleToOps
Methods inherited from interface net.minecraft.util.thread.MessageListener
ask, method_27918
-
Field Details
-
LOGGER
-
USER_CACHE_FILE
-
DEMO_LEVEL_INFO
-
session
-
saveHandler
-
snooper
-
serverGuiTickables
-
tickTimeTracker
-
profiler
-
networkIo
-
worldGenerationProgressListenerFactory
-
metadata
-
random
-
dataFixer
private final com.mojang.datafixers.DataFixer dataFixer -
serverIp
-
serverPort
private int serverPort -
registryManager
-
worlds
-
playerManager
-
running
private volatile boolean running -
stopped
private boolean stopped -
ticks
private int ticks -
proxy
-
onlineMode
private boolean onlineMode -
preventProxyConnections
private boolean preventProxyConnections -
pvpEnabled
private boolean pvpEnabled -
flightEnabled
private boolean flightEnabled -
motd
-
worldHeight
private int worldHeight -
playerIdleTimeout
private int playerIdleTimeout -
lastTickLengths
public final long[] lastTickLengths -
keyPair
-
userName
-
demo
private boolean demo -
resourcePackUrl
-
resourcePackHash
-
loading
private volatile boolean loading -
lastTimeReference
private long lastTimeReference -
profilerStartQueued
private boolean profilerStartQueued -
forceGameMode
private boolean forceGameMode -
sessionService
private final com.mojang.authlib.minecraft.MinecraftSessionService sessionService -
gameProfileRepo
private final com.mojang.authlib.GameProfileRepository gameProfileRepo -
userCache
-
lastPlayerSampleUpdate
private long lastPlayerSampleUpdate -
serverThread
-
timeReference
private long timeReference -
field_19248
private long field_19248 -
waitingForNextTick
private boolean waitingForNextTick -
iconFilePresent
@Environment(CLIENT) private boolean iconFilePresent -
dataPackManager
-
scoreboard
-
dataCommandStorage
-
bossBarManager
-
commandFunctionManager
-
metricsData
-
enforceWhitelist
private boolean enforceWhitelist -
tickTime
private float tickTime -
workerExecutor
-
serverId
-
serverResourceManager
-
structureManager
-
saveProperties
-
-
Constructor Details
-
MinecraftServer
public MinecraftServer(Thread thread, DynamicRegistryManager.Impl impl, LevelStorage.Session session, SaveProperties saveProperties, ResourcePackManager resourcePackManager, Proxy proxy, com.mojang.datafixers.DataFixer dataFixer, ServerResourceManager serverResourceManager, com.mojang.authlib.minecraft.MinecraftSessionService minecraftSessionService, com.mojang.authlib.GameProfileRepository gameProfileRepository, UserCache userCache, WorldGenerationProgressListenerFactory worldGenerationProgressListenerFactory)
-
-
Method Details
-
startServer
-
initScoreboard
-
setupServer
- Throws:
IOException
-
convertLevel
-
loadWorld
protected void loadWorld() -
method_27731
protected void method_27731() -
createWorlds
-
setupSpawn
private static void setupSpawn(ServerWorld world, ServerWorldProperties serverWorldProperties, boolean bonusChest, boolean debugWorld, boolean bool) -
setToDebugWorldProperties
-
prepareStartRegion
-
loadWorldResourcePack
protected void loadWorldResourcePack() -
getDefaultGameMode
-
isHardcore
public boolean isHardcore() -
getOpPermissionLevel
public abstract int getOpPermissionLevel() -
getFunctionPermissionLevel
public abstract int getFunctionPermissionLevel() -
shouldBroadcastRconToOps
public abstract boolean shouldBroadcastRconToOps() -
save
public boolean save(boolean suppressLogs, boolean bool, boolean bool2) -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceMessageListener<ServerTask>
-
shutdown
protected void shutdown() -
getServerIp
-
setServerIp
-
isRunning
public boolean isRunning() -
stop
public void stop(boolean bool) -
runServer
protected void runServer() -
shouldKeepTicking
private boolean shouldKeepTicking() -
method_16208
protected void method_16208() -
createTask
- Specified by:
createTask
in classThreadExecutor<ServerTask>
-
canExecute
- Specified by:
canExecute
in classThreadExecutor<ServerTask>
-
runTask
public boolean runTask()- Overrides:
runTask
in classThreadExecutor<ServerTask>
-
method_20415
private boolean method_20415() -
executeTask
- Overrides:
executeTask
in classReentrantThreadExecutor<ServerTask>
-
setFavicon
-
hasIconFile
@Environment(CLIENT) public boolean hasIconFile() -
getIconFile
-
getRunDirectory
-
setCrashReport
-
exit
protected void exit() -
tick
-
tickWorlds
-
isNetherAllowed
public boolean isNetherAllowed() -
addServerGuiTickable
-
setServerId
-
isStopping
@Environment(CLIENT) public boolean isStopping() -
getFile
- Parameters:
path
- relative path from the run directory
-
getOverworld
-
getWorld
-
getWorldRegistryKeys
-
getWorlds
-
getVersion
-
getCurrentPlayerCount
public int getCurrentPlayerCount() -
getMaxPlayerCount
public int getMaxPlayerCount() -
getPlayerNames
-
getServerModName
-
populateCrashReport
-
getModdedStatusMessage
-
sendSystemMessage
- Specified by:
sendSystemMessage
in interfaceCommandOutput
-
getKeyPair
-
getServerPort
public int getServerPort() -
setServerPort
public void setServerPort(int serverPort) -
getUserName
-
setServerName
-
isSinglePlayer
public boolean isSinglePlayer() -
method_31400
protected void method_31400() -
setDifficulty
-
adjustTrackingDistance
public int adjustTrackingDistance(int initialDistance) -
updateMobSpawnOptions
private void updateMobSpawnOptions() -
setDifficultyLocked
public void setDifficultyLocked(boolean locked) -
sendDifficulty
-
isMonsterSpawningEnabled
protected boolean isMonsterSpawningEnabled() -
isDemo
public boolean isDemo() -
setDemo
public void setDemo(boolean demo) -
getResourcePackUrl
-
getResourcePackHash
-
setResourcePack
-
addSnooperInfo
- Specified by:
addSnooperInfo
in interfaceSnooperListener
-
isDedicated
public abstract boolean isDedicated() -
getRateLimit
public abstract int getRateLimit() -
isOnlineMode
public boolean isOnlineMode() -
setOnlineMode
public void setOnlineMode(boolean onlineMode) -
shouldPreventProxyConnections
public boolean shouldPreventProxyConnections() -
setPreventProxyConnections
public void setPreventProxyConnections(boolean preventProxyConnections) -
shouldSpawnAnimals
public boolean shouldSpawnAnimals() -
shouldSpawnNpcs
public boolean shouldSpawnNpcs() -
isUsingNativeTransport
public abstract boolean isUsingNativeTransport() -
isPvpEnabled
public boolean isPvpEnabled() -
setPvpEnabled
public void setPvpEnabled(boolean pvpEnabled) -
isFlightEnabled
public boolean isFlightEnabled() -
setFlightEnabled
public void setFlightEnabled(boolean flightEnabled) -
areCommandBlocksEnabled
public abstract boolean areCommandBlocksEnabled()Specifies whether command blocks can execute commands on the server. -
getServerMotd
-
setMotd
-
getWorldHeight
public int getWorldHeight() -
setWorldHeight
public void setWorldHeight(int worldHeight) -
isStopped
public boolean isStopped() -
getPlayerManager
-
setPlayerManager
-
isRemote
public abstract boolean isRemote() -
setDefaultGameMode
-
getNetworkIo
-
isLoading
@Environment(CLIENT) public boolean isLoading() -
hasGui
public boolean hasGui() -
openToLan
Opens a server for LAN connections. This is only supported on an integrated server, a dedicated server will always fail to open to LAN.- Parameters:
gameMode
- the game mode connecting players will have set by defaultcheatsAllowed
- whether players on the server have operator permissionsport
- the port to open up to LAN connections- Returns:
- whether the server was successfully opened to LAN
-
getTicks
public int getTicks()Gets the amount of ticks the server has been running for. -
getSnooper
-
getSpawnProtectionRadius
public int getSpawnProtectionRadius() -
isSpawnProtected
-
setForceGameMode
public void setForceGameMode(boolean forceGameMode)Sets whether a player's current game mode should be set to the server's current game mode when a player has connected. -
shouldForceGameMode
public boolean shouldForceGameMode()Checks whether a player's current game mode should be set to the server's current game mode when a player has connected. -
acceptsStatusQuery
public boolean acceptsStatusQuery() -
getPlayerIdleTimeout
public int getPlayerIdleTimeout() -
setPlayerIdleTimeout
public void setPlayerIdleTimeout(int playerIdleTimeout) -
getSessionService
public com.mojang.authlib.minecraft.MinecraftSessionService getSessionService() -
getGameProfileRepo
public com.mojang.authlib.GameProfileRepository getGameProfileRepo() -
getUserCache
-
getServerMetadata
-
forcePlayerSampleUpdate
public void forcePlayerSampleUpdate() -
getMaxWorldBorderRadius
public int getMaxWorldBorderRadius() -
shouldExecuteAsync
public boolean shouldExecuteAsync()- Overrides:
shouldExecuteAsync
in classReentrantThreadExecutor<ServerTask>
-
getThread
- Specified by:
getThread
in classThreadExecutor<ServerTask>
-
getNetworkCompressionThreshold
public int getNetworkCompressionThreshold() -
getServerStartTime
public long getServerStartTime() -
getDataFixer
public com.mojang.datafixers.DataFixer getDataFixer() -
getSpawnRadius
-
getAdvancementLoader
-
getCommandFunctionManager
-
reloadResources
Reloads this server's datapacks.- Parameters:
datapacks
- a collection of datapacks to reload with- Returns:
- a completable future which specifies whether the reload was successful A reload has failed when the future is exceptionally completed.
- See Also:
CompletableFuture
-
loadDataPacks
public static DataPackSettings loadDataPacks(ResourcePackManager resourcePackManager, DataPackSettings dataPackSettings, boolean safeMode) -
method_29735
-
kickNonWhitelistedPlayers
-
getDataPackManager
-
getCommandManager
Gets the server's command manager. The command manager is responsible for parsing and dispatching commands. -
getCommandSource
Creates a command source which represents this Minecraft server instance. -
shouldReceiveFeedback
public boolean shouldReceiveFeedback()- Specified by:
shouldReceiveFeedback
in interfaceCommandOutput
-
shouldTrackOutput
public boolean shouldTrackOutput()- Specified by:
shouldTrackOutput
in interfaceCommandOutput
-
getRecipeManager
-
getTagManager
-
getScoreboard
-
getDataCommandStorage
-
getLootManager
-
getPredicateManager
-
getGameRules
-
getBossBarManager
-
isEnforceWhitelist
public boolean isEnforceWhitelist() -
setEnforceWhitelist
public void setEnforceWhitelist(boolean whitelistEnabled) -
getTickTime
public float getTickTime() -
getPermissionLevel
public int getPermissionLevel(com.mojang.authlib.GameProfile profile) -
getMetricsData
-
getProfiler
-
isHost
public abstract boolean isHost(com.mojang.authlib.GameProfile profile) -
dump
- Throws:
IOException
-
dumpStats
- Throws:
IOException
-
dumpExampleCrash
- Throws:
IOException
-
dumpGamerules
- Throws:
IOException
-
dumpClasspath
- Throws:
IOException
-
dumpThreads
- Throws:
IOException
-
startMonitor
-
endMonitor
-
isDebugRunning
public boolean isDebugRunning() -
enableProfiler
public void enableProfiler() -
stopDebug
-
getSavePath
-
syncChunkWrites
public boolean syncChunkWrites() -
getStructureManager
-
getSaveProperties
-
getRegistryManager
-
createFilterer
-