Beispiel #1
0
        public override void Use(Player p, string message)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args = message.SplitSpaces(2);
            Player   who  = PlayerInfo.FindMatches(p, args[0]);

            string reason = args.Length == 1 ? "you know why." : args[1];

            reason = ModActionCmd.ExpandReason(p, reason);
            if (reason == null)
            {
                return;
            }

            if (who == null)
            {
                WarnOffline(p, args, reason); return;
            }
            if (who == p)
            {
                Player.Message(p, "you can't warn yourself"); return;
            }
            if (p != null && p.Rank <= who.Rank)
            {
                MessageTooHighRank(p, "warn", false); return;
            }

            ModAction action = new ModAction(who.name, p, ModActionType.Warned, reason);

            OnModActionEvent.Call(action);
        }
Beispiel #2
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args = message.SplitSpaces(2);

            string target = PlayerInfo.FindMatchesPreferOnline(p, args[0]);

            if (target == null)
            {
                return;
            }

            Group group = ModActionCmd.CheckTarget(p, data, "freeze", target);

            if (group == null)
            {
                return;
            }

            if (Server.frozen.Contains(target))
            {
                DoUnfreeze(p, target, args);
            }
            else
            {
                // unfreeze has second argument as reason, freeze has third argument instead
                DoFreeze(p, target, message.SplitSpaces(3));
            }
        }
Beispiel #3
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args = message.SplitSpaces(2);

            string reason = args.Length > 1 ? args[1] : "";

            reason = ModActionCmd.ExpandReason(p, reason);
            if (reason == null)
            {
                return;
            }

            if (!Server.tempBans.Contains(args[0]))
            {
                int matches;
                args[0] = Group.BannedRank.Players.FindMatches(p, args[0], "banned players", out matches);
                if (args[0] == null)
                {
                    return;
                }
            }

            ModAction action = new ModAction(args[0], p, ModActionType.Unban, reason);

            OnModActionEvent.Call(action);
        }
Beispiel #4
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args = message.SplitSpaces(2);

            string reason = args.Length == 1 ? "you know why." : args[1];
            string target = ModActionCmd.FindName(p, "warn", "Warn", "", args[0], ref reason);

            if (target == null)
            {
                return;
            }

            reason = ModActionCmd.ExpandReason(p, reason);
            if (reason == null)
            {
                return;
            }

            Group group = ModActionCmd.CheckTarget(p, data, "warn", target);

            if (group == null)
            {
                return;
            }

            ModAction action = new ModAction(target, p, ModActionType.Warned, reason);

            OnModActionEvent.Call(action);
        }
Beispiel #5
0
        void DoFreeze(Player p, string target, string[] args)
        {
            if (args.Length < 2)
            {
                Help(p); return;
            }
            TimeSpan duration = TimeSpan.Zero;

            if (!CommandParser.GetTimespan(p, args[1], ref duration, "freeze for", "m"))
            {
                return;
            }

            string reason = args.Length > 2 ? args[2] : "";

            reason = ModActionCmd.ExpandReason(p, reason);
            if (reason == null)
            {
                return;
            }

            ModAction action = new ModAction(target, p, ModActionType.Frozen, reason, duration);

            OnModActionEvent.Call(action);
        }
Beispiel #6
0
        public override void Use(Player p, string message)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }

            string[] args   = message.SplitSpaces(2);
            string   reason = args.Length > 1 ? args[1] : "";
            string   target = ModActionCmd.FindName(p, "ban", "Ban", "", args[0], ref reason);

            if (target == null)
            {
                return;
            }

            reason = ModActionCmd.ExpandReason(p, reason);
            if (reason == null)
            {
                return;
            }

            Player who   = PlayerInfo.FindExact(target);
            Group  group = who != null ? who.group : Group.GroupIn(target);

            if (!CheckPerms(target, group, p))
            {
                return;
            }

            ModAction action = new ModAction(target, p, ModActionType.Ban, reason);

            action.targetGroup = group;
            OnModActionEvent.Call(action);
        }
