Package net.minecraft.server
Class MinecraftServer
java.lang.Object
net.minecraft.server.MinecraftServer
- All Implemented Interfaces:
Runnable,ICommandSender,IPlayerUsage
- Direct Known Subclasses:
DedicatedServer,IntegratedServer
public abstract class MinecraftServer
extends Object
implements ICommandSender, Runnable, IPlayerUsage
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal ServerCommandManagerThe task the server is currently working on(and will output on outputPercentRemaining).Stores debug datas for a set amount of time before sending it to the clientintprotected DifficultyintThe percentage of the current task finished so far.final long[]final long[]final long[]final long[]protected Proxyfinal Profilerfinal long[]long[][]Stats are [dimension][tick%100] system.nanoTime is stored.The server world instances. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddServerInfoToCrashReport(CrashReport par1CrashReport) Adds the server info, including from theWorldServer, to the crash report.voidaddServerStatsToSnooper(PlayerUsageSnooper par1PlayerUsageSnooper) voidaddServerTypeToSnooper(PlayerUsageSnooper par1PlayerUsageSnooper) protected booleanbooleancanCommandSenderUseCommand(int par1, String par2Str) Returns true if the command sender is allowed to use the given command.voidcanCreateBonusChest(boolean par1) abstract booleanprotected voidSet current task to null and set its percentage to 0.protected voidconvertMapIfNeeded(String par1Str) voidWARNING : directly calls getActiveAnvilConverter().deleteWorldDirectory(theWorldServer[0].getSaveHandler().getWorldDirectoryName());voidexecuteCommand(String par1Str) protected voidfinalTick(CrashReport par1CrashReport) Called on exit from the main run() loop.abstract intvoidfunc_143006_e(int par1) intvoidfunc_82010_a(IUpdatePlayerListBox par1IUpdatePlayerListBox) booleanString[]Returns an array of the usernames of all the connected players.intbooleanbooleanGets the name of this command sender (usually username, but possibly "Rcon")intReturns the number of players currently on the server.static longreturns the difference, measured in milliseconds, between the current system time and midnight, January 1, 1970 UTC.protected Fileabstract intDefaults to "1" (Easy) for the dedicated server, defaults to "2" (Normal) on the client.Returns a File object from the specified string.booleanabstract EnumGameTypebooleanReturns the server's hostname.static booleanGets KeyPair instanced in MinecraftServer.abstract ILogAgentintReturns the maximum number of players allowed on the server.Returns the server's Minecraft version as string.getMotd()Returns the server message of the daygetMOTD()abstract NetworkListenThreadReturn the position for this command sender.Used by RCon's Query in the form of "MajorServerMod 1.2.3: MyPlugin 1.3; AnotherPlugin 2.1; AndSoForth 1.0".intgetPort()Never used, but "getServerPort" is already taken.getPossibleCompletions(ICommandSender par1ICommandSender, String par2Str) If par2Str begins with /, then it searches for commands, otherwise it returns players.static MinecraftServerGets mcServer.static ServerConfigurationManagergetServerConfigurationManager(MinecraftServer par0MinecraftServer) Gets the current player count, maximum player count, and player entity list."getHostname" is already taken, but both return the hostname.Returns the username of the server owner (for integrated servers)intGets serverPort.intReturn the spawn protection area's size.intprotected voidvoidSets the serverRunning variable to false, in order to get the server to shut down.booleanisBlockProtected(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) Returns true if a player does not have permission to edit the block at the given coordinates.abstract booleanReturn whether command blocks are enabled.booleanReturns true if debugging is enabled, false otherwise.abstract booleanbooleanisDemo()Gets whether this is a demo or not.booleanabstract booleanDefaults to false.booleanbooleanbooleanbooleanbooleanbooleanReturns whether snooping is enabled or not.protected voidloadAllWorlds(String par1Str, String par2Str, long par3, WorldType par5WorldType, String par6Str) voidIf isDebuggingEnabled(), logs the message with a level of INFO.voidLogs the message with a level of INFO.voidLogs the error message with a level of SEVERE.voidlogWarning(String par1Str) Logs the message with a level of WARN.static voidprotected voidoutputPercentRemaining(String par1Str, int par2) Used to display a percent remaining given text and the percentage.voidrun()protected voidsaveAllWorlds(boolean par1) par1 indicates if a log message should be output.voidsendChatToPlayer(ChatMessageComponent par1ChatMessageComponent) voidbooleanvoidsetAllowFlight(boolean par1) voidsetAllowPvp(boolean par1) voidsetBuildLimit(int par1) voidsetCanSpawnAnimals(boolean par1) voidsetCanSpawnNPCs(boolean par1) voidsetConfigurationManager(ServerConfigurationManager par1ServerConfigurationManager) voidsetDemo(boolean par1) Sets whether this is a demo or not.voidsetDifficulty(Difficulty difficultyLevel) voidsetDifficultyForAllWorlds(Difficulty difficulty) voidsetDifficultyFromName(String challengeLevel) voidsetFolderName(String par1Str) voidsetForceGamemode(boolean par1) voidsetGameType(EnumGameType par1EnumGameType) Sets the game type for all worlds.voidsetHostname(String par1Str) voidsetKeyPair(KeyPair par1KeyPair) voidvoidsetOnlineMode(boolean par1) voidsetServerOwner(String par1Str) Sets the username of the owner of this server (in the case of an integrated server)voidsetServerPort(int par1) voidsetTexturePack(String par1Str) protected voidsetUserMessage(String par1Str) Typically "menu.convertingLevel", "menu.loadingLevel" or others.voidsetWorldName(String par1Str) abstract StringshareToLAN(EnumGameType var1, boolean var2) On dedicated does nothing.protected abstract booleanInitialises the server and starts it.voidvoidSaves all necessary data as preparation for stopping the server.protected voidDirectly calls System.exit(0), instantly killing the program.intThis is checked to be 16 upon receiving the packet, otherwise the packet is ignored.voidtick()Main function called by run() every loop.voidworldServerForDimension(int par1) Gets the worldServer by the given dimension.
-
Field Details
-
commandManager
-
theProfiler
-
debugUpdateTimeServer
public int debugUpdateTimeServer -
debugBuffer
Stores debug datas for a set amount of time before sending it to the client -
worldServers
The server world instances. -
serverProxy
-
currentTask
The task the server is currently working on(and will output on outputPercentRemaining). -
percentDone
public int percentDoneThe percentage of the current task finished so far. -
sentPacketCountArray
public final long[] sentPacketCountArray -
sentPacketSizeArray
public final long[] sentPacketSizeArray -
receivedPacketCountArray
public final long[] receivedPacketCountArray -
receivedPacketSizeArray
public final long[] receivedPacketSizeArray -
tickTimeArray
public final long[] tickTimeArray -
timeOfLastDimensionTick
public long[][] timeOfLastDimensionTickStats are [dimension][tick%100] system.nanoTime is stored. -
difficultyLevel
-
-
Constructor Details
-
MinecraftServer
-
-
Method Details
-
startServer
Initialises the server and starts it.- Throws:
IOException
-
convertMapIfNeeded
-
setUserMessage
Typically "menu.convertingLevel", "menu.loadingLevel" or others. -
getUserMessage
-
loadAllWorlds
-
initialWorldChunkLoad
protected void initialWorldChunkLoad() -
canStructuresSpawn
public abstract boolean canStructuresSpawn() -
getGameType
-
getDifficulty
public abstract int getDifficulty()Defaults to "1" (Easy) for the dedicated server, defaults to "2" (Normal) on the client. -
isHardcore
public abstract boolean isHardcore()Defaults to false. -
func_110455_j
public abstract int func_110455_j() -
outputPercentRemaining
Used to display a percent remaining given text and the percentage. -
clearCurrentTask
protected void clearCurrentTask()Set current task to null and set its percentage to 0. -
saveAllWorlds
protected void saveAllWorlds(boolean par1) par1 indicates if a log message should be output. -
stopServer
public void stopServer()Saves all necessary data as preparation for stopping the server. -
getServerHostname
"getHostname" is already taken, but both return the hostname. -
setHostname
-
isServerRunning
public boolean isServerRunning() -
initiateShutdown
public void initiateShutdown()Sets the serverRunning variable to false, in order to get the server to shut down. -
run
public void run() -
getDataDirectory
-
finalTick
Called on exit from the main run() loop. -
systemExitNow
protected void systemExitNow()Directly calls System.exit(0), instantly killing the program. -
tick
public void tick()Main function called by run() every loop. -
updateTimeLightAndEntities
public void updateTimeLightAndEntities() -
getAllowNether
public boolean getAllowNether() -
func_82010_a
-
main
-
startServerThread
public void startServerThread() -
getFile
Returns a File object from the specified string. -
logInfo
Logs the message with a level of INFO. -
logWarning
Logs the message with a level of WARN. -
worldServerForDimension
Gets the worldServer by the given dimension. -
getHostname
Returns the server's hostname. -
getPort
public int getPort()Never used, but "getServerPort" is already taken. -
getMotd
Returns the server message of the day -
getMinecraftVersion
Returns the server's Minecraft version as string. -
getCurrentPlayerCount
public int getCurrentPlayerCount()Returns the number of players currently on the server. -
getMaxPlayers
public int getMaxPlayers()Returns the maximum number of players allowed on the server. -
getAllUsernames
Returns an array of the usernames of all the connected players. -
getPlugins
Used by RCon's Query in the form of "MajorServerMod 1.2.3: MyPlugin 1.3; AnotherPlugin 2.1; AndSoForth 1.0". -
executeCommand
-
isDebuggingEnabled
public boolean isDebuggingEnabled()Returns true if debugging is enabled, false otherwise. -
logSevere
Logs the error message with a level of SEVERE. -
logDebug
If isDebuggingEnabled(), logs the message with a level of INFO. -
getServerModName
-
addServerInfoToCrashReport
Adds the server info, including from theWorldServer, to the crash report. -
getPossibleCompletions
If par2Str begins with /, then it searches for commands, otherwise it returns players. -
getServer
Gets mcServer. -
getCommandSenderName
Gets the name of this command sender (usually username, but possibly "Rcon")- Specified by:
getCommandSenderNamein interfaceICommandSender
-
sendChatToPlayer
- Specified by:
sendChatToPlayerin interfaceICommandSender
-
canCommandSenderUseCommand
Returns true if the command sender is allowed to use the given command.- Specified by:
canCommandSenderUseCommandin interfaceICommandSender
-
getCommandManager
-
getKeyPair
Gets KeyPair instanced in MinecraftServer. -
getServerPort
public int getServerPort()Gets serverPort. -
setServerPort
public void setServerPort(int par1) -
getServerOwner
Returns the username of the server owner (for integrated servers) -
setServerOwner
Sets the username of the owner of this server (in the case of an integrated server) -
isSinglePlayer
public boolean isSinglePlayer() -
getFolderName
-
setFolderName
-
setWorldName
-
getWorldName
-
setKeyPair
-
setDifficultyForAllWorlds
-
allowSpawnMonsters
protected boolean allowSpawnMonsters() -
isDemo
public boolean isDemo()Gets whether this is a demo or not. -
setDemo
public void setDemo(boolean par1) Sets whether this is a demo or not. -
canCreateBonusChest
public void canCreateBonusChest(boolean par1) -
getActiveAnvilConverter
-
deleteWorldAndStopServer
public void deleteWorldAndStopServer()WARNING : directly calls getActiveAnvilConverter().deleteWorldDirectory(theWorldServer[0].getSaveHandler().getWorldDirectoryName()); -
getTexturePack
-
setTexturePack
-
addServerStatsToSnooper
- Specified by:
addServerStatsToSnooperin interfaceIPlayerUsage
-
addServerTypeToSnooper
- Specified by:
addServerTypeToSnooperin interfaceIPlayerUsage
-
isSnooperEnabled
public boolean isSnooperEnabled()Returns whether snooping is enabled or not.- Specified by:
isSnooperEnabledin interfaceIPlayerUsage
-
textureSize
public int textureSize()This is checked to be 16 upon receiving the packet, otherwise the packet is ignored. -
isDedicatedServer
public abstract boolean isDedicatedServer() -
isServerInOnlineMode
public boolean isServerInOnlineMode() -
setOnlineMode
public void setOnlineMode(boolean par1) -
getCanSpawnAnimals
public boolean getCanSpawnAnimals() -
setCanSpawnAnimals
public void setCanSpawnAnimals(boolean par1) -
getCanSpawnNPCs
public boolean getCanSpawnNPCs() -
setCanSpawnNPCs
public void setCanSpawnNPCs(boolean par1) -
isPVPEnabled
public boolean isPVPEnabled() -
setAllowPvp
public void setAllowPvp(boolean par1) -
isFlightAllowed
public boolean isFlightAllowed() -
setAllowFlight
public void setAllowFlight(boolean par1) -
isCommandBlockEnabled
public abstract boolean isCommandBlockEnabled()Return whether command blocks are enabled. -
getMOTD
-
setMOTD
-
getBuildLimit
public int getBuildLimit() -
setBuildLimit
public void setBuildLimit(int par1) -
isServerStopped
public boolean isServerStopped() -
getConfigurationManager
-
setConfigurationManager
-
setGameType
Sets the game type for all worlds. -
getNetworkThread
-
serverIsInRunLoop
@Environment(CLIENT) public boolean serverIsInRunLoop() -
getGuiEnabled
public boolean getGuiEnabled() -
getTickCounter
public int getTickCounter() -
enableProfiling
public void enableProfiling() -
getPlayerUsageSnooper
-
getPlayerCoordinates
Return the position for this command sender.- Specified by:
getPlayerCoordinatesin interfaceICommandSender
-
getSpawnProtectionSize
public int getSpawnProtectionSize()Return the spawn protection area's size. -
getEntityWorld
- Specified by:
getEntityWorldin interfaceICommandSender
-
getLogAgent
- Specified by:
getLogAgentin interfaceIPlayerUsage
-
setForceGamemode
public void setForceGamemode(boolean par1) -
getForceGamemode
public boolean getForceGamemode() -
isBlockProtected
public boolean isBlockProtected(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) Returns true if a player does not have permission to edit the block at the given coordinates. -
getServerConfigurationManager
public static ServerConfigurationManager getServerConfigurationManager(MinecraftServer par0MinecraftServer) Gets the current player count, maximum player count, and player entity list. -
getIsServer
public static boolean getIsServer() -
getServerProxy
-
getCurrentTimeMillis
public static long getCurrentTimeMillis()returns the difference, measured in milliseconds, between the current system time and midnight, January 1, 1970 UTC. -
func_143007_ar
public int func_143007_ar() -
func_143006_e
public void func_143006_e(int par1) -
sendTimerSpeedImmediately
public void sendTimerSpeedImmediately() -
setDifficultyFromName
-
setDifficulty
-