Ejemplo n.º 1
0
        protected override void SetPlayerData(Player p, string target, string colName)
        {
            string col = "";
            Player who = PlayerInfo.FindExact(target);

            if (colName.Length == 0)
            {
                col = Group.GroupIn(target).Color;
                MessageFrom(target, who, "had their color removed");
            }
            else
            {
                col = Matcher.FindColor(p, colName);
                if (col == null)
                {
                    return;
                }
                MessageFrom(target, who, "had their color changed to " + col + Colors.Name(col));
            }

            if (who != null)
            {
                who.UpdateColor(col);
            }
            PlayerDB.Update(target, PlayerData.ColumnColor, col);
        }
Ejemplo n.º 2
0
        protected override void SetPlayerData(Player p, string target, string title)
        {
            if (title.Length >= 20)
            {
                p.Message("Title must be under 20 letters."); return;
            }
            Player who = PlayerInfo.FindExact(target);

            if (title.Length == 0)
            {
                MessageFrom(target, who, "had their title removed");
            }
            else
            {
                MessageFrom(target, who, "had their title changed to &b[" + title + "&b]");
            }

            if (who != null)
            {
                who.title = title;
            }
            if (who != null)
            {
                who.SetPrefix();
            }
            PlayerDB.Update(target, PlayerData.ColumnTitle, title.UnicodeToCp437());
        }
Ejemplo n.º 3
0
        static void SetTimespan(Player p, string[] args, string column, Player who, Action <TimeSpan> setter)
        {
            if (args.Length < 3)
            {
                p.Message("Timespan must be in the format: <number><quantifier>..");
                p.Message(CommandParser.TimespanHelp, "set time spent to");
                return;
            }

            TimeSpan span = TimeSpan.Zero;

            if (!CommandParser.GetTimespan(p, args[2], ref span, "set time spent to", "m"))
            {
                return;
            }

            if (who != null)
            {
                setter(span);
            }
            else
            {
                long secs = (long)span.TotalSeconds;
                PlayerDB.Update(args[0], column, secs.ToString());
            }
            MessageDataChanged(p, args[0], args[1], span.Shorten(true));
        }
Ejemplo n.º 4
0
        protected override void SetPlayerData(Player p, Player who, string colName)
        {
            string color = "";

            if (colName.Length == 0)
            {
                Chat.MessageFrom(who, "λNICK %Shad their title color removed");
            }
            else
            {
                color = Matcher.FindColor(p, colName);
                if (color == null)
                {
                    return;
                }
                if (color == who.titlecolor)
                {
                    p.Message(who.ColoredName + " %Salready has that title color."); return;
                }

                Chat.MessageFrom(who, "λNICK %Shad their title color changed to " + color + Colors.Name(color));
            }

            who.titlecolor = color;
            who.SetPrefix();
            PlayerDB.Update(who.name, PlayerData.ColumnTColor, color);
        }
Ejemplo n.º 5
0
        protected override void SetPlayerData(Player p, Player who, string colName)
        {
            string color = "";

            if (colName.Length == 0)
            {
                Chat.MessageFrom(who, "λNICK %Shad their color removed");
                who.color = who.group.Color;
            }
            else
            {
                color = Matcher.FindColor(p, colName);
                if (color == null)
                {
                    return;
                }
                if (color == who.color)
                {
                    p.Message("λNICK %Salready has that color."); return;
                }

                Chat.MessageFrom(who, "λNICK %Shad their color changed to " + color + Colors.Name(color));
                who.color = color;
            }

            Entities.GlobalRespawn(who);
            who.SetPrefix();
            PlayerDB.Update(who.name, PlayerData.ColumnColor, color);
        }
Ejemplo n.º 6
0
        protected override void SetPlayerData(Player p, Player who, string title)
        {
            if (title.Length >= 20)
            {
                p.Message("Title must be under 20 letters."); return;
            }

            if (title.Length == 0)
            {
                Chat.MessageFrom(who, "λNICK %Shad their title removed");
            }
            else
            {
                Chat.MessageFrom(who, "λNICK %Shad their title changed to &b[" + title + "&b]");
            }

            who.title = title;
            who.SetPrefix();
            PlayerDB.Update(who.name, PlayerData.ColumnTitle, title.UnicodeToCp437());
        }