Beispiel #7
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args = message.SplitSpaces(2);

            Player who = PlayerInfo.FindMatches(p, args[0]);

            if (who == null)
            {
                return;
            }
            string kickMsg = "by " + p.truename, reason = null;

            if (args.Length > 1)
            {
                reason = ModActionCmd.ExpandReason(p, args[1]);
                if (message == null)
                {
                    return;
                }
                kickMsg += "&f: " + reason;
            }

            ModAction action = new ModAction(who.name, p, ModActionType.Kicked, reason);

            OnModActionEvent.Call(action);
            who.Kick(kickMsg, "Kicked " + kickMsg);
        }
Beispiel #8
0
        public override void Use(Player p, string message, CommandData data) {
            if (message.Length == 0) {
                if (p.IsSuper) { SuperRequiresArgs(p, "player name or IP"); return; }
                message = p.name;
            }
            
            string name, ip = ModActionCmd.FindIP(p, message, "Location", out name);
            if (ip == null) return;
            
            if (HttpUtil.IsPrivateIP(ip)) {
                p.Message("%WPlayer has an internal IP, cannot trace"); return;
            }

            JsonContext ctx = new JsonContext();
            using (WebClient client = HttpUtil.CreateWebClient()) {
                ctx.Val = client.DownloadString(https://geoip.pw/" + ip);
            }
            
            JsonObject obj = (JsonObject)Json.ParseStream(ctx);
            GeoInfo info = new GeoInfo();
            if (obj == null || !ctx.Success) {
                p.Message("%WError parsing GeoIP info"); return;
            }
            
            if (elems == null) elems = ConfigElement.GetAll(typeof(GeoInfo));
            obj.Deserialise(elems, info);
            
            string target = name == null ? ip : "of " + PlayerInfo.GetColoredName(p, name);
            p.Message("The IP {0} %Shas been traced to: &b{1}%S/&b{2}", 
                      target, info.region, info.country);
        }
Beispiel #9
0
        public override void Use(Player p, string message, CommandData data)
        {
            string[] args = message.SplitSpaces(3);
            if (args.Length < 2)
            {
                Help(p); return;
            }
            string rankName, target;
            string reason = args.Length > 2 ? args[2] : null;

            if (args[0].CaselessEq("+up"))
            {
                rankName = args[0];
                target   = ModActionCmd.FindName(p, "promote", "Promote", "", args[1], ref reason);
            }
            else if (args[0].CaselessEq("-down"))
            {
                rankName = args[0];
                target   = ModActionCmd.FindName(p, "demote", "Demote", "", args[1], ref reason);
            }
            else
            {
                rankName = args[1];
                target   = ModActionCmd.FindName(p, "rank", "Rank", " " + rankName, args[0], ref reason);
            }

            if (target == null)
            {
                return;
            }
            if (p.name.CaselessEq(target))
            {
                p.Message("Cannot change your own rank."); return;
            }

            Group curRank = PlayerInfo.GetGroup(target);
            Group newRank = TargetRank(p, rankName, curRank);

            if (newRank == null)
            {
                return;
            }

            if (curRank == newRank)
            {
                p.Message("{0} %Sis already ranked {1}",
                          p.FormatNick(target), curRank.ColoredName);
                return;
            }
            if (!CanChangeRank(target, curRank, newRank, p, data, ref reason))
            {
                return;
            }

            ModAction action = new ModAction(target, p, ModActionType.Rank, reason);

            action.targetGroup = curRank;
            action.Metadata    = newRank;
            OnModActionEvent.Call(action);
        }
Beispiel #10
0
        public override void Use(Player p, string message)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args = message.SplitSpaces(3);

            Player who = PlayerInfo.FindMatches(p, args[0]);

            if (who == null)
            {
                return;
            }
            if (p != null && p == who)
            {
                Player.Message(p, "Cannot freeze yourself."); return;
            }
            if (p != null && who.Rank >= p.Rank)
            {
                MessageTooHighRank(p, "freeze", false); return;
            }

            if (who.frozen)
            {
                string reason = args.Length > 1 ? args[1] : "";
                reason = ModActionCmd.ExpandReason(p, reason);
                if (reason == null)
                {
                    return;
                }

                ModAction action = new ModAction(who.name, p, ModActionType.Unfrozen, reason);
                OnModActionEvent.Call(action);
            }
            else
            {
                if (args.Length < 2)
                {
                    Help(p); return;
                }
                TimeSpan duration = TimeSpan.Zero;
                if (!CommandParser.GetTimespan(p, args[1], ref duration, "freeze for", "m"))
                {
                    return;
                }

                string reason = args.Length > 2 ? args[2] : "";
                reason = ModActionCmd.ExpandReason(p, reason);
                if (reason == null)
                {
                    return;
                }

                ModAction action = new ModAction(who.name, p, ModActionType.Frozen, reason, duration);
                OnModActionEvent.Call(action);
            }
        }
