Esempio n. 1
0
 public WorldInfo(WorldSettings par1WorldSettings, String par2Str) {
   this.terrainType = WorldType.DEFAULT;
   this.generatorOptions = "";
   this.theGameRules = new GameRules();
   this.randomSeed = par1WorldSettings.getSeed();
   this.theGameType = par1WorldSettings.getGameType();
   this.mapFeaturesEnabled = par1WorldSettings.isMapFeaturesEnabled();
   this.levelName = par2Str;
   this.hardcore = par1WorldSettings.getHardcoreEnabled();
   this.terrainType = par1WorldSettings.getTerrainType();
   this.generatorOptions = par1WorldSettings.func_82749_j();
   this.allowCommands = par1WorldSettings.areCommandsAllowed();
   this.initialized = false;
 }
Esempio n. 2
0
 public WorldInfo(WorldSettings par1WorldSettings, String par2Str) {
   terrainType = WorldType.DEFAULT;
   randomSeed = par1WorldSettings.getSeed();
   theGameType = par1WorldSettings.getGameType();
   mapFeaturesEnabled = par1WorldSettings.isMapFeaturesEnabled();
   levelName = par2Str;
   hardcore = par1WorldSettings.getHardcoreEnabled();
   terrainType = par1WorldSettings.getTerrainType();
   allowCommands = par1WorldSettings.areCommandsAllowed();
   initialized = false;
 }
Esempio n. 3
0
  /** creates a spawn position at random within 256 blocks of 0,0 */
  protected void createSpawnPosition(WorldSettings par1WorldSettings) {
    if (!this.provider.canRespawnHere()) {
      this.worldInfo.setSpawnPosition(0, this.provider.getAverageGroundLevel(), 0);
    } else {
      this.findingSpawnPoint = true;
      WorldChunkManager var2 = this.provider.worldChunkMgr;
      List var3 = var2.getBiomesToSpawnIn();
      Random var4 = new Random(this.getSeed());
      ChunkPosition var5 = var2.findBiomePosition(0, 0, 256, var3, var4);
      int var6 = 0;
      int var7 = this.provider.getAverageGroundLevel();
      int var8 = 0;

      if (var5 != null) {
        var6 = var5.x;
        var8 = var5.z;
      } else {
        this.getWorldLogAgent().logWarning("Unable to find spawn biome");
      }

      int var9 = 0;

      while (!this.provider.canCoordinateBeSpawn(var6, var8)) {
        var6 += var4.nextInt(64) - var4.nextInt(64);
        var8 += var4.nextInt(64) - var4.nextInt(64);
        ++var9;

        if (var9 == 1000) {
          break;
        }
      }

      this.worldInfo.setSpawnPosition(var6, var7, var8);
      this.findingSpawnPoint = false;

      if (par1WorldSettings.isBonusChestEnabled()) {
        this.createBonusChest();
      }
    }
  }
