private void Init()
        {
            _instance = this;
            _jsonSettings.NullValueHandling = NullValueHandling.Ignore;
            LoadData();
            RegisterPermissions();
            if (!_config.FeatureTypes.Any(x => x.Value.Enabled))
            {
                PrintWarning("All functions are disabled. Please enable at least one.");
                Interface.Oxide.UnloadPlugin(Name);
                return;
            }

            foreach (var feature in _config.FeatureTypes)
            {
                var value = feature.Value;
                if (value.Enabled && (value.WebhookUrl == null || value.WebhookUrl == "https://support.discordapp.com/hc/en-us/articles/228383668-Intro-to-Webhooks"))
                {
                    value.Enabled = false;
                    PrintWarning($"{feature.Key} was enabled however the Webhook is incorrect.");
                }
            }

            RegisterCommands();
            CheckHooks();
        }
示例#2
0
        private void ProcessConfiguration(BasePlayer player, string type)
        {
            var entityName = type.Contains("cupboard") ? "Tool Cupboard" : (type.Contains("lock") ? "Code Lock" : "Turret");

            if (Configuration.SendToDiscord && DiscordMessages)
            {
                object fields = new[]
                {
                    new
                    {
                        name = "Player", value = $"{player.displayName} ({player.UserIDString})", inline = true
                    },
                    new
                    {
                        name = "Coordinates", value = $"teleportpos {FormattedCoordinates(player)}", inline = true
                    },
                    new
                    {
                        name = "Violation Type", value = $"{entityName}", inline = true
                    }
                };

                DiscordMessages?.Call("API_SendFancyMessage", Configuration.DiscordWebhook,
                                      Configuration.DiscordEmbedTitle, Configuration.DiscordEmbedColor,
                                      JsonConvert.SerializeObject(fields));
            }

            if (Configuration.SendToSlack && Slack)
            {
                Slack.CallHook("Message", Lang("slackMessage")
                               .Replace("{player}", player.displayName)
                               .Replace("{steamID}", player.UserIDString)
                               .Replace("{type}", entityName)
                               .Replace("{coordinates}", FormattedCoordinates(player)));
            }

            if (Configuration.SendToStaff)
            {
                foreach (var target in BasePlayer.activePlayerList.Where(x => x.IsAdmin || HasPermission(x, "grouplimits.notify")))
                {
                    PrintToChat(target, Lang("staffMessage")
                                .Replace("{player}", player.displayName)
                                .Replace("{steamID}", player.UserIDString)
                                .Replace("{type}", entityName)
                                .Replace("{coordinates}", FormattedCoordinates(player)));
                }
            }

            if (!Configuration.WarnPlayers)
            {
                return;
            }

            PrintToChat(player, Lang("playerMessage").Replace("{limit}", Configuration.MaxPlayers.ToString()));
        }
示例#3
0
        private void Notify(MessageWrapper messageWrapper)
        {
            if (GetConfig(false, "Settings", "Use PushAPI"))
            {
                PushAPI?.Call("PushMessage", "Plugin Update Notification", messageWrapper.GetNoFormatting());
            }

            if (GetConfig(false, "Settings", "Use EmailAPI"))
            {
                EmailAPI?.Call("EmailMessage", "Plugin Update Notification", messageWrapper.GetNoFormatting());
            }

            if (GetConfig(false, "Settings", "Use DiscordMessages") && !string.IsNullOrEmpty(GetConfig("", "Settings", "Discord Webhook")))
            {
                DiscordMessages?.Call("API_SendFancyMessage", GetConfig("", "Settings", "Discord Webhook"), messageWrapper.GetDiscordTitle(), messageWrapper.GetDiscordMessages(), null, messageWrapper.GetColourEmbed());
            }
        }
示例#4
0
        private void ProcessBan(IPlayer player, JObject clan, string reason)
        {
            string reason1 = "CLAN BAN (" + clan["tag"] + ") : " + reason;

            foreach (var member in clan["members"])
            {
                var target = covalence.Players.FindPlayerById(Convert.ToString(member));
                if (type == 1)
                {
                    EnhancedBanSystem.Call("BanPlayer", player.Name, target, reason1, 0.0);
                }
                if (type == 2)
                {
                    var exists = ServerUsers.Get(ulong.Parse(target.Id));
                    if (exists != null && ServerUsers.Get(ulong.Parse(target.Id)).group == ServerUsers.UserGroup.Banned)
                    {
                        SendMessage(player, GetLang("AlreadyBanned", player.Id, target.Name));
                        return;
                    }
                    ServerUsers.Set(ulong.Parse(target.Id), ServerUsers.UserGroup.Banned, target.Name, reason1);
                    ServerUsers.Save();
                    server.Broadcast(GetLang("PlayerBanned", null, target.Name, reason));
                    if (target.IsConnected)
                    {
                        target.Kick(reason);
                    }
                }
                if (type == 3)
                {
                    DiscordMessages.Call("ExecuteBan", target, player, reason1);
                }
            }
            if (AnnounceToServer)
            {
                server.Broadcast(GetLang("BanMessage", null, clan["tag"], reason));
            }
        }
 private void Unload()
 {
     SaveData();
     _instance = null;
 }