Пример #1
0
        private void DoTick()
        {
            List <string> arraylist = new List <string>();

            for (System.Collections.IEnumerator iterator = field_6037_b.Keys.GetEnumerator();
                 iterator.MoveNext();)
            {
                string s  = (string)iterator.Current;
                int    i1 = ((int)field_6037_b[s]);
                if (i1 > 0)
                {
                    field_6037_b[s] = i1 - 1;
                }
                else
                {
                    arraylist.Add(s);
                }
            }
            for (int i = 0; i < arraylist.Count; i++)
            {
                field_6037_b.Remove(arraylist[i]); //arraylist[i]
            }
            net.minecraft.src.AxisAlignedBB.ClearBoundingBoxPool();
            net.minecraft.src.Vec3D.Initialize();
            ticks++;
            for (int j = 0; j < worlds.Count; j++)
            {
                //if (j != 0 && !propertyManagerObj.GetBooleanProperty("allow-nether", true))
                //{
                //    continue;
                //}
                net.minecraft.src.WorldServer worldserver = worlds[j];
                if (ticks % 20 == 0)
                {
                    serverConfigurationManager.SendPacketToAllPlayersInDimension(new net.minecraft.src.Packet4UpdateTime(worldserver.GetWorldTime()), worldserver.worldProvider.worldType);
                }
                worldserver.Tick();
                while (worldserver.DoLighting())
                {
                }
                worldserver.CleanUp();
            }
            networkServer.HandleNetworkListenThread();
            serverConfigurationManager.OnTick();

            // CRAFTBUKKIT
            foreach (WorldServer w in worlds)
            {
                w.tracker.UpdateTrackedEntities();
            }
            //for (int k = 0; k < entityTracker.Length; k++)
            //{
            //    entityTracker[k].UpdateTrackedEntities();
            //}

            for (int l = 0; l < field_9010_p.Count; l++)
            {
                ((net.minecraft.src.IUpdatePlayerListBox)field_9010_p[l]).Update();
            }
            try
            {
                CommandLineParser();
            }
            catch (System.Exception exception)
            {
                logger.Warning("Unexpected exception while parsing console command");
                logger.Log(exception.ToString());
                //logger.Log(java.util.logging.Level.WARNING, "Unexpected exception while parsing console command", exception);
            }
        }
Пример #2
0
        private void InitWorld(net.minecraft.src.ISaveFormat isaveformat, string name, long seed)
        {
            if (isaveformat.IsOldSaveType(name))
            {
                logger.Info("Converting map!");
                isaveformat.ConverMapToMCRegion(name, new net.minecraft.src.ConvertProgressUpdater(this));
            }

            // CRAFTBUKKIT/SHARP start -- TODO Multiworld bukkit shit
            /* Initialize dimensions 0 and -1 (surface and nether) */
            worlds = new List <WorldServer>();// new net.minecraft.src.WorldServer[2];
            //net.minecraft.src.ServerNBTManager saveolddir = new net.minecraft.src.ServerNBTManager(".", name, true);
            for (int i = 0; i < (this.propertyManager.GetBoolean("allow-nether", true) ? 2 : 1); i++)
            {
                string      newname = i == 0 ? name : $"{name}_nether";
                WorldServer world;
                if (i == 0)
                {
                    world = new net.minecraft.src.WorldServer(this, new net.minecraft.src.ServerNBTManager(".", newname, true), newname, i != 0 ? -1 : 0, seed);
                }
                else
                {
                    string newpath = System.IO.Path.Combine(newname, "DIM-1");
                    string oldpath = System.IO.Path.Combine(name, "DIM-1");

                    if (System.IO.Directory.Exists(oldpath) && !System.IO.Directory.Exists(newpath))
                    {
                        logger.Info("---- Migration of old nether folder required ----");
                        logger.Info("Unfortunately due to the way that Minecraft implemented multiworld support in 1.6, Bukkit requires that you move your nether folder to a new location in order to operate correctly.");
                        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.");
                        logger.Info("Attempting to move " + oldpath + " to " + newpath + "...");

                        if (System.IO.File.Exists(newpath))
                        {
                            logger.Severe("A file or folder already exists at " + newpath + "!");
                            logger.Info("---- Migration of old nether folder failed ----");
                        }
                        else
                        {
                            try
                            {
                                System.IO.Directory.CreateDirectory(newname);
                                System.IO.Directory.Move(oldpath, newpath);

                                logger.Info("Success! To restore the nether in the future, simply move " + newpath + " to " + oldpath);
                                logger.Info("---- Migration of old nether folder complete ----");
                            }
                            catch (Exception e)
                            {
                                logger.Severe("An exception of type " + e.GetType().Name + " occurred!");
                                logger.Info("---- Migration of old nether folder failed ----");
                            }
                        }
                    }

                    world = new net.minecraft.src.SecondaryWorldServer(this, new net.minecraft.src.ServerNBTManager(".", newname, true), newname, i != 0 ? -1 : 0, seed, worlds[0]);
                }

                world.tracker = new EntityTracker(this, world);
                world.AddWorldAccess(new net.minecraft.src.WorldManager(this, world));
                world.difficultySetting = propertyManager.GetBoolean("spawn-monsters", true) ? 1 : 0;
                world.SetSpawnFlags(propertyManager.GetBoolean("spawn-monsters", true), spawnPeacefulMobs);
                worlds.Add(world);

                serverConfigurationManager.SetPlayerManager(worlds.ToArray());
            }
            // CRAFTBUKKIT/SHARP end

            short c         = 196;// '\304';
            long  timeStart = Sharpen.Runtime.CurrentTimeMillis();

            for (int i = 0; i < worlds.Count; i++)
            {
                //if (i != 0 && !propertyManagerObj.GetBooleanProperty("allow-nether", true))
                //    continue;

                Stopwatch sw = new Stopwatch();
                sw.Start();
                net.minecraft.src.WorldServer worldserver = worlds[i];

                logger.Info($"Preparing start region for level {i} (Seed: {worldserver.GetSeed()})");

                net.minecraft.src.ChunkCoordinates chunkcoordinates = worldserver.GetSpawnPoint();
                for (int k = -c; k <= c && serverRunning; k += 16)
                {
                    for (int i1 = -c; i1 <= c && serverRunning; i1 += 16)
                    {
                        long timeCurrent = Sharpen.Runtime.CurrentTimeMillis();
                        if (timeCurrent < timeStart)
                        {
                            timeStart = timeCurrent;
                        }
                        if (timeCurrent > timeStart + 1000L)
                        {
                            int j1 = (c * 2 + 1) * (c * 2 + 1);
                            int k1 = (k + c) * (c * 2 + 1) + (i1 + 1);
                            OutputPercentRemaining("Preparing spawn area", (k1 * 100) / j1);
                            timeStart = timeCurrent;
                        }
                        worldserver.chunkProviderServer.LoadChunk(chunkcoordinates.posX + k >> 4, chunkcoordinates.posZ + i1 >> 4);
                        while (worldserver.DoLighting() && serverRunning)
                        {
                        }
                    }
                }
                sw.Stop();
                logger.Fine($"Completed world gen {i} in {sw.Elapsed.TotalSeconds:0.000}s");
            }
            ClearCurrentTask();
        }