Beispiel #11
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args = message.SplitSpaces(3);

            Player who = PlayerInfo.FindMatches(p, args[0]);

            if (who == null)
            {
                return;
            }

            Group group = ModActionCmd.CheckTarget(p, data, "freeze", who.name);

            if (group == null)
            {
                return;
            }

            if (who.frozen)
            {
                string reason = args.Length > 1 ? args[1] : "";
                reason = ModActionCmd.ExpandReason(p, reason);
                if (reason == null)
                {
                    return;
                }

                ModAction action = new ModAction(who.name, p, ModActionType.Unfrozen, reason);
                OnModActionEvent.Call(action);
            }
            else
            {
                if (args.Length < 2)
                {
                    Help(p); return;
                }
                TimeSpan duration = TimeSpan.Zero;
                if (!CommandParser.GetTimespan(p, args[1], ref duration, "freeze for", "m"))
                {
                    return;
                }

                string reason = args.Length > 2 ? args[2] : "";
                reason = ModActionCmd.ExpandReason(p, reason);
                if (reason == null)
                {
                    return;
                }

                ModAction action = new ModAction(who.name, p, ModActionType.Frozen, reason, duration);
                OnModActionEvent.Call(action);
            }
        }
Beispiel #12
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                if (p.IsSuper)
                {
                    SuperRequiresArgs(p, "player name or IP"); return;
                }
                message = p.name;
            }

            string name, ip = ModActionCmd.FindIP(p, message, "Location", out name);

            if (ip == null)
            {
                return;
            }

            if (HttpUtil.IsPrivateIP(ip))
            {
                p.Message("%WPlayer has an internal IP, cannot trace"); return;
            }

            JsonContext ctx = new JsonContext();

            using (WebClient client = HttpUtil.CreateWebClient())
            {
                ctx.Val = client.DownloadString("http://geoip.pw/api/" + ip);
            }

            JsonObject obj  = (JsonObject)Json.ParseStream(ctx);
            GeoInfo    info = new GeoInfo();

            if (obj == null || !ctx.Success)
            {
                p.Message("%WError parsing GeoIP info"); return;
            }

            if (elems == null)
            {
                elems = ConfigElement.GetAll(typeof(GeoInfo));
            }
            obj.Deserialise(elems, info);

            string target = name == null ? ip : "of " + PlayerInfo.GetColoredName(p, name);

            p.Message("The IP {0} %Shas been traced to: ", target);
            p.Message("  Continent: &f{1}&S ({0})", info.continent_abbr, info.continent);
            p.Message("  Country: &f{1}&S ({0})", info.country_abbr, info.country);
            p.Message("  Region/State: &f{0}", info.subdivision);
            p.Message("  City: &f{0}", info.city);
            p.Message("  Time Zone: &f{0}", info.timezone);
            p.Message("  Hostname: &f{0}", info.host);
            p.Message("  Is using proxy: &f{0}", info.proxy);
            p.Message("Geoip information by: &9http://geoip.pw/");
        }