Esempio n. 4
0
 public WorldInfo(WorldSettings par1WorldSettings, String par2Str) {
   terrainType = WorldType.DEFAULT;
   generatorOptions = "";
   theGameRules = new GameRules();
   randomSeed = par1WorldSettings.getSeed();
   theGameType = par1WorldSettings.getGameType();
   mapFeaturesEnabled = par1WorldSettings.isMapFeaturesEnabled();
   levelName = par2Str;
   hardcore = par1WorldSettings.getHardcoreEnabled();
   terrainType = par1WorldSettings.getTerrainType();
   generatorOptions = par1WorldSettings.func_82749_j();
   allowCommands = par1WorldSettings.areCommandsAllowed();
   initialized = false;
   if (useNBXlite) {
     snowCovered = ODNBXlite.SnowCovered;
     mapTheme = ODNBXlite.MapTheme;
     mapGen = ODNBXlite.Generator;
     mapGenExtra = ODNBXlite.MapFeatures;
     mapType = ODNBXlite.IndevMapType;
     indevX = ODNBXlite.IndevWidthX;
     indevY = ODNBXlite.IndevHeight;
     indevZ = ODNBXlite.IndevWidthZ;
     flags = ODNBXlite.getFlags();
     structures = ODNBXlite.Structures;
     surrgroundheight = ODNBXlite.SurrGroundHeight;
     surrgroundtype = ODNBXlite.SurrGroundType;
     surrwaterheight = ODNBXlite.SurrWaterHeight;
     surrwatertype = ODNBXlite.SurrWaterType;
     cloudheight = ODNBXlite.CloudHeight;
     skybrightness = ODNBXlite.SkyBrightness;
     skycolor = ODNBXlite.SkyColor;
     fogcolor = ODNBXlite.FogColor;
     cloudcolor = ODNBXlite.CloudColor;
     nbxlite = true;
   }
 }
  private void a(Convertable convertable, String s, long i, WorldType worldtype) {
    if (convertable.isConvertable(s)) {
      log.info("Converting map!");
      convertable.convert(s, new ConvertProgressUpdater(this));
    }

    // CraftBukkit - removed world and ticktime arrays
    int j = this.propertyManager.getInt("gamemode", 0);

    j = WorldSettings.a(j);
    log.info("Default game type: " + j);
    // CraftBukkit start (+ removed worldsettings and servernbtmanager)
    boolean generateStructures = this.propertyManager.getBoolean("generate-structures", true);
    int worldCount = 3;

    for (int k = 0; k < worldCount; ++k) {
      WorldServer world;
      int dimension = 0;

      if (k == 1) {
        if (this.propertyManager.getBoolean("allow-nether", true)) {
          dimension = -1;
        } else {
          continue;
        }
      }

      if (k == 2) {
        // CraftBukkit - (+ don't do this in server.properties, do it in bukkit.yml)
        if (this.server.getAllowEnd()) {
          dimension = 1;
        } else {
          continue;
        }
      }

      String worldType = Environment.getEnvironment(dimension).toString().toLowerCase();
      String name = (dimension == 0) ? s : s + "_" + worldType;

      org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name);
      WorldSettings settings = new WorldSettings(i, j, generateStructures, false, worldtype);

      if (k == 0) {
        world =
            new WorldServer(
                this,
                new ServerNBTManager(server.getWorldContainer(), s, true),
                s,
                dimension,
                settings,
                org.bukkit.World.Environment.getEnvironment(dimension),
                gen); // CraftBukkit
      } else {
        String dim = "DIM" + dimension;

        File newWorld = new File(new File(name), dim);
        File oldWorld = new File(new File(s), dim);

        if ((!newWorld.isDirectory()) && (oldWorld.isDirectory())) {
          log.info("---- Migration of old " + worldType + " folder required ----");
          log.info(
              "Unfortunately due to the way that Minecraft implemented multiworld support in 1.6, Bukkit requires that you move your "
                  + worldType
                  + " folder to a new location in order to operate correctly.");
          log.info(
              "We will move this folder for you, but it will mean that you need to move it back should you wish to stop using Bukkit in the future.");
          log.info("Attempting to move " + oldWorld + " to " + newWorld + "...");

          if (newWorld.exists()) {
            log.severe("A file or folder already exists at " + newWorld + "!");
            log.info("---- Migration of old " + worldType + " folder failed ----");
          } else if (newWorld.getParentFile().mkdirs()) {
            if (oldWorld.renameTo(newWorld)) {
              log.info(
                  "Success! To restore "
                      + worldType
                      + " in the future, simply move "
                      + newWorld
                      + " to "
                      + oldWorld);
              log.info("---- Migration of old " + worldType + " folder complete ----");
            } else {
              log.severe("Could not move folder " + oldWorld + " to " + newWorld + "!");
              log.info("---- Migration of old " + worldType + " folder failed ----");
            }
          } else {
            log.severe("Could not create path for " + newWorld + "!");
            log.info("---- Migration of old " + worldType + " folder failed ----");
          }
        }

        if (convertable.isConvertable(name)) {
          log.info("Converting map!");
          convertable.convert(name, new ConvertProgressUpdater(this));
        }

        world =
            new SecondaryWorldServer(
                this,
                new ServerNBTManager(server.getWorldContainer(), name, true),
                name,
                dimension,
                settings,
                this.worlds.get(0),
                org.bukkit.World.Environment.getEnvironment(dimension),
                gen); // CraftBukkit
      }

      if (gen != null) {
        world.getWorld().getPopulators().addAll(gen.getDefaultPopulators(world.getWorld()));
      }

      this.server
          .getPluginManager()
          .callEvent(new org.bukkit.event.world.WorldInitEvent(world.getWorld()));

      world.tracker = new EntityTracker(this, world); // CraftBukkit
      world.addIWorldAccess(new WorldManager(this, world));
      world.difficulty = this.propertyManager.getInt("difficulty", 1);
      world.setSpawnFlags(
          this.propertyManager.getBoolean("spawn-monsters", true), this.spawnAnimals);
      world.getWorldData().setGameType(j);
      this.worlds.add(world);
      this.serverConfigurationManager.setPlayerFileData(this.worlds.toArray(new WorldServer[0]));
    }
    // CraftBukkit end

    short short1 = 196;
    long l = System.currentTimeMillis();

    // CraftBukkit start
    for (int i1 = 0; i1 < this.worlds.size(); ++i1) {
      WorldServer worldserver = this.worlds.get(i1);
      log.info("Preparing start region for level " + i1 + " (Seed: " + worldserver.getSeed() + ")");
      if (!worldserver.getWorld().getKeepSpawnInMemory()) {
        continue;
      }
      // CraftBukkit end
      ChunkCoordinates chunkcoordinates = worldserver.getSpawn();

      for (int j1 = -short1; j1 <= short1 && this.isRunning; j1 += 16) {
        for (int k1 = -short1; k1 <= short1 && this.isRunning; k1 += 16) {
          long l1 = System.currentTimeMillis();

          if (l1 < l) {
            l = l1;
          }

          if (l1 > l + 1000L) {
            int i2 = (short1 * 2 + 1) * (short1 * 2 + 1);
            int j2 = (j1 + short1) * (short1 * 2 + 1) + k1 + 1;

            this.b("Preparing spawn area", j2 * 100 / i2);
            l = l1;
          }

          worldserver.chunkProviderServer.getChunkAt(
              chunkcoordinates.x + j1 >> 4, chunkcoordinates.z + k1 >> 4);

          while (worldserver.updateLights() && this.isRunning) {;
          }
        }
      }
    }

    // CraftBukkit start
    for (World world : this.worlds) {
      this.server
          .getPluginManager()
          .callEvent(new org.bukkit.event.world.WorldLoadEvent(world.getWorld()));
    }
    // CraftBukkit end

    this.t();
  }
