-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #234 from ServerMod/dank-3.3.0
Finalize release 3.3.0
- Loading branch information
Showing
10 changed files
with
320 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Text; | ||
using MultiAdmin.Config; | ||
using MultiAdmin.Config.ConfigHandler; | ||
using MultiAdmin.Features.Attributes; | ||
using MultiAdmin.Utility; | ||
|
||
namespace MultiAdmin.Features | ||
{ | ||
[Feature] | ||
internal class ConfigGenerator : Feature, ICommand | ||
{ | ||
|
||
public ConfigGenerator(Server server) : base(server) | ||
{ | ||
} | ||
|
||
public string GetCommand() | ||
{ | ||
return "CONFIGGEN"; | ||
} | ||
|
||
public string GetCommandDescription() | ||
{ | ||
return "Generates a full default MultiAdmin config file"; | ||
} | ||
|
||
public string GetUsage() | ||
{ | ||
return "[FILE LOCATION]"; | ||
} | ||
|
||
public void OnCall(string[] args) | ||
{ | ||
if (args.IsEmpty()) | ||
{ | ||
Server.Write("You must specify the location of the file."); | ||
return; | ||
} | ||
|
||
string path = Utils.GetFullPathSafe(string.Join(" ", args)); | ||
|
||
ConfigEntry[] registeredConfigs = MultiAdminConfig.GlobalConfig.GetRegisteredConfigs(); | ||
|
||
List<string> lines = new List<string>(registeredConfigs.Length); | ||
foreach (ConfigEntry configEntry in registeredConfigs) | ||
{ | ||
switch (configEntry) | ||
{ | ||
case ConfigEntry<string[]> config: | ||
{ | ||
lines.Add($"{config.Key}: {(config.Default == null ? "" : string.Join(", ", config.Default))}"); | ||
break; | ||
} | ||
|
||
default: | ||
{ | ||
lines.Add($"{configEntry.Key}: {configEntry.ObjectDefault ?? ""}"); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
File.WriteAllLines(path, lines); | ||
Server.Write($"Default config written to \"{path}\""); | ||
} | ||
|
||
public bool PassToGame() | ||
{ | ||
return false; | ||
} | ||
|
||
public override void OnConfigReload() | ||
{ | ||
} | ||
|
||
public override string GetFeatureDescription() | ||
{ | ||
return "Generates a full default MultiAdmin config file"; | ||
} | ||
|
||
public override string GetFeatureName() | ||
{ | ||
return "Config Generator"; | ||
} | ||
|
||
public override void Init() | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
|
||
namespace MultiAdmin | ||
{ | ||
[Flags] | ||
public enum ModFeatures | ||
{ | ||
None = 0, | ||
|
||
// Replaces detecting game output with MultiAdmin events for game events | ||
CustomEvents = 1 << 0, | ||
|
||
// Supporting all current features | ||
All = ~(~0 << 1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.