Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Commit eced3a1

Browse files
author
Dankrushen
authored
Merge pull request #218 from Grover-c13/3.2.2
MultiAdmin Version 3.2.2 Update
2 parents 5389c06 + 6330542 commit eced3a1

32 files changed

+937
-222
lines changed

MultiAdmin.sln

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio 15
33
VisualStudioVersion = 15.0.27130.2026
44
MinimumVisualStudioVersion = 10.0.40219.1
5-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiAdmin", "MultiAdmin/MultiAdmin.csproj", "{8384BF3C-5FC8-4395-A3DE-440C6C531D36}"
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiAdmin", "MultiAdmin\MultiAdmin.csproj", "{8384BF3C-5FC8-4395-A3DE-440C6C531D36}"
6+
EndProject
7+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiAdminTests", "MultiAdminTests\MultiAdminTests.csproj", "{D56F8899-C7BB-4ADE-A62C-DEC4DC8C2EE8}"
68
EndProject
79
Global
810
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -14,6 +16,10 @@ Global
1416
{8384BF3C-5FC8-4395-A3DE-440C6C531D36}.Debug|Any CPU.Build.0 = Release|Any CPU
1517
{8384BF3C-5FC8-4395-A3DE-440C6C531D36}.Release|Any CPU.ActiveCfg = Release|Any CPU
1618
{8384BF3C-5FC8-4395-A3DE-440C6C531D36}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{D56F8899-C7BB-4ADE-A62C-DEC4DC8C2EE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20+
{D56F8899-C7BB-4ADE-A62C-DEC4DC8C2EE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
21+
{D56F8899-C7BB-4ADE-A62C-DEC4DC8C2EE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
22+
{D56F8899-C7BB-4ADE-A62C-DEC4DC8C2EE8}.Release|Any CPU.Build.0 = Release|Any CPU
1723
EndGlobalSection
1824
GlobalSection(SolutionProperties) = preSolution
1925
HideSolutionNode = FALSE

MultiAdmin/Config/Config.cs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Text;
55
using MultiAdmin.ConsoleTools;
6+
using MultiAdmin.Utility;
67

78
namespace MultiAdmin.Config
89
{
@@ -59,7 +60,7 @@ public void ReadConfigFile()
5960

6061
public bool Contains(string key)
6162
{
62-
return rawData != null && rawData.Any(entry => entry.ToLower().StartsWith(key.ToLower() + ":"));
63+
return rawData != null && rawData.Any(entry => entry.StartsWith($"{key}:", StringComparison.CurrentCultureIgnoreCase));
6364
}
6465

6566
private static string CleanValue(string value)
@@ -184,6 +185,40 @@ public float GetFloat(string key, float def = 0)
184185
return def;
185186
}
186187

188+
public double GetDouble(string key, double def = 0)
189+
{
190+
try
191+
{
192+
string value = GetString(key);
193+
194+
if (!string.IsNullOrEmpty(value) && double.TryParse(value, out double parsedValue))
195+
return parsedValue;
196+
}
197+
catch (Exception e)
198+
{
199+
Program.LogDebugException(nameof(GetDouble), e);
200+
}
201+
202+
return def;
203+
}
204+
205+
public decimal GetDecimal(string key, decimal def = 0)
206+
{
207+
try
208+
{
209+
string value = GetString(key);
210+
211+
if (!string.IsNullOrEmpty(value) && decimal.TryParse(value, out decimal parsedValue))
212+
return parsedValue;
213+
}
214+
catch (Exception e)
215+
{
216+
Program.LogDebugException(nameof(GetDecimal), e);
217+
}
218+
219+
return def;
220+
}
221+
187222
public bool GetBool(string key, bool def = false)
188223
{
189224
try

MultiAdmin/Config/MultiAdminConfig.cs

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using System.Reflection;
66
using MultiAdmin.Config.ConfigHandler;
77
using MultiAdmin.ConsoleTools;
8+
using MultiAdmin.ServerIO;
9+
using MultiAdmin.Utility;
810

911
namespace MultiAdmin.Config
1012
{
@@ -33,7 +35,7 @@ public class MultiAdminConfig : InheritableConfigRegister
3335
"MultiAdmin Debug Logging", "Enables MultiAdmin debug logging, this logs to a separate file than any other logs");
3436

3537
public ConfigEntry<string[]> DebugLogBlacklist { get; } =
36-
new ConfigEntry<string[]>("multiadmin_debug_log_blacklist", new string[] {"ProcessFile"},
38+
new ConfigEntry<string[]>("multiadmin_debug_log_blacklist", new string[] {nameof(OutputHandler.ProcessFile), nameof(Utils.StringMatches)},
3739
"MultiAdmin Debug Logging Blacklist", "Which tags to block for MultiAdmin debug logging");
3840

3941
public ConfigEntry<string[]> DebugLogWhitelist { get; } =
@@ -84,22 +86,26 @@ public class MultiAdminConfig : InheritableConfigRegister
8486
new ConfigEntry<bool>("manual_start", false,
8587
"Manual Start", "Whether or not to start the server automatically when launching MultiAdmin");
8688

87-
public ConfigEntry<float> MaxMemory { get; } =
88-
new ConfigEntry<float>("max_memory", 2048,
89+
public ConfigEntry<decimal> MaxMemory { get; } =
90+
new ConfigEntry<decimal>("max_memory", 2048,
8991
"Max Memory", "The amount of memory in megabytes for MultiAdmin to check against");
9092

91-
public ConfigEntry<float> RestartLowMemory { get; } =
92-
new ConfigEntry<float>("restart_low_memory", 400,
93+
public ConfigEntry<decimal> RestartLowMemory { get; } =
94+
new ConfigEntry<decimal>("restart_low_memory", 400,
9395
"Restart Low Memory", "Restart if the game's remaining memory falls below this value in megabytes");
9496

95-
public ConfigEntry<float> RestartLowMemoryRoundEnd { get; } =
96-
new ConfigEntry<float>("restart_low_memory_roundend", 450,
97+
public ConfigEntry<decimal> RestartLowMemoryRoundEnd { get; } =
98+
new ConfigEntry<decimal>("restart_low_memory_roundend", 450,
9799
"Restart Low Memory Round-End", "Restart at the end of the round if the game's remaining memory falls below this value in megabytes");
98100

99101
public ConfigEntry<int> MaxPlayers { get; } =
100102
new ConfigEntry<int>("max_players", 20,
101103
"Max Players", "The number of players to display as the maximum for the server (within MultiAdmin, not in-game)");
102104

105+
public ConfigEntry<int> OutputReadAttempts { get; } =
106+
new ConfigEntry<int>("output_read_attempts", 100,
107+
"Output Read Attempts", "The number of times to attempt reading a message from the server before giving up");
108+
103109
public ConfigEntry<bool> RandomInputColors { get; } =
104110
new ConfigEntry<bool>("random_input_colors", false,
105111
"Random Input Colors", "Randomize the new input system's colors every time a message is input");
@@ -108,16 +114,28 @@ public class MultiAdminConfig : InheritableConfigRegister
108114
new ConfigEntry<int>("restart_every_num_rounds", -1,
109115
"Restart Every Number of Rounds", "Restart the server every number of rounds");
110116

117+
public ConfigEntry<bool> RestartEveryNumRoundsCounting { get; } =
118+
new ConfigEntry<bool>("restart_every_num_rounds_counting", false,
119+
"Restart Every Number of Rounds Counting", "Whether to print the count of rounds passed after each round if the server is set to restart after a number of rounds");
120+
111121
public ConfigEntry<bool> SafeServerShutdown { get; } =
112122
new ConfigEntry<bool>("safe_server_shutdown", true,
113-
"Safe Server Shutdown", "When MultiAdmin closes, if this is true, MultiAdmin will attempt to safely shutdown all the servers");
123+
"Safe Server Shutdown", "When MultiAdmin closes, if this is true, MultiAdmin will attempt to safely shutdown all servers");
124+
125+
public ConfigEntry<int> SafeShutdownCheckDelay { get; } =
126+
new ConfigEntry<int>("safe_shutdown_check_delay", 100,
127+
"Safe Shutdown Check Delay", "The time in milliseconds between checking if a server is still running when safely shutting down");
114128

115-
public ConfigEntry<float> ServerRestartTimeout { get; } =
116-
new ConfigEntry<float>("server_restart_timeout", 10,
129+
public ConfigEntry<int> SafeShutdownTimeout { get; } =
130+
new ConfigEntry<int>("safe_shutdown_timeout", 10000,
131+
"Safe Shutdown Timeout", "The time in milliseconds before MultiAdmin gives up on safely shutting down a server");
132+
133+
public ConfigEntry<double> ServerRestartTimeout { get; } =
134+
new ConfigEntry<double>("server_restart_timeout", 10,
117135
"Server Restart Timeout", "The time in seconds before MultiAdmin forces a server restart if it doesn't respond to the regular restart command");
118136

119-
public ConfigEntry<float> ServerStopTimeout { get; } =
120-
new ConfigEntry<float>("server_stop_timeout", 10,
137+
public ConfigEntry<double> ServerStopTimeout { get; } =
138+
new ConfigEntry<double>("server_stop_timeout", 10,
121139
"Server Stop Timeout", "The time in seconds before MultiAdmin forces a server shutdown if it doesn't respond to the regular shutdown command");
122140

123141
public ConfigEntry<string> ServersFolder { get; } =
@@ -241,6 +259,18 @@ public override void UpdateConfigValueInheritable(ConfigEntry configEntry)
241259
break;
242260
}
243261

262+
case ConfigEntry<double> config:
263+
{
264+
config.Value = Config.GetDouble(config.Key, config.Default);
265+
break;
266+
}
267+
268+
case ConfigEntry<decimal> config:
269+
{
270+
config.Value = Config.GetDecimal(config.Key, config.Default);
271+
break;
272+
}
273+
244274
case ConfigEntry<bool> config:
245275
{
246276
config.Value = Config.GetBool(config.Key, config.Default);
@@ -283,7 +313,7 @@ public MultiAdminConfig[] GetConfigHierarchy(bool highestToLowest = true)
283313
{
284314
List<MultiAdminConfig> configHierarchy = new List<MultiAdminConfig>();
285315

286-
foreach (InheritableConfigRegister configRegister in GetConfigRegisterHierarchy(highestToLowest))
316+
foreach (ConfigRegister configRegister in GetConfigRegisterHierarchy(highestToLowest))
287317
{
288318
if (configRegister is MultiAdminConfig config)
289319
configHierarchy.Add(config);

MultiAdmin/ConsoleTools/ColoredConsole.cs

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace MultiAdmin.ConsoleTools
77
{
8-
public class ColoredConsole
8+
public static class ColoredConsole
99
{
1010
public static readonly object WriteLock = new object();
1111

@@ -94,6 +94,58 @@ public ColoredMessage(string text, ConsoleColor? textColor = null, ConsoleColor?
9494
this.backgroundColor = backgroundColor;
9595
}
9696

97+
public bool Equals(ColoredMessage other)
98+
{
99+
return string.Equals(text, other.text) && textColor == other.textColor && backgroundColor == other.backgroundColor;
100+
}
101+
102+
public override bool Equals(object obj)
103+
{
104+
if (ReferenceEquals(null, obj))
105+
{
106+
return false;
107+
}
108+
109+
if (ReferenceEquals(this, obj))
110+
{
111+
return true;
112+
}
113+
114+
if (obj.GetType() != GetType())
115+
{
116+
return false;
117+
}
118+
119+
return Equals((ColoredMessage)obj);
120+
}
121+
122+
public override int GetHashCode()
123+
{
124+
unchecked
125+
{
126+
int hashCode = text != null ? text.GetHashCode() : 0;
127+
hashCode = (hashCode * 397) ^ textColor.GetHashCode();
128+
hashCode = (hashCode * 397) ^ backgroundColor.GetHashCode();
129+
return hashCode;
130+
}
131+
}
132+
133+
public static bool operator ==(ColoredMessage firstMessage, ColoredMessage secondMessage)
134+
{
135+
if (ReferenceEquals(firstMessage, secondMessage))
136+
return true;
137+
138+
if (ReferenceEquals(firstMessage, null) || ReferenceEquals(secondMessage, null))
139+
return false;
140+
141+
return firstMessage.Equals(secondMessage);
142+
}
143+
144+
public static bool operator !=(ColoredMessage firstMessage, ColoredMessage secondMessage)
145+
{
146+
return !(firstMessage == secondMessage);
147+
}
148+
97149
public override string ToString()
98150
{
99151
return text;

MultiAdmin/Features/ConfigReload.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using System.Linq;
21
using MultiAdmin.Features.Attributes;
2+
using MultiAdmin.Utility;
33

44
namespace MultiAdmin.Features
55
{
@@ -27,7 +27,7 @@ public string GetUsage()
2727

2828
public void OnCall(string[] args)
2929
{
30-
if (!args.Any() || !args[0].ToLower().Equals("reload")) return;
30+
if (args.IsNullOrEmpty() || !args[0].ToLower().Equals("reload")) return;
3131

3232
Server.Write("Reloading configs...");
3333

@@ -48,7 +48,7 @@ public override string GetFeatureDescription()
4848

4949
public override string GetFeatureName()
5050
{
51-
return "Config reload";
51+
return "Config Reload";
5252
}
5353

5454
public override void Init()

MultiAdmin/Features/FolderCopyRoundQueue.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
2-
using System.Linq;
32
using MultiAdmin.Features.Attributes;
3+
using MultiAdmin.Utility;
44

55
namespace MultiAdmin.Features
66
{
@@ -17,7 +17,7 @@ public FileCopyRoundQueue(Server server) : base(server)
1717
{
1818
}
1919

20-
public bool HasValidQueue => queue != null && queue.Any();
20+
public bool HasValidQueue => !queue.IsNullOrEmpty();
2121

2222
public void OnRoundEnd()
2323
{

MultiAdmin/Features/GithubGenerator.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
using System.Collections.Generic;
22
using System.IO;
3-
using System.Linq;
43
using System.Text;
54
using MultiAdmin.Config;
65
using MultiAdmin.Config.ConfigHandler;
76
using MultiAdmin.Features.Attributes;
7+
using MultiAdmin.Utility;
88

99
namespace MultiAdmin.Features
1010
{
@@ -35,15 +35,15 @@ public string GetUsage()
3535

3636
public void OnCall(string[] args)
3737
{
38-
if (!args.Any())
38+
if (args.IsEmpty())
3939
{
4040
Server.Write("You must specify the location of the file.");
4141
return;
4242
}
4343

4444
string dir = string.Join(" ", args);
4545

46-
List<string> lines = new List<string> {"# MultiAdmin", string.Empty, "## Features"};
46+
List<string> lines = new List<string> {"# MultiAdmin", string.Empty, "## Features", string.Empty};
4747

4848
foreach (Feature feature in Server.features)
4949
{
@@ -80,7 +80,7 @@ public void OnCall(string[] args)
8080

8181
case ConfigEntry<string[]> config:
8282
{
83-
stringBuilder.Append($"String List{ColumnSeparator}{(!config.Default?.Any() ?? true ? EmptyIndicator : string.Join(", ", config.Default))}");
83+
stringBuilder.Append($"String List{ColumnSeparator}{(config.Default?.IsEmpty() ?? true ? EmptyIndicator : string.Join(", ", config.Default))}");
8484
break;
8585
}
8686

@@ -102,6 +102,18 @@ public void OnCall(string[] args)
102102
break;
103103
}
104104

105+
case ConfigEntry<double> config:
106+
{
107+
stringBuilder.Append($"Double{ColumnSeparator}{config.Default}");
108+
break;
109+
}
110+
111+
case ConfigEntry<decimal> config:
112+
{
113+
stringBuilder.Append($"Decimal{ColumnSeparator}{config.Default}");
114+
break;
115+
}
116+
105117
case ConfigEntry<bool> config:
106118
{
107119
stringBuilder.Append($"Boolean{ColumnSeparator}{config.Default}");

MultiAdmin/Features/HelpCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
43
using MultiAdmin.Features.Attributes;
4+
using MultiAdmin.Utility;
55

66
namespace MultiAdmin.Features
77
{
@@ -29,7 +29,7 @@ public void OnCall(string[] args)
2929
foreach (KeyValuePair<string, ICommand> command in Server.commands)
3030
{
3131
string usage = command.Value.GetUsage();
32-
if (usage.Any()) usage = " " + usage;
32+
if (!usage.IsEmpty()) usage = " " + usage;
3333
string output = $"{command.Key.ToUpper()}{usage}: {command.Value.GetCommandDescription()}";
3434
helpOutput.Add(output);
3535
}

0 commit comments

Comments
 (0)