コード例 #1
0
 protected override void Load()
 {
     Instance = this;
     Database = new DatabaseManager();
     UnturnedPermissions.OnJoinRequested += Events_OnJoinRequested;
     U.Events.OnPlayerConnected          += RocketServerEvents_OnPlayerConnected;
 }
コード例 #2
0
        public void Execute(IRocketPlayer caller, params string[] command)
        {
            SteamPlayer   otherSteamPlayer = null;
            SteamPlayerID steamPlayerID    = null;

            if (command.Length == 0 || command.Length > 2)
            {
                UnturnedChat.Say(caller, GlobalBan.Instance.Translate("command_generic_invalid_parameter"));
                return;
            }

            var      isOnline = false;
            CSteamID steamid;
            string   charactername = null;

            if (!PlayerTool.tryGetSteamPlayer(command[0], out otherSteamPlayer))
            {
                var player = GlobalBan.GetPlayer(command[0]);
                if (player.Key != null)
                {
                    steamid       = player.Key;
                    charactername = player.Value;
                }
                else
                {
                    UnturnedChat.Say(caller, GlobalBan.Instance.Translate("command_generic_player_not_found"));
                    return;
                }
            }
            else
            {
                isOnline      = true;
                steamid       = otherSteamPlayer.playerID.steamID;
                charactername = otherSteamPlayer.playerID.characterName;
            }

            if (command.Length >= 2)
            {
                GlobalBan.Instance.Database.BanPlayer(charactername, steamid.ToString(), caller.DisplayName, command[1],
                                                      31536000);
                UnturnedChat.Say(GlobalBan.Instance.Translate("command_ban_public_reason", charactername, command[1]));
                if (isOnline)
                {
                    Provider.kick(steamPlayerID.steamID, command[1]);
                }
            }
            else
            {
                GlobalBan.Instance.Database.BanPlayer(charactername, steamid.ToString(), caller.DisplayName, "",
                                                      31536000);
                UnturnedChat.Say(GlobalBan.Instance.Translate("command_ban_public", charactername));
                if (isOnline)
                {
                    Provider.kick(steamPlayerID.steamID,
                                  GlobalBan.Instance.Translate("command_ban_private_default_reason"));
                }
            }
        }
コード例 #3
0
        public void Execute(IRocketPlayer caller, params string[] command)
        {
            try
            {
                if (command.Length == 0 || command.Length > 3)
                {
                    UnturnedChat.Say(caller, GlobalBan.Instance.Translate("command_generic_invalid_parameter"));
                    return;
                }

                var isOnline = false;

                CSteamID steamid;
                string   charactername = null;


                var otherPlayer   = UnturnedPlayer.FromName(command[0]);
                var otherPlayerID = command.GetCSteamIDParameter(0);
                if (otherPlayer == null || otherPlayer.CSteamID.ToString() == "0" ||
                    caller != null && otherPlayer.CSteamID.ToString() == caller.Id)
                {
                    var player = GlobalBan.GetPlayer(command[0]);
                    if (player.Key.ToString() != "0")
                    {
                        steamid       = player.Key;
                        charactername = player.Value;
                    }
                    else
                    {
                        if (otherPlayerID != null)
                        {
                            steamid = new CSteamID(otherPlayerID.Value);
                            var playerProfile = new Profile(otherPlayerID.Value);
                            charactername = playerProfile.SteamID;
                        }
                        else
                        {
                            UnturnedChat.Say(caller, GlobalBan.Instance.Translate("command_generic_player_not_found"));
                            return;
                        }
                    }
                }
                else
                {
                    isOnline      = true;
                    steamid       = otherPlayer.CSteamID;
                    charactername = otherPlayer.CharacterName;
                }

                var adminName = "Console";
                if (caller != null)
                {
                    adminName = caller.ToString();
                }

                if (command.Length == 3)
                {
                    var duration = 0;
                    if (int.TryParse(command[2], out duration))
                    {
                        GlobalBan.Instance.Database.BanPlayer(charactername, steamid.ToString(), adminName, command[1],
                                                              duration);
                        UnturnedChat.Say(GlobalBan.Instance.Translate("command_ban_public_reason", charactername,
                                                                      command[1]));
                        if (isOnline)
                        {
                            Provider.kick(steamid, command[1]);
                        }
                    }
                    else
                    {
                        UnturnedChat.Say(caller, GlobalBan.Instance.Translate("command_generic_invalid_parameter"));
                        return;
                    }
                }
                else if (command.Length == 2)
                {
                    GlobalBan.Instance.Database.BanPlayer(charactername, steamid.ToString(), adminName, command[1], 0);
                    UnturnedChat.Say(GlobalBan.Instance.Translate("command_ban_public_reason", charactername,
                                                                  command[1]));
                    if (isOnline)
                    {
                        Provider.kick(steamid, command[1]);
                    }
                }
                else
                {
                    GlobalBan.Instance.Database.BanPlayer(charactername, steamid.ToString(), adminName, "", 0);
                    UnturnedChat.Say(GlobalBan.Instance.Translate("command_ban_public", charactername));
                    if (isOnline)
                    {
                        Provider.kick(steamid, GlobalBan.Instance.Translate("command_ban_private_default_reason"));
                    }
                }
            }
            catch (System.Exception ex)
            {
                Logger.LogException(ex);
            }
        }
コード例 #4
0
 public CommandUnban(IPlugin plugin)
 {
     _globalBanPlugin = (GlobalBan)plugin;
 }
コード例 #5
0
 public DatabaseManager(GlobalBan globalBanPlugin)
 {
     _globalBanPlugin = globalBanPlugin;
     new I18N.West.CP1250();
     CheckSchema();
 }
コード例 #6
0
 public CommandKick(IPlugin plugin)
 {
     _globalBanPlugin = (GlobalBan)plugin;
 }