예제 #1
0
        public bool TryDoCommand(Players.Player causedBy, string chattext, List <string> splits)
        {
            if (!splits[0].Equals("/ban"))
            {
                return(false);
            }
            if (!PermissionsManager.CheckAndWarnPermission(causedBy, AntiGrief.MOD_PREFIX + "ban"))
            {
                return(true);
            }
            var m = Regex.Match(chattext, @"/ban (?<targetplayername>['].+[']|[^ ]+)");

            if (!m.Success)
            {
                Chat.Send(causedBy, "Command didn't match, use /ban [targetplayername]");
                return(true);
            }
            var targetPlayerName = m.Groups ["targetplayername"].Value;

            Players.Player targetPlayer;
            string         error;

            if (!PlayerHelper.TryGetPlayer(targetPlayerName, out targetPlayer, out error))
            {
                Chat.Send(causedBy, $"Could not find target player '{targetPlayerName}'; {error}");
                return(true);
            }
            Chat.Send(targetPlayer, "<color=red>You were banned from the server</color>");
            Chat.SendToConnected($"{targetPlayer.Name} is banned by {causedBy.Name}");
            BlackAndWhitelisting.AddBlackList(targetPlayer.ID.steamID.m_SteamID);
            BlackAndWhitelisting.Reload();
            Players.Disconnect(targetPlayer);
            return(true);
        }
예제 #2
0
 protected override bool RunCommand(Players.Player ply, string[] args, NetworkID[] targets)
 {
     if (PermissionsManager.CheckAndWarnPermission(ply, "unban"))
     {
         //TODO: Log unbans
         var targetPlayer = Players.GetPlayer(targets[0]);
         Classes.Managers.BanManager.removeBan(targetPlayer.ID);
         BlackAndWhitelisting.RemoveBlackList(targetPlayer.ID.steamID.m_SteamID);
         Chat.send(ply, $"Unbanned {targetPlayer.Name}", Chat.ChatColour.cyan);
     }
     return(true);
 }
예제 #3
0
        public static void OnNPCHit(NPC.NPCBase npc, ModLoader.OnHitData data)
        {
            if (!IsKilled(npc, data) || !IsHitByPlayer(data.HitSourceType) || !(data.HitSourceObject is Players.Player))
            {
                return;
            }
            Players.Player killer = (Players.Player)data.HitSourceObject;
            foreach (Players.Player owner in npc.Colony.Owners)
            {
                if (owner == killer)
                {
                    return;
                }
            }

            int kills;

            if (!KillCounter.TryGetValue(killer, out kills))
            {
                kills = 0;
            }
            KillCounter[killer] = ++kills;
            if (NpcKillsBanThreshold > 0 && kills >= NpcKillsBanThreshold)
            {
                Chat.SendToConnected($"{killer.Name} banned for killing too many colonists");
                BlackAndWhitelisting.AddBlackList(killer.ID.steamID.m_SteamID);
                Players.Disconnect(killer);
            }
            else if (NpcKillsKickThreshold > 0 && kills >= NpcKillsKickThreshold)
            {
                Chat.SendToConnected($"{killer.Name} kicked for killing too many colonists");
                Players.Disconnect(killer);
            }
            else if (NpcKillsJailThreshold > 0 && kills >= NpcKillsJailThreshold)
            {
                Chat.SendToConnected($"{killer.Name} put in Jail for killing too many colonists");
                JailManager.jailPlayer(killer, null, "Killing Colonists", JailManager.DEFAULT_JAIL_TIME);
            }
            Log.Write($"{killer.Name} killed a colonist of {npc.Colony.ColonyID} at {npc.Position}");
            int remainingJail = NpcKillsJailThreshold - kills;
            int remainingKick = NpcKillsKickThreshold - kills;

            Chat.Send(killer, $"You killed a colonist, remaining until jail: {remainingJail}, remaining until kick: {remainingKick}");
        }
예제 #4
0
        protected override bool RunCommand(Players.Player ply, string[] args, NetworkID[] targets)
        {
            if (PermissionsManager.CheckAndWarnPermission(ply, "ban"))
            {
                var targetPlayer = Players.GetPlayer(targets[0]);
                BlackAndWhitelisting.AddBlackList(targetPlayer.ID.steamID.m_SteamID);

                var reason = "";
                if (args.Length > 1)
                {
                    reason = String.Join(" ", args, 1, args.Length - 1);
                }

                Classes.Managers.BanManager.addBan(targetPlayer.ID, reason);
                ServerManager.Disconnect(targetPlayer);
                Chat.send(ply, $"Banned {targetPlayer.Name}", Chat.ChatColour.cyan);
            }
            return(true);
        }