Esempio n. 6
0
 public WorldInfo(WorldSettings worldsettings, String s) {
   randomSeed = worldsettings.func_35518_a();
   field_35920_p = worldsettings.func_35519_b();
   field_35919_q = worldsettings.func_35520_c();
   levelName = s;
 }
Esempio n. 7
0
  protected void a(String s, String s1, long i, WorldType worldtype, String s2) {
    this.a(s);
    this.b("menu.loadingLevel");
    this.worldServer = new WorldServer[3];
    /* CraftBukkit start - Remove ticktime arrays and worldsettings
    this.h = new long[this.worldServer.length][100];
    IDataManager idatamanager = this.convertable.a(s, true);

    this.a(this.T(), idatamanager);
    WorldData worlddata = idatamanager.getWorldData();
    WorldSettings worldsettings;

    if (worlddata == null) {
        if (this.W()) {
            worldsettings = DemoWorldServer.a;
        } else {
            worldsettings = new WorldSettings(i, this.getGamemode(), this.getGenerateStructures(), this.isHardcore(), worldtype);
            worldsettings.setGeneratorSettings(s2);
            if (this.M) {
                worldsettings.a();
            }
        }

        worlddata = new WorldData(worldsettings, s1);
    } else {
        worlddata.a(s1);
        worldsettings = new WorldSettings(worlddata);
    }
    */
    int worldCount = 3;

    for (int j = 0; j < worldCount; ++j) {
      WorldServer world;
      byte dimension = 0;

      if (j == 1) {
        if (getAllowNether()) {
          dimension = -1;
        } else {
          continue;
        }
      }

      if (j == 2) {
        if (server.getAllowEnd()) {
          dimension = 1;
        } else {
          continue;
        }
      }

      String worldType =
          org.bukkit.World.Environment.getEnvironment(dimension).toString().toLowerCase();
      String name = (dimension == 0) ? s : s + "_" + worldType;

      org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name);
      WorldSettings worldsettings =
          new WorldSettings(
              i, this.getGamemode(), this.getGenerateStructures(), this.isHardcore(), worldtype);
      worldsettings.setGeneratorSettings(s2);

      if (j == 0) {
        IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), s1, true);
        WorldData worlddata = idatamanager.getWorldData();
        if (worlddata == null) {
          worlddata = new WorldData(worldsettings, s1);
        }
        worlddata.checkName(
            s1); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take
                 // the last loaded world as respawn (in this case the end)
        if (this.W()) {
          world =
              (WorldServer)
                  (new DemoWorldServer(
                          this, idatamanager, worlddata, dimension, this.methodProfiler))
                      .b();
        } else {
          world =
              (WorldServer)
                  (new WorldServer(
                          this,
                          idatamanager,
                          worlddata,
                          dimension,
                          this.methodProfiler,
                          org.bukkit.World.Environment.getEnvironment(dimension),
                          gen))
                      .b();
        }

        world.a(worldsettings);
        this.server.scoreboardManager =
            new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(
                this, world.getScoreboard());
      } else {
        String dim = "DIM" + dimension;

        File newWorld = new File(new File(name), dim);
        File oldWorld = new File(new File(s), dim);

        if ((!newWorld.isDirectory()) && (oldWorld.isDirectory())) {
          MinecraftServer.LOGGER.info(
              "---- Migration of old " + worldType + " folder required ----");
          MinecraftServer.LOGGER.info(
              "Unfortunately due to the way that Minecraft implemented multiworld support in 1.6, Bukkit requires that you move your "
                  + worldType
                  + " folder to a new location in order to operate correctly.");
          MinecraftServer.LOGGER.info(
              "We will move this folder for you, but it will mean that you need to move it back should you wish to stop using Bukkit in the future.");
          MinecraftServer.LOGGER.info("Attempting to move " + oldWorld + " to " + newWorld + "...");

          if (newWorld.exists()) {
            MinecraftServer.LOGGER.warn("A file or folder already exists at " + newWorld + "!");
            MinecraftServer.LOGGER.info(
                "---- Migration of old " + worldType + " folder failed ----");
          } else if (newWorld.getParentFile().mkdirs()) {
            if (oldWorld.renameTo(newWorld)) {
              MinecraftServer.LOGGER.info(
                  "Success! To restore "
                      + worldType
                      + " in the future, simply move "
                      + newWorld
                      + " to "
                      + oldWorld);
              // Migrate world data too.
              try {
                com.google.common.io.Files.copy(
                    new File(new File(s), "level.dat"), new File(new File(name), "level.dat"));
              } catch (IOException exception) {
                MinecraftServer.LOGGER.warn("Unable to migrate world data.");
              }
              MinecraftServer.LOGGER.info(
                  "---- Migration of old " + worldType + " folder complete ----");
            } else {
              MinecraftServer.LOGGER.warn(
                  "Could not move folder " + oldWorld + " to " + newWorld + "!");
              MinecraftServer.LOGGER.info(
                  "---- Migration of old " + worldType + " folder failed ----");
            }
          } else {
            MinecraftServer.LOGGER.warn("Could not create path for " + newWorld + "!");
            MinecraftServer.LOGGER.info(
                "---- Migration of old " + worldType + " folder failed ----");
          }
        }

        IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), name, true);
        // world =, b0 to dimension, s1 to name, added Environment and gen
        WorldData worlddata = idatamanager.getWorldData();
        if (worlddata == null) {
          worlddata = new WorldData(worldsettings, name);
        }
        worlddata.checkName(
            name); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take
                   // the last loaded world as respawn (in this case the end)
        world =
            (WorldServer)
                new SecondaryWorldServer(
                        this,
                        idatamanager,
                        dimension,
                        this.worlds.get(0),
                        this.methodProfiler,
                        worlddata,
                        org.bukkit.World.Environment.getEnvironment(dimension),
                        gen)
                    .b();
      }

      if (gen != null) {
        world.getWorld().getPopulators().addAll(gen.getDefaultPopulators(world.getWorld()));
      }

      this.server
          .getPluginManager()
          .callEvent(new org.bukkit.event.world.WorldInitEvent(world.getWorld()));

      world.addIWorldAccess(new WorldManager(this, world));
      if (!this.S()) {
        world.getWorldData().setGameType(this.getGamemode());
      }

      worlds.add(world);
      getPlayerList().setPlayerFileData(worlds.toArray(new WorldServer[worlds.size()]));
    }

    // CraftBukkit end
    this.a(this.getDifficulty());
    this.k();
  }
