Core: Fix autoload commands for unix, where file names are case sensitive

also make all the scripting commands Nobody by default.
This commit is contained in:
UnknownShadow200 2016-11-21 15:01:12 +11:00
parent c794c5dfe4
commit 44ed2fd088
4 changed files with 8 additions and 9 deletions

View File

@ -24,7 +24,7 @@ namespace MCGalaxy.Commands {
public override string shortcut { get { return ""; } } public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.Other; } } public override string type { get { return CommandTypes.Other; } }
public override bool museumUsable { get { return true; } } public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } } public override LevelPermission defaultRank { get { return LevelPermission.Nobody; } }
public CmdCmdCreate() { } public CmdCmdCreate() { }
public override void Use(Player p, string message) { public override void Use(Player p, string message) {

View File

@ -24,7 +24,7 @@ namespace MCGalaxy.Commands {
public override string shortcut { get { return ""; } } public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.Other; } } public override string type { get { return CommandTypes.Other; } }
public override bool museumUsable { get { return true; } } public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } } public override LevelPermission defaultRank { get { return LevelPermission.Nobody; } }
public CmdCompile() { } public CmdCompile() { }
public override void Use(Player p, string message) { public override void Use(Player p, string message) {

View File

@ -22,7 +22,7 @@ namespace MCGalaxy.Commands
public override string name { get { return "compload"; } } public override string name { get { return "compload"; } }
public override string shortcut { get { return "cml"; } } public override string shortcut { get { return "cml"; } }
public override string type { get { return CommandTypes.Other; } } public override string type { get { return CommandTypes.Other; } }
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } } public override LevelPermission defaultRank { get { return LevelPermission.Nobody; } }
public override bool museumUsable { get { return true; } } public override bool museumUsable { get { return true; } }
public override void Use(Player p, string message) { public override void Use(Player p, string message) {

View File

@ -137,11 +137,11 @@ namespace MCGalaxy {
if (!File.Exists(AutoloadFile)) { File.Create(AutoloadFile); return; } if (!File.Exists(AutoloadFile)) { File.Create(AutoloadFile); return; }
string[] list = File.ReadAllLines(AutoloadFile); string[] list = File.ReadAllLines(AutoloadFile);
foreach (string cmd in list) { foreach (string cmdName in list) {
if (cmd == "") continue; if (cmdName == "") continue;
string error = Scripting.Load("Cmd" + cmd.ToLower()); string error = Scripting.Load("Cmd" + cmdName);
if (error != null) { Server.s.Log(error); continue; } if (error != null) { Server.s.Log(error); continue; }
Server.s.Log("AUTOLOAD: Loaded " + cmd.ToLower() + ".dll"); Server.s.Log("AUTOLOAD: Loaded Cmd" + cmdName + ".dll");
} }
} }
@ -149,8 +149,7 @@ namespace MCGalaxy {
/// <param name="command">Name of the command to be loaded (make sure it's prefixed by Cmd before bringing it in here or you'll have problems).</param> /// <param name="command">Name of the command to be loaded (make sure it's prefixed by Cmd before bringing it in here or you'll have problems).</param>
/// <returns>Error string on failure, null on success.</returns> /// <returns>Error string on failure, null on success.</returns>
public static string Load(string command) { public static string Load(string command) {
if (command.Length < 3 || command.Substring(0, 3).ToLower() != "cmd") if (!command.CaselessStarts("cmd")) return "Invalid command name specified.";
return "Invalid command name specified.";
try { try {
byte[] data = File.ReadAllBytes(DllDir + command + ".dll"); byte[] data = File.ReadAllBytes(DllDir + command + ".dll");
Assembly lib = Assembly.Load(data); // TODO: Assembly.LoadFile instead? Assembly lib = Assembly.Load(data); // TODO: Assembly.LoadFile instead?