Beispiel #13
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args = message.SplitSpaces(2);

            Player who = PlayerInfo.FindMatches(p, args[0]);

            if (who == null)
            {
                if (Server.muted.Contains(args[0]))
                {
                    Unmute(p, args[0], args);
                }
                return;
            }
            if (who.muted)
            {
                Unmute(p, who.name, args); return;
            }

            Group group = ModActionCmd.CheckTarget(p, data, "mute", who.name);

            if (group == null)
            {
                return;
            }

            // unmute has second argument as reason, mute has third argument instead
            args = message.SplitSpaces(3);

            TimeSpan duration = Server.Config.ChatSpamMuteTime;

            if (args.Length > 1)
            {
                if (!CommandParser.GetTimespan(p, args[1], ref duration, "mute for", "s"))
                {
                    return;
                }
            }

            string reason = args.Length > 2 ? args[2] : "";

            reason = ModActionCmd.ExpandReason(p, reason);
            if (reason == null)
            {
                return;
            }

            ModAction action = new ModAction(who.name, p, ModActionType.Muted, reason, duration);

            OnModActionEvent.Call(action);
        }
Beispiel #14
0
        public override void Use(Player p, string message)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args = message.SplitSpaces(3);

            Player who = PlayerInfo.FindMatches(p, args[0]);

            if (who == null)
            {
                if (Server.muted.Contains(args[0]))
                {
                    Unmute(p, args[0], args);
                }
                return;
            }
            if (p != null && p == who)
            {
                Player.Message(p, "You cannot mute or unmute yourself."); return;
            }

            if (who.muted)
            {
                Unmute(p, who.name, args);
            }
            else
            {
                if (p != null && who.Rank >= p.Rank)
                {
                    MessageTooHighRank(p, "mute", false); return;
                }

                TimeSpan duration = TimeSpan.FromSeconds(ServerConfig.ChatSpamMuteTime);
                if (args.Length > 1)
                {
                    if (!CommandParser.GetTimespan(p, args[1], ref duration, "mute for", "s"))
                    {
                        return;
                    }
                }

                string reason = args.Length > 2 ? args[2] : "";
                reason = ModActionCmd.ExpandReason(p, reason);
                if (reason == null)
                {
                    return;
                }

                ModAction action = new ModAction(who.name, p, ModActionType.Muted, reason, duration);
                OnModActionEvent.Call(action);
            }
        }
Beispiel #15
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args = message.SplitSpaces(3);
            string   target;

            if (args[0].CaselessEq(UNMUTE_FLAG))
            {
                if (args.Length == 1)
                {
                    Help(p); return;
                }
                target = PlayerInfo.FindMatchesPreferOnline(p, args[1]);
                if (target == null)
                {
                    return;
                }

                if (!Server.muted.Contains(target))
                {
                    p.Message("{0}&S is not muted.", p.FormatNick(target));
                    return;
                }

                DoUnmute(p, target, args.Length > 2 ? args[2] : "");
                return;
            }

            target = PlayerInfo.FindMatchesPreferOnline(p, args[0]);
            if (target == null)
            {
                return;
            }

            if (Server.muted.Contains(target))
            {
                p.Message("{0}&S is already muted.", p.FormatNick(target));
                p.Message("You may unmute them with &T/Unmute {0}", target);
            }
            else
            {
                Group group = ModActionCmd.CheckTarget(p, data, "mute", target);
                if (group == null)
                {
                    return;
                }

                DoMute(p, target, args);
            }
        }
Beispiel #16
0
        public override void Use(Player p, string message)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args   = message.SplitSpaces(3);
            string   reason = args.Length > 2 ? args[2] : "";

            string target = ModActionCmd.FindName(p, "temp ban", "TempBan",
                                                  args.Length == 1 ? "" : " " + args[1],
                                                  args[0], ref reason);

            if (target == null)
            {
                return;
            }
            Player who = PlayerInfo.FindExact(target);

            Group grp = who == null?PlayerInfo.GetGroup(target) : who.group;

            if (p != null && grp.Permission >= p.Rank)
            {
                MessageTooHighRank(p, "temp ban", false); return;
            }
            if (Server.tempBans.Contains(target))
            {
                Player.Message(p, "{0} %Sis already temp-banned.", PlayerInfo.GetColoredName(p, target));
                return;
            }

            TimeSpan span = TimeSpan.FromHours(1);

            if (args.Length > 1 && !CommandParser.GetTimespan(p, args[1], ref span, "temp ban for", "m"))
            {
                return;
            }
            if (span.TotalSeconds < 1)
            {
                Player.Message(p, "Cannot temp ban someone for less than a second."); return;
            }

            reason = ModActionCmd.ExpandReason(p, reason);
            if (reason == null)
            {
                return;
            }

            ModAction action = new ModAction(target, p, ModActionType.Ban, reason, span);

            action.targetGroup = grp;
            OnModActionEvent.Call(action);
        }
