mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Add a generic ConfigEnum attribute.
This commit is contained in:
parent
8c35ff76d1
commit
5fe23756f5
@ -138,4 +138,28 @@ namespace MCGalaxy.Config {
|
||||
return time.ToShortDateString();
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ConfigEnumAttribute : ConfigAttribute {
|
||||
|
||||
/// <summary> The type of members of this enumeration. </summary>
|
||||
public Type EnumType;
|
||||
|
||||
public ConfigEnumAttribute(string name, string section, string desc,
|
||||
object defValue, Type enumType)
|
||||
: base(name, section, desc, defValue) {
|
||||
EnumType = enumType;
|
||||
}
|
||||
|
||||
public override object Parse(string value) {
|
||||
object result;
|
||||
try {
|
||||
result = Enum.Parse(EnumType, value, true);
|
||||
} catch {
|
||||
Server.s.Log("Config key \"" + Name + "\" is not a valid enum member, " +
|
||||
"using default of " + DefaultValue);
|
||||
return DefaultValue;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,9 @@ using MCGalaxy.Commands;
|
||||
using Sharkbite.Irc;
|
||||
|
||||
namespace MCGalaxy {
|
||||
|
||||
public enum IRCControllerVerify { None, HalfOp, OpChannel };
|
||||
|
||||
public sealed class ForgeBot {
|
||||
public static readonly string ResetSignal = "\x0F\x03";
|
||||
private Connection connection;
|
||||
|
@ -45,7 +45,6 @@ namespace MCGalaxy.Levels.IO {
|
||||
w.WriteLine("#Level properties for " + level.name);
|
||||
w.WriteLine("#Drown-time in seconds is [drown time] * 200 / 3 / 1000");
|
||||
w.WriteLine("Physics = " + level.physics);
|
||||
w.WriteLine("BuildType = " + level.BuildType);
|
||||
ConfigElement.Serialise(Server.levelConfig, " settings", w, level);
|
||||
}
|
||||
|
||||
@ -97,8 +96,6 @@ namespace MCGalaxy.Levels.IO {
|
||||
switch (key.ToLower()) {
|
||||
case "physics":
|
||||
level.setPhysics(int.Parse(value)); break;
|
||||
case "buildtype":
|
||||
level.BuildType = (BuildType)Enum.Parse(typeof(BuildType), value); break;
|
||||
default:
|
||||
if (!ConfigElement.Parse(Server.levelConfig, key, value, level))
|
||||
Server.s.Log("\"" + key + "\" was not a recognised level property key.");
|
||||
|
@ -253,6 +253,7 @@ namespace MCGalaxy
|
||||
[ConfigBool("Pillaring", "Game", null, false)]
|
||||
public bool Pillaring = !ZombieGame.noPillaring;
|
||||
|
||||
[ConfigEnum("BuildType", "Game", null, BuildType.Normal, typeof(BuildType))]
|
||||
public BuildType BuildType = BuildType.Normal;
|
||||
public bool CanPlace { get { return Buildable && BuildType != BuildType.NoModify; } }
|
||||
public bool CanDelete { get { return Deletable && BuildType != BuildType.NoModify; } }
|
||||
|
@ -321,7 +321,6 @@ namespace MCGalaxy {
|
||||
|
||||
isDev = Server.Devs.CaselessContains(name);
|
||||
isMod = Server.Mods.CaselessContains(name);
|
||||
Group foundGrp = Group.findPlayerGroup(name);
|
||||
|
||||
try {
|
||||
Server.TempBan tBan = Server.tempBans.Find(tB => tB.name.ToLower() == name.ToLower());
|
||||
@ -335,6 +334,7 @@ namespace MCGalaxy {
|
||||
} catch { }
|
||||
|
||||
if (!CheckWhitelist()) return;
|
||||
Group foundGrp = Group.findPlayerGroup(name);
|
||||
|
||||
// ban check
|
||||
if (Server.bannedIP.Contains(ip) && (!Server.useWhitelist || !onWhitelist)) {
|
||||
|
@ -250,6 +250,8 @@ namespace MCGalaxy
|
||||
public static bool ircIdentify = false;
|
||||
[ConfigString("irc-password", "IRC bot", null, "", true)]
|
||||
public static string ircPassword = "";
|
||||
[ConfigEnum("irc-controller-verify", "IRC bot", null, IRCControllerVerify.HalfOp, typeof(IRCControllerVerify))]
|
||||
public static IRCControllerVerify IRCVerify = IRCControllerVerify.HalfOp;
|
||||
|
||||
[ConfigBool("admin-verification", "Admin", null, true)]
|
||||
public static bool verifyadmins = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user