예제 #1
0
        public static void InvokeCommand(ref string query, ref CommandSender sender, ref bool allow)
        {
            if (RemoteAdminCommandEvent == null)
            {
                return;
            }

            RACommandEvent ev = new RACommandEvent()
            {
                Allow   = allow,
                Command = query,
                Sender  = sender
            };

            RemoteAdminCommandEvent.Invoke(ref ev);

            query  = ev.Command;
            sender = ev.Sender;
            allow  = ev.Allow;

            lock (lockObject)
            {
                File.AppendAllText(PluginManager.LogsPath, $"[{DateTime.Now}] {sender.Nickname} ({sender.SenderId}) ran command: {query}. Command Permitted: {allow}" + Environment.NewLine);
            }
        }
예제 #2
0
        //Do not use this as plugin command handler, this is only meant to handle the EXILED reload command, handle commands similarly from within your plugin.
        public static void CommandHandler(ref RACommandEvent ev)
        {
            string[] args = ev.Command.Split(' ');

            switch (args[0].ToLower())
            {
            case "reloadplugins":
                ev.Allow = false;
                PluginManager.ReloadPlugins();
                ev.Sender.RAMessage("Reloading ploogins...");
                break;

            case "reloadconfigs":
                ev.Allow = false;
                Plugin.Config.Reload();
                ev.Sender.RAMessage("Configs have been reloaded!");
                break;

            case "reconnectrs":
                ev.Allow = false;
                PlayerManager.localPlayer.GetComponent <PlayerStats>()?.Roundrestart();
                Timing.CallDelayed(1.5f, Application.Quit);
                break;
            }
        }
예제 #3
0
        public static void InvokeCommand(ref string query, ref CommandSender sender, ref bool allow)
        {
            OnCommand adminCommandEvent = RemoteAdminCommandEvent;

            if (adminCommandEvent == null)
            {
                return;
            }

            RACommandEvent ev = new RACommandEvent()
            {
                Allow   = allow,
                Command = query,
                Sender  = sender
            };

            adminCommandEvent?.Invoke(ref ev);
            query  = ev.Command;
            sender = ev.Sender;
            allow  = ev.Allow;
        }