Ejemplo n.º 7
0
        protected override void SetPlayerData(Player p, string target, string title)
        {
            if (title.Length >= 20)
            {
                p.Message("Title must be under 20 letters."); return;
            }
            Player who; string editee; bool globalMessage;

            GetPlayerDataMessageInfo(p, target, out who, out editee, out globalMessage);

            string message;

            if (title.Length == 0)
            {
                message = p.ColoredName + " &Sremoved " + editee + " title";
            }
            else
            {
                message = p.ColoredName + " &Schanged " + editee + " title to &b[" + title + "&b]";
            }
            if (globalMessage)
            {
                Chat.MessageAll(message);
            }
            else
            {
                Chat.MessageFrom(p, message);
            }

            if (who != null)
            {
                who.title = title;
            }
            if (who != null)
            {
                who.SetPrefix();
            }
            PlayerDB.Update(target, PlayerData.ColumnTitle, title.UnicodeToCp437());
        }
Ejemplo n.º 8
0
        static void SetInteger(Player p, string[] args, string column, int max, Player who,
                               Action <int> setter, int type)
        {
            if (args.Length < 3)
            {
                p.Message("You must specify a positive integer, which can be {0} at most.", max); return;
            }

            int value = 0;

            if (!CommandParser.GetInt(p, args[2], "Amount", ref value, 0, max))
            {
                return;
            }

            if (who != null)
            {
                setter(value);
            }
            else
            {
                string dbValue = args[2];
                // special case handling for packed forms of totalBlocks and totalCuboided
                if (type == 1)
                {
                    long packed = GetLong(args[0], column) & ~PlayerData.LoBitsMask; // hi value only
                    packed |= (uint)value;
                    dbValue = packed.ToString();
                }
                else if (type == 2)
                {
                    long packed = GetLong(args[0], column) & PlayerData.LoBitsMask; // lo value only
                    packed |= ((long)value) << PlayerData.HiBitsShift;
                    dbValue = packed.ToString();
                }
                PlayerDB.Update(args[0], column, dbValue);
            }
            MessageDataChanged(p, args[0], args[1], args[2]);
        }
Ejemplo n.º 9
0
        protected override void SetPlayerData(Player p, string target, string colName)
        {
            string col = "";
            Player who; string editee; bool globalMessage;

            GetPlayerDataMessageInfo(p, target, out who, out editee, out globalMessage);

            string message;

            if (colName.Length == 0)
            {
                col     = Group.GroupIn(target).Color;
                message = p.ColoredName + " &Sremoved " + editee + " color";
                PlayerDB.Update(target, PlayerData.ColumnColor, "");
            }
            else
            {
                col = Matcher.FindColor(p, colName);
                if (col == null)
                {
                    return;
                }
                message = p.ColoredName + " &Schanged " + editee + " color to " + col + Colors.Name(col);
                PlayerDB.Update(target, PlayerData.ColumnColor, col);
            }
            if (globalMessage)
            {
                Chat.MessageAll(message);
            }
            else
            {
                Chat.MessageFrom(p, message);
            }

            if (who != null)
            {
                who.UpdateColor(col);
            }
        }
Ejemplo n.º 10
0
        static void SetDate(Player p, string[] args, string column, Player who, Action <DateTime> setter)
        {
            if (args.Length < 3)
            {
                p.Message("Dates must be in the format: " + Database.DateFormat);
                return;
            }

            DateTime date;

            if (!DateTime.TryParseExact(args[2], Database.DateFormat, null, 0, out date))
            {
                p.Message("Invalid date. It must be in format: " + Database.DateFormat);
                return;
            }

            if (who != null)
            {
                setter(date);
            }
            PlayerDB.Update(args[0], column, args[2]);
            MessageDataChanged(p, args[0], args[1], args[2]);
        }
Ejemplo n.º 11
0
        static void SetColor(Player p, string[] args, string column, Player who, Action <string> setter)
        {
            if (args.Length < 3)
            {
                p.Message("Color format: color name, or \"null\" to reset to default color."); return;
            }

            string col = args[2] == "null" ? "" : Matcher.FindColor(p, args[2]);

            if (col == null)
            {
                return;
            }

            if (who != null)
            {
                setter(col);
                who.SetPrefix();
                args[0] = who.name;
            }

            PlayerDB.Update(args[0], column, col);
            MessageDataChanged(p, args[0], args[1], args[2]);
        }