Beispiel #17
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args   = message.SplitSpaces(3);
            string   reason = args.Length > 2 ? args[2] : "";

            string target = ModActionCmd.FindName(p, "temp ban", "TempBan",
                                                  args.Length == 1 ? "" : " " + args[1],
                                                  args[0], ref reason);

            if (target == null)
            {
                return;
            }

            Group group = ModActionCmd.CheckTarget(p, data, "temp ban", target);

            if (group == null)
            {
                return;
            }

            if (Server.tempBans.Contains(target))
            {
                p.Message("{0} &Sis already temp-banned.", p.FormatNick(target));
                return;
            }

            TimeSpan span = TimeSpan.FromHours(1);

            if (args.Length > 1 && !CommandParser.GetTimespan(p, args[1], ref span, "temp ban for", "m"))
            {
                return;
            }
            if (span.TotalSeconds < 1)
            {
                p.Message("Cannot temp ban someone for less than a second."); return;
            }

            reason = ModActionCmd.ExpandReason(p, reason);
            if (reason == null)
            {
                return;
            }

            ModAction action = new ModAction(target, p, ModActionType.Ban, reason, span);

            action.targetGroup = group;
            OnModActionEvent.Call(action);
        }
Beispiel #18
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                if (p.IsSuper)
                {
                    SuperRequiresArgs(p, "player name or IP"); return;
                }
                message = p.name;
            }

            string name, ip = ModActionCmd.FindIP(p, message, "Location", out name);

            if (ip == null)
            {
                return;
            }

            if (HttpUtil.IsPrivateIP(ip))
            {
                p.Message("&WPlayer has an internal IP, cannot trace"); return;
            }

            string json, region = null, country = null;

            using (WebClient client = HttpUtil.CreateWebClient()) {
                json = client.DownloadString("http://ipinfo.io/" + ip + "/geo");
            }

            JsonReader reader = new JsonReader(json);

            reader.OnMember = (obj, key, value) => {
                if (key == "region")
                {
                    region = (string)value;
                }
                if (key == "country")
                {
                    country = (string)value;
                }
            };

            reader.Parse();
            if (reader.Failed)
            {
                p.Message("&WError parsing GeoIP info"); return;
            }

            string suffix = HasExtraPerm(p, data.Rank, 1) ? "&b{1}%S/&b{2}" : "&b{2}";
            string nick   = name == null ? ip : "of " + p.FormatNick(name);

            p.Message("The IP {0} %Straces to: " + suffix, nick, region, country);
        }
Beispiel #19
0
        public override void Use(Player p, string message)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args = message.SplitSpaces(2);

            Player who = PlayerInfo.FindMatches(p, args[0]);

            if (who == null)
            {
                return;
            }

            string kickMsg = null, reason = null;

            if (p == null)
            {
                kickMsg = "by (console)";
            }
            else
            {
                kickMsg = "by " + p.truename;
            }

            if (args.Length > 1)
            {
                reason = ModActionCmd.ExpandReason(p, args[1]);
                if (message == null)
                {
                    return;
                }
                kickMsg += "&f: " + reason;
            }

            if (p != null && p == who)
            {
                Player.Message(p, "You cannot kick yourself."); return;
            }
            if (p != null && who.Rank >= p.Rank)
            {
                Chat.MessageGlobal(p, p.ColoredName + " %Stried to kick "
                                   + who.ColoredName + " %Sbut failed.", false);
                return;
            }

            ModAction action = new ModAction(who.name, p, ModActionType.Kicked, reason);

            OnModActionEvent.Call(action);
            who.Kick(kickMsg, "Kicked " + kickMsg);
        }
