void cmdEnabled(ConsoleSystem.Arg args) { if (args.Player() != null) { if (!args.Player().IsAdmin() && !permission.UserHasPermission(args.Player().UserIDString, "antilootdespawn.enabled")) { return; } } else { if (!args.CheckPermissions()) { return; } } if (args.HasArgs()) { enabled = (args.Args[0] == "true" ? true : args.Args[0] == "false" ? false : args.Args[0] == "1" ? true : args.Args[0] == "0" ? false : true); Config["enabled"] = enabled; SaveConfig(); } args.ReplyWith($"antilootdespawn.enabled = {enabled}"); }
void cmdMultiplier(ConsoleSystem.Arg args) { if (args.Player() != null) { if (!args.Player().IsAdmin() && !permission.UserHasPermission(args.Player().UserIDString, "antilootdespawn.multiplier")) { return; } } else { if (!args.CheckPermissions()) { return; } } if (args.HasArgs()) { despawnMultiplier = Convert.ToSingle(args.Args[0]); Config["multiplier"] = despawnMultiplier; SaveConfig(); } args.ReplyWith($"antilootdespawn.multiplier = {despawnMultiplier}"); }
void cmdList(ConsoleSystem.Arg args) { if (args.Player() != null) { if (!args.Player().IsAdmin() && !permission.UserHasPermission(args.Player().UserIDString, "antilootdespawn")) { return; } } else { if (!args.CheckPermissions()) { return; } } args.ReplyWith($"antilootdespawn.enabled = {enabled}\nantilootdespawn.multiplier = {despawnMultiplier}"); }
public static void find(ref ConsoleSystem.Arg arg) { string str; if (!arg.HasArgs(1)) { return; } string args = arg.Args[0]; string empty = string.Empty; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < (int)assemblies.Length; i++) { Type[] types = assemblies[i].GetTypes(); for (int j = 0; j < (int)types.Length; j++) { if (types[j].IsSubclassOf(typeof(ConsoleSystem))) { MethodInfo[] methods = types[j].GetMethods(); for (int k = 0; k < (int)methods.Length; k++) { if (methods[k].IsStatic) { if (!(args != "*") || types[j].Name.Contains(args) || methods[k].Name.Contains(args)) { if (arg.CheckPermissions(methods[k].GetCustomAttributes(true))) { str = empty; empty = string.Concat(new string[] { str, types[j].Name, ".", global.BuildMethodString(ref methods[k]), "\n" }); } } } } FieldInfo[] fields = types[j].GetFields(); for (int l = 0; l < (int)fields.Length; l++) { if (fields[l].IsStatic) { if (!(args != "*") || types[j].Name.Contains(args) || fields[l].Name.Contains(args)) { if (arg.CheckPermissions(fields[l].GetCustomAttributes(true))) { str = empty; empty = string.Concat(new string[] { str, types[j].Name, ".", global.BuildFieldsString(ref fields[l]), "\n" }); } } } } PropertyInfo[] properties = types[j].GetProperties(); for (int m = 0; m < (int)properties.Length; m++) { if (!(args != "*") || types[j].Name.Contains(args) || properties[m].Name.Contains(args)) { if (arg.CheckPermissions(properties[m].GetCustomAttributes(true))) { str = empty; empty = string.Concat(new string[] { str, types[j].Name, ".", global.BuildPropertyString(ref properties[m]), "\n" }); } } } } } } arg.ReplyWith(string.Concat("Finding ", args, ":\n", empty)); }
public static void find(ref ConsoleSystem.Arg arg) { if (arg.HasArgs(1)) { string str = arg.Args[0]; string str2 = string.Empty; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Type[] types = assemblies[i].GetTypes(); for (int j = 0; j < types.Length; j++) { if (types[j].IsSubclassOf(typeof(ConsoleSystem))) { string str3; MethodInfo[] methods = types[j].GetMethods(); for (int k = 0; k < methods.Length; k++) { if ((methods[k].IsStatic && (((str == "*") || types[j].Name.Contains(str)) || methods[k].Name.Contains(str))) && arg.CheckPermissions(methods[k].GetCustomAttributes(true))) { str3 = str2; string[] textArray1 = new string[] { str3, types[j].Name, ".", BuildMethodString(ref methods[k]), "\n" }; str2 = string.Concat(textArray1); } } FieldInfo[] fields = types[j].GetFields(); for (int m = 0; m < fields.Length; m++) { if ((fields[m].IsStatic && (((str == "*") || types[j].Name.Contains(str)) || fields[m].Name.Contains(str))) && arg.CheckPermissions(fields[m].GetCustomAttributes(true))) { str3 = str2; string[] textArray2 = new string[] { str3, types[j].Name, ".", BuildFieldsString(ref fields[m]), "\n" }; str2 = string.Concat(textArray2); } } PropertyInfo[] properties = types[j].GetProperties(); for (int n = 0; n < properties.Length; n++) { if ((((str == "*") || types[j].Name.Contains(str)) || properties[n].Name.Contains(str)) && arg.CheckPermissions(properties[n].GetCustomAttributes(true))) { str3 = str2; string[] textArray3 = new string[] { str3, types[j].Name, ".", BuildPropertyString(ref properties[n]), "\n" }; str2 = string.Concat(textArray3); } } } } } arg.ReplyWith("Finding " + str + ":\n" + str2); } }
public static bool RunCommand(ref ConsoleSystem.Arg arg, bool bWantReply = true) { bool flag; Type[] typeArray = ConsoleSystem.FindTypes(arg.Class); if ((int)typeArray.Length == 0) { if (bWantReply) { arg.ReplyWith(string.Concat("Console class not found: ", arg.Class)); } return(false); } if (bWantReply) { arg.ReplyWith(string.Concat(new string[] { "command ", arg.Class, ".", arg.Function, " was executed" })); } Type[] typeArray1 = typeArray; for (int i = 0; i < (int)typeArray1.Length; i++) { Type type = typeArray1[i]; MethodInfo method = type.GetMethod(arg.Function); if (method != null && method.IsStatic) { if (!arg.CheckPermissions(method.GetCustomAttributes(true))) { if (bWantReply) { arg.ReplyWith(string.Concat("No permission: ", arg.Class, ".", arg.Function)); } return(false); } object[] objArray = new ConsoleSystem.Arg[] { arg }; try { method.Invoke(null, objArray); arg = objArray[0] as ConsoleSystem.Arg; return(true); } catch (Exception exception1) { Exception exception = exception1; Debug.LogWarning(string.Concat(new string[] { "Error: ", arg.Class, ".", arg.Function, " - ", exception.Message })); arg.ReplyWith(string.Concat(new string[] { "Error: ", arg.Class, ".", arg.Function, " - ", exception.Message })); flag = false; } return(flag); } FieldInfo field = type.GetField(arg.Function); if (field != null && field.IsStatic) { if (!arg.CheckPermissions(field.GetCustomAttributes(true))) { if (bWantReply) { arg.ReplyWith(string.Concat("No permission: ", arg.Class, ".", arg.Function)); } return(false); } Type fieldType = field.FieldType; if (arg.HasArgs(1)) { try { string str = field.GetValue(null).ToString(); if (fieldType == typeof(float)) { field.SetValue(null, float.Parse(arg.Args[0])); } if (fieldType == typeof(int)) { field.SetValue(null, int.Parse(arg.Args[0])); } if (fieldType == typeof(string)) { field.SetValue(null, arg.Args[0]); } if (fieldType == typeof(bool)) { field.SetValue(null, bool.Parse(arg.Args[0])); } if (bWantReply) { arg.ReplyWith(string.Concat(new string[] { arg.Class, ".", arg.Function, ": changed ", Facepunch.Utility.String.QuoteSafe(str), " to ", Facepunch.Utility.String.QuoteSafe(field.GetValue(null).ToString()), " (", fieldType.Name, ")" })); } } catch (Exception exception2) { if (bWantReply) { arg.ReplyWith(string.Concat("error setting value: ", arg.Class, ".", arg.Function)); } } } else if (bWantReply) { arg.ReplyWith(string.Concat(new string[] { arg.Class, ".", arg.Function, ": ", Facepunch.Utility.String.QuoteSafe(field.GetValue(null).ToString()), " (", fieldType.Name, ")" })); } return(true); } PropertyInfo property = type.GetProperty(arg.Function); if (property != null && property.GetGetMethod().IsStatic&& property.GetSetMethod().IsStatic) { if (!arg.CheckPermissions(property.GetCustomAttributes(true))) { if (bWantReply) { arg.ReplyWith(string.Concat("No permission: ", arg.Class, ".", arg.Function)); } return(false); } Type propertyType = property.PropertyType; if (arg.HasArgs(1)) { try { string str1 = property.GetValue(null, null).ToString(); if (propertyType == typeof(float)) { property.SetValue(null, float.Parse(arg.Args[0]), null); } if (propertyType == typeof(int)) { property.SetValue(null, int.Parse(arg.Args[0]), null); } if (propertyType == typeof(string)) { property.SetValue(null, arg.Args[0], null); } if (propertyType == typeof(bool)) { property.SetValue(null, bool.Parse(arg.Args[0]), null); } if (bWantReply) { arg.ReplyWith(string.Concat(new string[] { arg.Class, ".", arg.Function, ": changed ", Facepunch.Utility.String.QuoteSafe(str1), " to ", Facepunch.Utility.String.QuoteSafe(property.GetValue(null, null).ToString()), " (", propertyType.Name, ")" })); } } catch (Exception exception3) { if (bWantReply) { arg.ReplyWith(string.Concat("error setting value: ", arg.Class, ".", arg.Function)); } } } else if (bWantReply) { arg.ReplyWith(string.Concat(new string[] { arg.Class, ".", arg.Function, ": ", Facepunch.Utility.String.QuoteSafe(property.GetValue(null, null).ToString()), " (", propertyType.Name, ")" })); } return(true); } } if (bWantReply) { arg.ReplyWith(string.Concat("Command not found: ", arg.Class, ".", arg.Function)); } return(false); }