Ejemplo n.º 12
0
 public static void UpdateMoney(string name, int money)
 {
     PlayerDB.Update(name, PlayerData.ColumnMoney, money.ToString());
 }
Ejemplo n.º 13
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args = message.SplitSpaces(3);
            args[0] = PlayerInfo.FindMatchesPreferOnline(p, args[0]);

            if (args[0] == null)
            {
                return;
            }
            Player who = PlayerInfo.FindExact(args[0]);

            if (args.Length == 1)
            {
                p.Message("&WYou must specify a type to modify.");
                MessageValidTypes(p); return;
            }

            string opt = args[1].ToLower();

            if (opt == "firstlogin")
            {
                SetDate(p, args, PlayerData.ColumnFirstLogin, who,
                        v => who.FirstLogin = v);
            }
            else if (opt == "lastlogin")
            {
                SetDate(p, args, PlayerData.ColumnLastLogin, who,
                        v => who.LastLogin = v);
            }
            else if (opt == "logins")
            {
                SetInteger(p, args, PlayerData.ColumnLogins, 1000000000, who,
                           v => who.TimesVisited = v, type_norm);
            }
            else if (opt == "deaths")
            {
                SetInteger(p, args, PlayerData.ColumnDeaths, short.MaxValue, who,
                           v => who.TimesDied = v, type_norm);
            }
            else if (opt == "money")
            {
                SetInteger(p, args, PlayerData.ColumnMoney, 100000000, who,
                           v => who.money = v, type_norm);
            }
            else if (opt == "title")
            {
                if (args.Length < 3)
                {
                    p.Message("Title can be up to 20 characters. Use \"null\" to remove the title"); return;
                }
                if (args[2].Length >= 20)
                {
                    p.Message("Title must be under 20 characters"); return;
                }
                if (args[2] == "null")
                {
                    args[2] = "";
                }

                if (who != null)
                {
                    who.title = args[2];
                    who.SetPrefix();
                }

                PlayerDB.Update(args[0], PlayerData.ColumnTitle, args[2].UnicodeToCp437());
                MessageDataChanged(p, args[0], args[1], args[2]);
            }
            else if (opt == "ip")
            {
                if (args.Length < 3)
                {
                    p.Message("A new IP address must be provided."); return;
                }

                IPAddress ip;
                if (!IPAddress.TryParse(args[2], out ip))
                {
                    p.Message("&W\"{0}\" is not a valid IP address.", args[2]); return;
                }

                if (who != null)
                {
                    who.SetIP(ip);
                }
                PlayerDB.Update(args[0], PlayerData.ColumnIP, args[2]);
                MessageDataChanged(p, args[0], args[1], args[2]);
            }
            else if (opt == "modified")
            {
                SetInteger(p, args, PlayerData.ColumnBlocks, int.MaxValue, who,
                           v => who.TotalModified = v, type_lo);
            }
            else if (opt == "drawn")
            {
                SetInteger(p, args, PlayerData.ColumnDrawn, int.MaxValue, who,
                           v => who.TotalDrawn = v, type_lo);
            }
            else if (opt == "placed")
            {
                SetInteger(p, args, PlayerData.ColumnBlocks, int.MaxValue, who,
                           v => who.TotalPlaced = v, type_hi);
            }
            else if (opt == "deleted")
            {
                SetInteger(p, args, PlayerData.ColumnDrawn, int.MaxValue, who,
                           v => who.TotalDeleted = v, type_hi);
            }
            else if (opt == "totalkicked")
            {
                SetInteger(p, args, PlayerData.ColumnKicked, 16777215, who,
                           v => who.TimesBeenKicked = v, type_norm);
            }
            else if (opt == "messages")
            {
                SetInteger(p, args, PlayerData.ColumnMessages, 16777215, who,
                           v => who.TotalMessagesSent = v, type_norm);
            }
            else if (opt == "timespent")
            {
                SetTimespan(p, args, PlayerData.ColumnTimeSpent, who,
                            v => who.TotalTime = v);
            }
            else if (opt == "color")
            {
                SetColor(p, args, PlayerData.ColumnColor, who,
                         v => who.UpdateColor(v.Length == 0 ? who.group.Color : v));
            }
            else if (opt == "titlecolor")
            {
                SetColor(p, args, PlayerData.ColumnTColor, who,
                         v => who.titlecolor = v);
            }
            else
            {
                p.Message("&WInvalid type");
                MessageValidTypes(p);
            }
        }