Beispiel #20
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                if (p.IsSuper)
                {
                    SuperRequiresArgs(p, "player name or IP"); return;
                }
                message = p.name;
            }

            string name, ip = ModActionCmd.FindIP(p, message, "Location", out name);

            if (ip == null)
            {
                return;
            }

            if (IPUtil.IsPrivate(IPAddress.Parse(ip)))
            {
                p.Message("&WPlayer has an internal IP, cannot trace"); return;
            }

            string json;

            try {
                WebRequest  req = HttpUtil.CreateRequest("http://ipinfo.io/" + ip + "/geo");
                WebResponse res = req.GetResponse();
                json = HttpUtil.GetResponseText(res);
            } catch (Exception ex) {
                HttpUtil.DisposeErrorResponse(ex);
                throw;
            }

            JsonReader reader = new JsonReader(json);
            JsonObject obj    = (JsonObject)reader.Parse();

            if (obj == null)
            {
                p.Message("&WError parsing GeoIP info"); return;
            }

            object region = null, country = null;

            obj.TryGetValue("region", out region);
            obj.TryGetValue("country", out country);

            string suffix = HasExtraPerm(p, data.Rank, 1) ? "&b{1}&S/&b{2}" : "&b{2}";
            string nick   = name == null ? ip : "of " + p.FormatNick(name);

            p.Message("The IP {0} &Straces to: " + suffix, nick, region, country);
        }
Beispiel #21
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args = message.SplitSpaces(2);
            string   name, addr = ModActionCmd.FindIP(p, args[0], "BanIP", out name);

            if (addr == null)
            {
                return;
            }

            IPAddress ip;

            if (!IPAddress.TryParse(addr, out ip))
            {
                p.Message("\"{0}\" is not a valid IP.", addr); return;
            }
            if (IPAddress.IsLoopback(ip))
            {
                p.Message("You cannot IP ban the server."); return;
            }
            if (ip.Equals(p.IP))
            {
                p.Message("You cannot IP ban yourself."); return;
            }
            if (Server.bannedIP.Contains(addr))
            {
                p.Message("{0} is already IP banned.", addr); return;
            }

            // Check if IP is shared by any other higher ranked accounts
            if (!CheckIP(p, data, addr))
            {
                return;
            }

            string reason = args.Length > 1 ? args[1] : "";

            reason = ModActionCmd.ExpandReason(p, reason);
            if (reason == null)
            {
                return;
            }

            ModAction action = new ModAction(addr, p, ModActionType.BanIP, reason);

            OnModActionEvent.Call(action);
        }
Beispiel #22
0
        static void Unmute(Player p, string name, string[] args)
        {
            string reason = args.Length > 1 ? args[1] : "";

            reason = ModActionCmd.ExpandReason(p, reason);
            if (reason == null)
            {
                return;
            }

            ModAction action = new ModAction(name, p, ModActionType.Unmuted, reason);

            OnModActionEvent.Call(action);
        }
Beispiel #23
0
        internal static bool CanChangeRank(string name, Group curRank, Group newRank,
                                           Player p, CommandData data, ref string reason)
        {
            Group banned = Group.BannedRank;

            if (reason == null)
            {
                reason = newRank.Permission >= curRank.Permission ?
                         Server.Config.DefaultPromoteMessage : Server.Config.DefaultDemoteMessage;
            }
            reason = ModActionCmd.ExpandReason(p, reason);
            if (reason == null)
            {
                return(false);
            }

            if (newRank == banned)
            {
                p.Message("Use /ban to change a player's rank to {0}%S.", banned.ColoredName); return(false);
            }
            if (curRank == banned)
            {
                p.Message("Use /unban to change a player's rank from %S{0}.", banned.ColoredName); return(false);
            }

            if (!p.IsConsole)
            {
                if (!CheckRank(p, data, curRank.Permission, "change the rank of", false))
                {
                    return(false);
                }
                if (newRank.Permission >= data.Rank)
                {
                    p.Message("Cannot rank a player to a rank equal to or higher than yours."); return(false);
                }
            }

            if (newRank.Permission == curRank.Permission)
            {
                p.Message("{0} %Sis already ranked {1}.",
                          PlayerInfo.GetColoredName(p, name), curRank.ColoredName); return(false);
            }

            OnChangingGroupEvent.Call(name, curRank, newRank);
            if (Group.cancelrank)
            {
                Group.cancelrank = false; return(false);
            }
            return(true);
        }
