Exemplo n.º 1
0
 public ActionResult OpenWorld(Edition edition, string folder, bool bypass_mapwarning = false)
 {
     if (!bypass_mapwarning && ImportingMapPreviews.Any())
     {
         return(ActionResult.MapsNotImported);
     }
     if (SelectedWorld is IDisposable disp)
     {
         disp.Dispose();
     }
     try
     {
         if (edition == Edition.Java)
         {
             SelectedWorld = new JavaWorld(folder);
         }
         else if (edition == Edition.Bedrock)
         {
             SelectedWorld = new BedrockWorld(folder);
         }
         else
         {
             throw new ArgumentException($"Don't know what edition {edition} is");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Could not open this world. Perhaps it's the wrong edition, or is missing some important files.\n\n" + ex.Message, "Failed to open world!");
         return(ActionResult.Failure);
     }
     SelectedWorld.Initialize();
     NewWorldOpened();
     PlayerDestinations = new List <string>();
     PlayerDestinations.Add(LOCAL_IDENTIFIER);
     foreach (var uuid in SelectedWorld.GetPlayerIDs())
     {
         PlayerDestinations.Add(uuid);
     }
     return(ActionResult.Success);
 }
Exemplo n.º 2
0
 public ActionResult OpenWorld(Edition edition, string folder, bool bypass_mapwarning = false)
 {
     if (!bypass_mapwarning && ImportingMapPreviews.Any())
     {
         return(ActionResult.MapsNotImported);
     }
     if (SelectedWorld is IDisposable disp)
     {
         disp.Dispose();
     }
     try
     {
         if (edition == Edition.Java)
         {
             SelectedWorld = new JavaWorld(folder);
         }
         else if (edition == Edition.Bedrock)
         {
             SelectedWorld = new BedrockWorld(folder);
         }
         else
         {
             throw new ArgumentException($"Don't know what edition {edition} is");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Could not open this world. Perhaps it's the wrong edition, or is missing some important files.\n\n" + ex.Message, "Failed to open world!");
         return(ActionResult.Failure);
     }
     SelectedWorld.Initialize();
     UI.PlayerSelector.Items.Clear();
     UI.PlayerSelector.Items.Add(LOCAL_IDENTIFIER);
     UI.PlayerSelector.Items.Add(NOBODY_IDENTIFIER);
     UI.PlayerSelector.Items.AddRange(SelectedWorld.GetPlayerIDs().ToArray());
     UI.PlayerSelector.SelectedIndex = Properties.Settings.Default.GiveChest ? 0 : 1;
     NewWorldOpened();
     return(ActionResult.Success);
 }