Esempio n. 8
0
  private void a(Convertable convertable, String s, long i, WorldType worldtype) {
    if (convertable.isConvertable(s)) {
      log.info("Converting map!");
      convertable.convert(s, new ConvertProgressUpdater(this));
    }

    this.worldServer = new WorldServer[3];
    this.g = new long[this.worldServer.length][100];
    int j = this.propertyManager.getInt("gamemode", 0);

    j = WorldSettings.a(j);
    log.info("Default game type: " + j);
    boolean flag = this.propertyManager.getBoolean("generate-structures", true);
    WorldSettings worldsettings = new WorldSettings(i, j, flag, false, worldtype);
    ServerNBTManager servernbtmanager = new ServerNBTManager(new File("."), s, true);

    for (int k = 0; k < this.worldServer.length; ++k) {
      byte b0 = 0;

      if (k == 1) {
        b0 = -1;
      }

      if (k == 2) {
        b0 = 1;
      }

      if (k == 0) {
        this.worldServer[k] = new WorldServer(this, servernbtmanager, s, b0, worldsettings);
      } else {
        this.worldServer[k] =
            new SecondaryWorldServer(
                this, servernbtmanager, s, b0, worldsettings, this.worldServer[0]);
      }

      this.worldServer[k].addIWorldAccess(new WorldManager(this, this.worldServer[k]));
      this.worldServer[k].difficulty = this.propertyManager.getInt("difficulty", 1);
      this.worldServer[k].setSpawnFlags(
          this.propertyManager.getBoolean("spawn-monsters", true), this.spawnAnimals);
      this.worldServer[k].getWorldData().setGameType(j);
      this.serverConfigurationManager.setPlayerFileData(this.worldServer);
    }

    short short1 = 196;
    long l = System.currentTimeMillis();

    for (int i1 = 0; i1 < 1; ++i1) {
      log.info("Preparing start region for level " + i1);
      WorldServer worldserver = this.worldServer[i1];
      ChunkCoordinates chunkcoordinates = worldserver.getSpawn();

      for (int j1 = -short1; j1 <= short1 && this.isRunning; j1 += 16) {
        for (int k1 = -short1; k1 <= short1 && this.isRunning; k1 += 16) {
          long l1 = System.currentTimeMillis();

          if (l1 < l) {
            l = l1;
          }

          if (l1 > l + 1000L) {
            int i2 = (short1 * 2 + 1) * (short1 * 2 + 1);
            int j2 = (j1 + short1) * (short1 * 2 + 1) + k1 + 1;

            this.b("Preparing spawn area", j2 * 100 / i2);
            l = l1;
          }

          worldserver.chunkProviderServer.getChunkAt(
              chunkcoordinates.x + j1 >> 4, chunkcoordinates.z + k1 >> 4);

          while (worldserver.updateLights() && this.isRunning) {;
          }
        }
      }
    }

    this.t();
  }
