Skip to content

Commit

Permalink
Merge pull request #221 from Grover-c13/3.2.4
Browse files Browse the repository at this point in the history
MultiAdmin Version 3.2.4 Update
  • Loading branch information
Dankrushen authored Nov 18, 2019
2 parents 34da69c + 0f81189 commit c93c52d
Show file tree
Hide file tree
Showing 9 changed files with 234 additions and 143 deletions.
8 changes: 8 additions & 0 deletions MultiAdmin/Config/MultiAdminConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ public class MultiAdminConfig : InheritableConfigRegister
new ConfigEntry<double>("server_stop_timeout", 10,
"Server Stop Timeout", "The time in seconds before MultiAdmin forces a server shutdown if it doesn't respond to the regular shutdown command");

public ConfigEntry<bool> ServerStartRetry { get; } =
new ConfigEntry<bool>("server_start_retry", true,
"Server Start Retry", "Whether to try to start the server again after crashing");

public ConfigEntry<int> ServerStartRetryDelay { get; } =
new ConfigEntry<int>("server_start_retry_delay", 10000,
"Server Start Retry Delay", "The time in milliseconds to wait before trying to start the server again after crashing");

public ConfigEntry<string> ServersFolder { get; } =
new ConfigEntry<string>("servers_folder", "servers",
"Servers Folder", "The location of the `servers` folder for MultiAdmin to load multiple server configurations from");
Expand Down
28 changes: 16 additions & 12 deletions MultiAdmin/EventInterfaces.cs
Original file line number Diff line number Diff line change
@@ -1,45 +1,53 @@
namespace MultiAdmin
{
public interface IEventServerPreStart
public interface IMAEvent
{
}

public interface IEventServerPreStart: IMAEvent
{
void OnServerPreStart();
}

public interface IEventServerStart
public interface IEventServerStart: IMAEvent
{
void OnServerStart();
}

public interface IEventServerStop
public interface IEventServerStop: IMAEvent
{
void OnServerStop();
}

public interface IEventRoundEnd
public interface IEventRoundEnd: IMAEvent
{
void OnRoundEnd();
}

public interface IEventWaitingForPlayers
public interface IEventWaitingForPlayers: IMAEvent
{
void OnWaitingForPlayers();
}

public interface IEventRoundStart
public interface IEventRoundStart: IMAEvent
{
void OnRoundStart();
}

public interface IEventCrash
public interface IEventCrash: IMAEvent
{
void OnCrash();
}

public interface IEventTick
public interface IEventTick: IMAEvent
{
void OnTick();
}

public interface IServerMod: IMAEvent
{
}

public interface IEventServerFull : IServerMod
{
void OnServerFull();
Expand All @@ -60,10 +68,6 @@ public interface IEventAdminAction : IServerMod
void OnAdminAction(string message);
}

public interface IServerMod
{
}

public interface ICommand
{
void OnCall(string[] args);
Expand Down
5 changes: 2 additions & 3 deletions MultiAdmin/Features/MultiAdminInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,12 @@ public override void OnConfigReload()

public void PrintInfo()
{
Server.Write($"MultiAdmin v{Program.MaVersion} (https://github.com/Grover-c13/MultiAdmin/)", ConsoleColor.DarkMagenta);
Server.Write("Released under MIT License Copyright © Grover 2019", ConsoleColor.DarkMagenta);
Server.Write($"{nameof(MultiAdmin)} v{Program.MaVersion} (https://github.com/Grover-c13/MultiAdmin/)\nReleased under MIT License Copyright © Grover 2019", ConsoleColor.DarkMagenta);
}

public override string GetFeatureDescription()
{
return "Prints MultiAdmin license and version information";
return $"Prints {nameof(MultiAdmin)} license and version information";
}

public override string GetFeatureName()
Expand Down
19 changes: 10 additions & 9 deletions MultiAdmin/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ namespace MultiAdmin
{
public static class Program
{
public const string MaVersion = "3.2.3.1";
public const string RecommendedMonoVersion = "5.18.0";
public const string MaVersion = "3.2.4.3";
public const string RecommendedMonoVersion = "5.18";

private static readonly List<Server> InstantiatedServers = new List<Server>();

private static readonly string MaDebugLogDir = Utils.GetFullPathSafe("logs");
private static readonly string MaDebugLogFile = !string.IsNullOrEmpty(MaDebugLogDir) ? Utils.GetFullPathSafe($"{MaDebugLogDir}{Path.DirectorySeparatorChar}{Utils.DateTime}_MA_{MaVersion}_debug_log.txt") : null;
private static readonly string MaDebugLogFile = !string.IsNullOrEmpty(MaDebugLogDir) ? Utils.GetFullPathSafe(Path.Combine(MaDebugLogDir, $"{Utils.DateTime}_MA_{MaVersion}_debug_log.txt")) : null;

private static uint? portArg;

Expand Down Expand Up @@ -178,7 +178,8 @@ public static void Main()

Headless = GetFlagFromArgs("headless", "h");

CheckMonoVersion();
if (!Headless)
CheckMonoVersion();

string serverIdArg = GetParamFromArgs("server-id", "id");
string configArg = GetParamFromArgs("config", "c");
Expand Down Expand Up @@ -372,11 +373,11 @@ public static Process StartServer(Server server)
return serverProcess;
}

private static bool IsVersionFormat(string input)
private static bool IsVersionFormat(string input, char separator = '.')
{
foreach (char character in input)
{
if (!char.IsNumber(character) && character != '.')
if (!char.IsNumber(character) && character != separator)
return false;
}

Expand All @@ -388,17 +389,17 @@ public static void CheckMonoVersion()
try
{
string monoVersionRaw = Type.GetType("Mono.Runtime")?.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static)?.Invoke(null, null)?.ToString();
string monoVersion = monoVersionRaw?.Split(' ').FirstOrDefault(IsVersionFormat);
string monoVersion = monoVersionRaw?.Split(' ').FirstOrDefault(version => IsVersionFormat(version));

if (string.IsNullOrEmpty(monoVersion))
return;

int versionDifference = Utils.CompareVersionStrings(monoVersion, RecommendedMonoVersion);

if (versionDifference >= 0 && (versionDifference != 0 || monoVersion.Length >= RecommendedMonoVersion.Length))
if (versionDifference >= 0)
return;

Write($"Warning: Your Mono version ({monoVersion}) is below the recommended version ({RecommendedMonoVersion})", ConsoleColor.Red);
Write($"Warning: Your Mono version ({monoVersion}) is below the minimum recommended version ({RecommendedMonoVersion})", ConsoleColor.Red);
Write("Please update your Mono installation: https://www.mono-project.com/download/stable/", ConsoleColor.Red);
}
catch (Exception e)
Expand Down
Loading

0 comments on commit c93c52d

Please sign in to comment.