예제 #4
0
        public static void RemoteAdminCommandEvent(ref RACommandEvent ev)
        {
            if (ev.Command.Contains("REQUEST_DATA PLAYER_LIST SILENT"))
            {
                return;
            }
            string[]     args   = ev.Command.Split(' ');
            ReferenceHub sender = ev.Sender.SenderId == "SERVER CONSOLE" || ev.Sender.SenderId == "GAME CONSOLE" ? Player.GetPlayer(PlayerManager.localPlayer) : Player.GetPlayer(ev.Sender.SenderId);

            switch (args[0].ToLower())
            {
            case "ep":
                ev.Allow = false;
                if (!sender.CheckPermission("ep.use"))
                {
                    ev.Sender.RaReply("ExiledPermissions#No permission.", true, true, string.Empty);
                    return;
                }
                if (args.Length == 1)
                {
                    ev.Sender.RaReply("ExiledPermissions#Commands:", true, true, string.Empty);
                    ev.Sender.RaReply("ExiledPermissions# - EP RELOAD - Reload permissions.", true, true, string.Empty);
                    ev.Sender.RaReply("ExiledPermissions# - EP ADDGROUP <NAME> - Add group.", true, true, string.Empty);
                    ev.Sender.RaReply("ExiledPermissions# - EP REMOVEGROUP <NAME> - Remove group.", true, true, string.Empty);
                    ev.Sender.RaReply("ExiledPermissions# - EP GROUP <NAME> ADD/REMOVE <PERMISSION> - Add/remove permission from group.", true, true, string.Empty);
                    return;
                }
                else if (args.Length > 1)
                {
                    switch (args[1].ToLower())
                    {
                    case "reload":
                        if (!sender.CheckPermission("ep.reload"))
                        {
                            ev.Sender.RaReply("ExiledPermissions#No permission.", true, true, string.Empty);
                            return;
                        }
                        PermissionPlugin.ReloadPermissions();
                        ev.Sender.RaReply("ExiledPermissions#Plugin reloaded.", true, true, string.Empty);
                        return;

                    case "addgroup":
                        if (!sender.CheckPermission("ep.addgroup"))
                        {
                            ev.Sender.RaReply("ExiledPermissions#No permission.", true, true, string.Empty);
                            return;
                        }
                        if (args.Length > 2)
                        {
                            PermissionPlugin.ReloadPermissions();
                            if (PermissionPlugin.permissionsconfig.groups.ContainsKey(args[2]))
                            {
                                ev.Sender.RaReply("ExiledPermissions#Group " + args[2] + " already exists.", true, true, string.Empty);
                                return;
                            }
                            PermissionPlugin.permissionsconfig.groups.Add(args[2], new PermissionPlugin.Group());
                            PermissionPlugin.SavePermissions();
                            ev.Sender.RaReply("ExiledPermissions#Group " + args[2] + " has been added.", true, true, string.Empty);
                        }
                        else
                        {
                            ev.Sender.RaReply("ExiledPermissions#EP ADDGROUP <NAME>", true, true, string.Empty);
                        }
                        return;

                    case "removegroup":
                        if (!sender.CheckPermission("ep.removegroup"))
                        {
                            ev.Sender.RaReply("ExiledPermissions#No permission.", true, true, string.Empty);
                            return;
                        }
                        if (args.Length > 2)
                        {
                            PermissionPlugin.ReloadPermissions();
                            if (!PermissionPlugin.permissionsconfig.groups.ContainsKey(args[2]))
                            {
                                ev.Sender.RaReply("ExiledPermissions#Group " + args[2] + " does not exist.", true, true, string.Empty);
                                return;
                            }
                            PermissionPlugin.permissionsconfig.groups.Remove(args[2]);
                            PermissionPlugin.SavePermissions();
                            ev.Sender.RaReply("ExiledPermissions#Group " + args[2] + " removed.", true, true, string.Empty);
                        }
                        else
                        {
                            ev.Sender.RaReply("ExiledPermissions#EP REMOVEGROUP <NAME>", true, true, string.Empty);
                        }
                        return;

                    case "group":
                        if (!sender.CheckPermission("ep.group"))
                        {
                            ev.Sender.RaReply("ExiledPermissions#No permission.", true, true, string.Empty);
                            return;
                        }
                        if (args.Length > 3)
                        {
                            switch (args[3].ToLower())
                            {
                            case "add":
                                if (!sender.CheckPermission("ep.addpermission"))
                                {
                                    ev.Sender.RaReply("ExiledPermissions#No permission.", true, true, string.Empty);
                                    return;
                                }
                                if (args.Length == 4)
                                {
                                    ev.Sender.RaReply("ExiledPermissions#EP GROUP <NAME> ADD <PERMISSION>", true, true, string.Empty);
                                    return;
                                }
                                PermissionPlugin.ReloadPermissions();
                                if (!PermissionPlugin.permissionsconfig.groups.ContainsKey(args[2]))
                                {
                                    ev.Sender.RaReply("ExiledPermissions#Group " + args[2] + " does not exist.", true, true, string.Empty);
                                    return;
                                }
                                PermissionPlugin.permissionsconfig.groups.TryGetValue(args[2], out PermissionPlugin.Group val);
                                if (!val.permissions.Contains(args[4]))
                                {
                                    val.permissions.Add(args[4]);
                                }
                                PermissionPlugin.SavePermissions();
                                ev.Sender.RaReply("ExiledPermissions#Permission " + args[4] + " for group " + args[2] + " added.", true, true, string.Empty);
                                return;

                            case "remove":
                                if (!sender.CheckPermission("ep.removepermission"))
                                {
                                    ev.Sender.RaReply("ExiledPermissions#No permission.", true, true, string.Empty);
                                    return;
                                }
                                if (args.Length == 4)
                                {
                                    ev.Sender.RaReply("ExiledPermissions#EP GROUP <NAME> REMOVE <PERMISSION>", true, true, string.Empty);
                                    return;
                                }
                                PermissionPlugin.ReloadPermissions();
                                if (!PermissionPlugin.permissionsconfig.groups.ContainsKey(args[2]))
                                {
                                    ev.Sender.RaReply("ExiledPermissions#Group " + args[2] + " does not exist.", true, true, string.Empty);
                                    return;
                                }
                                PermissionPlugin.permissionsconfig.groups.TryGetValue(args[2], out PermissionPlugin.Group val2);
                                if (val2.permissions.Contains(args[4]))
                                {
                                    val2.permissions.Remove(args[4]);
                                }
                                PermissionPlugin.SavePermissions();
                                ev.Sender.RaReply("ExiledPermissions#Permission " + args[4] + " for group " + args[2] + " removed.", true, true, string.Empty);
                                return;
                            }
                        }
                        else if (args.Length > 2)
                        {
                            if (!PermissionPlugin.permissionsconfig.groups.ContainsKey(args[2]))
                            {
                                ev.Sender.RaReply("ExiledPermissions#Group " + args[2] + " does not exist.", true, true, string.Empty);
                                return;
                            }
                            PermissionPlugin.permissionsconfig.groups.TryGetValue(args[2], out PermissionPlugin.Group val2);
                            ev.Sender.RaReply("ExiledPermissions#Group: " + args[2], true, true, string.Empty);
                            ev.Sender.RaReply("ExiledPermissions# Default: " + val2.Default, true, true, string.Empty);
                            if (val2.inheritance.Count != 0)
                            {
                                ev.Sender.RaReply("ExiledPermissions# Inheritance: ", true, true, string.Empty);
                                foreach (string per in val2.inheritance)
                                {
                                    ev.Sender.RaReply("ExiledPermissions# - " + per, true, true, string.Empty);
                                }
                            }
                            if (val2.permissions.Count != 0)
                            {
                                ev.Sender.RaReply("ExiledPermissions# Permissions: ", true, true, string.Empty);
                                foreach (string per in val2.permissions)
                                {
                                    ev.Sender.RaReply("ExiledPermissions# - " + per, true, true, string.Empty);
                                }
                            }
                        }
                        else
                        {
                            ev.Sender.RaReply("ExiledPermissions#EP GROUP <NAME>", true, true, string.Empty);
                            ev.Sender.RaReply("ExiledPermissions#EP GROUP <NAME> ADD/REMOVE <PERMISSION>", true, true, string.Empty);
                        }
                        return;

                    default:
                        ev.Sender.RaReply("ExiledPermissions#Commands:", true, true, string.Empty);
                        ev.Sender.RaReply("ExiledPermissions# - EP RELOAD - Reload permissions.", true, true, string.Empty);
                        ev.Sender.RaReply("ExiledPermissions# - EP ADDGROUP <NAME> - Add group.", true, true, string.Empty);
                        ev.Sender.RaReply("ExiledPermissions# - EP REMOVEGROUP <NAME> - Remove group.", true, true, string.Empty);
                        ev.Sender.RaReply("ExiledPermissions# - EP GROUP <NAME> - Info about group.", true, true, string.Empty);
                        ev.Sender.RaReply("ExiledPermissions# - EP GROUP <NAME> ADD/REMOVE <PERMISSION> - Add/remove permission from group.", true, true, string.Empty);
                        return;
                    }
                }
                break;
            }
        }