Esempio n. 9
0
  /** 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;
  }
Esempio n. 10
0
  protected void b(WorldSettings worldsettings) {
    if (!this.worldProvider.e()) {
      this.worldData.setSpawn(0, this.worldProvider.getSeaLevel(), 0);
    } else {
      this.isLoading = true;
      WorldChunkManager worldchunkmanager = this.worldProvider.e;
      List list = worldchunkmanager.a();
      Random random = new Random(this.getSeed());
      ChunkPosition chunkposition = worldchunkmanager.a(0, 0, 256, list, random);
      int i = 0;
      int j = this.worldProvider.getSeaLevel();
      int k = 0;

      // CraftBukkit start
      if (this.generator != null) {
        Random rand = new Random(this.getSeed());
        org.bukkit.Location spawn =
            this.generator.getFixedSpawnLocation(((WorldServer) this).getWorld(), rand);

        if (spawn != null) {
          if (spawn.getWorld() != ((WorldServer) this).getWorld()) {
            throw new IllegalStateException(
                "Cannot set spawn point for "
                    + this.worldData.getName()
                    + " to be in another world ("
                    + spawn.getWorld().getName()
                    + ")");
          } else {
            this.worldData.setSpawn(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ());
            this.isLoading = false;
            return;
          }
        }
      }
      // CraftBukkit end

      if (chunkposition != null) {
        i = chunkposition.x;
        k = chunkposition.z;
      } else {
        this.getLogger().warning("Unable to find spawn biome");
      }

      int l = 0;

      while (!this.canSpawn(i, k)) { // CraftBukkit - use our own canSpawn
        i += random.nextInt(64) - random.nextInt(64);
        k += random.nextInt(64) - random.nextInt(64);
        ++l;
        if (l == 1000) {
          break;
        }
      }

      this.worldData.setSpawn(i, j, k);
      this.isLoading = false;
      if (worldsettings.c()) {
        this.k();
      }
    }
  }
Esempio n. 11
0
  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;
      }
    }
  }