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 Details

    • commandManager

      public final ServerCommandManager commandManager
    • theProfiler

      public final Profiler theProfiler
    • debugUpdateTimeServer

      public int debugUpdateTimeServer
    • debugBuffer

      public DebugDataBuffer debugBuffer
      Stores debug datas for a set amount of time before sending it to the client
    • worldServers

      public WorldServer[] worldServers
      The server world instances.
    • serverProxy

      protected Proxy serverProxy
    • 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
    • timeOfLastDimensionTick

      public long[][] timeOfLastDimensionTick
      Stats are [dimension][tick%100] system.nanoTime is stored.
    • difficultyLevel

      protected Difficulty difficultyLevel
  • Constructor Details

    • MinecraftServer

      public MinecraftServer(File par1File)
  • Method Details

    • startServer

      protected abstract boolean startServer() throws IOException
      Initialises the server and starts it.
      Throws:
      IOException
    • convertMapIfNeeded

      protected void convertMapIfNeeded(String par1Str)
    • setUserMessage

      protected void setUserMessage(String par1Str)
      Typically "menu.convertingLevel", "menu.loadingLevel" or others.
    • getUserMessage

      @Environment(CLIENT) public String getUserMessage()
    • loadAllWorlds

      protected void loadAllWorlds(String par1Str, String par2Str, long par3, WorldType par5WorldType, String par6Str)
    • initialWorldChunkLoad

      protected void initialWorldChunkLoad()
    • 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.
    • func_110455_j

      public abstract int func_110455_j()
    • outputPercentRemaining

      protected void outputPercentRemaining(String par1Str, int par2)
      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

      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
    • getDataDirectory

      protected File getDataDirectory()
    • finalTick

      protected void finalTick(CrashReport par1CrashReport)
      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

      public void func_82010_a(IUpdatePlayerListBox par1IUpdatePlayerListBox)
    • main

      public static void main(String[] par0ArrayOfStr)
    • 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.
    • getHostname

      public String getHostname()
      Returns the server's hostname.
    • getPort

      public int getPort()
      Never used, but "getServerPort" is already taken.
    • getMotd

      public String getMotd()
      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(ChatMessageComponent par1ChatMessageComponent)
      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
    • 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

      @Environment(CLIENT) public void setWorldName(String par1Str)
    • getWorldName

      @Environment(CLIENT) public String getWorldName()
    • setKeyPair

      public void setKeyPair(KeyPair par1KeyPair)
    • setDifficultyForAllWorlds

      public void setDifficultyForAllWorlds(Difficulty difficulty)
    • 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

      public ISaveFormat getActiveAnvilConverter()
    • deleteWorldAndStopServer

      public void deleteWorldAndStopServer()
      WARNING : directly calls getActiveAnvilConverter().deleteWorldDirectory(theWorldServer[0].getSaveHandler().getWorldDirectoryName());
    • 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

      @Environment(CLIENT) 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

      @Environment(CLIENT) 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.
    • getEntityWorld

      public World getEntityWorld()
      Specified by:
      getEntityWorld in interface ICommandSender
    • getLogAgent

      public abstract ILogAgent getLogAgent()
      Specified by:
      getLogAgent in interface IPlayerUsage
    • 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

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

      public void setDifficultyFromName(String challengeLevel)
    • setDifficulty

      public void setDifficulty(Difficulty difficultyLevel)