2010-12-22 16:22:23 +01:00
package net.minecraft.server ;
2011-01-29 22:50:29 +01:00
import java.awt.GraphicsEnvironment ;
2010-12-22 16:22:23 +01:00
import java.io.File ;
2011-01-11 09:25:13 +01:00
import java.io.IOException ;
2010-12-22 16:22:23 +01:00
import java.net.InetAddress ;
import java.util.ArrayList ;
import java.util.Collections ;
import java.util.HashMap ;
2010-12-28 20:52:24 +01:00
import java.util.Iterator ;
2010-12-22 16:22:23 +01:00
import java.util.List ;
2011-03-31 22:40:00 +02:00
import java.util.Random ;
2010-12-22 16:22:23 +01:00
import java.util.logging.Level ;
import java.util.logging.Logger ;
2010-12-28 20:52:24 +01:00
2011-01-11 09:25:13 +01:00
// CraftBukkit start
2011-02-23 13:56:36 +01:00
import java.io.PrintStream ;
2011-01-11 09:25:13 +01:00
import java.net.UnknownHostException ;
2011-02-25 17:12:38 +01:00
import jline.ConsoleReader ;
2011-01-11 09:25:13 +01:00
import joptsimple.OptionSet ;
2011-05-26 14:48:22 +02:00
import org.bukkit.World.Environment ;
2010-12-22 16:22:23 +01:00
import org.bukkit.craftbukkit.CraftServer ;
2011-02-20 02:53:06 +01:00
import org.bukkit.craftbukkit.LoggerOutputStream ;
2011-02-25 17:12:38 +01:00
import org.bukkit.craftbukkit.command.ColouredConsoleSender ;
2011-02-03 00:53:04 +01:00
import org.bukkit.craftbukkit.scheduler.CraftScheduler ;
2011-03-29 22:01:04 +02:00
import org.bukkit.craftbukkit.util.ServerShutdownThread ;
2011-03-26 23:20:35 +01:00
import org.bukkit.event.world.WorldSaveEvent ;
2011-04-20 19:05:14 +02:00
// CraftBukkit
2010-12-22 16:22:23 +01:00
2011-02-23 03:37:56 +01:00
public class MinecraftServer implements Runnable , ICommandListener {
2010-12-22 16:22:23 +01:00
2011-04-20 19:05:14 +02:00
public static Logger log = Logger . getLogger ( " Minecraft " ) ;
2011-01-11 09:25:13 +01:00
public static HashMap b = new HashMap ( ) ;
2011-04-20 19:05:14 +02:00
public NetworkListenThread networkListenThread ;
public PropertyManager propertyManager ;
2011-05-28 22:50:08 +02:00
// public WorldServer[] worldServer; // CraftBukkit - removed!
2011-04-20 19:05:14 +02:00
public ServerConfigurationManager serverConfigurationManager ;
public ConsoleCommandHandler consoleCommandHandler ; // CraftBukkit - made public
private boolean isRunning = true ;
public boolean isStopped = false ;
int ticks = 0 ;
2010-12-22 16:22:23 +01:00
public String i ;
public int j ;
2011-04-20 22:47:26 +02:00
private List r = new ArrayList ( ) ;
private List s = Collections . synchronizedList ( new ArrayList ( ) ) ;
2011-05-28 22:50:08 +02:00
// public EntityTracker[] tracker = new EntityTracker[2]; // CraftBukkit - removed!
2011-04-20 19:05:14 +02:00
public boolean onlineMode ;
public boolean spawnAnimals ;
public boolean pvpMode ;
2011-04-20 22:47:26 +02:00
public boolean o ;
2010-12-28 20:52:24 +01:00
2011-02-23 13:56:36 +01:00
// CraftBukkit start
2011-02-21 23:30:01 +01:00
public int spawnProtection ;
2011-05-26 23:15:27 +02:00
public List < WorldServer > worlds = new ArrayList < WorldServer > ( ) ;
2011-01-29 22:50:29 +01:00
public CraftServer server ;
public OptionSet options ;
2011-02-25 17:12:38 +01:00
public ColouredConsoleSender console ;
public ConsoleReader reader ;
2011-05-09 20:51:01 +02:00
public static int currentTick ;
2011-05-14 16:29:42 +02:00
// CraftBukkit end
2010-12-22 16:22:23 +01:00
2011-02-23 13:56:36 +01:00
public MinecraftServer ( OptionSet options ) { // CraftBukkit - adds argument OptionSet
2011-02-21 23:30:01 +01:00
new ThreadSleepForever ( this ) ;
2011-02-25 17:12:38 +01:00
// CraftBukkit start
this . options = options ;
try {
this . reader = new ConsoleReader ( ) ;
} catch ( IOException ex ) {
Logger . getLogger ( MinecraftServer . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ;
}
2011-03-29 22:01:04 +02:00
Runtime . getRuntime ( ) . addShutdownHook ( new ServerShutdownThread ( this ) ) ;
2011-02-25 17:12:38 +01:00
// CraftBukkit end
2011-02-21 23:30:01 +01:00
}
2011-04-20 19:05:14 +02:00
private boolean init ( ) throws UnknownHostException { // CraftBukkit - added throws UnknownHostException
this . consoleCommandHandler = new ConsoleCommandHandler ( this ) ;
2010-12-28 20:52:24 +01:00
ThreadCommandReader threadcommandreader = new ThreadCommandReader ( this ) ;
2010-12-22 16:22:23 +01:00
2011-01-29 22:50:29 +01:00
threadcommandreader . setDaemon ( true ) ;
threadcommandreader . start ( ) ;
2011-05-14 16:29:42 +02:00
ConsoleLogManager . init ( this ) ; // CraftBukkit
2011-02-20 02:53:06 +01:00
2011-02-23 13:56:36 +01:00
// CraftBukkit start
2011-04-20 19:05:14 +02:00
System . setOut ( new PrintStream ( new LoggerOutputStream ( log , Level . INFO ) , true ) ) ;
System . setErr ( new PrintStream ( new LoggerOutputStream ( log , Level . SEVERE ) , true ) ) ;
2011-02-23 13:56:36 +01:00
// CraftBukkit end
2011-02-20 02:53:06 +01:00
2011-05-31 15:55:45 +02:00
log . info ( " Starting minecraft server version Beta 1.6.6 " ) ;
2010-12-22 16:22:23 +01:00
if ( Runtime . getRuntime ( ) . maxMemory ( ) / 1024L / 1024L < 512L ) {
2011-04-20 19:05:14 +02:00
log . warning ( " **** NOT ENOUGH RAM! " ) ;
log . warning ( " To start the server with more ram, launch it as \" java -Xmx1024M -Xms1024M -jar minecraft_server.jar \" " ) ;
2010-12-22 16:22:23 +01:00
}
2011-01-29 22:50:29 +01:00
2011-04-20 19:05:14 +02:00
log . info ( " Loading properties " ) ;
2011-04-22 06:42:56 +02:00
this . propertyManager = new PropertyManager ( options ) ; // CraftBukkit - CLI argument support
2011-04-20 19:05:14 +02:00
String s = this . propertyManager . getString ( " server-ip " , " " ) ;
2010-12-22 16:22:23 +01:00
2011-04-20 19:05:14 +02:00
this . onlineMode = this . propertyManager . getBoolean ( " online-mode " , true ) ;
this . spawnAnimals = this . propertyManager . getBoolean ( " spawn-animals " , true ) ;
this . pvpMode = this . propertyManager . getBoolean ( " pvp " , true ) ;
2011-04-20 22:47:26 +02:00
this . o = this . propertyManager . getBoolean ( " allow-flight " , false ) ;
2011-05-14 16:29:42 +02:00
this . spawnProtection = this . propertyManager . getInt ( " spawn-protection " , 16 ) ; // CraftBukkit - Configurable spawn protection start
2010-12-28 20:52:24 +01:00
InetAddress inetaddress = null ;
2010-12-22 16:22:23 +01:00
2010-12-28 20:52:24 +01:00
if ( s . length ( ) > 0 ) {
inetaddress = InetAddress . getByName ( s ) ;
2010-12-22 16:22:23 +01:00
}
2011-04-20 19:05:14 +02:00
int i = this . propertyManager . getInt ( " server-port " , 25565 ) ;
2011-01-29 22:50:29 +01:00
2011-04-20 19:05:14 +02:00
log . info ( " Starting Minecraft server on " + ( s . length ( ) = = 0 ? " * " : s ) + " : " + i ) ;
2011-01-29 22:50:29 +01:00
2010-12-22 16:22:23 +01:00
try {
2011-04-20 19:05:14 +02:00
this . networkListenThread = new NetworkListenThread ( this , inetaddress , i ) ;
2011-02-21 23:30:01 +01:00
} catch ( Throwable ioexception ) { // CraftBukkit - IOException -> Throwable
2011-04-20 19:05:14 +02:00
log . warning ( " **** FAILED TO BIND TO PORT! " ) ;
log . log ( Level . WARNING , " The exception was: " + ioexception . toString ( ) ) ;
log . warning ( " Perhaps a server is already running on that port? " ) ;
2010-12-22 16:22:23 +01:00
return false ;
}
2011-01-29 22:50:29 +01:00
2011-04-20 19:05:14 +02:00
if ( ! this . onlineMode ) {
log . warning ( " **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE! " ) ;
log . warning ( " The server will make no attempt to authenticate usernames. Beware. " ) ;
log . warning ( " While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose. " ) ;
log . warning ( " To change this, set \" online-mode \" to \" true \" in the server.settings file. " ) ;
2010-12-22 16:22:23 +01:00
}
2010-12-26 03:20:29 +01:00
2011-04-20 19:05:14 +02:00
this . serverConfigurationManager = new ServerConfigurationManager ( this ) ;
2011-05-28 22:50:08 +02:00
// CraftBukkit - removed trackers
2011-02-23 03:37:56 +01:00
long j = System . nanoTime ( ) ;
2011-04-20 19:05:14 +02:00
String s1 = this . propertyManager . getString ( " level-name " , " world " ) ;
String s2 = this . propertyManager . getString ( " level-seed " , " " ) ;
2011-03-31 22:40:00 +02:00
long k = ( new Random ( ) ) . nextLong ( ) ;
if ( s2 . length ( ) > 0 ) {
try {
k = Long . parseLong ( s2 ) ;
} catch ( NumberFormatException numberformatexception ) {
k = ( long ) s2 . hashCode ( ) ;
}
}
2011-01-29 22:50:29 +01:00
2011-04-20 19:05:14 +02:00
log . info ( " Preparing level \" " + s1 + " \" " ) ;
2011-03-31 22:40:00 +02:00
this . a ( new WorldLoaderServer ( new File ( " . " ) ) , s1 , k ) ;
2011-02-25 21:57:38 +01:00
// CraftBukkit start
long elapsed = System . nanoTime ( ) - j ;
2011-05-14 16:29:42 +02:00
String time = String . format ( " %.3fs " , elapsed / 10000000000 . 0D ) ;
2011-04-20 19:05:14 +02:00
log . info ( " Done ( " + time + " )! For help, type \" help \" or \" ? \" " ) ;
2011-02-25 21:57:38 +01:00
// CraftBukkit end
2010-12-22 16:22:23 +01:00
return true ;
}
2011-03-31 22:40:00 +02:00
private void a ( Convertable convertable , String s , long i ) {
2011-04-20 19:05:14 +02:00
if ( convertable . isConvertable ( s ) ) {
log . info ( " Converting map! " ) ;
convertable . convert ( s , new ConvertProgressUpdater ( this ) ) ;
2011-02-23 03:37:56 +01:00
}
2011-05-28 22:50:08 +02:00
// CraftBukkit start
2011-05-26 14:48:22 +02:00
for ( int j = 0 ; j < ( this . propertyManager . getBoolean ( " allow-nether " , true ) ? 2 : 1 ) ; + + j ) {
WorldServer world ;
int dimension = j = = 0 ? 0 : - 1 ;
2011-02-05 19:15:04 +01:00
2011-05-26 14:48:22 +02:00
if ( j = = 0 ) {
2011-06-06 15:52:02 +02:00
world = new WorldServer ( this , new ServerNBTManager ( new File ( " . " ) , s , true ) , s , dimension , i , org . bukkit . World . Environment . getEnvironment ( dimension ) , null ) ; // CraftBukkit
2011-05-26 14:48:22 +02:00
} else {
String name = s + " _ " + Environment . getEnvironment ( dimension ) . toString ( ) . toLowerCase ( ) ;
2011-06-06 15:52:02 +02:00
world = new SecondaryWorldServer ( this , new ServerNBTManager ( new File ( " . " ) , name , true ) , name , dimension , i , worlds . get ( 0 ) , org . bukkit . World . Environment . getEnvironment ( dimension ) , null ) ; // CraftBukkit
2011-05-26 14:48:22 +02:00
}
world . tracker = new EntityTracker ( this , dimension ) ;
world . addIWorldAccess ( new WorldManager ( this , world ) ) ;
world . spawnMonsters = this . propertyManager . getBoolean ( " spawn-monsters " , true ) ? 1 : 0 ;
world . setSpawnFlags ( this . propertyManager . getBoolean ( " spawn-monsters " , true ) , this . spawnAnimals ) ;
worlds . add ( world ) ;
this . serverConfigurationManager . setPlayerFileData ( worlds . toArray ( new WorldServer [ 0 ] ) ) ;
}
2011-05-28 22:50:08 +02:00
// CraftBukkit end
2011-02-05 19:15:04 +01:00
2011-01-29 22:50:29 +01:00
short short1 = 196 ;
2011-05-26 14:48:22 +02:00
long k = System . currentTimeMillis ( ) ;
2011-01-29 22:50:29 +01:00
2011-05-28 22:50:08 +02:00
for ( int l = 0 ; l < this . worlds . size ( ) ; + + l ) { // CraftBukkit
2011-05-26 14:48:22 +02:00
log . info ( " Preparing start region for level " + l ) ;
2011-05-28 22:50:08 +02:00
// if (l == 0 || this.propertyManager.getBoolean("allow-nether", true)) { // CraftBukkit
WorldServer worldserver = this . worlds . get ( l ) ; // CraftBukkit
ChunkCoordinates chunkcoordinates = worldserver . getSpawn ( ) ;
2011-01-29 22:50:29 +01:00
2011-05-28 22:50:08 +02:00
for ( int i1 = - short1 ; i1 < = short1 & & this . isRunning ; i1 + = 16 ) {
for ( int j1 = - short1 ; j1 < = short1 & & this . isRunning ; j1 + = 16 ) {
long k1 = System . currentTimeMillis ( ) ;
2011-05-26 14:48:22 +02:00
2011-05-28 22:50:08 +02:00
if ( k1 < k ) {
k = k1 ;
}
2011-01-14 14:31:10 +01:00
2011-05-28 22:50:08 +02:00
if ( k1 > k + 1000L ) {
int l1 = ( short1 * 2 + 1 ) * ( short1 * 2 + 1 ) ;
int i2 = ( i1 + short1 ) * ( short1 * 2 + 1 ) + j1 + 1 ;
2011-01-29 22:50:29 +01:00
2011-05-28 22:50:08 +02:00
this . a ( " Preparing spawn area " , i2 * 100 / l1 ) ;
k = k1 ;
}
2011-01-29 22:50:29 +01:00
2011-05-28 22:50:08 +02:00
worldserver . chunkProviderServer . getChunkAt ( chunkcoordinates . x + i1 > > 4 , chunkcoordinates . z + j1 > > 4 ) ;
2011-01-29 22:50:29 +01:00
2011-05-28 22:50:08 +02:00
while ( worldserver . doLighting ( ) & & this . isRunning ) {
;
}
2011-02-05 19:15:04 +01:00
}
2010-12-22 16:22:23 +01:00
}
2011-05-28 22:50:08 +02:00
// } // CraftBukkit
2010-12-22 16:22:23 +01:00
}
2010-12-28 20:52:24 +01:00
2011-01-29 22:50:29 +01:00
this . e ( ) ;
2010-12-22 16:22:23 +01:00
}
2011-01-29 22:50:29 +01:00
private void a ( String s , int i ) {
this . i = s ;
this . j = i ;
2011-04-20 19:05:14 +02:00
log . info ( s + " : " + i + " % " ) ;
2010-12-22 16:22:23 +01:00
}
private void e ( ) {
2011-01-29 22:50:29 +01:00
this . i = null ;
this . j = 0 ;
2011-01-11 09:25:13 +01:00
server . loadPlugins ( ) ; // CraftBukkit
2010-12-22 16:22:23 +01:00
}
2011-04-20 19:05:14 +02:00
void saveChunks ( ) { // CraftBukkit - private -> default
log . info ( " Saving chunks " ) ;
2011-02-05 19:15:04 +01:00
2011-05-28 22:50:08 +02:00
// CraftBukkit start
2011-05-26 14:48:22 +02:00
for ( int i = 0 ; i < this . worlds . size ( ) ; + + i ) {
WorldServer worldserver = this . worlds . get ( i ) ;
2011-02-19 21:29:51 +01:00
2011-05-26 14:48:22 +02:00
worldserver . save ( true , ( IProgressUpdate ) null ) ;
worldserver . saveLevel ( ) ;
WorldSaveEvent event = new WorldSaveEvent ( worldserver . getWorld ( ) ) ;
2011-05-14 16:29:42 +02:00
server . getPluginManager ( ) . callEvent ( event ) ;
2011-02-05 19:15:04 +01:00
}
2011-05-26 23:29:57 +02:00
2011-05-26 14:48:22 +02:00
WorldServer world = this . worlds . get ( 0 ) ;
if ( ! world . E ) {
2011-05-16 23:29:57 +02:00
this . serverConfigurationManager . savePlayers ( ) ;
}
2011-02-23 13:56:36 +01:00
// CraftBukkit end
2010-12-22 16:22:23 +01:00
}
2011-05-14 16:29:42 +02:00
public void stop ( ) { // CraftBukkit - private -> public
2011-04-20 19:05:14 +02:00
log . info ( " Stopping server " ) ;
2011-02-21 23:30:01 +01:00
// CraftBukkit start
2011-02-23 13:56:36 +01:00
if ( server ! = null ) {
2011-02-01 21:37:07 +01:00
server . disablePlugins ( ) ;
}
2011-02-23 13:56:36 +01:00
// CraftBukkit end
2011-02-02 00:32:18 +01:00
2011-04-20 19:05:14 +02:00
if ( this . serverConfigurationManager ! = null ) {
this . serverConfigurationManager . savePlayers ( ) ;
2011-01-27 22:15:41 +01:00
}
2011-06-05 17:54:56 +02:00
// CraftBukkit start - multiworld is handled in saveChunks() already.
WorldServer worldserver = this . worlds . get ( 0 ) ;
2011-05-26 14:48:22 +02:00
2011-06-05 17:54:56 +02:00
if ( worldserver ! = null ) {
this . saveChunks ( ) ;
2010-12-22 16:22:23 +01:00
}
2011-05-26 14:48:22 +02:00
// CraftBukkit end
2010-12-22 16:22:23 +01:00
}
public void a ( ) {
2011-04-20 19:05:14 +02:00
this . isRunning = false ;
2010-12-22 16:22:23 +01:00
}
public void run ( ) {
try {
2011-04-20 19:05:14 +02:00
if ( this . init ( ) ) {
2011-01-29 22:50:29 +01:00
long i = System . currentTimeMillis ( ) ;
2010-12-28 20:52:24 +01:00
2011-04-20 19:05:14 +02:00
for ( long j = 0L ; this . isRunning ; Thread . sleep ( 1L ) ) {
2011-01-29 22:50:29 +01:00
long k = System . currentTimeMillis ( ) ;
long l = k - i ;
2010-12-28 20:52:24 +01:00
2011-01-29 22:50:29 +01:00
if ( l > 2000L ) {
2011-04-20 19:05:14 +02:00
log . warning ( " Can \ 't keep up! Did the system time change, or is the server overloaded? " ) ;
2011-01-29 22:50:29 +01:00
l = 2000L ;
2010-12-22 16:22:23 +01:00
}
2011-01-29 22:50:29 +01:00
if ( l < 0L ) {
2011-04-20 19:05:14 +02:00
log . warning ( " Time ran backwards! Did the system time change? " ) ;
2011-01-29 22:50:29 +01:00
l = 0L ;
2010-12-22 16:22:23 +01:00
}
2011-01-29 22:50:29 +01:00
j + = l ;
i = k ;
2011-05-28 22:50:08 +02:00
if ( this . worlds . get ( 0 ) . everyoneDeeplySleeping ( ) ) { // CraftBukkit
2011-01-29 22:50:29 +01:00
this . h ( ) ;
2011-02-23 03:37:56 +01:00
j = 0L ;
} else {
while ( j > 50L ) {
2011-05-09 20:51:01 +02:00
MinecraftServer . currentTick = ( int ) ( System . currentTimeMillis ( ) / 50 ) ; // CraftBukkit
2011-02-23 03:37:56 +01:00
j - = 50L ;
this . h ( ) ;
}
2010-12-22 16:22:23 +01:00
}
}
} else {
2011-04-20 19:05:14 +02:00
while ( this . isRunning ) {
2011-01-29 22:50:29 +01:00
this . b ( ) ;
2010-12-22 16:22:23 +01:00
try {
Thread . sleep ( 10L ) ;
2010-12-28 20:52:24 +01:00
} catch ( InterruptedException interruptedexception ) {
interruptedexception . printStackTrace ( ) ;
2010-12-22 16:22:23 +01:00
}
}
}
2011-02-23 03:37:56 +01:00
} catch ( Throwable throwable ) {
throwable . printStackTrace ( ) ;
2011-04-20 19:05:14 +02:00
log . log ( Level . SEVERE , " Unexpected exception " , throwable ) ;
2011-01-29 22:50:29 +01:00
2011-04-20 19:05:14 +02:00
while ( this . isRunning ) {
2011-01-29 22:50:29 +01:00
this . b ( ) ;
2010-12-22 16:22:23 +01:00
try {
Thread . sleep ( 10L ) ;
2010-12-28 20:52:24 +01:00
} catch ( InterruptedException interruptedexception1 ) {
interruptedexception1 . printStackTrace ( ) ;
2010-12-22 16:22:23 +01:00
}
}
} finally {
2011-01-14 14:31:10 +01:00
try {
2011-04-20 19:05:14 +02:00
this . stop ( ) ;
this . isStopped = true ;
2011-02-23 03:37:56 +01:00
} catch ( Throwable throwable1 ) {
throwable1 . printStackTrace ( ) ;
2011-01-14 14:31:10 +01:00
} finally {
System . exit ( 0 ) ;
}
2010-12-22 16:22:23 +01:00
}
}
private void h ( ) {
2011-01-11 09:25:13 +01:00
ArrayList arraylist = new ArrayList ( ) ;
2011-01-29 22:50:29 +01:00
Iterator iterator = b . keySet ( ) . iterator ( ) ;
2010-12-28 20:52:24 +01:00
2011-01-29 22:50:29 +01:00
while ( iterator . hasNext ( ) ) {
2010-12-28 20:52:24 +01:00
String s = ( String ) iterator . next ( ) ;
2011-01-29 22:50:29 +01:00
int i = ( ( Integer ) b . get ( s ) ) . intValue ( ) ;
2010-12-28 20:52:24 +01:00
2011-01-29 22:50:29 +01:00
if ( i > 0 ) {
b . put ( s , Integer . valueOf ( i - 1 ) ) ;
2010-12-22 16:22:23 +01:00
} else {
2011-01-29 22:50:29 +01:00
arraylist . add ( s ) ;
2010-12-22 16:22:23 +01:00
}
}
2010-12-28 20:52:24 +01:00
2011-01-29 22:50:29 +01:00
int j ;
for ( j = 0 ; j < arraylist . size ( ) ; + + j ) {
b . remove ( arraylist . get ( j ) ) ;
2010-12-22 16:22:23 +01:00
}
2010-12-26 03:20:29 +01:00
AxisAlignedBB . a ( ) ;
Vec3D . a ( ) ;
2011-04-20 19:05:14 +02:00
+ + this . ticks ;
2011-02-05 19:15:04 +01:00
2011-05-28 22:50:08 +02:00
for ( j = 0 ; j < this . worlds . size ( ) ; + + j ) { // CraftBukkit
// if (j == 0 || this.propertyManager.getBoolean("allow-nether", true)) { // CraftBukkit
WorldServer worldserver = this . worlds . get ( j ) ; // CraftBukkit
2011-02-07 02:59:06 +01:00
2011-05-28 22:50:08 +02:00
if ( this . ticks % 20 = = 0 ) {
// CraftBukkit start - only send timeupdates to the people in that world
for ( int i = 0 ; i < this . serverConfigurationManager . players . size ( ) ; + + i ) {
EntityPlayer entityplayer = ( EntityPlayer ) this . serverConfigurationManager . players . get ( i ) ;
entityplayer . netServerHandler . sendPacket ( new Packet4UpdateTime ( entityplayer . world . getTime ( ) ) ) ;
}
2011-05-26 14:48:22 +02:00
}
2011-02-19 21:29:51 +01:00
2011-05-28 22:50:08 +02:00
( ( CraftScheduler ) server . getScheduler ( ) ) . mainThreadHeartbeat ( this . ticks ) ;
// CraftBukkit end
2011-05-26 23:29:57 +02:00
2011-05-28 22:50:08 +02:00
worldserver . doTick ( ) ;
2011-01-29 22:50:29 +01:00
2011-05-28 22:50:08 +02:00
while ( worldserver . doLighting ( ) ) {
;
}
2011-02-19 21:29:51 +01:00
2011-05-28 22:50:08 +02:00
worldserver . cleanUp ( ) ;
}
// } // CraftBukkit
2011-05-26 14:48:22 +02:00
2011-04-20 19:05:14 +02:00
this . networkListenThread . a ( ) ;
this . serverConfigurationManager . b ( ) ;
2011-05-26 14:48:22 +02:00
2011-05-28 22:50:08 +02:00
// CraftBukkit start
2011-05-26 14:48:22 +02:00
for ( j = 0 ; j < this . worlds . size ( ) ; + + j ) {
this . worlds . get ( j ) . tracker . a ( ) ;
}
2011-05-28 22:50:08 +02:00
// CraftBukkit end
2011-01-29 22:50:29 +01:00
2011-04-20 22:47:26 +02:00
for ( j = 0 ; j < this . r . size ( ) ; + + j ) {
( ( IUpdatePlayerListBox ) this . r . get ( j ) ) . a ( ) ;
2010-12-28 20:52:24 +01:00
}
2010-12-22 16:22:23 +01:00
try {
2011-01-29 22:50:29 +01:00
this . b ( ) ;
2010-12-28 20:52:24 +01:00
} catch ( Exception exception ) {
2011-04-20 19:05:14 +02:00
log . log ( Level . WARNING , " Unexpected exception while parsing console command " , exception ) ;
2010-12-22 16:22:23 +01:00
}
}
2011-04-20 19:05:14 +02:00
public void issueCommand ( String s , ICommandListener icommandlistener ) {
2011-04-20 22:47:26 +02:00
this . s . add ( new ServerCommand ( s , icommandlistener ) ) ;
2010-12-22 16:22:23 +01:00
}
public void b ( ) {
2011-04-20 22:47:26 +02:00
while ( this . s . size ( ) > 0 ) {
ServerCommand servercommand = ( ServerCommand ) this . s . remove ( 0 ) ;
2010-12-28 20:52:24 +01:00
2011-04-20 22:47:26 +02:00
// this.consoleCommandHandler.handle(servercommand); // CraftBukkit - Removed its now called in server.displatchCommand
2011-03-12 19:23:57 +01:00
server . dispatchCommand ( console , servercommand ) ; // CraftBukkit
2010-12-22 16:22:23 +01:00
}
}
2010-12-28 20:52:24 +01:00
public void a ( IUpdatePlayerListBox iupdateplayerlistbox ) {
2011-04-20 22:47:26 +02:00
this . r . add ( iupdateplayerlistbox ) ;
2010-12-22 16:22:23 +01:00
}
2011-02-23 13:56:36 +01:00
public static void main ( final OptionSet options ) { // CraftBukkit - replaces main(String args[])
2011-04-20 22:47:26 +02:00
StatisticList . a ( ) ;
2010-12-22 16:22:23 +01:00
try {
2011-05-26 14:48:22 +02:00
MinecraftServer minecraftserver = new MinecraftServer ( options ) ; // CraftBukkit pass in the options
2011-01-29 22:50:29 +01:00
2011-01-11 09:25:13 +01:00
// CraftBukkit - remove gui
2010-12-22 16:22:23 +01:00
2010-12-28 20:52:24 +01:00
( new ThreadServerApplication ( " Server thread " , minecraftserver ) ) . start ( ) ;
} catch ( Exception exception ) {
2011-04-20 19:05:14 +02:00
log . log ( Level . SEVERE , " Failed to start the minecraft server " , exception ) ;
2010-12-22 16:22:23 +01:00
}
}
2010-12-28 20:52:24 +01:00
public File a ( String s ) {
return new File ( s ) ;
2010-12-22 16:22:23 +01:00
}
2011-04-20 19:05:14 +02:00
public void sendMessage ( String s ) {
log . info ( s ) ;
2010-12-22 16:22:23 +01:00
}
2011-03-31 22:40:00 +02:00
public void c ( String s ) {
2011-04-20 19:05:14 +02:00
log . warning ( s ) ;
2011-03-31 22:40:00 +02:00
}
2011-04-20 19:05:14 +02:00
public String getName ( ) {
2010-12-22 16:22:23 +01:00
return " CONSOLE " ;
}
2010-12-28 20:52:24 +01:00
2011-05-26 14:48:22 +02:00
public WorldServer a ( int i ) {
2011-05-28 22:50:08 +02:00
// CraftBukkit start
2011-05-26 23:15:27 +02:00
for ( WorldServer world : worlds ) {
if ( world . dimension = = i ) {
return world ;
}
}
2011-05-28 22:50:08 +02:00
2011-05-26 23:15:27 +02:00
return worlds . get ( 0 ) ;
2011-05-28 22:50:08 +02:00
// CraftBukkit end
2011-05-26 14:48:22 +02:00
}
public EntityTracker b ( int i ) {
2011-05-28 22:50:08 +02:00
return a ( i ) . tracker ; // CraftBukkit
2011-05-26 14:48:22 +02:00
}
2011-04-20 19:05:14 +02:00
public static boolean isRunning ( MinecraftServer minecraftserver ) {
return minecraftserver . isRunning ;
2010-12-28 20:52:24 +01:00
}
2011-01-11 09:25:13 +01:00
}