public abstract class MinecraftServer extends java.lang.Object implements java.lang.Runnable, ICommandSender, IThreadListener, ISnooperInfo
Modifier and Type | Field and Description |
---|---|
ICommandManager |
commandManager |
java.lang.String |
currentTask
The task the server is currently working on(and will output on outputPercentRemaining).
|
java.util.Queue<java.util.concurrent.FutureTask<?>> |
futureTaskQueue |
int |
percentDone
The percentage of the current task finished so far.
|
protected java.net.Proxy |
serverProxy |
Profiler |
theProfiler |
long[] |
tickTimeArray |
static java.io.File |
USER_CACHE_FILE |
WorldServer[] |
worlds
The server world instances.
|
java.util.Hashtable<java.lang.Integer,long[]> |
worldTickTimes |
Constructor and Description |
---|
MinecraftServer(java.io.File anvilFileIn,
java.net.Proxy proxyIn,
DataFixer dataFixerIn,
YggdrasilAuthenticationService authServiceIn,
MinecraftSessionService sessionServiceIn,
GameProfileRepository profileRepoIn,
PlayerProfileCache profileCacheIn) |
Modifier and Type | Method and Description |
---|---|
<any> |
addScheduledTask(java.lang.Runnable runnableToSchedule) |
CrashReport |
addServerInfoToCrashReport(CrashReport report)
Adds the server info, including from theWorldServer, to the crash report.
|
void |
addServerStatsToSnooper(Snooper playerSnooper) |
void |
addServerTypeToSnooper(Snooper playerSnooper) |
boolean |
allowSpawnMonsters() |
void |
applyServerIconToResponse(ServerStatusResponse response) |
<V> <any> |
callFromMainThread(java.util.concurrent.Callable<V> callable) |
void |
canCreateBonusChest(boolean enable) |
abstract boolean |
canStructuresSpawn() |
boolean |
canUseCommand(int permLevel,
java.lang.String commandName)
Returns
true if the CommandSender is allowed to execute the command, false if not |
protected void |
clearCurrentTask()
Set current task to null and set its percentage to 0.
|
void |
convertMapIfNeeded(java.lang.String worldNameIn) |
ServerCommandManager |
createCommandManager() |
void |
enableProfiling() |
void |
finalTick(CrashReport report)
Called on exit from the main run() loop.
|
ISaveFormat |
getActiveAnvilConverter() |
boolean |
getAllowNether() |
int |
getBuildLimit() |
boolean |
getCanSpawnAnimals() |
boolean |
getCanSpawnNPCs() |
ICommandManager |
getCommandManager() |
Entity |
getCommandSenderEntity()
Returns the entity associated with the command sender.
|
int |
getCurrentPlayerCount()
Returns the number of players currently on the server.
|
long |
getCurrentTime() |
static long |
getCurrentTimeMillis() |
java.io.File |
getDataDirectory() |
DataFixer |
getDataFixer() |
abstract EnumDifficulty |
getDifficulty()
Get the server's difficulty
|
ITextComponent |
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()
Get the forceGamemode field (whether joining players will be put in their old gamemode or the default one)
|
GameProfileRepository |
getGameProfileRepository() |
abstract 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() |
MinecraftSessionService |
getMinecraftSessionService() |
java.lang.String |
getMinecraftVersion()
Returns the server's Minecraft version as string.
|
java.lang.String |
getMOTD() |
java.lang.String |
getName()
Get the name of this object.
|
int |
getNetworkCompressionThreshold()
The compression treshold.
|
NetworkSystem |
getNetworkSystem() |
java.lang.String[] |
getOnlinePlayerNames()
Returns an array of the usernames of all the connected players.
|
GameProfile[] |
getOnlinePlayerProfiles()
Returns an array of the GameProfiles of all the connected players
|
abstract int |
getOpPermissionLevel() |
PlayerList |
getPlayerList() |
PlayerProfileCache |
getPlayerProfileCache() |
Snooper |
getPlayerUsageSnooper() |
BlockPos |
getPosition()
Get the position in the world.
|
Vec3d |
getPositionVector()
Get the position vector.
|
boolean |
getPreventProxyConnections() |
java.lang.String |
getResourcePackHash() |
java.lang.String |
getResourcePackUrl() |
MinecraftServer |
getServer()
Get the Minecraft server instance
|
java.lang.String |
getServerHostname()
"getHostname" is already taken, but both return the hostname.
|
java.lang.String |
getServerModName() |
java.lang.String |
getServerOwner()
Returns the username of the server owner (for integrated servers)
|
int |
getServerPort()
Gets serverPort.
|
java.net.Proxy |
getServerProxy() |
ServerStatusResponse |
getServerStatusResponse() |
java.lang.Thread |
getServerThread() |
int |
getSpawnProtectionSize()
Return the spawn protection area's size.
|
int |
getSpawnRadius(WorldServer worldIn) |
java.util.List<java.lang.String> |
getTabCompletions(ICommandSender sender,
java.lang.String input,
BlockPos pos,
boolean hasTargetBlock) |
int |
getTickCounter() |
java.lang.String |
getUserMessage() |
java.io.File |
getWorldIconFile() |
java.lang.String |
getWorldName() |
abstract boolean |
init()
Initialises the server and starts it.
|
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.
|
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.
|
boolean |
isWorldIconSet() |
void |
loadAllWorlds(java.lang.String saveName,
java.lang.String worldNameIn,
long seed,
WorldType type,
java.lang.String generatorOptions) |
void |
logDebug(java.lang.String msg)
If isDebuggingEnabled(), logs the message with a level of INFO.
|
void |
logInfo(java.lang.String msg)
Logs the message with a level of INFO.
|
void |
logSevere(java.lang.String msg)
Logs the error message with a level of SEVERE.
|
void |
logWarning(java.lang.String msg)
Logs the message with a level of WARN.
|
static void |
main(java.lang.String[] p_main_0_) |
protected void |
outputPercentRemaining(java.lang.String message,
int percent)
Used to display a percent remaining given text and the percentage.
|
void |
refreshStatusNextTick() |
void |
registerTickable(ITickable tickable) |
void |
run() |
void |
saveAllWorlds(boolean isSilent)
par1 indicates if a log message should be output.
|
boolean |
sendCommandFeedback()
Returns true if the command sender should be sent feedback about executed commands
|
void |
sendMessage(ITextComponent component)
Send a chat message to the CommandSender
|
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 |
setDemo(boolean demo)
Sets whether this is a demo or not.
|
void |
setDifficultyForAllWorlds(EnumDifficulty difficulty) |
void |
setFolderName(java.lang.String name) |
void |
setForceGamemode(boolean force)
Set the forceGamemode field (whether joining players will be put in their old gamemode or the default one)
|
void |
setGameType(GameType gameMode)
Sets the game type for all worlds.
|
void |
setHostname(java.lang.String host) |
void |
setKeyPair(java.security.KeyPair keyPair) |
void |
setMOTD(java.lang.String motdIn) |
void |
setOnlineMode(boolean online) |
void |
setPlayerIdleTimeout(int idleTimeout) |
void |
setPlayerList(PlayerList list) |
void |
setPreventProxyConnections(boolean p_190517_1_) |
void |
setResourcePack(java.lang.String url,
java.lang.String hash) |
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)
|
void |
setServerPort(int port) |
protected void |
setUserMessage(java.lang.String message)
Typically "menu.convertingLevel", "menu.loadingLevel" or others.
|
void |
setWorldName(java.lang.String worldNameIn) |
abstract java.lang.String |
shareToLAN(GameType type,
boolean allowCheats)
On dedicated does nothing.
|
abstract boolean |
shouldBroadcastConsoleToOps()
Get if console command events should be broadcast to ops
|
abstract boolean |
shouldBroadcastRconToOps()
Get if RCON command events should be broadcast to ops
|
abstract boolean |
shouldUseNativeTransport()
Get if native transport should be used.
|
void |
startServerThread() |
void |
stopServer()
Saves all necessary data as preparation for stopping the server.
|
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.
|
public static final java.io.File USER_CACHE_FILE
public final ICommandManager commandManager
public final Profiler theProfiler
public WorldServer[] worlds
protected final java.net.Proxy serverProxy
public java.lang.String currentTask
public int percentDone
public final long[] tickTimeArray
public java.util.Hashtable<java.lang.Integer,long[]> worldTickTimes
public final java.util.Queue<java.util.concurrent.FutureTask<?>> futureTaskQueue
public MinecraftServer(java.io.File anvilFileIn, java.net.Proxy proxyIn, DataFixer dataFixerIn, YggdrasilAuthenticationService authServiceIn, MinecraftSessionService sessionServiceIn, GameProfileRepository profileRepoIn, PlayerProfileCache profileCacheIn)
public ServerCommandManager createCommandManager()
public abstract boolean init() throws java.io.IOException
java.io.IOException
public void convertMapIfNeeded(java.lang.String worldNameIn)
protected void setUserMessage(java.lang.String message)
public java.lang.String getUserMessage()
public void loadAllWorlds(java.lang.String saveName, java.lang.String worldNameIn, long seed, WorldType type, java.lang.String generatorOptions)
public void initialWorldChunkLoad()
public void setResourcePackFromWorld(java.lang.String worldNameIn, ISaveHandler saveHandlerIn)
public abstract boolean canStructuresSpawn()
public abstract GameType getGameType()
public abstract EnumDifficulty getDifficulty()
public abstract boolean isHardcore()
public abstract int getOpPermissionLevel()
public abstract boolean shouldBroadcastRconToOps()
public abstract boolean shouldBroadcastConsoleToOps()
protected void outputPercentRemaining(java.lang.String message, int percent)
protected void clearCurrentTask()
public void saveAllWorlds(boolean isSilent)
public void stopServer()
public boolean isServerRunning()
public void initiateShutdown()
public void run()
run
in interface java.lang.Runnable
public void applyServerIconToResponse(ServerStatusResponse response)
public boolean isWorldIconSet()
public java.io.File getWorldIconFile()
public java.io.File getDataDirectory()
public void finalTick(CrashReport report)
public 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[] getOnlinePlayerNames()
public GameProfile[] getOnlinePlayerProfiles()
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, boolean hasTargetBlock)
public boolean isAnvilFileSet()
public java.lang.String getName()
getName
in interface ICommandSender
public void sendMessage(ITextComponent component)
sendMessage
in interface ICommandSender
public boolean canUseCommand(int permLevel, java.lang.String commandName)
true
if the CommandSender is allowed to execute the command, false
if notcanUseCommand
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 worldNameIn)
public java.lang.String getWorldName()
public void setKeyPair(java.security.KeyPair keyPair)
public void setDifficultyForAllWorlds(EnumDifficulty difficulty)
public boolean allowSpawnMonsters()
public boolean isDemo()
public void setDemo(boolean demo)
public void canCreateBonusChest(boolean enable)
public ISaveFormat getActiveAnvilConverter()
public java.lang.String getResourcePackUrl()
public java.lang.String getResourcePackHash()
public void setResourcePack(java.lang.String url, java.lang.String hash)
public void addServerStatsToSnooper(Snooper playerSnooper)
addServerStatsToSnooper
in interface ISnooperInfo
public void addServerTypeToSnooper(Snooper playerSnooper)
addServerTypeToSnooper
in interface ISnooperInfo
public boolean isSnooperEnabled()
isSnooperEnabled
in interface ISnooperInfo
public abstract boolean isDedicatedServer()
public boolean isServerInOnlineMode()
public void setOnlineMode(boolean online)
public boolean getPreventProxyConnections()
public boolean getCanSpawnAnimals()
public void setCanSpawnAnimals(boolean spawnAnimals)
public boolean getCanSpawnNPCs()
public abstract boolean shouldUseNativeTransport()
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 PlayerList getPlayerList()
public void setPlayerList(PlayerList list)
public void setGameType(GameType gameMode)
public NetworkSystem getNetworkSystem()
public boolean serverIsInRunLoop()
public boolean getGuiEnabled()
public abstract java.lang.String shareToLAN(GameType type, boolean allowCheats)
public int getTickCounter()
public void enableProfiling()
public Snooper 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 Vec3d 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 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 ITextComponent getDisplayName()
getDisplayName
in interface ICommandSender
public boolean isAnnouncingPlayerAchievements()
public MinecraftSessionService getMinecraftSessionService()
public 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 MinecraftServer getServer()
getServer
in interface ICommandSender
public int getMaxWorldSize()
public <V> <any> callFromMainThread(java.util.concurrent.Callable<V> callable)
public <any> addScheduledTask(java.lang.Runnable runnableToSchedule)
addScheduledTask
in interface IThreadListener
public boolean isCallingFromMinecraftThread()
isCallingFromMinecraftThread
in interface IThreadListener
public int getNetworkCompressionThreshold()
public DataFixer getDataFixer()
public int getSpawnRadius(WorldServer worldIn)
public java.lang.String getServerHostname()
public void setHostname(java.lang.String host)
public void registerTickable(ITickable tickable)
public static void main(java.lang.String[] p_main_0_)
public void logInfo(java.lang.String msg)
public boolean isDebuggingEnabled()
public void logSevere(java.lang.String msg)
public void logDebug(java.lang.String msg)
public int getServerPort()
public void setServerPort(int port)
public void setPreventProxyConnections(boolean p_190517_1_)
public int getSpawnProtectionSize()
public void setForceGamemode(boolean force)
public long getCurrentTime()
public java.lang.Thread getServerThread()