Beispiel #24
0
        void DoUnfreeze(Player p, string target, string[] args)
        {
            string reason = args.Length > 1 ? args[1] : "";

            reason = ModActionCmd.ExpandReason(p, reason);
            if (reason == null)
            {
                return;
            }

            ModAction action = new ModAction(target, p, ModActionType.Unfrozen, reason);

            OnModActionEvent.Call(action);
        }
Beispiel #25
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                if (p.IsSuper)
                {
                    SuperRequiresArgs(p, "player name or IP"); return;
                }
                message = p.name;
            }

            string name, ip = ModActionCmd.FindIP(p, message, "Location", out name);

            if (ip == null)
            {
                return;
            }

            if (HttpUtil.IsPrivateIP(ip))
            {
                p.Message("%WPlayer has an internal IP, cannot trace"); return;
            }

            bool   success;
            string ipInfo;

            using (WebClient client = HttpUtil.CreateWebClient()) {
                ipInfo = client.DownloadString("http://ipinfo.io/" + ip + "/geo");
            }

            JsonObject obj  = (JsonObject)Json.Parse(ipInfo, out success);
            GeoInfo    info = new GeoInfo();

            if (obj == null || !success)
            {
                p.Message("%WError parsing GeoIP info"); return;
            }

            if (elems == null)
            {
                elems = ConfigElement.GetAll(typeof(GeoInfo));
            }
            obj.Deserialise(elems, info);

            string suffix = HasExtraPerm(p, data.Rank, 1) ? "&b{1}%S/&b{2}" : "&b{2}";
            string nick   = name == null ? ip : "of " + p.FormatNick(name);

            p.Message("The IP {0} %Straces to: " + suffix, nick, info.region, info.country);
        }
Beispiel #26
0
        void HandleAdd(Player p, string[] args)
        {
            if (args.Length != 2)
            {
                p.Message("You need to provide a reason for the report."); return;
            }

            string target = PlayerDB.MatchNames(p, args[0]);

            if (target == null)
            {
                return;
            }
            string nick = p.FormatNick(target);

            List <string> reports = new List <string>();

            if (HasReports(target))
            {
                reports = Utils.ReadAllLinesList(ReportPath(target));
            }
            ItemPerms checkPerms = CommandExtraPerms.Find(name, 1);

            if (reports.Count >= 5)
            {
                p.Message("{0} &Walready has 5 reports! Please wait until an {1} &Whas reviewed these reports first!",
                          nick, CommandExtraPerms.Find(name, 1).Describe());
                return;
            }

            string reason = ModActionCmd.ExpandReason(p, args[1]);

            if (reason == null)
            {
                return;
            }

            reports.Add(reason + " - Reported by " + p.name + " at " + DateTime.Now);
            File.WriteAllLines(ReportPath(target), reports.ToArray());
            p.Message("&aReport sent! It should be viewed when a {0} &ais online",
                      checkPerms.Describe());

            string opsMsg = "λNICK &Sreported " + nick + "&S. Reason: " + reason;

            Chat.MessageFrom(ChatScope.Perms, p, opsMsg, checkPerms, null, true);
            string allMsg = "Use &T/Report check " + target + " &Sto see all of their reports";

            Chat.MessageFrom(ChatScope.Perms, p, allMsg, checkPerms, null, true);
        }
