Skip to content

Commit

Permalink
Config wizard fix (pterodactyl and missing directory), version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
zabszk committed Jan 6, 2021
1 parent 5fa167e commit acaf197
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 7 deletions.
48 changes: 42 additions & 6 deletions Core/ConfigWizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static void RunConfigWizard()
while (!string.IsNullOrWhiteSpace(input) && !input.Equals("edit", StringComparison.OrdinalIgnoreCase) &&
!input.Equals("keep", StringComparison.OrdinalIgnoreCase))
{
Console.Write("Do you want to edit that configuration? [edit/keep]: ");
Console.WriteLine("Do you want to edit that configuration? [edit/keep]: ");
input = Console.ReadLine();
}

Expand Down Expand Up @@ -82,7 +82,7 @@ private static bool BoolInput(string question)
{
while (true)
{
Console.Write(question + " [yes/no]: ");
Console.WriteLine(question + " [yes/no]: ");
var input = Console.ReadLine();

if (input == null) continue;
Expand All @@ -99,7 +99,7 @@ private static ushort UshortInput(string question)
{
while (true)
{
Console.Write(question + " ");
Console.WriteLine(question + " ");
var input = Console.ReadLine();

if (input == null) continue;
Expand All @@ -114,12 +114,30 @@ private static void SaveConfig()
while (!string.IsNullOrWhiteSpace(input) && !input.Equals("this", StringComparison.OrdinalIgnoreCase) &&
!input.Equals("global", StringComparison.OrdinalIgnoreCase))
{
Console.Write($"Do you want to save the configuration only for THIS server (on port {LocalAdmin.GamePort} or should it become a GLOBAL configuration (default one for all future servers - servers not configured yet)? [this/global]: ");
Console.WriteLine($"Do you want to save the configuration only for THIS server (on port {LocalAdmin.GamePort} or should it become a GLOBAL configuration (default one for all future servers - servers not configured yet)? [this/global]: ");
input = Console.ReadLine();
}

var cfgPath =
$"{LocalAdmin.GameUserDataRoot}config{Path.DirectorySeparatorChar}{LocalAdmin.GamePort}{Path.DirectorySeparatorChar}config_localadmin.txt";
$"{LocalAdmin.GameUserDataRoot}config{Path.DirectorySeparatorChar}{LocalAdmin.GamePort}{Path.DirectorySeparatorChar}";

if (!Directory.Exists(cfgPath))
{
try
{
Directory.CreateDirectory(cfgPath);
}
catch (Exception e)
{
Console.WriteLine("FATAL ERROR: Can't create config directory.");
Console.WriteLine("Path: " + cfgPath);
Console.WriteLine("Exception: " + e.Message);
Environment.Exit(1);
return;
}
}

cfgPath += "config_localadmin.txt";

if (input != null && input.Equals("this", StringComparison.OrdinalIgnoreCase))
{
Expand Down Expand Up @@ -172,7 +190,25 @@ private static void SaveConfig()
}
}

cfgPath = $"{LocalAdmin.GameUserDataRoot}config{Path.DirectorySeparatorChar}config_localadmin_global.txt";
cfgPath = $"{LocalAdmin.GameUserDataRoot}config{Path.DirectorySeparatorChar}";

if (!Directory.Exists(cfgPath))
{
try
{
Directory.CreateDirectory(cfgPath);
}
catch (Exception e)
{
Console.WriteLine("FATAL ERROR: Can't **GLOBAL** config directory.");
Console.WriteLine("Path: " + cfgPath);
Console.WriteLine("Exception: " + e.Message);
Environment.Exit(1);
return;
}
}

cfgPath += "config_localadmin_global.txt";

if (File.Exists(cfgPath))
{
Expand Down
2 changes: 1 addition & 1 deletion Core/LocalAdmin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace LocalAdmin.V2.Core

public sealed class LocalAdmin : IDisposable
{
public const string VersionString = "2.3.5";
public const string VersionString = "2.3.6";
public static LocalAdmin? Singleton;
public static ushort GamePort;
private static bool _firstRun = true;
Expand Down

0 comments on commit acaf197

Please sign in to comment.