Example #1
0
        public static string Func_25097_a(ISaveFormat par0ISaveFormat, string par1Str)
        {
            for (par1Str = par1Str.Replace("[\\./\"]|COM", "_"); par0ISaveFormat.GetWorldInfo(par1Str) != null; par1Str = new StringBuilder().Append(par1Str).Append("-").ToString())
            {
            }

            return(par1Str);
        }
        /// <summary>
        /// loads the saves
        /// </summary>
        private void LoadSaves()
        {
            ISaveFormat isaveformat = Mc.GetSaveLoader();

            SaveList = isaveformat.GetSaveList();
            SaveList.Sort();
            SelectedWorld = -1;
            Console.WriteLine(SaveList.Count + " is total loaded saves");
        }
Example #3
0
        /// <summary>
        /// Adds the buttons (and other controls) to the screen in question.
        /// </summary>
        public override void InitGui()
        {
            StringTranslate stringtranslate = StringTranslate.GetInstance();

            //Keyboard.EnableRepeatEvents(true);
            ControlList.Clear();
            ControlList.Add(new GuiButton(0, Width / 2 - 100, Height / 4 + 96 + 12, stringtranslate.TranslateKey("selectWorld.renameButton")));
            ControlList.Add(new GuiButton(1, Width / 2 - 100, Height / 4 + 120 + 12, stringtranslate.TranslateKey("gui.cancel")));
            ISaveFormat isaveformat = Mc.GetSaveLoader();
            WorldInfo   worldinfo   = isaveformat.GetWorldInfo(WorldName);
            string      s           = worldinfo.GetWorldName();

            TheGuiTextField = new GuiTextField(FontRenderer, Width / 2 - 100, 60, 200, 20);
            TheGuiTextField.setFocused(true);
            TheGuiTextField.SetText(s);
        }
        public override void ConfirmClicked(bool par1, int par2)
        {
            if (Deleting)
            {
                Deleting = false;

                if (par1)
                {
                    ISaveFormat isaveformat = Mc.GetSaveLoader();
                    isaveformat.FlushCache();
                    isaveformat.DeleteWorldDirectory(GetSaveFileName(par2));
                    LoadSaves();
                }

                Mc.DisplayGuiScreen(this);
            }
        }
Example #5
0
        private void initWorld(ISaveFormat isaveformat, string s)
        {
            if (isaveformat.func_22102_a(s))
            {
                logger.info("Converting map!");
                isaveformat.func_22101_a(s, new ConvertProgressUpdater(this));
            }
            logger.info("Preparing start region");
            worldMngr = new WorldServer(this, new SaveOldDir(new File("."), s, true), s,
                                        propertyManagerObj.getBooleanProperty("hellworld", false) ? -1 : 0);
            worldMngr.addWorldAccess(new WorldManager(this));
            worldMngr.difficultySetting = propertyManagerObj.getBooleanProperty("spawn-monsters", true) ? 1 : 0;
            worldMngr.setAllowedSpawnTypes(propertyManagerObj.getBooleanProperty("spawn-monsters", true),
                                           spawnPeacefulMobs);
            configManager.setPlayerManager(worldMngr);
            char             c = '\x00C4'; // \304
            long             l = java.lang.System.currentTimeMillis();
            ChunkCoordinates chunkcoordinates = worldMngr.func_22078_l();

            for (int i = -c; i <= c && serverRunning; i += 16)
            {
                for (int j = -c; j <= c && serverRunning; j += 16)
                {
                    long l1 = java.lang.System.currentTimeMillis();
                    if (l1 < l)
                    {
                        l = l1;
                    }
                    if (l1 > l + 1000L)
                    {
                        int k  = (c * 2 + 1) * (c * 2 + 1);
                        int i1 = (i + c) * (c * 2 + 1) + (j + 1);
                        outputPercentRemaining("Preparing spawn area", (i1 * 100) / k);
                        l = l1;
                    }
                    worldMngr.field_20911_y.loadChunk(chunkcoordinates.posX + i >> 4, chunkcoordinates.posZ + j >> 4);
                    while (worldMngr.func_6156_d() && serverRunning)
                    {
                        ;
                    }
                }
            }

            clearCurrentTask();
        }
Example #6
0
        /// <summary>
        /// Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
        /// </summary>
        protected override void ActionPerformed(GuiButton par1GuiButton)
        {
            if (!par1GuiButton.Enabled)
            {
                return;
            }

            if (par1GuiButton.Id == 1)
            {
                Mc.DisplayGuiScreen(ParentGuiScreen);
            }
            else if (par1GuiButton.Id == 0)
            {
                ISaveFormat isaveformat = Mc.GetSaveLoader();
                isaveformat.RenameWorld(WorldName, TheGuiTextField.GetText().Trim());
                Mc.DisplayGuiScreen(ParentGuiScreen);
            }
        }
        /// <summary>
        /// Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
        /// </summary>
        protected override void ActionPerformed(GuiButton par1GuiButton)
        {
            switch (par1GuiButton.Id)
            {
            default:
                break;

            case 1:
                if (Mc.TheWorld.GetWorldInfo().IsHardcoreModeEnabled())
                {
                    string s = Mc.TheWorld.GetSaveHandler().GetSaveDirectoryName();
                    Mc.ExitToMainMenu("Deleting world");
                    ISaveFormat isaveformat = Mc.GetSaveLoader();
                    isaveformat.FlushCache();
                    isaveformat.DeleteWorldDirectory(s);
                    Mc.DisplayGuiScreen(new GuiMainMenu());
                }
                else
                {
                    Mc.ThePlayer.RespawnPlayer();
                    Mc.DisplayGuiScreen(null);
                }

                break;

            case 2:
                if (Mc.IsMultiplayerWorld())
                {
                    Mc.TheWorld.SendQuittingDisconnectingPacket();
                }

                Mc.ChangeWorld1(null);
                Mc.DisplayGuiScreen(new GuiMainMenu());
                break;
            }
        }
 /// <summary>
 /// Serializes the object in the specified format
 /// </summary>
 /// <param name="ostream">the output stream to serialize the object to</param>
 /// <param name="format">the format to save the object in</param>
 /// <remarks>Enables the visitor pattern for saving objects in differing formats</remarks>
 public void SaveAs( System.IO.StreamWriter ostream, ISaveFormat format )
 {
     format.Stream(ostream, this);
 }