Beispiel #27
0
        public override void Use(Player p, string message)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args = message.SplitSpaces(2);
            args[0] = ModActionCmd.FindIP(p, args[0], "IP ban", "banip");
            if (args[0] == null)
            {
                return;
            }

            IPAddress ip;

            if (!IPAddress.TryParse(args[0], out ip))
            {
                Player.Message(p, "\"{0}\" is not a valid IP.", args[0]); return;
            }
            if (IPAddress.IsLoopback(ip))
            {
                Player.Message(p, "You cannot IP ban the server."); return;
            }
            if (p != null && p.ip == args[0])
            {
                Player.Message(p, "You cannot IP ban yourself."); return;
            }
            if (Server.bannedIP.Contains(args[0]))
            {
                Player.Message(p, "{0} is already IP banned.", args[0]); return;
            }
            // Check if IP is shared by any other higher ranked accounts
            if (!CheckIP(p, args[0]))
            {
                return;
            }

            string reason = args.Length > 1 ? args[1] : "";

            reason = ModActionCmd.ExpandReason(p, reason);
            if (reason == null)
            {
                return;
            }

            ModAction action = new ModAction(args[0], p, ModActionType.BanIP, reason);

            OnModActionEvent.Call(action);
        }
Beispiel #28
0
        void DoUnmute(Player p, string target, string reason)
        {
            reason = ModActionCmd.ExpandReason(p, reason);
            if (reason == null)
            {
                return;
            }
            if (p.name == target)
            {
                p.Message("You cannot unmute yourself."); return;
            }

            ModAction action = new ModAction(target, p, ModActionType.Unmuted, reason);

            OnModActionEvent.Call(action);
        }
Beispiel #29
0
        void HandleAdd(Player p, string[] args)
        {
            if (args.Length != 2)
            {
                p.Message("You need to provide a reason for the report."); return;
            }
            string target = PlayerDB.MatchNames(p, args[0]);

            if (target == null)
            {
                return;
            }

            List <string> reports = new List <string>();

            if (File.Exists("extra/reported/" + target + ".txt"))
            {
                reports = Utils.ReadAllLinesList("extra/reported/" + target + ".txt");
            }

            ItemPerms checkPerms = CommandExtraPerms.Find(name, 1);

            if (reports.Count >= 5)
            {
                p.Message("{0} %Walready has 5 reports! Please wait until an {1} %Whas reviewed these reports first!",
                          p.FormatNick(target), checkPerms.Describe());
                return;
            }

            string reason = args[1];

            reason = ModActionCmd.ExpandReason(p, reason);
            if (reason == null)
            {
                return;
            }

            reports.Add(reason + " - Reported by " + p.name + " at " + DateTime.Now);
            File.WriteAllLines("extra/reported/" + target + ".txt", reports.ToArray());
            p.Message("&aReport sent! It should be viewed when a {0} &ais online",
                      checkPerms.Describe());

            string opsMsg = "λNICK %Smade a report, view it with %T/Report check " + target;

            Chat.MessageFrom(ChatScope.Perms, p, opsMsg, checkPerms, null, true);
        }
Beispiel #30
0
        public override void Use(Player p, string message)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args = message.SplitSpaces(2);

            string reason = args.Length > 1 ? args[1] : "";

            reason = ModActionCmd.ExpandReason(p, reason);
            if (reason == null)
            {
                return;
            }

            if (message.CaselessEq("set") && p != null)
            {
                p.level.Config.JailX    = p.Pos.X; p.level.Config.JailY = p.Pos.Y; p.level.Config.JailZ = p.Pos.Z;
                p.level.Config.jailrotx = p.Rot.RotY; p.level.Config.jailroty = p.Rot.HeadX;
                Player.Message(p, "Set Jail point.");
                return;
            }

            Player who = PlayerInfo.FindMatches(p, args[0]);

            if (who == null)
            {
                return;
            }

            if (!who.jailed)
            {
                if (p != null && who.Rank >= p.Rank)
                {
                    MessageTooHighRank(p, "jail", false); return;
                }
                ModAction action = new ModAction(who.name, p, ModActionType.Jailed, reason);
                OnModActionEvent.Call(action);
            }
            else
            {
                ModAction action = new ModAction(who.name, p, ModActionType.Unjailed, reason);
                OnModActionEvent.Call(action);
            }
        }