public static async Task <bool> IsBanned(string userID, bool ipcheck)
        {
            using (HttpClient client = new HttpClient())
            {
                string ipcheckstatus = "UID";
                if (ipcheck)
                {
                    ipcheckstatus = "IP";
                }
                var webRequest = await client.GetAsync("https://bans.kingsplayground.fun/bancheck.php?KEY=" + Plugin.APIKey + "&STEAMID=" + userID + "&TYPE=" + ipcheckstatus);

                if (!webRequest.IsSuccessStatusCode)
                {
                    Log.Error("Web API connection error in IsBanned(): " + webRequest.StatusCode + " - " + webRequest.Content.ReadAsStringAsync());
                    return(false);
                }

                string apiResponse = await webRequest.Content.ReadAsStringAsync();

                if (apiResponse.Contains("OK"))
                {
                    return(false);
                }
                else if (apiResponse.Contains("BAN"))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
        public static async Task <bool> IssueBan(string userID, string userName, string adminID, string durationinseconds, BanHandler.BanType type)
        {
            using (HttpClient client = new HttpClient())
            {
                string typeofban = "-1";
                if (type == BanHandler.BanType.UserId)
                {
                    typeofban = "0";
                }
                else if (type == BanHandler.BanType.IP)
                {
                    typeofban = "1";
                }
                var webRequest = await client.GetAsync("https://bans.kingsplayground.fun/issueban.php?KEY=" + Plugin.APIKey + "&STEAMID=" + userID + "&USERNAME="******"&AID=" + adminID + "&TYPE=" + typeofban + "&DURATION=" + durationinseconds);

                if (!webRequest.IsSuccessStatusCode)
                {
                    Log.Error("Web API connection error in IssueBan(): " + webRequest.StatusCode + " - " + webRequest.Content.ReadAsStringAsync());
                    return(false);
                }

                string apiResponse = await webRequest.Content.ReadAsStringAsync();

                if (apiResponse.Contains("OK"))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Пример #3
0
 public void DoorInteract(ref DoorInteractionEvent ev)
 {
     try {
         if (ev.Player.GetRole() == RoleType.Scp0492 && ev.Door.doorType == 2 && !ev.Door.Networklocked)
         {
             if ((!plugin.canClose && ev.Door.NetworkisOpen) ||
                 (plugin.griefProtection && ev.Door.DoorName.StartsWith("106")))
             {
                 return;
             }
             int  amount = 0;
             Door d      = ev.Door;
             foreach (ReferenceHub hub in Player.GetHubs(RoleType.Scp0492))
             {
                 if (Vector3.Distance(d.transform.position, hub.GetPosition()) <= plugin.distanceNeeded)
                 {
                     amount++;
                 }
             }
             if (amount >= plugin.amountNeeded)
             {
                 ev.Allow = true;
                 if (plugin.currentMode != Mode.OPEN && !ev.Door.NetworkisOpen && plugin.canClose)
                 {
                     d.DestroyDoor(plugin.currentMode == Mode.LOCK_BREAK);
                     if (plugin.forceDestroy)
                     {
                         d.destroyed        = true;
                         d.Networkdestroyed = true;
                         return;
                     }
                     Timing.CallDelayed(0.5f, () => {
                         d.Networklocked = true;
                         d.locked        = true;
                     });
                     if (plugin.unlockLater)
                     {
                         Timing.CallDelayed(plugin.unlockAfter, () => {
                             d.Networklocked = false;
                             d.locked        = false;
                         });
                     }
                 }
             }
             else
             {
                 if (plugin.neededBroadcastDuration <= 0)
                 {
                     ev.Player.ClearBroadcasts();
                     ev.Player.Broadcast(plugin.neededBroadcastDuration, plugin.neededBroadcast.Replace("%amount", $"{plugin.amountNeeded - amount}"), false);
                 }
             }
         }
     } catch (Exception e) {
         Log.Error("ZDB DoorInteract error: " + e.StackTrace);
     }
 }
Пример #4
0
 public void OnCommand(ref RACommandEvent ev)
 {
     try {
         if (ev.Command.Contains("REQUEST_DATA PLAYER_LIST SILENT"))
         {
             return;
         }
         string[]     args   = ev.Command.ToLower().Split(' ');
         ReferenceHub sender = ev.Sender.SenderId == "SERVER CONSOLE" || ev.Sender.SenderId == "GAME CONSOLE" ? Player.GetPlayer(PlayerManager.localPlayer) : Player.GetPlayer(ev.Sender.SenderId);
         if (args[0] == "zdb")
         {
             ev.Allow = false;
             if (!sender.CheckPermission("command"))
             {
                 ev.Sender.RAMessage("<color=red>Access denied.</color>");
                 return;
             }
             if (args.Length > 1)
             {
                 if (args[1] == "toggle")
                 {
                     plugin.IsEnabled = !plugin.IsEnabled;
                     if (plugin.IsEnabled)
                     {
                         plugin.Register();
                     }
                     else
                     {
                         plugin.Unregister();
                     }
                     Plugin.Config.SetString("zdb_toggle", plugin.IsEnabled.ToString());
                     plugin.ReloadConfig();
                     ev.Sender.RAMessage("zdb_toggle has now been set to: " + plugin.IsEnabled.ToString());
                     return;
                 }
                 else if (args[1] == "reload")
                 {
                     plugin.ReloadConfig();
                     ev.Sender.RAMessage("<color=green>Configuration values have been reloaded.</color>");
                     return;
                 }
             }
             ev.Sender.RAMessage("Try using \"zdb <toggle/reload>\"");
             return;
         }
         return;
     } catch (Exception e) {
         Log.Error("Command error: " + e.StackTrace);
     }
 }
        public static async Task <string> GetAdminRole(string userID)
        {
            using (HttpClient client = new HttpClient())
            {
                var webRequest = await client.GetAsync("https://bans.kingsplayground.fun/admincheck.php?KEY=" + Plugin.APIKey + "&STEAMID=" + userID);

                if (!webRequest.IsSuccessStatusCode)
                {
                    Log.Error("Web API connection error in GetAdminRole(): " + webRequest.StatusCode + " - " + webRequest.Content.ReadAsStringAsync());
                    return("");
                }

                string apiResponse = await webRequest.Content.ReadAsStringAsync();

                return(apiResponse);
            }
        }
        public static async Task <bool> UpdatePlaytime(string userID, long connecttime, long disconnecttime, int serverport)
        {
            using (HttpClient client = new HttpClient())
            {
                var webRequest = await client.GetAsync("https://bans.kingsplayground.fun/playtime.php?KEY=" + Plugin.APIKey + "&STEAMID=" + userID + "&CONNECT=" + connecttime + "&DISCONNECT=" + disconnecttime + "&PORT=" + serverport);

                if (!webRequest.IsSuccessStatusCode)
                {
                    Log.Error("Web API connection error in UpdatePlaytime(): " + webRequest.StatusCode + " - " + webRequest.Content.ReadAsStringAsync());
                    return(false);
                }

                string apiResponse = await webRequest.Content.ReadAsStringAsync();

                Log.Debug($"[Playtime] The player API returned: {apiResponse}");
                return(true);
            }
        }
Пример #7
0
        public void OnCommand(ref RACommandEvent ev)
        {
            try {
                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);
                if (args [0].ToLower() == "lights_reload")
                {
                    ev.Allow = false;
                    if (!checkPermission(ev, sender, "reload"))
                    {
                        ev.Sender.RAMessage(plugin.AccessDenied);
                        return;
                    }
                    plugin.reloadConfig();
                    ev.Sender.RAMessage("<color=red>Configuration variables reloaded.</color>");
                    return;
                }

                #region Command: Lights
                if (args [0].ToLower() == plugin.CmdName || args [0].ToLower() == plugin.CmdAlias)
                {
                    ev.Allow = false;
                    if (!checkPermission(ev, sender, "light"))
                    {
                        ev.Sender.RAMessage(plugin.AccessDenied);
                        return;
                    }
                    if (args.Length < 2)
                    {
                        ev.Sender.RAMessage(plugin.HelpOne.Replace("%cmd", args [0]));
                        ev.Sender.RAMessage(plugin.HelpTwo);
                        return;
                    }
                    else if (args.Length >= 2)
                    {
                        if (!args [1].All(char.IsDigit))
                        {
                            ev.Sender.RAMessage(plugin.HelpOne.Replace("%cmd", args [0]));
                            ev.Sender.RAMessage(plugin.HelpTwo);
                            return;
                        }
                        bool OnlyHCZ = false;
                        if (args.Length >= 3)
                        {
                            string [] _t = plugin.TrueArguments.Split(',');
                            if (_t.Contains(args[2].ToLower()))
                            {
                                OnlyHCZ = true;
                            }
                            else
                            {
                                ev.Sender.RAMessage(plugin.NotRecognized.Replace("%arg", args [2]));
                            }
                        }
                        ev.Sender.RAMessage(plugin.Success.Replace("%s", args [1]).Replace("%value", OnlyHCZ + ""));
                        if (plugin.DoAnnouncement)
                        {
                            foreach (ReferenceHub h in Player.GetHubs())
                            {
                                h.Broadcast(plugin.AnnounceDuration, plugin.Announcement.Replace("%player", ev.Sender.Nickname).Replace("%s", args[1]));
                            }
                        }

                        if (OnlyHCZ && plugin.CassieAnnounceHCZ)
                        {
                            plugin.cassieMessage(plugin.CassieAnnouncement);
                        }
                        else if (!OnlyHCZ && plugin.CassieAnnounceBoth)
                        {
                            plugin.cassieMessage(plugin.CassieAnnouncementBoth);
                        }
                        lightsOff(float.Parse(args [1]), OnlyHCZ);
                        return;
                    }
                    return;
                }
                #endregion
                return;
            } catch (Exception e) {
                Log.Error("Command error: " + e.StackTrace);
            }
        }
Пример #8
0
        public void LoadTranslation()
        {
            string appData                   = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string pluginsPath               = Path.Combine(appData, "Plugins");
            string configPath                = Path.Combine(pluginsPath, "Integration");
            string translationFileName       = Path.Combine(configPath, "translations.json");
            string translationBackupFileName = Path.Combine(configPath, "translations_backup.json");

            if (!Directory.Exists(configPath))
            {
                Directory.CreateDirectory(configPath);
            }

            if (!File.Exists(translationFileName))
            {
                string defaults = JObject.FromObject(translation).ToString();

                File.WriteAllText(translationFileName, defaults);
                return;
            }

            string  fileText = File.ReadAllText(translationFileName);
            JObject o;

            try
            {
                o = JObject.Parse(fileText);
            }
            catch (Exception e)
            {
                Log.Info("Invalid or corrupted translation file, creating backup and overwriting.");
                Log.Error(e.Message);

                string json = JObject.FromObject(translation).ToString();

                File.Copy(translationFileName, translationBackupFileName, true);

                File.WriteAllText(translationFileName, json);
                return;
            }

            JsonSerializer j = new JsonSerializer();

            j.Error += Json_Error;

            try
            {
                translation = o.ToObject <Translation>(j);
            }
            catch (Exception e)
            {
                Log.Info("Invalid or corrupted translation file, creating backup and overwriting.");
                Log.Error(e.Message);
                refreshTranslationFile = true;
            }

            if (refreshTranslationFile)
            {
                string json = JObject.FromObject(translation).ToString();

                Log.Info("Invalid or missing translation element detected fixing: " + string.Join(", ", propertyNames) + ".");

                File.Copy(translationFileName, translationBackupFileName, true);

                File.WriteAllText(translationFileName, json);
                return;
            }
        }
Пример #9
0
        public void OnCommand(ref RACommandEvent ev)
        {
            try {
                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);
                if (args [0].ToLower() == "lightsconfig")
                {
                    ev.Allow = false;
                    if (!checkPermission(ev, sender, "config"))
                    {
                        ev.Sender.RAMessage(plugin.AccessDenied);
                        return;
                    }
                    if (args.Length >= 2)
                    {
                        if (args[1].ToLower() == "set")
                        {
                            if (!checkPermission(ev, sender, "set"))
                            {
                                return;
                            }
                            if (args.Length >= 4)
                            {
                                if (args[2].ToLower().StartsWith("lights_"))
                                {
                                    Plugin.Config.SetString(args[2].ToLower(), ev.Command.Substring(ev.Command.LastIndexOf(args[3])));
                                    ev.Sender.RAMessage($"<color=yellow>{args[2].ToLower()}</color> <color=green>has been set to:</color> <color=yellow>{args[3]}</color><color=green>.</color>");
                                    return;
                                }
                            }
                        }
                        else if (args[1].ToLower() == "reload")
                        {
                            if (!checkPermission(ev, sender, "reload"))
                            {
                                return;
                            }
                            plugin.reloadConfig();
                            ev.Sender.RAMessage("<color=green>Configuration variables reloaded.</color>");
                            return;
                        }
                        else if (args[1].ToLower() == "variables")
                        {
                            ev.Sender.RAMessage(
                                "<color=red>Each color shows the type of each variable.</color>\n" +
                                "<color=yellow>String</color> - <color=green>Integer</color> - <color=red>Float</color> - <color=#ff00ffff>Boolean</color>\n" +
                                "<color=yellow>lights_command -</color>" +
                                "<color=yellow>lights_alias -</color>" +
                                "<color=yellow>lights_true_arguments -</color>" +
                                "<color=#ff00ffff>lights_announce -</color>" +
                                "<color=green>lights_announce_duration -</color>" +
                                "<color=yellow>lights_announce_text -</color>" +
                                "<color=yellow>lights_message_access_denied -</color>" +
                                "<color=yellow>lights_message_help -</color>" +
                                "<color=yellow>lights_message_not_recognized -</color>" +
                                "<color=yellow>lights_message_success -</color>" +
                                "<color=yellow>lights_cassie_announcement_hcz -</color>" +
                                "<color=yellow>lights_cassie_announcement_both -</color>" +
                                "<color=#ff00ffff>lights_cassie_announceforhcz -</color>" +
                                "<color=#ff00ffff>lights_cassie_announceforboth -</color>" +
                                "<color=#ff00ffff>lights_cassie_makenoise -</color>" +
                                "<color=#ff00ffff>lights_startblackout_toggle -</color>" +
                                "<color=red>lights_startblackout_delay_max -</color>" +
                                "<color=red>lights_startblackout_delay_min -</color>" +
                                "<color=#ff00ffff>lights_multipleblackout_toggle -</color>" +
                                "<color=red>lights_multipleblackout_duration_max -</color>" +
                                "<color=red>lights_multipleblackout_duration_min -</color>" +
                                "<color=red>lights_multipleblackout_timebetween_max -</color>" +
                                "<color=red>lights_multipleblackout_timebetween_min -</color>" +
                                "<color=green>lights_multipleblackout_maxamount -</color>" +
                                "<color=yellow>lights_cassie_announcement_auto -</color>" +
                                "<color=#ff00ffff>lights_cassie_announceauto</color>");
                            return;
                        }
                    }
                    ev.Sender.RAMessage("<color=red>Please try one of the following:</color> " +
                                        "\n<color=#f29f05>\"lightsconfig set <config_variable> <value>\" -> Change the value of a config variable of the plugin.</color>" +
                                        "\n<color=#f29f05>\"lightsconfig variables\" -> Gives you a list of all variables available.</color>" +
                                        "\n<color=#f29f05>\"lightsconfig reload\" -> Reloads config variables.</color>");
                    return;
                }

                #region Command: Lights
                if (args [0].ToLower() == plugin.CmdName || args [0].ToLower() == plugin.CmdAlias)
                {
                    ev.Allow = false;
                    if (!checkPermission(ev, sender, "light"))
                    {
                        ev.Sender.RAMessage(plugin.AccessDenied);
                        return;
                    }
                    if (args.Length < 2)
                    {
                        ev.Sender.RAMessage(plugin.HelpMessage.Replace("%cmd", args [0]));
                        return;
                    }
                    else if (args.Length >= 2)
                    {
                        if (!args [1].All(char.IsDigit))
                        {
                            ev.Sender.RAMessage(plugin.HelpMessage.Replace("%cmd", args [0]));
                            return;
                        }
                        bool OnlyHCZ = false;
                        if (args.Length >= 3)
                        {
                            string [] _t = plugin.TrueArguments.Split(',');
                            if (_t.Contains(args[2].ToLower()))
                            {
                                OnlyHCZ = true;
                            }
                            else
                            {
                                ev.Sender.RAMessage(plugin.NotRecognized.Replace("%arg", args [2]));
                            }
                        }
                        ev.Sender.RAMessage(plugin.Success.Replace("%s", args [1]).Replace("%value", OnlyHCZ + ""));
                        if (plugin.DoAnnouncement)
                        {
                            foreach (ReferenceHub h in Player.GetHubs())
                            {
                                h.Broadcast(plugin.AnnounceDuration, plugin.Announcement.Replace("%player", ev.Sender.Nickname).Replace("%s", args[1]));
                            }
                        }

                        if (OnlyHCZ && plugin.CassieAnnounceHCZ)
                        {
                            plugin.cassieMessage(plugin.CassieAnnouncement);
                        }
                        else if (!OnlyHCZ && plugin.CassieAnnounceBoth)
                        {
                            plugin.cassieMessage(plugin.CassieAnnouncementBoth);
                        }
                        lightsOff(float.Parse(args [1]), OnlyHCZ);
                        return;
                    }
                    return;
                }
                #endregion
                return;
            } catch (Exception e) {
                Log.Error("Command error: " + e.StackTrace);
            }
        }