using Oxide.Core; using System.Collections.Generic; using Newtonsoft.Json; namespace Oxide.Plugins { [Info("PermAdder", "RoadTech", "1.0.0")] class PermAdder : RustPlugin { private ConfigData configData; private class ConfigData { [JsonProperty(PropertyName = "Permissions")] public List Permissions { get; set; } } private void Init() { configData = Config.ReadObject(); if (configData == null) { LoadDefaultConfig(); } foreach(var perm in configData.Permissions) { permission.RegisterPermission(perm, this); } } protected override void LoadDefaultConfig() { ConfigData defaultConfig = new ConfigData { Permissions = new List { } }; Config.WriteObject(defaultConfig, true); } [ChatCommand("addperm")] private void AddPermissionCommand(BasePlayer player, string command, string[] args) { if (args.Length < 1) { PrintToChat(player, "Usage: /addperm [permission]"); return; } string permName = "permadder." + args[0]; if (!permission.PermissionExists(permName, this)) { configData.Permissions.Add(permName); permission.RegisterPermission(permName, this); Config.WriteObject(configData, true); PrintToChat(player, $"Permission '{permName}' has been added."); } else { PrintToChat(player, $"Permission '{permName}' already exists."); } } [ChatCommand("removeperm")] private void RemovePermissionCommand(BasePlayer player, string command, string[] args) { if (args.Length < 1) { PrintToChat(player, "Usage: /removeperm [permission]"); return; } string permName = "permadder." + args[0]; if (permission.PermissionExists(permName, this)) { configData.Permissions.Remove(permName); permission.RevokeGroupPermission("default", permName); Config.WriteObject(configData, true); PrintToChat(player, $"Permission '{permName}' has been removed."); } else { PrintToChat(player, $"Permission '{permName}' does not exist."); } } } }