public WorldInfo(NBTTagCompound par1NBTTagCompound) { terrainType = WorldType.DEFAULT; randomSeed = par1NBTTagCompound.getLong("RandomSeed"); if (par1NBTTagCompound.hasKey("generatorName")) { String s = par1NBTTagCompound.getString("generatorName"); terrainType = WorldType.parseWorldType(s); if (terrainType == null) { terrainType = WorldType.DEFAULT; } else if (terrainType.isVersioned()) { int i = 0; if (par1NBTTagCompound.hasKey("generatorVersion")) { i = par1NBTTagCompound.getInteger("generatorVersion"); } terrainType = terrainType.getWorldTypeForGeneratorVersion(i); } } theGameType = EnumGameType.getByID(par1NBTTagCompound.getInteger("GameType")); if (par1NBTTagCompound.hasKey("MapFeatures")) { mapFeaturesEnabled = par1NBTTagCompound.getBoolean("MapFeatures"); } else { mapFeaturesEnabled = true; } spawnX = par1NBTTagCompound.getInteger("SpawnX"); spawnY = par1NBTTagCompound.getInteger("SpawnY"); spawnZ = par1NBTTagCompound.getInteger("SpawnZ"); worldTime = par1NBTTagCompound.getLong("Time"); lastTimePlayed = par1NBTTagCompound.getLong("LastPlayed"); sizeOnDisk = par1NBTTagCompound.getLong("SizeOnDisk"); levelName = par1NBTTagCompound.getString("LevelName"); saveVersion = par1NBTTagCompound.getInteger("version"); rainTime = par1NBTTagCompound.getInteger("rainTime"); raining = par1NBTTagCompound.getBoolean("raining"); thunderTime = par1NBTTagCompound.getInteger("thunderTime"); thundering = par1NBTTagCompound.getBoolean("thundering"); hardcore = par1NBTTagCompound.getBoolean("hardcore"); if (par1NBTTagCompound.hasKey("initialized")) { initialized = par1NBTTagCompound.getBoolean("initialized"); } else { initialized = true; } if (par1NBTTagCompound.hasKey("allowCommands")) { allowCommands = par1NBTTagCompound.getBoolean("allowCommands"); } else { allowCommands = theGameType == EnumGameType.CREATIVE; } if (par1NBTTagCompound.hasKey("Player")) { playerTag = par1NBTTagCompound.getCompoundTag("Player"); dimension = playerTag.getInteger("Dimension"); } }
private void updateTagCompound( NBTTagCompound par1NBTTagCompound, NBTTagCompound par2NBTTagCompound) { par1NBTTagCompound.setLong("RandomSeed", randomSeed); par1NBTTagCompound.setString("generatorName", terrainType.getWorldTypeName()); par1NBTTagCompound.setInteger("generatorVersion", terrainType.getGeneratorVersion()); par1NBTTagCompound.setInteger("GameType", theGameType.getID()); par1NBTTagCompound.setBoolean("MapFeatures", mapFeaturesEnabled); par1NBTTagCompound.setInteger("SpawnX", spawnX); par1NBTTagCompound.setInteger("SpawnY", spawnY); par1NBTTagCompound.setInteger("SpawnZ", spawnZ); par1NBTTagCompound.setLong("Time", worldTime); par1NBTTagCompound.setLong("SizeOnDisk", sizeOnDisk); par1NBTTagCompound.setLong("LastPlayed", System.currentTimeMillis()); par1NBTTagCompound.setString("LevelName", levelName); par1NBTTagCompound.setInteger("version", saveVersion); par1NBTTagCompound.setInteger("rainTime", rainTime); par1NBTTagCompound.setBoolean("raining", raining); par1NBTTagCompound.setInteger("thunderTime", thunderTime); par1NBTTagCompound.setBoolean("thundering", thundering); par1NBTTagCompound.setBoolean("hardcore", hardcore); par1NBTTagCompound.setBoolean("allowCommands", allowCommands); par1NBTTagCompound.setBoolean("initialized", initialized); if (par2NBTTagCompound != null) { par1NBTTagCompound.setCompoundTag("Player", par2NBTTagCompound); } }
public WorldInfo(NBTTagCompound par1NBTTagCompound) { terrainType = WorldType.DEFAULT; generatorOptions = ""; theGameRules = new GameRules(); randomSeed = par1NBTTagCompound.getLong("RandomSeed"); if (par1NBTTagCompound.hasKey("generatorName")) { String s = par1NBTTagCompound.getString("generatorName"); terrainType = WorldType.parseWorldType(s); if (terrainType == null) { terrainType = WorldType.DEFAULT; } else if (terrainType.isVersioned()) { int i = 0; if (par1NBTTagCompound.hasKey("generatorVersion")) { i = par1NBTTagCompound.getInteger("generatorVersion"); } terrainType = terrainType.getWorldTypeForGeneratorVersion(i); } if (par1NBTTagCompound.hasKey("generatorOptions")) { generatorOptions = par1NBTTagCompound.getString("generatorOptions"); } } theGameType = EnumGameType.getByID(par1NBTTagCompound.getInteger("GameType")); if (par1NBTTagCompound.hasKey("MapFeatures")) { mapFeaturesEnabled = par1NBTTagCompound.getBoolean("MapFeatures"); } else { if (useNBXlite) { mapFeaturesEnabled = ODNBXlite.Generator == ODNBXlite.GEN_NEWBIOMES; } else { mapFeaturesEnabled = false; } } spawnX = par1NBTTagCompound.getInteger("SpawnX"); spawnY = par1NBTTagCompound.getInteger("SpawnY"); spawnZ = par1NBTTagCompound.getInteger("SpawnZ"); totalTime = par1NBTTagCompound.getLong("Time"); if (par1NBTTagCompound.hasKey("DayTime")) { worldTime = par1NBTTagCompound.getLong("DayTime"); } else { worldTime = totalTime; } lastTimePlayed = par1NBTTagCompound.getLong("LastPlayed"); sizeOnDisk = par1NBTTagCompound.getLong("SizeOnDisk"); levelName = par1NBTTagCompound.getString("LevelName"); saveVersion = par1NBTTagCompound.getInteger("version"); rainTime = par1NBTTagCompound.getInteger("rainTime"); raining = par1NBTTagCompound.getBoolean("raining"); thunderTime = par1NBTTagCompound.getInteger("thunderTime"); thundering = par1NBTTagCompound.getBoolean("thundering"); hardcore = par1NBTTagCompound.getBoolean("hardcore"); if (par1NBTTagCompound.hasKey("initialized")) { initialized = par1NBTTagCompound.getBoolean("initialized"); } else { initialized = true; } if (par1NBTTagCompound.hasKey("allowCommands")) { allowCommands = par1NBTTagCompound.getBoolean("allowCommands"); } else { allowCommands = theGameType == EnumGameType.CREATIVE; } if (useNBXlite) { nbxlite = par1NBTTagCompound.hasKey("NBXlite"); if (nbxlite) { NBTTagCompound nbxliteTag = par1NBTTagCompound.getCompoundTag("NBXlite"); mapGen = ODNBXlite.getGen(nbxliteTag.getString("Generator"), 0); mapGenExtra = ODNBXlite.getGen(nbxliteTag.getString("Generator"), 1); snowCovered = ODNBXlite.getGen(nbxliteTag.getString("Generator"), 2) > 0; flags = nbxliteTag.getString("Flags"); if (nbxliteTag.getInteger("Version") < 3) { if (nbxliteTag.getString("Generator").endsWith("/jungle")) { flags += (flags.length() <= 0) ? "jungle" : ";jungle"; } if (nbxliteTag.getBoolean("NewOres")) { flags += (flags.length() <= 0) ? "newores" : ";newores"; } } if (nbxliteTag.getInteger("Version") < 4) { if (mapGen == ODNBXlite.GEN_NEWBIOMES || mapGen == ODNBXlite.GEN_OLDBIOMES && (mapGenExtra == ODNBXlite.FEATURES_BETA15 || mapGenExtra == ODNBXlite.FEATURES_BETA173)) { flags += (flags.length() <= 0) ? "weather" : ";weather"; } } if (nbxliteTag.getInteger("Version") < 5) { structures = ODNBXlite.getDefaultStructures(mapFeaturesEnabled, mapGen, mapGenExtra); } else { structures = new boolean[ODNBXlite.STRUCTURES.length]; NBTTagCompound structuresTag = nbxliteTag.getCompoundTag("Structures"); for (int i = 0; i < structures.length; i++) { structures[i] = structuresTag.getBoolean(ODNBXlite.STRUCTURES[i]); } } NBTTagCompound themeTag = nbxliteTag.getCompoundTag("Theme"); if (mapGen == ODNBXlite.GEN_BIOMELESS) { mapTheme = themeTag.getInteger("Generation"); if (nbxliteTag.getInteger("Version") < 2) { if (mapTheme == 2) { mapTheme = 3; } else if (mapTheme == 3) { mapTheme = 2; } } } else { mapTheme = ODNBXlite.THEME_NORMAL; } cloudheight = themeTag.getFloat("CloudHeight"); skybrightness = themeTag.getInteger("SkyBrightness"); skycolor = themeTag.getInteger("SkyColor"); fogcolor = themeTag.getInteger("FogColor"); cloudcolor = themeTag.getInteger("CloudColor"); if (mapGen == ODNBXlite.GEN_BIOMELESS) { if (mapGenExtra == ODNBXlite.FEATURES_INDEV || mapGenExtra == ODNBXlite.FEATURES_CLASSIC) { NBTTagCompound finiteTag = nbxliteTag.getCompoundTag("Indev"); indevX = finiteTag.getInteger("X"); indevY = finiteTag.getInteger("Y"); indevZ = finiteTag.getInteger("Z"); surrgroundtype = finiteTag.getInteger("SurroundingGroundType"); surrwatertype = finiteTag.getInteger("SurroundingWaterType"); surrgroundheight = finiteTag.getInteger("SurroundingGroundHeight"); surrwaterheight = finiteTag.getInteger("SurroundingWaterHeight"); mapType = finiteTag.getInteger("Type"); } } } if (par1NBTTagCompound.hasKey("snowCovered")) { snowCovered = par1NBTTagCompound.getBoolean("snowCovered"); ODNBXlite.SnowCovered = snowCovered; } if (par1NBTTagCompound.hasKey("SnowCovered")) { snowCovered = par1NBTTagCompound.getBoolean("SnowCovered"); ODNBXlite.SnowCovered = snowCovered; } } if (par1NBTTagCompound.hasKey("Player")) { playerTag = par1NBTTagCompound.getCompoundTag("Player"); dimension = playerTag.getInteger("Dimension"); } if (par1NBTTagCompound.hasKey("GameRules")) { theGameRules.readGameRulesFromNBT(par1NBTTagCompound.getCompoundTag("GameRules")); } }
private void updateTagCompound( NBTTagCompound par1NBTTagCompound, NBTTagCompound par2NBTTagCompound) { par1NBTTagCompound.setLong("RandomSeed", randomSeed); par1NBTTagCompound.setString("generatorName", terrainType.getWorldTypeName()); par1NBTTagCompound.setInteger("generatorVersion", terrainType.getGeneratorVersion()); par1NBTTagCompound.setString("generatorOptions", generatorOptions); par1NBTTagCompound.setInteger("GameType", theGameType.getID()); par1NBTTagCompound.setBoolean("MapFeatures", mapFeaturesEnabled); par1NBTTagCompound.setInteger("SpawnX", spawnX); par1NBTTagCompound.setInteger("SpawnY", spawnY); par1NBTTagCompound.setInteger("SpawnZ", spawnZ); par1NBTTagCompound.setLong("Time", totalTime); par1NBTTagCompound.setLong("DayTime", worldTime); par1NBTTagCompound.setLong("SizeOnDisk", sizeOnDisk); par1NBTTagCompound.setLong("LastPlayed", MinecraftServer.func_130071_aq()); par1NBTTagCompound.setString("LevelName", levelName); par1NBTTagCompound.setInteger("version", saveVersion); par1NBTTagCompound.setInteger("rainTime", rainTime); par1NBTTagCompound.setBoolean("raining", raining); par1NBTTagCompound.setInteger("thunderTime", thunderTime); par1NBTTagCompound.setBoolean("thundering", thundering); par1NBTTagCompound.setBoolean("hardcore", hardcore); par1NBTTagCompound.setBoolean("allowCommands", allowCommands); par1NBTTagCompound.setBoolean("initialized", initialized); par1NBTTagCompound.setCompoundTag("GameRules", theGameRules.writeGameRulesToNBT()); if (nbxlite && useNBXlite) { NBTTagCompound nbxliteTag = new NBTTagCompound(); nbxliteTag.setInteger("Version", NBXLITE_INFO_VERSION); nbxliteTag.setString("Generator", ODNBXlite.getGenName(mapGen, mapGenExtra, snowCovered)); nbxliteTag.setString("Flags", flags); NBTTagCompound structuresTag = new NBTTagCompound(); for (int i = 0; i < structures.length; i++) { structuresTag.setBoolean(ODNBXlite.STRUCTURES[i], structures[i]); } nbxliteTag.setCompoundTag("Structures", structuresTag); NBTTagCompound themeTag = new NBTTagCompound(); themeTag.setInteger("Generation", mapTheme); themeTag.setFloat("CloudHeight", cloudheight); themeTag.setInteger("SkyColor", skycolor); themeTag.setInteger("FogColor", fogcolor); themeTag.setInteger("CloudColor", cloudcolor); themeTag.setInteger("SkyBrightness", skybrightness); nbxliteTag.setCompoundTag("Theme", themeTag); if (mapGen == ODNBXlite.GEN_BIOMELESS && (mapGenExtra == ODNBXlite.FEATURES_INDEV || mapGenExtra == ODNBXlite.FEATURES_CLASSIC)) { NBTTagCompound finiteTag = new NBTTagCompound(); finiteTag.setInteger("X", indevX); finiteTag.setInteger("Y", indevY); finiteTag.setInteger("Z", indevZ); finiteTag.setInteger("Type", mapType); finiteTag.setInteger("SurroundingGroundType", ODNBXlite.SurrGroundType); finiteTag.setInteger("SurroundingWaterType", ODNBXlite.SurrWaterType); finiteTag.setInteger("SurroundingGroundHeight", ODNBXlite.SurrGroundHeight); finiteTag.setInteger("SurroundingWaterHeight", ODNBXlite.SurrWaterHeight); nbxliteTag.setCompoundTag("Indev", finiteTag); } par1NBTTagCompound.setCompoundTag("NBXlite", nbxliteTag); } if (par2NBTTagCompound != null) { par1NBTTagCompound.setCompoundTag("Player", par2NBTTagCompound); } }
public GenLayerBiome(long par1, GenLayer par3GenLayer, WorldType par4WorldType) { super(par1); this.allowedBiomes = par4WorldType.getBiomesForWorldType(); this.parent = par3GenLayer; }
/** Starts this server. */ public void start() { // Determine console mode and start reading input consoleManager.startConsole(config.getBoolean(ServerConfig.Key.USE_JLINE)); consoleManager.startFile(config.getString(ServerConfig.Key.LOG_FILE)); if (getProxySupport()) { if (getOnlineMode()) { logger.warning("Proxy support is enabled, but online mode is enabled."); } else { logger.info("Proxy support is enabled."); } } else if (!getOnlineMode()) { logger.warning( "The server is running in offline mode! Only do this if you know what you're doing."); } // Load player lists opsList.load(); whitelist.load(); nameBans.load(); ipBans.load(); // DRAGONET-Start this.dragonetServer = new DragonetServer(this); this.dragonetServer.initialize(); // DRAGONET-End // Start loading plugins loadPlugins(); enablePlugins(PluginLoadOrder.STARTUP); // Create worlds String name = config.getString(ServerConfig.Key.LEVEL_NAME); String seedString = config.getString(ServerConfig.Key.LEVEL_SEED); boolean structs = getGenerateStructures(); WorldType type = WorldType.getByName(getWorldType()); if (type == null) { type = WorldType.NORMAL; } long seed = new Random().nextLong(); if (!seedString.isEmpty()) { try { long parsed = Long.parseLong(seedString); if (parsed != 0) { seed = parsed; } } catch (NumberFormatException ex) { seed = seedString.hashCode(); } } createWorld( WorldCreator.name(name) .environment(Environment.NORMAL) .seed(seed) .type(type) .generateStructures(structs)); if (getAllowNether()) { createWorld( WorldCreator.name(name + "_nether") .environment(Environment.NETHER) .seed(seed) .type(type) .generateStructures(structs)); } if (getAllowEnd()) { createWorld( WorldCreator.name(name + "_the_end") .environment(Environment.THE_END) .seed(seed) .type(type) .generateStructures(structs)); } // Finish loading plugins enablePlugins(PluginLoadOrder.POSTWORLD); commandMap.registerServerAliases(); scheduler.start(); }
private boolean init() throws java.net.UnknownHostException { // CraftBukkit - added throws UnknownHostException this.consoleCommandHandler = new ConsoleCommandHandler(this); ThreadCommandReader threadcommandreader = new ThreadCommandReader(this); threadcommandreader.setDaemon(true); threadcommandreader.start(); ConsoleLogManager.init(this); // CraftBukkit // CraftBukkit start System.setOut(new PrintStream(new LoggerOutputStream(log, Level.INFO), true)); System.setErr(new PrintStream(new LoggerOutputStream(log, Level.SEVERE), true)); // CraftBukkit end log.info("Starting minecraft server version 1.2.5"); if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) { log.warning("**** NOT ENOUGH RAM!"); log.warning("You can allocate(allow)"); } log.info("Loading properties"); this.propertyManager = new PropertyManager(this.options); // CraftBukkit - CLI argument support this.y = this.propertyManager.getString("server-ip", ""); this.onlineMode = this.propertyManager.getBoolean("online-mode", true); this.spawnAnimals = this.propertyManager.getBoolean("spawn-animals", true); this.spawnNPCs = this.propertyManager.getBoolean("spawn-npcs", true); this.pvpMode = this.propertyManager.getBoolean("pvp", true); this.allowFlight = this.propertyManager.getBoolean("allow-flight", false); this.motd = this.propertyManager.getString("motd", "A Custom Modpack Server from Atex"); this.motd.replace('\u00a7', '$'); InetAddress inetaddress = null; if (this.y.length() > 0) { inetaddress = InetAddress.getByName(this.y); } this.z = this.propertyManager.getInt("server-port", 25565); log.info( String.format( "Starting Minecraft server on %s:%s", (this.y.length() == 0 ? "*" : this.y), this.z)); try { this.networkListenThread = new NetworkListenThread(this, inetaddress, this.z); } catch (Throwable ioexception) { // CraftBukkit - IOException -> Throwable 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?"); return false; } 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.properties file."); // CraftBukkit - type. Seriously. :D } this.serverConfigurationManager = new ServerConfigurationManager(this); // CraftBukkit - removed trackers long i = System.nanoTime(); String s = this.propertyManager.getString("level-name", "world"); String s1 = this.propertyManager.getString("level-seed", ""); String s2 = this.propertyManager.getString("level-type", "DEFAULT"); long j = (new Random()).nextLong(); if (s1.length() > 0) { try { long k = Long.parseLong(s1); if (k != 0L) { j = k; } } catch (NumberFormatException numberformatexception) { j = (long) s1.hashCode(); } } WorldType worldtype = WorldType.getType(s2); if (worldtype == null) { worldtype = WorldType.NORMAL; } this.t = this.propertyManager.getInt("max-build-height", 256); this.t = (this.t + 8) / 16 * 16; this.t = MathHelper.a(this.t, 64, 256); this.propertyManager.a("max-build-height", Integer.valueOf(this.t)); log.info("Preparing level \"" + s + "\""); this.a( new WorldLoaderServer(server.getWorldContainer()), s, j, worldtype); // CraftBukkit - world container long l = System.nanoTime() - i; String s3 = String.format("%.3fs", new Object[] {Double.valueOf((double) l / 1.0E9D)}); log.info("Done (" + s3 + ")! For help, type \"help\" or \"?\""); if (this.propertyManager.getBoolean("enable-query", false)) { log.info("Starting GS4 status listener"); this.I = new RemoteStatusListener(this); this.I.a(); } if (this.propertyManager.getBoolean("enable-rcon", false)) { log.info("Starting remote control listener"); this.J = new RemoteControlListener(this); this.J.a(); this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(); // CraftBukkit } // CraftBukkit start if (this.propertyManager.properties.containsKey("spawn-protection")) { log.info( "'spawn-protection' in server.properties has been moved to 'settings.spawn-radius' in bukkit.yml. I will move your config for you."); this.server.setSpawnRadius(this.propertyManager.getInt("spawn-protection", 16)); this.propertyManager.properties.remove("spawn-protection"); this.propertyManager.savePropertiesFile(); } // CraftBukkit end return true; }
public WorldInfo(NBTTagCompound par1NBTTagCompound) { this.terrainType = WorldType.DEFAULT; this.generatorOptions = ""; this.theGameRules = new GameRules(); this.randomSeed = par1NBTTagCompound.getLong("RandomSeed"); if (par1NBTTagCompound.hasKey("generatorName")) { String var2 = par1NBTTagCompound.getString("generatorName"); this.terrainType = WorldType.parseWorldType(var2); if (this.terrainType == null) { this.terrainType = WorldType.DEFAULT; } else if (this.terrainType.isVersioned()) { int var3 = 0; if (par1NBTTagCompound.hasKey("generatorVersion")) { var3 = par1NBTTagCompound.getInteger("generatorVersion"); } this.terrainType = this.terrainType.getWorldTypeForGeneratorVersion(var3); } if (par1NBTTagCompound.hasKey("generatorOptions")) { this.generatorOptions = par1NBTTagCompound.getString("generatorOptions"); } } this.theGameType = EnumGameType.getByID(par1NBTTagCompound.getInteger("GameType")); if (par1NBTTagCompound.hasKey("MapFeatures")) { this.mapFeaturesEnabled = par1NBTTagCompound.getBoolean("MapFeatures"); } else { this.mapFeaturesEnabled = true; } this.spawnX = par1NBTTagCompound.getInteger("SpawnX"); this.spawnY = par1NBTTagCompound.getInteger("SpawnY"); this.spawnZ = par1NBTTagCompound.getInteger("SpawnZ"); this.totalTime = par1NBTTagCompound.getLong("Time"); if (par1NBTTagCompound.hasKey("DayTime")) { this.worldTime = par1NBTTagCompound.getLong("DayTime"); } else { this.worldTime = this.totalTime; } this.lastTimePlayed = par1NBTTagCompound.getLong("LastPlayed"); this.sizeOnDisk = par1NBTTagCompound.getLong("SizeOnDisk"); this.levelName = par1NBTTagCompound.getString("LevelName"); this.saveVersion = par1NBTTagCompound.getInteger("version"); this.rainTime = par1NBTTagCompound.getInteger("rainTime"); this.raining = par1NBTTagCompound.getBoolean("raining"); this.thunderTime = par1NBTTagCompound.getInteger("thunderTime"); this.thundering = par1NBTTagCompound.getBoolean("thundering"); this.hardcore = par1NBTTagCompound.getBoolean("hardcore"); if (par1NBTTagCompound.hasKey("initialized")) { this.initialized = par1NBTTagCompound.getBoolean("initialized"); } else { this.initialized = true; } if (par1NBTTagCompound.hasKey("allowCommands")) { this.allowCommands = par1NBTTagCompound.getBoolean("allowCommands"); } else { this.allowCommands = this.theGameType == EnumGameType.CREATIVE; } if (par1NBTTagCompound.hasKey("Player")) { this.playerTag = par1NBTTagCompound.getCompoundTag("Player"); this.dimension = this.playerTag.getInteger("Dimension"); } if (par1NBTTagCompound.hasKey("GameRules")) { this.theGameRules.readGameRulesFromNBT(par1NBTTagCompound.getCompoundTag("GameRules")); } }
private boolean init() { this.consoleCommandHandler = new ConsoleCommandHandler(this); ThreadCommandReader threadcommandreader = new ThreadCommandReader(this); threadcommandreader.setDaemon(true); threadcommandreader.start(); ConsoleLogManager.init(); log.info("Starting minecraft server version 1.2.4"); if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) { log.warning( "To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); } log.info("Loading properties"); this.propertyManager = new PropertyManager(new File("server.properties")); this.y = this.propertyManager.getString("server-ip", ""); this.onlineMode = this.propertyManager.getBoolean("online-mode", true); this.spawnAnimals = this.propertyManager.getBoolean("spawn-animals", true); this.spawnNPCs = this.propertyManager.getBoolean("spawn-npcs", true); this.pvpMode = this.propertyManager.getBoolean("pvp", true); this.allowFlight = this.propertyManager.getBoolean("allow-flight", false); this.motd = this.propertyManager.getString("motd", "A Minecraft Server"); this.motd.replace('\u00a7', '$'); InetAddress inetaddress = null; if (this.y.length() > 0) { inetaddress = InetAddress.getByName(this.y); } this.z = this.propertyManager.getInt("server-port", 25565); log.info( "Starting Minecraft server on " + (this.y.length() == 0 ? "*" : this.y) + ":" + this.z); try { this.networkListenThread = new NetworkListenThread(this, inetaddress, this.z); } catch (IOException ioexception) { 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?"); return false; } 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."); } this.serverConfigurationManager = new ServerConfigurationManager(this); this.tracker[0] = new EntityTracker(this, 0); this.tracker[1] = new EntityTracker(this, -1); this.tracker[2] = new EntityTracker(this, 1); long i = System.nanoTime(); String s = this.propertyManager.getString("level-name", "world"); String s1 = this.propertyManager.getString("level-seed", ""); String s2 = this.propertyManager.getString("level-type", "DEFAULT"); long j = (new Random()).nextLong(); if (s1.length() > 0) { try { long k = Long.parseLong(s1); if (k != 0L) { j = k; } } catch (NumberFormatException numberformatexception) { j = (long) s1.hashCode(); } } WorldType worldtype = WorldType.getType(s2); if (worldtype == null) { worldtype = WorldType.NORMAL; } this.t = this.propertyManager.getInt("max-build-height", 256); this.t = (this.t + 8) / 16 * 16; this.t = MathHelper.a(this.t, 64, 256); this.propertyManager.a("max-build-height", Integer.valueOf(this.t)); log.info("Preparing level \"" + s + "\""); this.a(new WorldLoaderServer(new File(".")), s, j, worldtype); log.info("Done (" + (System.nanoTime() - i) + "ns)! For help, type \"help\" or \"?\""); if (this.propertyManager.getBoolean("enable-query", false)) { log.info("Starting GS4 status listener"); this.I = new RemoteStatusListener(this); this.I.a(); } if (this.propertyManager.getBoolean("enable-rcon", false)) { log.info("Starting remote control listener"); this.J = new RemoteControlListener(this); this.J.a(); } return true; }
/** Initialises the server and starts it. */ protected boolean startServer() throws IOException { DedicatedServerCommandThread var1 = new DedicatedServerCommandThread(this); var1.setDaemon(true); var1.start(); this.getLogAgent().func_98233_a("Starting minecraft server version 1.6.2"); if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) { this.getLogAgent() .func_98236_b( "To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); } this.getLogAgent().func_98233_a("Loading properties"); this.settings = new PropertyManager(new File("server.properties"), this.getLogAgent()); if (this.isSinglePlayer()) { this.setHostname("127.0.0.1"); } else { this.setOnlineMode(this.settings.getBooleanProperty("online-mode", true)); this.setHostname(this.settings.getStringProperty("server-ip", "")); } this.setCanSpawnAnimals(this.settings.getBooleanProperty("spawn-animals", true)); this.setCanSpawnNPCs(this.settings.getBooleanProperty("spawn-npcs", true)); this.setAllowPvp(this.settings.getBooleanProperty("pvp", true)); this.setAllowFlight(this.settings.getBooleanProperty("allow-flight", false)); this.setTexturePack(this.settings.getStringProperty("texture-pack", "")); this.setMOTD(this.settings.getStringProperty("motd", "A Minecraft Server")); this.func_104055_i(this.settings.getBooleanProperty("force-gamemode", false)); if (this.settings.getIntProperty("difficulty", 1) < 0) { this.settings.setProperty("difficulty", Integer.valueOf(0)); } else if (this.settings.getIntProperty("difficulty", 1) > 3) { this.settings.setProperty("difficulty", Integer.valueOf(3)); } this.canSpawnStructures = this.settings.getBooleanProperty("generate-structures", true); int var2 = this.settings.getIntProperty("gamemode", EnumGameType.SURVIVAL.getID()); this.gameType = WorldSettings.getGameTypeById(var2); this.getLogAgent().func_98233_a("Default game type: " + this.gameType); InetAddress var3 = null; if (this.getServerHostname().length() > 0) { var3 = InetAddress.getByName(this.getServerHostname()); } if (this.getServerPort() < 0) { this.setServerPort(this.settings.getIntProperty("server-port", 25565)); } this.getLogAgent().func_98233_a("Generating keypair"); this.setKeyPair(CryptManager.generateKeyPair()); this.getLogAgent() .func_98233_a( "Starting Minecraft server on " + (this.getServerHostname().length() == 0 ? "*" : this.getServerHostname()) + ":" + this.getServerPort()); try { this.networkThread = new DedicatedServerListenThread(this, var3, this.getServerPort()); } catch (IOException var16) { this.getLogAgent().func_98236_b("**** FAILED TO BIND TO PORT!"); this.getLogAgent() .logWarningFormatted("The exception was: {0}", new Object[] {var16.toString()}); this.getLogAgent().func_98236_b("Perhaps a server is already running on that port?"); return false; } if (!this.isServerInOnlineMode()) { this.getLogAgent().func_98236_b("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); this.getLogAgent() .func_98236_b("The server will make no attempt to authenticate usernames. Beware."); this.getLogAgent() .func_98236_b( "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."); this.getLogAgent() .func_98236_b( "To change this, set \"online-mode\" to \"true\" in the server.properties file."); } this.setConfigurationManager(new DedicatedPlayerList(this)); long var4 = System.nanoTime(); if (this.getFolderName() == null) { this.setFolderName(this.settings.getStringProperty("level-name", "world")); } String var6 = this.settings.getStringProperty("level-seed", ""); String var7 = this.settings.getStringProperty("level-type", "DEFAULT"); String var8 = this.settings.getStringProperty("generator-settings", ""); long var9 = (new Random()).nextLong(); if (var6.length() > 0) { try { long var11 = Long.parseLong(var6); if (var11 != 0L) { var9 = var11; } } catch (NumberFormatException var15) { var9 = (long) var6.hashCode(); } } WorldType var17 = WorldType.parseWorldType(var7); if (var17 == null) { var17 = WorldType.DEFAULT; } this.setBuildLimit(this.settings.getIntProperty("max-build-height", 256)); this.setBuildLimit((this.getBuildLimit() + 8) / 16 * 16); this.setBuildLimit(MathHelper.clamp_int(this.getBuildLimit(), 64, 256)); this.settings.setProperty("max-build-height", Integer.valueOf(this.getBuildLimit())); this.getLogAgent().func_98233_a("Preparing level \"" + this.getFolderName() + "\""); this.loadAllWorlds(this.getFolderName(), this.getFolderName(), var9, var17, var8); long var12 = System.nanoTime() - var4; String var14 = String.format("%.3fs", new Object[] {Double.valueOf((double) var12 / 1.0E9D)}); this.getLogAgent().func_98233_a("Done (" + var14 + ")! For help, type \"help\" or \"?\""); if (this.settings.getBooleanProperty("enable-query", false)) { this.getLogAgent().func_98233_a("Starting GS4 status listener"); this.theRConThreadQuery = new RConThreadQuery(this); this.theRConThreadQuery.startThread(); } if (this.settings.getBooleanProperty("enable-rcon", false)) { this.getLogAgent().func_98233_a("Starting remote control listener"); this.theRConThreadMain = new RConThreadMain(this); this.theRConThreadMain.startThread(); } // TODO: Hakkit Start. HakkitServer hakkitServer = new HakkitServer(); hakkitServer.setMinecraftServer(this); Hakkit.setServer(hakkitServer); // TODO: Hakkit End return true; }
protected boolean init() throws java.net.UnknownHostException { // CraftBukkit - throws UnknownHostException ThreadCommandReader threadcommandreader = new ThreadCommandReader(this, "Server console handler"); threadcommandreader.setDaemon(true); threadcommandreader.start(); // CraftBukkit start - TODO: handle command-line logging arguments java.util.logging.Logger global = java.util.logging.Logger.getLogger(""); global.setUseParentHandlers(false); for (java.util.logging.Handler handler : global.getHandlers()) { global.removeHandler(handler); } global.addHandler(new org.bukkit.craftbukkit.util.ForwardLogHandler()); final org.apache.logging.log4j.core.Logger logger = ((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger()); for (org.apache.logging.log4j.core.Appender appender : logger.getAppenders().values()) { if (appender instanceof org.apache.logging.log4j.core.appender.ConsoleAppender) { logger.removeAppender(appender); } } new Thread(new org.bukkit.craftbukkit.util.TerminalConsoleWriterThread(System.out, this.reader)) .start(); System.setOut(new PrintStream(new LoggerOutputStream(logger, Level.INFO), true)); System.setErr(new PrintStream(new LoggerOutputStream(logger, Level.WARN), true)); // CraftBukkit end i.info("Starting minecraft server version 1.7.10"); if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) { i.warn( "To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); } i.info("Loading properties"); this.propertyManager = new PropertyManager(this.options); // CraftBukkit - CLI argument support this.n = new EULA(new File("eula.txt")); if (!this.n.a()) { i.info( "You need to agree to the EULA in order to run the server. Go to eula.txt for more info."); this.n.b(); return false; } else { if (this.N()) { this.c("127.0.0.1"); } else { this.setOnlineMode(this.propertyManager.getBoolean("online-mode", true)); this.c(this.propertyManager.getString("server-ip", "")); } this.setSpawnAnimals(this.propertyManager.getBoolean("spawn-animals", true)); this.setSpawnNPCs(this.propertyManager.getBoolean("spawn-npcs", true)); this.setPvP(this.propertyManager.getBoolean("pvp", true)); this.setAllowFlight(this.propertyManager.getBoolean("allow-flight", false)); this.setTexturePack(this.propertyManager.getString("resource-pack", "")); this.setMotd(this.propertyManager.getString("motd", "A Minecraft Server")); this.setForceGamemode(this.propertyManager.getBoolean("force-gamemode", false)); this.setIdleTimeout(this.propertyManager.getInt("player-idle-timeout", 0)); if (this.propertyManager.getInt("difficulty", 1) < 0) { this.propertyManager.setProperty("difficulty", Integer.valueOf(0)); } else if (this.propertyManager.getInt("difficulty", 1) > 3) { this.propertyManager.setProperty("difficulty", Integer.valueOf(3)); } this.generateStructures = this.propertyManager.getBoolean("generate-structures", true); int gamemode = this.propertyManager.getInt( "gamemode", EnumGamemode.SURVIVAL .getId()); // CraftBukkit - Unique name to avoid stomping on logger this.p = WorldSettings.a(gamemode); // CraftBukkit - Use new name i.info("Default game type: " + this.p); InetAddress inetaddress = null; if (this.getServerIp().length() > 0) { inetaddress = InetAddress.getByName(this.getServerIp()); } if (this.L() < 0) { this.setPort(this.propertyManager.getInt("server-port", 25565)); } i.info("Generating keypair"); this.a(MinecraftEncryption.b()); i.info( "Starting Minecraft server on " + (this.getServerIp().length() == 0 ? "*" : this.getServerIp()) + ":" + this.L()); try { this.ai().a(inetaddress, this.L()); } catch (Throwable ioexception) { // CraftBukkit - IOException -> Throwable i.warn("**** FAILED TO BIND TO PORT!"); i.warn("The exception was: {}", new Object[] {ioexception.toString()}); i.warn("Perhaps a server is already running on that port?"); return false; } this.a((PlayerList) (new DedicatedPlayerList(this))); // CraftBukkit if (!this.getOnlineMode()) { i.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); i.warn("The server will make no attempt to authenticate usernames. Beware."); i.warn( "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."); i.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file."); } if (this.aE()) { this.getUserCache().c(); } if (!NameReferencingFileConverter.a(this.propertyManager)) { return false; } else { // this.a((PlayerList) (new DedicatedPlayerList(this))); // CraftBukkit - moved up this.convertable = new WorldLoaderServer( server.getWorldContainer()); // CraftBukkit - moved from MinecraftServer constructor long j = System.nanoTime(); if (this.O() == null) { this.k(this.propertyManager.getString("level-name", "world")); } String s = this.propertyManager.getString("level-seed", ""); String s1 = this.propertyManager.getString("level-type", "DEFAULT"); String s2 = this.propertyManager.getString("generator-settings", ""); long k = (new Random()).nextLong(); if (s.length() > 0) { try { long l = Long.parseLong(s); if (l != 0L) { k = l; } } catch (NumberFormatException numberformatexception) { k = (long) s.hashCode(); } } WorldType worldtype = WorldType.getType(s1); if (worldtype == null) { worldtype = WorldType.NORMAL; } this.at(); this.getEnableCommandBlock(); this.l(); this.getSnooperEnabled(); this.c(this.propertyManager.getInt("max-build-height", 256)); this.c((this.getMaxBuildHeight() + 8) / 16 * 16); this.c(MathHelper.a(this.getMaxBuildHeight(), 64, 256)); this.propertyManager.setProperty( "max-build-height", Integer.valueOf(this.getMaxBuildHeight())); i.info("Preparing level \"" + this.O() + "\""); this.a(this.O(), this.O(), k, worldtype, s2); long i1 = System.nanoTime() - j; String s3 = String.format("%.3fs", new Object[] {Double.valueOf((double) i1 / 1.0E9D)}); i.info("Done (" + s3 + ")! For help, type \"help\" or \"?\""); if (this.propertyManager.getBoolean("enable-query", false)) { i.info("Starting GS4 status listener"); this.k = new RemoteStatusListener(this); this.k.a(); } if (this.propertyManager.getBoolean("enable-rcon", false)) { i.info("Starting remote control listener"); this.l = new RemoteControlListener(this); this.l.a(); this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(); // CraftBukkit } // CraftBukkit start if (this.server.getBukkitSpawnRadius() > -1) { i.info( "'settings.spawn-radius' in bukkit.yml has been moved to 'spawn-protection' in server.properties. I will move your config for you."); this.propertyManager.properties.remove("spawn-protection"); this.propertyManager.getInt("spawn-protection", this.server.getBukkitSpawnRadius()); this.server.removeBukkitSpawnRadius(); this.propertyManager.savePropertiesFile(); } // CraftBukkit end return true; } } }