public abstract class MinecraftServer extends java.lang.Object implements java.lang.Runnable, ICommandSender, IThreadListener, IPlayerUsage
Modifier and Type | Field and Description |
---|---|
private boolean |
allowFlight
Determines if flight is allowed or not.
|
private ISaveFormat |
anvilConverterForAnvilFile |
private java.io.File |
anvilFile |
private com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService |
authService |
private int |
buildLimit
Maximum build height.
|
private boolean |
canSpawnAnimals
True if the server has animals turned on.
|
private boolean |
canSpawnNPCs |
protected ICommandManager |
commandManager |
java.lang.String |
currentTask
The task the server is currently working on(and will output on outputPercentRemaining).
|
private long |
currentTime |
private boolean |
enableBonusChest |
private java.lang.String |
folderName |
protected java.util.Queue<java.util.concurrent.FutureTask<?>> |
futureTaskQueue |
private boolean |
isDemo |
private boolean |
isGamemodeForced |
private static org.apache.logging.log4j.Logger |
logger |
private int |
maxPlayerIdleMinutes |
private static MinecraftServer |
mcServer
Instance of Minecraft Server.
|
private java.lang.String |
motd
The server MOTD string.
|
private long |
nanoTimeSinceStatusRefresh |
private NetworkSystem |
networkSystem |
private boolean |
onlineMode
True if the server is in online mode.
|
int |
percentDone
The percentage of the current task finished so far.
|
private java.util.List<ITickable> |
playersOnline |
private PlayerProfileCache |
profileCache |
private com.mojang.authlib.GameProfileRepository |
profileRepo |
private boolean |
pvpEnabled
Indicates whether PvP is active on the server or not.
|
private java.util.Random |
random |
private java.lang.String |
resourcePackHash |
private java.lang.String |
resourcePackUrl
The texture pack for the server
|
private ServerConfigurationManager |
serverConfigManager
The ServerConfigurationManager instance.
|
private boolean |
serverIsRunning |
private java.security.KeyPair |
serverKeyPair |
private java.lang.String |
serverOwner
Username of the server owner (for integrated servers)
|
private int |
serverPort
The server's port.
|
protected java.net.Proxy |
serverProxy |
private boolean |
serverRunning
Indicates whether the server is running or not.
|
private boolean |
serverStopped
Indicates to other classes that the server is safely stopped.
|
private java.lang.Thread |
serverThread |
private com.mojang.authlib.minecraft.MinecraftSessionService |
sessionService |
private boolean |
startProfiling |
private ServerStatusResponse |
statusResponse |
Profiler |
theProfiler |
private int |
tickCounter
Incremented every tick.
|
long[] |
tickTimeArray |
long[][] |
timeOfLastDimensionTick
Stats are [dimension][tick%100] system.nanoTime is stored.
|
private long |
timeOfLastWarning
Set when warned for "Can't keep up", which triggers again after 15 seconds.
|
private PlayerUsageSnooper |
usageSnooper
The PlayerUsageSnooper instance.
|
static java.io.File |
USER_CACHE_FILE |
private java.lang.String |
userMessage |
private boolean |
worldIsBeingDeleted
If true, there is no need to save chunks or stop the server, because that is already being done.
|
private java.lang.String |
worldName |
WorldServer[] |
worldServers
The server world instances.
|
Constructor and Description |
---|
MinecraftServer(java.io.File workDir,
java.net.Proxy proxy,
java.io.File profileCacheDir) |
MinecraftServer(java.net.Proxy proxy,
java.io.File workDir) |
Modifier and Type | Method and Description |
---|---|
void |
addChatMessage(IChatComponent component)
Send a chat message to the CommandSender
|
private void |
addFaviconToStatusResponse(ServerStatusResponse response) |
com.google.common.util.concurrent.ListenableFuture<java.lang.Object> |
addScheduledTask(java.lang.Runnable runnableToSchedule) |
CrashReport |
addServerInfoToCrashReport(CrashReport report)
Adds the server info, including from theWorldServer, to the crash report.
|
void |
addServerStatsToSnooper(PlayerUsageSnooper playerSnooper) |
void |
addServerTypeToSnooper(PlayerUsageSnooper playerSnooper) |
protected boolean |
allowSpawnMonsters() |
<V> com.google.common.util.concurrent.ListenableFuture<V> |
callFromMainThread(java.util.concurrent.Callable<V> callable) |
boolean |
canCommandSenderUseCommand(int permLevel,
java.lang.String commandName)
Returns
true if the CommandSender is allowed to execute the command, false if not |
void |
canCreateBonusChest(boolean enable) |
abstract boolean |
canStructuresSpawn() |
protected void |
clearCurrentTask()
Set current task to null and set its percentage to 0.
|
protected void |
convertMapIfNeeded(java.lang.String worldNameIn) |
protected ServerCommandManager |
createNewCommandManager() |
void |
deleteWorldAndStopServer()
WARNING : directly calls
getActiveAnvilConverter().deleteWorldDirectory(theWorldServer[0].getSaveHandler().getWorldDirectoryName());
|
void |
enableProfiling() |
protected void |
finalTick(CrashReport report)
Called on exit from the main run() loop.
|
abstract boolean |
func_181034_q() |
abstract boolean |
func_181035_ah() |
abstract boolean |
func_183002_r() |
ISaveFormat |
getActiveAnvilConverter() |
boolean |
getAllowNether() |
java.lang.String[] |
getAllUsernames()
Returns an array of the usernames of all the connected players.
|
int |
getBuildLimit() |
boolean |
getCanSpawnAnimals() |
boolean |
getCanSpawnNPCs() |
ICommandManager |
getCommandManager() |
Entity |
getCommandSenderEntity()
Returns the entity associated with the command sender.
|
ServerConfigurationManager |
getConfigurationManager() |
int |
getCurrentPlayerCount()
Returns the number of players currently on the server.
|
static long |
getCurrentTimeMillis() |
java.io.File |
getDataDirectory() |
abstract EnumDifficulty |
getDifficulty()
Get the server's difficulty
|
IChatComponent |
getDisplayName()
Get the formatted ChatComponent that will be used for the sender's username in chat
|
Entity |
getEntityFromUuid(java.util.UUID uuid) |
World |
getEntityWorld()
Get the world, if available.
|
java.io.File |
getFile(java.lang.String fileName)
Returns a File object from the specified string.
|
java.lang.String |
getFolderName() |
boolean |
getForceGamemode() |
com.mojang.authlib.GameProfileRepository |
getGameProfileRepository() |
com.mojang.authlib.GameProfile[] |
getGameProfiles()
Returns an array of the GameProfiles of all the connected players
|
abstract WorldSettings.GameType |
getGameType() |
boolean |
getGuiEnabled() |
java.security.KeyPair |
getKeyPair()
Gets KeyPair instanced in MinecraftServer.
|
int |
getMaxPlayerIdleMinutes() |
int |
getMaxPlayers()
Returns the maximum number of players allowed on the server.
|
int |
getMaxWorldSize() |
com.mojang.authlib.minecraft.MinecraftSessionService |
getMinecraftSessionService() |
java.lang.String |
getMinecraftVersion()
Returns the server's Minecraft version as string.
|
java.lang.String |
getMOTD() |
java.lang.String |
getName()
Gets the name of this command sender (usually username, but possibly "Rcon")
|
int |
getNetworkCompressionTreshold()
The compression treshold.
|
NetworkSystem |
getNetworkSystem() |
abstract int |
getOpPermissionLevel() |
PlayerProfileCache |
getPlayerProfileCache() |
PlayerUsageSnooper |
getPlayerUsageSnooper() |
BlockPos |
getPosition()
Get the position in the world.
|
Vec3 |
getPositionVector()
Get the position vector.
|
java.lang.String |
getResourcePackHash() |
java.lang.String |
getResourcePackUrl() |
static MinecraftServer |
getServer()
Gets mcServer.
|
java.lang.String |
getServerModName() |
java.lang.String |
getServerOwner()
Returns the username of the server owner (for integrated servers)
|
java.net.Proxy |
getServerProxy() |
ServerStatusResponse |
getServerStatusResponse() |
int |
getSpawnProtectionSize()
Return the spawn protection area's size.
|
java.util.List<java.lang.String> |
getTabCompletions(ICommandSender sender,
java.lang.String input,
BlockPos pos) |
int |
getTickCounter() |
java.lang.String |
getUserMessage() |
java.lang.String |
getWorldName() |
protected void |
initialWorldChunkLoad() |
void |
initiateShutdown()
Sets the serverRunning variable to false, in order to get the server to shut down.
|
boolean |
isAnnouncingPlayerAchievements() |
boolean |
isAnvilFileSet() |
boolean |
isBlockProtected(World worldIn,
BlockPos pos,
EntityPlayer playerIn) |
boolean |
isCallingFromMinecraftThread() |
abstract boolean |
isCommandBlockEnabled()
Return whether command blocks are enabled.
|
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.
|
protected void |
loadAllWorlds(java.lang.String p_71247_1_,
java.lang.String p_71247_2_,
long seed,
WorldType type,
java.lang.String p_71247_6_) |
void |
logWarning(java.lang.String msg)
Logs the message with a level of WARN.
|
protected void |
outputPercentRemaining(java.lang.String message,
int percent)
Used to display a percent remaining given text and the percentage.
|
void |
refreshStatusNextTick() |
void |
run() |
protected void |
saveAllWorlds(boolean dontLog)
par1 indicates if a log message should be output.
|
boolean |
sendCommandFeedback()
Returns true if the command sender should be sent feedback about executed commands
|
boolean |
serverIsInRunLoop() |
void |
setAllowFlight(boolean allow) |
void |
setAllowPvp(boolean allowPvp) |
void |
setBuildLimit(int maxBuildHeight) |
void |
setCanSpawnAnimals(boolean spawnAnimals) |
void |
setCanSpawnNPCs(boolean spawnNpcs) |
void |
setCommandStat(CommandResultStats.Type type,
int amount) |
void |
setConfigManager(ServerConfigurationManager configManager) |
void |
setDemo(boolean demo)
Sets whether this is a demo or not.
|
void |
setDifficultyForAllWorlds(EnumDifficulty difficulty) |
void |
setFolderName(java.lang.String name) |
void |
setGameType(WorldSettings.GameType gameMode)
Sets the game type for all worlds.
|
protected void |
setInstance() |
void |
setKeyPair(java.security.KeyPair keyPair) |
void |
setMOTD(java.lang.String motdIn) |
void |
setOnlineMode(boolean online) |
void |
setPlayerIdleTimeout(int idleTimeout) |
void |
setResourcePack(java.lang.String url,
java.lang.String hash) |
protected void |
setResourcePackFromWorld(java.lang.String worldNameIn,
ISaveHandler saveHandlerIn) |
void |
setServerOwner(java.lang.String owner)
Sets the username of the owner of this server (in the case of an integrated server)
|
protected void |
setUserMessage(java.lang.String message)
Typically "menu.convertingLevel", "menu.loadingLevel" or others.
|
void |
setWorldName(java.lang.String p_71246_1_) |
abstract java.lang.String |
shareToLAN(WorldSettings.GameType type,
boolean allowCheats)
On dedicated does nothing.
|
protected abstract boolean |
startServer()
Initialises the server and starts it.
|
void |
startServerThread() |
void |
stopServer()
Saves all necessary data as preparation for stopping the server.
|
protected void |
systemExitNow()
Directly calls System.exit(0), instantly killing the program.
|
void |
tick()
Main function called by run() every loop.
|
void |
updateTimeLightAndEntities() |
WorldServer |
worldServerForDimension(int dimension)
Gets the worldServer by the given dimension.
|
private static final org.apache.logging.log4j.Logger logger
public static final java.io.File USER_CACHE_FILE
private static MinecraftServer mcServer
private final ISaveFormat anvilConverterForAnvilFile
private final PlayerUsageSnooper usageSnooper
private final java.io.File anvilFile
private final java.util.List<ITickable> playersOnline
protected final ICommandManager commandManager
public final Profiler theProfiler
private final NetworkSystem networkSystem
private final ServerStatusResponse statusResponse
private final java.util.Random random
private int serverPort
public WorldServer[] worldServers
private ServerConfigurationManager serverConfigManager
private boolean serverRunning
private boolean serverStopped
private int tickCounter
protected final java.net.Proxy serverProxy
public java.lang.String currentTask
public int percentDone
private boolean onlineMode
private boolean canSpawnAnimals
private boolean canSpawnNPCs
private boolean pvpEnabled
private boolean allowFlight
private java.lang.String motd
private int buildLimit
private int maxPlayerIdleMinutes
public final long[] tickTimeArray
public long[][] timeOfLastDimensionTick
private java.security.KeyPair serverKeyPair
private java.lang.String serverOwner
private java.lang.String folderName
private java.lang.String worldName
private boolean isDemo
private boolean enableBonusChest
private boolean worldIsBeingDeleted
private java.lang.String resourcePackUrl
private java.lang.String resourcePackHash
private boolean serverIsRunning
private long timeOfLastWarning
private java.lang.String userMessage
private boolean startProfiling
private boolean isGamemodeForced
private final com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService authService
private final com.mojang.authlib.minecraft.MinecraftSessionService sessionService
private long nanoTimeSinceStatusRefresh
private final com.mojang.authlib.GameProfileRepository profileRepo
private final PlayerProfileCache profileCache
protected final java.util.Queue<java.util.concurrent.FutureTask<?>> futureTaskQueue
private java.lang.Thread serverThread
private long currentTime
public MinecraftServer(java.net.Proxy proxy, java.io.File workDir)
public MinecraftServer(java.io.File workDir, java.net.Proxy proxy, java.io.File profileCacheDir)
protected ServerCommandManager createNewCommandManager()
protected abstract boolean startServer() throws java.io.IOException
java.io.IOException
protected void convertMapIfNeeded(java.lang.String worldNameIn)
protected void setUserMessage(java.lang.String message)
public java.lang.String getUserMessage()
protected void loadAllWorlds(java.lang.String p_71247_1_, java.lang.String p_71247_2_, long seed, WorldType type, java.lang.String p_71247_6_)
protected void initialWorldChunkLoad()
protected void setResourcePackFromWorld(java.lang.String worldNameIn, ISaveHandler saveHandlerIn)
public abstract boolean canStructuresSpawn()
public abstract WorldSettings.GameType getGameType()
public abstract EnumDifficulty getDifficulty()
public abstract boolean isHardcore()
public abstract int getOpPermissionLevel()
public abstract boolean func_181034_q()
public abstract boolean func_183002_r()
protected void outputPercentRemaining(java.lang.String message, int percent)
protected void clearCurrentTask()
protected void saveAllWorlds(boolean dontLog)
public void stopServer()
public boolean isServerRunning()
public void initiateShutdown()
protected void setInstance()
public void run()
run
in interface java.lang.Runnable
private void addFaviconToStatusResponse(ServerStatusResponse response)
public java.io.File getDataDirectory()
protected void finalTick(CrashReport report)
protected void systemExitNow()
public void tick()
public void updateTimeLightAndEntities()
public boolean getAllowNether()
public void startServerThread()
public java.io.File getFile(java.lang.String fileName)
public void logWarning(java.lang.String msg)
public WorldServer worldServerForDimension(int dimension)
public java.lang.String getMinecraftVersion()
public int getCurrentPlayerCount()
public int getMaxPlayers()
public java.lang.String[] getAllUsernames()
public com.mojang.authlib.GameProfile[] getGameProfiles()
public java.lang.String getServerModName()
public CrashReport addServerInfoToCrashReport(CrashReport report)
public java.util.List<java.lang.String> getTabCompletions(ICommandSender sender, java.lang.String input, BlockPos pos)
public static MinecraftServer getServer()
public boolean isAnvilFileSet()
public java.lang.String getName()
getName
in interface ICommandSender
public void addChatMessage(IChatComponent component)
addChatMessage
in interface ICommandSender
public boolean canCommandSenderUseCommand(int permLevel, java.lang.String commandName)
true
if the CommandSender is allowed to execute the command, false
if notcanCommandSenderUseCommand
in interface ICommandSender
public ICommandManager getCommandManager()
public java.security.KeyPair getKeyPair()
public java.lang.String getServerOwner()
public void setServerOwner(java.lang.String owner)
public boolean isSinglePlayer()
public java.lang.String getFolderName()
public void setFolderName(java.lang.String name)
public void setWorldName(java.lang.String p_71246_1_)
public java.lang.String getWorldName()
public void setKeyPair(java.security.KeyPair keyPair)
public void setDifficultyForAllWorlds(EnumDifficulty difficulty)
protected boolean allowSpawnMonsters()
public boolean isDemo()
public void setDemo(boolean demo)
public void canCreateBonusChest(boolean enable)
public ISaveFormat getActiveAnvilConverter()
public void deleteWorldAndStopServer()
public java.lang.String getResourcePackUrl()
public java.lang.String getResourcePackHash()
public void setResourcePack(java.lang.String url, java.lang.String hash)
public void addServerStatsToSnooper(PlayerUsageSnooper playerSnooper)
addServerStatsToSnooper
in interface IPlayerUsage
public void addServerTypeToSnooper(PlayerUsageSnooper playerSnooper)
addServerTypeToSnooper
in interface IPlayerUsage
public boolean isSnooperEnabled()
isSnooperEnabled
in interface IPlayerUsage
public abstract boolean isDedicatedServer()
public boolean isServerInOnlineMode()
public void setOnlineMode(boolean online)
public boolean getCanSpawnAnimals()
public void setCanSpawnAnimals(boolean spawnAnimals)
public boolean getCanSpawnNPCs()
public abstract boolean func_181035_ah()
public void setCanSpawnNPCs(boolean spawnNpcs)
public boolean isPVPEnabled()
public void setAllowPvp(boolean allowPvp)
public boolean isFlightAllowed()
public void setAllowFlight(boolean allow)
public abstract boolean isCommandBlockEnabled()
public java.lang.String getMOTD()
public void setMOTD(java.lang.String motdIn)
public int getBuildLimit()
public void setBuildLimit(int maxBuildHeight)
public boolean isServerStopped()
public ServerConfigurationManager getConfigurationManager()
public void setConfigManager(ServerConfigurationManager configManager)
public void setGameType(WorldSettings.GameType gameMode)
public NetworkSystem getNetworkSystem()
public boolean serverIsInRunLoop()
public boolean getGuiEnabled()
public abstract java.lang.String shareToLAN(WorldSettings.GameType type, boolean allowCheats)
public int getTickCounter()
public void enableProfiling()
public PlayerUsageSnooper getPlayerUsageSnooper()
public BlockPos getPosition()
null
is not allowed! If you are not an entity in the world, return
the coordinates 0, 0, 0getPosition
in interface ICommandSender
public Vec3 getPositionVector()
null
is not allowed! If you are not an entity in the world, return 0.0D,
0.0D, 0.0DgetPositionVector
in interface ICommandSender
public World getEntityWorld()
null
is not allowed! If you are not an entity in the world, return
the overworldgetEntityWorld
in interface ICommandSender
public Entity getCommandSenderEntity()
getCommandSenderEntity
in interface ICommandSender
public int getSpawnProtectionSize()
public boolean isBlockProtected(World worldIn, BlockPos pos, EntityPlayer playerIn)
public boolean getForceGamemode()
public java.net.Proxy getServerProxy()
public static long getCurrentTimeMillis()
public int getMaxPlayerIdleMinutes()
public void setPlayerIdleTimeout(int idleTimeout)
public IChatComponent getDisplayName()
getDisplayName
in interface ICommandSender
public boolean isAnnouncingPlayerAchievements()
public com.mojang.authlib.minecraft.MinecraftSessionService getMinecraftSessionService()
public com.mojang.authlib.GameProfileRepository getGameProfileRepository()
public PlayerProfileCache getPlayerProfileCache()
public ServerStatusResponse getServerStatusResponse()
public void refreshStatusNextTick()
public Entity getEntityFromUuid(java.util.UUID uuid)
public boolean sendCommandFeedback()
sendCommandFeedback
in interface ICommandSender
public void setCommandStat(CommandResultStats.Type type, int amount)
setCommandStat
in interface ICommandSender
public int getMaxWorldSize()
public <V> com.google.common.util.concurrent.ListenableFuture<V> callFromMainThread(java.util.concurrent.Callable<V> callable)
public com.google.common.util.concurrent.ListenableFuture<java.lang.Object> addScheduledTask(java.lang.Runnable runnableToSchedule)
addScheduledTask
in interface IThreadListener
public boolean isCallingFromMinecraftThread()
isCallingFromMinecraftThread
in interface IThreadListener
public int getNetworkCompressionTreshold()