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

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `String` | `currentTask` The task the server is currently working on(and will output on outputPercentRemaining).
    `static Logger` | `logger` The logging system.
    `int` | `percentDone` The percentage of the current task finished so far.
    `long[]` | `receivedPacketCountArray`
    `long[]` | `receivedPacketSizeArray`
    `long[]` | `sentPacketCountArray`
    `long[]` | `sentPacketSizeArray`
    `Profiler` | `theProfiler`
    `long[]` | `tickTimeArray`
    `WorldServer[]` | `worldServers` The server world instances.
    `Hashtable<Integer,long[]>` | `worldTickTimes` Stats are [dimension][tick%100] system.nanoTime is stored.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MinecraftServer(File par1File)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `CrashReport` | `addServerInfoToCrashReport(CrashReport par1CrashReport)` Adds the server info, including from theWorldServer, to the crash report.
    `void` | `addServerStatsToSnooper(PlayerUsageSnooper par1PlayerUsageSnooper)`
    `void` | `addServerTypeToSnooper(PlayerUsageSnooper par1PlayerUsageSnooper)`
    `boolean` | `canCommandSenderUseCommand(int par1, String par2Str)` Returns true if the command sender is allowed to use the given command.
    `void` | `canCreateBonusChest(boolean par1)`
    `abstract boolean` | `canStructuresSpawn()`
    `void` | `deleteWorldAndStopServer()` WARNING : directly calls getActiveAnvilConverter().deleteWorldDirectory(theWorldServer[0].getSaveHandler().getSaveDirectoryName());
    `void` | `enableProfiling()`
    `String` | `executeCommand(String par1Str)`
    `static void` | `fmlReentry(ArgsWrapper wrap)`
    `void` | `func_82010_a(IUpdatePlayerListBox par1IUpdatePlayerListBox)`
    `ISaveFormat` | `getActiveAnvilConverter()`
    `boolean` | `getAllowNether()`
    `String[]` | `getAllUsernames()` Returns an array of the usernames of all the connected players.
    `int` | `getBuildLimit()`
    `boolean` | `getCanSpawnAnimals()`
    `boolean` | `getCanSpawnNPCs()`
    `ICommandManager` | `getCommandManager()`
    `String` | `getCommandSenderName()` Gets the name of this command sender (usually username, but possibly "Rcon")
    `ServerConfigurationManager` | `getConfigurationManager()`
    `int` | `getCurrentPlayerCount()` Returns the number of players currently on the server.
    `abstract int` | `getDifficulty()` Defaults to "1" (Easy) for the dedicated server, defaults to "2" (Normal) on the client.
    `File` | `getFile(String par1Str)` Returns a File object from the specified string.
    `String` | `getFolderName()`
    `abstract EnumGameType` | `getGameType()`
    `boolean` | `getGuiEnabled()`
    `String` | `getHostname()` Returns the server's hostname.
    `KeyPair` | `getKeyPair()` Gets KeyPair instanced in MinecraftServer.
    `int` | `getMaxPlayers()` Returns the maximum number of players allowed on the server.
    `String` | `getMinecraftVersion()` Returns the server's Minecraft version as string.
    `String` | `getMOTD()`
    `abstract NetworkListenThread` | `getNetworkThread()`
    `ChunkCoordinates` | `getPlayerCoordinates()` Return the position for this command sender.
    `PlayerUsageSnooper` | `getPlayerUsageSnooper()`
    `String` | `getPlugins()` Used by RCon's Query in the form of "MajorServerMod 1.2.3: MyPlugin 1.3; AnotherPlugin 2.1; AndSoForth 1.0".
    `int` | `getPort()` Never used, but "getServerPort" is already taken.
    `List` | `getPossibleCompletions(ICommandSender par1ICommandSender, String par2Str)` If par2Str begins with /, then it searches for commands, otherwise it returns players.
    `static MinecraftServer` | `getServer()` Gets mcServer.
    `static ServerConfigurationManager` | `getServerConfigurationManager(MinecraftServer par0MinecraftServer)` Gets the current player count, maximum player count, and player entity list.
    `String` | `getServerHostname()` "getHostname" is already taken, but both return the hostname.
    `String` | `getServerModName()`
    `String` | `getServerMOTD()` Returns the server message of the day
    `String` | `getServerOwner()` Returns the username of the server owner (for integrated servers)
    `int` | `getServerPort()` Gets serverPort.
    `int` | `getSpawnProtectionSize()` Return the spawn protection area's size.
    `String` | `getTexturePack()`
    `int` | `getTickCounter()`
    `String` | `getUserMessage()`
    `String` | `getWorldName()`
    `void` | `initiateShutdown()` Sets the serverRunning variable to false, in order to get the server to shut down.
    `abstract boolean` | `isCommandBlockEnabled()` Return whether command blocks are enabled.
    `boolean` | `isDebuggingEnabled()` Returns true if debugging is enabled, false otherwise.
    `abstract boolean` | `isDedicatedServer()`
    `boolean` | `isDemo()` Gets whether this is a demo or not.
    `boolean` | `isFlightAllowed()`
    `abstract boolean` | `isHardcore()` Defaults to false.
    `boolean` | `isPVPEnabled()`
    `boolean` | `isServerInOnlineMode()`
    `boolean` | `isServerRunning()`
    `boolean` | `isServerStopped()`
    `boolean` | `isSinglePlayer()`
    `boolean` | `isSnooperEnabled()` Returns whether snooping is enabled or not.
    `void` | `logDebug(String par1Str)` If isDebuggingEnabled(), logs the message with a level of INFO.
    `void` | `logInfo(String par1Str)` Logs the message with a level of INFO.
    `void` | `logSevere(String par1Str)` Logs the error message with a level of SEVERE.
    `void` | `logWarning(String par1Str)` Logs the message with a level of WARN.
    `static void` | `main(String[] par0ArrayOfStr)`
    `void` | `run()`
    `void` | `sendChatToPlayer(String par1Str)`
    `boolean` | `serverIsInRunLoop()`
    `void` | `setAllowFlight(boolean par1)`
    `void` | `setAllowPvp(boolean par1)`
    `void` | `setBuildLimit(int par1)`
    `void` | `setCanSpawnAnimals(boolean par1)`
    `void` | `setCanSpawnNPCs(boolean par1)`
    `void` | `setConfigurationManager(ServerConfigurationManager par1ServerConfigurationManager)`
    `void` | `setDemo(boolean par1)` Sets whether this is a demo or not.
    `void` | `setDifficultyForAllWorlds(int par1)`
    `void` | `setFolderName(String par1Str)`
    `void` | `setGameType(EnumGameType par1EnumGameType)` Sets the game type for all worlds.
    `void` | `setHostname(String par1Str)`
    `void` | `setKeyPair(KeyPair par1KeyPair)`
    `void` | `setMOTD(String par1Str)`
    `void` | `setOnlineMode(boolean par1)`
    `void` | `setServerOwner(String par1Str)` Sets the username of the owner of this server (in the case of an integrated server)
    `void` | `setServerPort(int par1)`
    `void` | `setTexturePack(String par1Str)`
    `void` | `setWorldName(String par1Str)`
    `abstract String` | `shareToLAN(EnumGameType var1, boolean var2)` On dedicated does nothing.
    `void` | `startServerThread()`
    `void` | `stopServer()` Saves all necessary data as preparation for stopping the server.
    `int` | `textureSize()` This is checked to be 16 upon receiving the packet, otherwise the packet is ignored.
    `void` | `tick()` Main function called by run() every loop.
    `String` | `translateString(String par1Str, Object... par2ArrayOfObj)` Translates and formats the given string key with the given arguments.
    `void` | `updateTimeLightAndEntities()`
    `WorldServer` | `worldServerForDimension(int par1)` Gets the worldServer by the given dimension.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### logger

          public static Logger logger

      The logging system.

    - #### theProfiler

          public final Profiler theProfiler

    - #### worldServers

          public WorldServer[] worldServers

      The server world instances.

    - #### currentTask

          public String currentTask

      The task the server is currently working on(and will output on outputPercentRemaining).

    - #### percentDone

          public int percentDone

      The 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

    - #### worldTickTimes

          public Hashtable<Integer,long[]> worldTickTimes

      Stats are [dimension][tick%100] system.nanoTime is stored.

  - ### Constructor Detail

    - #### MinecraftServer

          public MinecraftServer(File par1File)

  - ### Method Detail

    - #### getUserMessage

          public String getUserMessage()

    - #### canStructuresSpawn

          public abstract boolean canStructuresSpawn()

    - #### getGameType

          public abstract EnumGameType 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.

    - #### stopServer

          public void stopServer()

      Saves all necessary data as preparation for stopping the server.

    - #### getServerHostname

          public String getServerHostname()

      "getHostname" is already taken, but both return the hostname.

    - #### setHostname

          public void setHostname(String par1Str)

    - #### 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()

      Specified by:
        `run` in interface `Runnable`

    - #### tick

          public void tick()

      Main function called by run() every loop.

    - #### updateTimeLightAndEntities

          public void updateTimeLightAndEntities()

    - #### getAllowNether

          public boolean getAllowNether()

    - #### startServerThread

          public void startServerThread()

    - #### getFile

          public File getFile(String par1Str)

      Returns a File object from the specified string.

    - #### logInfo

          public void logInfo(String par1Str)

      Logs the message with a level of INFO.

    - #### logWarning

          public void logWarning(String par1Str)

      Logs the message with a level of WARN.

    - #### worldServerForDimension

          public WorldServer worldServerForDimension(int par1)

      Gets the worldServer by the given dimension.

    - #### func_82010_a

          public void func_82010_a(IUpdatePlayerListBox par1IUpdatePlayerListBox)

    - #### getHostname

          public String getHostname()

      Returns the server's hostname.

    - #### getPort

          public int getPort()

      Never used, but "getServerPort" is already taken.

    - #### getServerMOTD

          public String getServerMOTD()

      Returns the server message of the day

    - #### getMinecraftVersion

          public String 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

          public String[] getAllUsernames()

      Returns an array of the usernames of all the connected players.

    - #### getPlugins

          public String getPlugins()

      Used by RCon's Query in the form of "MajorServerMod 1.2.3: MyPlugin 1.3; AnotherPlugin 2.1; AndSoForth 1.0".

    - #### executeCommand

          public String executeCommand(String par1Str)

    - #### isDebuggingEnabled

          public boolean isDebuggingEnabled()

      Returns true if debugging is enabled, false otherwise.

    - #### logSevere

          public void logSevere(String par1Str)

      Logs the error message with a level of SEVERE.

    - #### logDebug

          public void logDebug(String par1Str)

      If isDebuggingEnabled(), logs the message with a level of INFO.

    - #### getServerModName

          public String getServerModName()

    - #### addServerInfoToCrashReport

          public CrashReport addServerInfoToCrashReport(CrashReport par1CrashReport)

      Adds the server info, including from theWorldServer, to the crash report.

    - #### getPossibleCompletions

          public List getPossibleCompletions(ICommandSender par1ICommandSender,
                                    String par2Str)

      If par2Str begins with /, then it searches for commands, otherwise it returns players.

    - #### getServer

          public static MinecraftServer getServer()

      Gets mcServer.

    - #### getCommandSenderName

          public String getCommandSenderName()

      Gets the name of this command sender (usually username, but possibly "Rcon")
      Specified by:
        `getCommandSenderName` in interface `ICommandSender`

    - #### sendChatToPlayer

          public void sendChatToPlayer(String par1Str)

      Specified by:
        `sendChatToPlayer` in interface `ICommandSender`

    - #### canCommandSenderUseCommand

          public boolean canCommandSenderUseCommand(int par1,
                                           String par2Str)

      Returns true if the command sender is allowed to use the given command.
      Specified by:
        `canCommandSenderUseCommand` in interface `ICommandSender`

    - #### translateString

          public String translateString(String par1Str,
                               Object... par2ArrayOfObj)

      Translates and formats the given string key with the given arguments.
      Specified by:
        `translateString` in interface `ICommandSender`

    - #### getCommandManager

          public ICommandManager getCommandManager()

    - #### getKeyPair

          public KeyPair getKeyPair()

      Gets KeyPair instanced in MinecraftServer.

    - #### getServerPort

          public int getServerPort()

      Gets serverPort.

    - #### setServerPort

          public void setServerPort(int par1)

    - #### getServerOwner

          public String getServerOwner()

      Returns the username of the server owner (for integrated servers)

    - #### setServerOwner

          public void setServerOwner(String par1Str)

      Sets the username of the owner of this server (in the case of an integrated server)

    - #### isSinglePlayer

          public boolean isSinglePlayer()

    - #### getFolderName

          public String getFolderName()

    - #### setFolderName

          public void setFolderName(String par1Str)

    - #### setWorldName

          public void setWorldName(String par1Str)

    - #### getWorldName

          public String getWorldName()

    - #### setKeyPair

          public void setKeyPair(KeyPair par1KeyPair)

    - #### setDifficultyForAllWorlds

          public void setDifficultyForAllWorlds(int par1)

    - #### 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

          public ISaveFormat getActiveAnvilConverter()

    - #### deleteWorldAndStopServer

          public void deleteWorldAndStopServer()

      WARNING : directly calls getActiveAnvilConverter().deleteWorldDirectory(theWorldServer[0].getSaveHandler().getSaveDirectoryName());

    - #### getTexturePack

          public String getTexturePack()

    - #### setTexturePack

          public void setTexturePack(String par1Str)

    - #### addServerStatsToSnooper

          public void addServerStatsToSnooper(PlayerUsageSnooper par1PlayerUsageSnooper)

      Specified by:
        `addServerStatsToSnooper` in interface `IPlayerUsage`

    - #### addServerTypeToSnooper

          public void addServerTypeToSnooper(PlayerUsageSnooper par1PlayerUsageSnooper)

      Specified by:
        `addServerTypeToSnooper` in interface `IPlayerUsage`

    - #### isSnooperEnabled

          public boolean isSnooperEnabled()

      Returns whether snooping is enabled or not.
      Specified by:
        `isSnooperEnabled` in interface `IPlayerUsage`

    - #### 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

          public String getMOTD()

    - #### setMOTD

          public void setMOTD(String par1Str)

    - #### getBuildLimit

          public int getBuildLimit()

    - #### setBuildLimit

          public void setBuildLimit(int par1)

    - #### isServerStopped

          public boolean isServerStopped()

    - #### getConfigurationManager

          public ServerConfigurationManager getConfigurationManager()

    - #### setConfigurationManager

          public void setConfigurationManager(ServerConfigurationManager par1ServerConfigurationManager)

    - #### setGameType

          public void setGameType(EnumGameType par1EnumGameType)

      Sets the game type for all worlds.

    - #### getNetworkThread

          public abstract NetworkListenThread getNetworkThread()

    - #### serverIsInRunLoop

          public boolean serverIsInRunLoop()

    - #### getGuiEnabled

          public boolean getGuiEnabled()

    - #### shareToLAN

          public abstract String shareToLAN(EnumGameType var1,
                          boolean var2)

      On dedicated does nothing. On integrated, sets commandsAllowedForAll, gameType and allows external connections.

    - #### getTickCounter

          public int getTickCounter()

    - #### enableProfiling

          public void enableProfiling()

    - #### getPlayerUsageSnooper

          public PlayerUsageSnooper getPlayerUsageSnooper()

    - #### getPlayerCoordinates

          public ChunkCoordinates getPlayerCoordinates()

      Return the position for this command sender.
      Specified by:
        `getPlayerCoordinates` in interface `ICommandSender`

    - #### getSpawnProtectionSize

          public int getSpawnProtectionSize()

      Return the spawn protection area's size.

    - #### getServerConfigurationManager

          public static ServerConfigurationManager getServerConfigurationManager(MinecraftServer par0MinecraftServer)

      Gets the current player count, maximum player count, and player entity list.

    - #### main

          public static void main(String[] par0ArrayOfStr)

    - #### fmlReentry

          public static void fmlReentry(ArgsWrapper wrap)