Ejemplo n.º 1
0
 public override void Use(Player p, string message)
 {
     if (message != "")
     {
         Help(p);
         return;
     }
     else
     {
         string hasirc;
         string ircdetails = "";
         if (Server.irc)
         {
             hasirc     = "&aEnabled" + "&g.";
             ircdetails = Server.ircServer + " > " + Server.ircChannel;
         }
         else
         {
             hasirc = "&cDisabled" + "&g.";
         }
         Player.SendMessage(p, "IRC is " + hasirc);
         if (ircdetails != "")
         {
             Player.SendMessage(p, "Location: " + ircdetails);
             Player.SendMessage(p, "Current users in IRC channels:");
             string[] names = IRCBot.GetChannelUsers(Server.ircChannel).ToArray();
             Player.SendMessage(p, "(IRC) " + Server.ircChannel + ": " + (names.Length > 0 ? String.Join(", ", names) : "None"));
             if (p == null || (p != null && p.group.Permission > Server.opchatperm))
             {
                 names = IRCBot.GetChannelUsers(Server.ircOpChannel).ToArray();
                 Player.SendMessage(p, "(OP IRC) " + Server.ircOpChannel + ": " + (names.Length > 0 ? String.Join(", ", names) : "None"));
             }
         }
     }
 }
Ejemplo n.º 2
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Player.SendMessage(p, "You"); return;
            }

            if (p.muted)
            {
                Player.SendMessage(p, "You are currently muted and cannot use this command."); return;
            }
            if (Server.chatmod && !p.voice)
            {
                Player.SendMessage(p, "Chat moderation is on, you cannot emote."); return;
            }

            if (Server.worldChat && !p.levelchat)
            {
                Player.GlobalChat(p, p.color + "*" + p.displayName + " " + message, false);
            }
            else
            {
                Player.GlobalChatLevel(p, p.color + "*" + p.displayName + " " + message, false);
            }
            IRCBot.Say("*" + p.displayName + " " + message);
            //AllServerChat.Say("*" + p.name + " " + message);
        }
Ejemplo n.º 3
0
 public override void Use(Player p, string message)
 {
     if (message != "")
     {
         Help(p);
         return;
     }
     else
     {
         string hasirc;
         string ircdetails = "";
         if (Server.irc)
         {
             hasirc     = "&aEnabled" + Server.DefaultColor + ".";
             ircdetails = Server.ircServer + " > " + Server.ircChannel;
         }
         else
         {
             hasirc = "&cDisabled" + Server.DefaultColor + ".";
         }
         Player.SendMessage(p, "IRC is " + hasirc);
         if (ircdetails != "")
         {
             Player.SendMessage(p, "Location: " + ircdetails);
             Player.SendMessage(p, "Current users in IRC channel:");
             try
             {
                 if (IRCBot.GetConnectedUsers().Length > 0)
                 {
                     try
                     {
                         foreach (string user in IRCBot.GetConnectedUsers())
                         {
                             try
                             {
                                 if (!Char.IsLetter(user[0]))
                                 {
                                     Player.SendMessage(p, user.Substring(1));
                                 }
                                 else
                                 {
                                     Player.SendMessage(p, user);
                                 }
                             }
                             catch { }
                         }
                     }
                     catch { }
                 }
                 else
                 {
                     Player.SendMessage(p, "None");
                 }
             }
             catch { }
         }
     }
 }
Ejemplo n.º 4
0
 public override void Use(Player p, string message)
 {
     if (message == "")
     {
         Help(p); return;
     }
     Player.GlobalChat(p, message, false);
     IRCBot.Say(message);
     //AllServerChat.Say(message);
 }
Ejemplo n.º 5
0
        public override void Use(Player p, string message)
        {
            if (message == "" || message.Split(' ').Length < 2)
            {
                Help(p); return;
            }
            string[] msg = message.Split(new char[] { ' ' }, 2);
            Player   who = Player.Find(msg[0]);

            if (msg[1] == "")
            {
                Help(p); return;
            }
            if (who == null)
            {
                Player.GlobalMessage(msg[0] + ": &2" + msg[1]);
                if (Server.irc)
                {
                    IRCBot.Say(msg[0] + ": " + msg[1]);
                }
                if (p != null)
                {
                    Server.s.Log("(" + p.name + " impersonating " + msg[0] + ") " + msg[0] + ": " + msg[1]);
                }
                else
                {
                    Server.s.Log("(Console impersonating " + msg[0] + ") " + msg[0] + ": " + msg[1]);
                }
            }
            else
            {
                if (p != null && who.group.Permission >= p.group.Permission)
                {
                    Player.SendMessage(p, "You can't impersonate a player of same or higher rank!"); return;
                }
                Player.GlobalChat(who, msg[1], true);
                IRCBot.Say(who.prefix + who.displayName + ": " + msg[1]);
                if (p != null)
                {
                    Server.s.Log("(" + p.name + " impersonating " + who.displayName + ") " + who.prefix + who.displayName + ": " + msg[1]);
                }
                else
                {
                    Server.s.Log("(Console impersonating " + who.name + ") " + who.prefix + who.displayName + ": " + msg[1]);
                }
            }
        }
Ejemplo n.º 6
0
        public override void Use(Player p, string message)
        {
            try
            {
                switch (message.ToLower())
                {
                case "irc": IRCBot.Reset(); break;

                case "global": GlobalChatBot.Reset(); break;

                case "":
                case "all":
                    IRCBot.Reset();
                    GlobalChatBot.Reset();
                    break;

                default: Help(p); break;
                }
                Player.SendMessage(p, "Successfully resetted bot(s).");
            }
            catch (Exception e) { Server.ErrorLog(e); Player.SendMessage(p, "Failed to reset bot(s)."); }
        }
Ejemplo n.º 7
0
 public override void Use(Player p, string message)
 {
     if (message != "list")
     {
         if (p.joker)
         {
             message = "";
         }
         if (!Server.afkset.Contains(p.name))
         {
             Server.afkset.Add(p.name);
             if (p.muted)
             {
                 message = "";
             }
             Player.GlobalMessage("-" + p.color + p.name + Server.DefaultColor + "- is AFK " + message);
             IRCBot.Say(p.name + " is AFK " + message);
             //AllServerChat.Say(p.name + " is AFK " + message);
             //if (!p.afkTimer.Enabled) { p.afkTimer.Start(); }
             p.afkStart = DateTime.Now;
             return;
         }
         else
         {
             Server.afkset.Remove(p.name);
             Player.GlobalMessage("-" + p.color + p.name + Server.DefaultColor + "- is no longer AFK");
             IRCBot.Say(p.name + " is no longer AFK");
             //AllServerChat.Say(p.name + " is no longer AFK " + message);
             return;
         }
     }
     else
     {
         foreach (string s in Server.afkset)
         {
             Player.SendMessage(p, s);
         }
     }
 }
Ejemplo n.º 8
0
        public override void Use(Player p, string message)
        {
            try
            {
                if (message == "")
                {
                    Help(p); return;
                }
                bool stealth = false; bool totalBan = false;
                if (message[0] == '#')
                {
                    message = message.Remove(0, 1).Trim();
                    stealth = true;
                    Server.s.Log("Stealth Ban Attempted");
                }
                else if (message[0] == '@')
                {
                    totalBan = true;
                    message  = message.Remove(0, 1).Trim();
                }

                Player who = Player.Find(message.Split(' ')[0]);

                if (who == null)
                {
                    /*if (!Player.ValidName(message))
                     * {
                     *  Player.SendMessage(p, "Invalid name \"" + message + "\".");
                     *  return;
                     * }*/

                    if (Server.devs.Contains(message.Split(' ')[0].ToLower()))
                    {
                        Player.SendMessage(p, "Woah!! You can't ban a MCDawn Developer!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Developer!");
                        }
                        else
                        {
                            Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Developer!");
                        }
                        return;
                    }
                    if (Server.staff.Contains(message.Split(' ')[0].ToLower()))
                    {
                        Player.SendMessage(p, "Woah!! You can't ban a MCDawn Staff Member!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Staff Member!");
                        }
                        else
                        {
                            Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Staff Member!");
                        }
                        return;
                    }
                    if (Server.administration.Contains(message.Split(' ')[0].ToLower()))
                    {
                        Player.SendMessage(p, "Woah!! You can't ban a MCDawn Administrator!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Administrator!");
                        }
                        else
                        {
                            Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Administrator!");
                        }
                        return;
                    }

                    Group foundGroup = Group.findPlayerGroup(message.Split(' ')[0]);

                    if (foundGroup.Permission >= LevelPermission.Operator)
                    {
                        Player.SendMessage(p, "You can't ban a " + foundGroup.name + "!");
                        return;
                    }
                    if (foundGroup.Permission == LevelPermission.Banned)
                    {
                        Player.SendMessage(p, message.Split(' ')[0] + " is already banned.");
                        return;
                    }
                    if (p != null && foundGroup.Permission >= p.group.Permission)
                    {
                        Player.SendMessage(p, "You cannot ban a person ranked equal or higher than you.");
                        return;
                    }

                    foundGroup.playerList.Remove(message.Split(' ')[0]);
                    foundGroup.playerList.Save();

                    if (p != null)
                    {
                        Player.GlobalMessage(message.Split(' ')[0] + " &f(offline)" + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + ".");
                    }
                    else
                    {
                        Player.GlobalMessage(message.Split(' ')[0] + " &f(offline)" + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + " by Console.");
                    }
                    Group.findPerm(LevelPermission.Banned).playerList.Add(message.Split(' ')[0]);
                    if (message.Trim().Split(' ').Length == 1)
                    {
                        message += " No reason given.";
                    }
                    if (p != null)
                    {
                        if (!message.Substring(message.IndexOf(" ") + 1).ToLower().Contains(p.name.ToLower()))
                        {
                            message += " (" + p.name + ")";
                        }
                    }
                    else
                    {
                        if (!message.Substring(message.IndexOf(" ") + 1).ToLower().Contains("console"))
                        {
                            message += " (Console)";
                        }
                    }
                    MySQL.executeQuery("UPDATE Players SET lastRankReason = '[" + DateTime.Now.ToString() + "] " + message.Substring(message.IndexOf(" ") + 1).Replace("'", "\\'").Trim() + "' WHERE Name = '" + message.Split(' ')[0] + "'");
                    Player.GlobalChat(null, "&6Reason: &f" + message.Substring(message.IndexOf(" ") + 1).Trim(), false);
                }
                else
                {
                    if (!Player.ValidName(who.name))
                    {
                        Player.SendMessage(p, "Invalid name \"" + who.name + "\".");
                        return;
                    }
                    if (Server.devs.Contains(who.originalName.ToLower()))
                    {
                        Player.SendMessage(p, "Woah!! You can't ban a MCDawn Developer!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban an MCDawn Developer!");
                        }
                        else
                        {
                            Player.GlobalMessage("The Console is crazy! Trying to ban an MCDawn Developer!");
                        }
                        return;
                    }
                    if (Server.staff.Contains(who.originalName.ToLower()))
                    {
                        Player.SendMessage(p, "Woah!! You can't ban a MCDawn Staff Member!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Staff Member!");
                        }
                        else
                        {
                            Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Staff Member!");
                        }
                        return;
                    }
                    if (Server.administration.Contains(who.originalName.ToLower()))
                    {
                        Player.SendMessage(p, "Woah!! You can't ban a MCDawn Administrator!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Administrator!");
                        }
                        else
                        {
                            Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Administrator!");
                        }
                        return;
                    }

                    if (who.group.Permission >= LevelPermission.Operator)
                    {
                        Player.SendMessage(p, "You can't ban a " + who.group.name + "!");
                        return;
                    }
                    if (who.group.Permission == LevelPermission.Banned)
                    {
                        Player.SendMessage(p, who.name + " is already banned.");
                        return;
                    }

                    who.group.playerList.Remove(message.Split(' ')[0]);
                    who.group.playerList.Save();

                    if (p != null)
                    {
                        if (stealth)
                        {
                            Player.GlobalMessageOps(who.color + who.name + Server.DefaultColor + " is now STEALTH &8banned" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + ".");
                        }
                        else
                        {
                            Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + ".", false);
                        }
                    }
                    else
                    {
                        if (stealth)
                        {
                            Player.GlobalMessageOps(who.color + who.name + Server.DefaultColor + " is now STEALTH &8banned" + Server.DefaultColor + " by Console.");
                        }
                        else
                        {
                            Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + " by Console.", false);
                        }
                    }

                    if (message.Trim().Split(' ').Length == 1)
                    {
                        message += " No reason given.";
                    }
                    if (p != null)
                    {
                        if (!message.Substring(message.IndexOf(" ") + 1).ToLower().Contains(p.name.ToLower()))
                        {
                            message += " (" + p.name + ")";
                        }
                    }
                    else
                    {
                        if (!message.Substring(message.IndexOf(" ") + 1).ToLower().Contains("console"))
                        {
                            message += " (Console)";
                        }
                    }
                    MySQL.executeQuery("UPDATE Players SET lastRankReason = '[" + DateTime.Now.ToString() + "] " + message.Substring(message.IndexOf(" ") + 1).Replace("'", "\\'").Trim() + "' WHERE Name = '" + who.name + "'");
                    who.lastRankReason = "[" + DateTime.Now.ToString() + "] " + message.Substring(message.IndexOf(" ") + 1).Trim();

                    who.group = Group.findPerm(LevelPermission.Banned);
                    who.color = who.group.color;
                    Player.GlobalDie(who, false);
                    Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
                    Group.findPerm(LevelPermission.Banned).playerList.Add(who.name);
                    Player.GlobalChat(null, "&6Reason: &f" + message.Substring(message.IndexOf(" ") + 1).Trim(), false);
                }
                Group.findPerm(LevelPermission.Banned).playerList.Save();

                if (p != null)
                {
                    IRCBot.Say(message.Split(' ')[0] + " is now banned by " + p.name + ".");
                    Server.s.Log("BANNED: " + message.Split(' ')[0].ToLower() + " by " + p.name + ".");
                }
                else
                {
                    IRCBot.Say(message.Split(' ')[0] + " is now banned by Console.");
                    Server.s.Log("BANNED: " + message.Split(' ')[0].ToLower() + " by Console.");
                }

                if (totalBan == true)
                {
                    Command.all.Find("undo").Use(p, message.Split(' ')[0] + " 0");
                    Command.all.Find("banip").Use(p, "@ " + message.Split(' ')[0]);
                }
            }
            catch (Exception e) { Server.ErrorLog(e); }
        }
Ejemplo n.º 9
0
        void HandleChat(byte[] message)
        {
            try
            {
                if (!loggedIn)
                {
                    return;
                }

                string text = enc.GetString(message, 0, 64).Trim();
                text = Regex.Replace(text, @"\s\s+", " ");

                if (text.Length == 0)
                {
                    return;
                }

                if (text.StartsWith("//") || text.StartsWith("./"))
                {
                    text = text.Remove(0, 1); goto chat;
                }
                if (text == "/")
                {
                    HandleCommand("repeat", ""); return;
                }
                if (text[0] == '/' || text[0] == '!')
                {
                    text = text.Remove(0, 1);
                    int pos = text.IndexOf(' ');
                    if (pos == -1)
                    {
                        HandleCommand(text.ToLower(), ""); return;
                    }
                    string cmd = text.Substring(0, pos).ToLower();
                    string msg = text.Substring(pos + 1);
                    HandleCommand(cmd, msg);
                    return;
                }
                if (text[0] == '@')
                {
                    text = text.Remove(0, 1).Trim();
                    string[] words = text.Split(new char[] { ' ' }, 2);
                    Player   who   = Player.Find(words[0]);
                    if (who == null)
                    {
                        Server.s.Log("Player could not be found!"); return;
                    }
                    who.SendMessage("&bFrom Remote Console: &f" + words[1]);
                    Server.s.Log("(whispers to " + who.name + ") <CONSOLE> " + words[1]);
                    if (!Server.devs.Contains(who.name.ToLower()))
                    {
                        Player.GlobalMessageDevs("To Devs &f-" + "&gRemote Console &b[>] " + who.color + who.name + "&f- " + words[1]);
                    }
                }
                if (text[0] == '#')
                {
                    string newtext = text;
                    if (text[0] == '#')
                    {
                        newtext = text.Remove(0, 1).Trim();
                    }

                    Player.GlobalMessageOps("To Ops &f-Remote Console [&a" + name + "&g]&f- " + newtext);
                    Server.s.Log("(OPs): Remote Console [" + name + "] " + newtext);
                    IRCBot.Say(name + ": " + newtext, true);
                    try { if (!Server.cli)
                          {
                              MCDawn.Gui.Window.thisWindow.WriteOpLine("<REMOTE CONSOLE [" + name + "]> " + newtext);
                          }
                    }
                    catch { }
                    return;
                }
                if (text[0] == ';')
                {
                    string newtext = text;
                    if (text[0] == ';')
                    {
                        newtext = text.Remove(0, 1).Trim();
                    }
                    Player.GlobalMessageAdmins("To Admins &f-Remote Console [&a" + name + "&g]&f- " + newtext);
                    Server.s.Log("(Admins): Remote Console [" + name + "]: " + newtext);
                    try { if (!Server.cli)
                          {
                              MCDawn.Gui.Window.thisWindow.WriteAdminLine("<REMOTE CONSOLE [" + name + "]> " + newtext);
                          }
                    }
                    catch { }
                    //IRCBot.Say(name + ": " + newtext, true);
                    //AllServerChat.Say("(Admins) " + prefix + name + ": " + text);
                    return;
                }

chat:
                Player.GlobalChat(null, "Remote Console [&a" + name + "&g]:&f " + text, false);
                IRCBot.Say("Remote Console [" + name + "]: " + text);
                Server.s.Log("<REMOTE CONSOLE [" + name + "]> " + text);
            }
            catch (Exception e) { Server.ErrorLog(e); Player.GlobalMessage("An error occurred: " + e.Message); }
        }
Ejemplo n.º 10
0
        public override void Use(Player p, string message)
        {
            string usingName = "";

            if (message == "")
            {
                Help(p); return;
            }
            if (message[0] == '@')
            {
                usingName = message.Remove(0, 1).Trim();
                message   = message.Remove(0, 1).Trim();
                message   = message.Replace("'", "\\'");
                message   = message.Replace("--", "");
                Player who = Player.Find(message);
                if (Server.devs.Contains(message.ToLower()))
                {
                    Player.SendMessage(p, "Woah!! You can't ban a MCDawn Developer!");
                    if (p != null)
                    {
                        Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Developer!");
                    }
                    else
                    {
                        Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Developer!");
                    }
                    return;
                }
                if (Server.staff.Contains(message.ToLower()))
                {
                    Player.SendMessage(p, "Woah!! You can't ban a MCDawn Staff Member!");
                    if (p != null)
                    {
                        Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Staff Member!");
                    }
                    else
                    {
                        Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Staff Member!");
                    }
                    return;
                }
                if (Server.administration.Contains(message.ToLower()))
                {
                    Player.SendMessage(p, "Woah!! You can't ban a MCDawn Administrator!");
                    if (p != null)
                    {
                        Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Administrator!");
                    }
                    else
                    {
                        Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Administrator!");
                    }
                    return;
                }
                if (who == null)
                {
                    DataTable ip;
                    int       tryCounter = 0;
                    rerun :  try
                    {
                        ip = MySQL.fillData("SELECT IP FROM Players WHERE Name = '" + message + "'");
                    }
                    catch (Exception e)
                    {
                        tryCounter++;
                        if (tryCounter < 10)
                        {
                            goto rerun;
                        }
                        else
                        {
                            Server.ErrorLog(e);
                            return;
                        }
                    }
                    if (ip.Rows.Count > 0)
                    {
                        message = ip.Rows[0]["IP"].ToString();
                    }
                    else
                    {
                        Player.SendMessage(p, "Unable to find an IP address for that user.");
                        return;
                    }
                    ip.Dispose();
                }
                else
                {
                    message = who.ip;
                }
            }
            else
            {
                Player who = Player.Find(message);
                if (who != null)
                {
                    message = who.ip;
                }
            }

            if (message.Contains("127.0.0.") || message.Contains("192.168."))
            {
                Player.SendMessage(p, "You can't ip-ban the server!"); return;
            }
            if (message.IndexOf('.') == -1)
            {
                Player.SendMessage(p, "Invalid IP!"); return;
            }
            if (message.Split('.').Length != 4)
            {
                Player.SendMessage(p, "Invalid IP!"); return;
            }
            if (p != null && p.ip == message)
            {
                Player.SendMessage(p, "You can't ip-ban yourself.!"); return;
            }
            if (Server.bannedIP.Contains(message))
            {
                Player.SendMessage(p, message + " is already ip-banned."); return;
            }

            // Check if IP belongs to an op+
            // First get names of active ops+ with that ip
            List <string> opNamesWithThatIP = (from pl in Player.players where (pl.ip == message && [email protected] >= LevelPermission.Operator) select pl.originalName).ToList();
            List <string> devCheck          = (from pl in Player.players where (pl.ip == message && (Server.devs.Contains(pl.originalName.ToLower()) || Server.staff.Contains(pl.originalName.ToLower()) || Server.administration.Contains(pl.originalName.ToLower()))) select pl.originalName).ToList();
            // Next, add names from the database
            DataTable dbnames = MySQL.fillData("SELECT Name FROM Players WHERE IP = '" + message + "'");

            foreach (DataRow row in dbnames.Rows)
            {
                opNamesWithThatIP.Add(row[0].ToString());
            }

            foreach (DataRow row in dbnames.Rows)
            {
                devCheck.Add(row[0].ToString());
            }

            if (devCheck != null && devCheck.Count > 0)
            {
                foreach (string dev in devCheck)
                {
                    if (Server.devs.Contains(dev.ToLower()))
                    {
                        Player.SendMessage(p, "Woah!! You can't ban a MCDawn Developer!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Developer!");
                        }
                        else
                        {
                            Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Developer!");
                        }
                        return;
                    }
                    if (Server.staff.Contains(dev.ToLower()))
                    {
                        Player.SendMessage(p, "Woah!! You can't ban a MCDawn Staff Member!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Staff Member!");
                        }
                        else
                        {
                            Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Staff Member!");
                        }
                        return;
                    }
                    if (Server.administration.Contains(dev.ToLower()))
                    {
                        Player.SendMessage(p, "Woah!! You can't ban a MCDawn Administrator!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Administrator!");
                        }
                        else
                        {
                            Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Administrator!");
                        }
                        return;
                    }
                }
            }

            if (opNamesWithThatIP != null && opNamesWithThatIP.Count > 0)
            {
                // We have at least one op+ with a matching IP
                // Check permissions of everybody who matched that IP
                foreach (string opname in opNamesWithThatIP)
                {
                    // If one of these guys is a dev, don't allow the ipban to proceed!
                    if (Server.devs.Contains(opname.ToLower()))
                    {
                        Player.SendMessage(p, "Woah!! You can't ban a MCDawn Developer!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Developer!");
                        }
                        else
                        {
                            Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Developer!");
                        }
                        return;
                    }
                    if (Server.staff.Contains(opname.ToLower()))
                    {
                        Player.SendMessage(p, "Woah!! You can't ban a MCDawn Staff Member!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Staff Member!");
                        }
                        else
                        {
                            Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Staff Member!");
                        }
                        return;
                    }
                    if (Server.administration.Contains(opname.ToLower()))
                    {
                        Player.SendMessage(p, "Woah!! You can't ban a MCDawn Administrator!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Administrator!");
                        }
                        else
                        {
                            Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Administrator!");
                        }
                        return;
                    }
                    // Console can ban anybody else, so skip this section
                    if (p != null)
                    {
                        // If one of these guys matches a player with a higher rank don't allow the ipban to proceed!
                        Group grp = Group.findPlayerGroup(opname);
                        if (grp != null)
                        {
                            if (grp.Permission >= p.group.Permission)
                            {
                                Player.SendMessage(p, "You can only IP-ban IPs of players with a lower rank.");
                                Player.SendMessage(p, Server.DefaultColor + opname + "(" + grp.color + grp.name + Server.DefaultColor + ") also has the IP of " + message + ".");
                                Server.s.Log(p.name + " attempted to IP-ban " + message + " [Player " + opname + "(" + grp.name + ") also has the IP of " + message + "]");
                                return;
                            }
                        }
                    }
                }
            }



            if (p != null)
            {
                IRCBot.Say(message.ToLower() + " is now ip-banned by " + p.name + ".");
                Server.s.Log("IP-BANNED: " + message.ToLower() + " by " + p.name + ".");
                Player.GlobalMessage(message + " is now &8ip-banned" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + ".");
            }
            else
            {
                IRCBot.Say(message.ToLower() + " is now ip-banned by Console.");
                Server.s.Log("IP-BANNED: " + message.ToLower() + " by Console.");
                Player.GlobalMessage(message + " is now &8ip-banned" + Server.DefaultColor + " by Console.");
            }
            Server.bannedIP.Add(message);
            Server.bannedIP.Save("banned-ip.txt", false);

            /*try {
             *  Player.players.ForEach(delegate(Player pl) {
             *      if (((Player.Find(usingName).ip == pl.ip && pl.name.ToLower() != usingName.ToLower()) || (message == pl.ip)) && pl.group.Permission < p.group.Permission)
             *          pl.Kick("Kicked by ip-ban!");
             *  });
             * }
             * catch { } // try catched for possible enumeration error >.>*/
        }
Ejemplo n.º 11
0
        void OnPrivMsg(object sender, IrcEventArgs e)
        {
            Server.s.Log("[IRC] " + e.Data.Nick + " [>] Console: " + e.Data.Message);
            if (Server.ircControllers.Contains(e.Data.Nick))
            {
                string cmd;
                string msg;
                int    len = e.Data.Message.Split(' ').Length;
                cmd = e.Data.Message.Split(' ')[0];
                if (len > 1)
                {
                    msg = e.Data.Message.Substring(e.Data.Message.IndexOf(' ')).Trim();
                }
                else
                {
                    msg = "";
                }

                if (msg != "" || cmd == "restart" || cmd == "update")
                {
                    Server.s.Log(cmd + " : " + msg);
                    switch (cmd)
                    {
                    case "kick":
                        if (Player.Find(msg.Split()[0]) != null)
                        {
                            Command.all.Find("kick").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Player not found.");
                        }
                        break;

                    case "ban":
                        if (Player.Find(msg) != null)
                        {
                            Command.all.Find("ban").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Player not found.");
                        }
                        break;

                    case "banip":
                        if (Player.Find(msg) != null)
                        {
                            Command.all.Find("banip").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Player not found.");
                        }
                        break;

                    case "say":
                        irc.SendMessage(SendType.Message, channel, msg); break;

                    case "setrank":
                        if (Player.Find(msg.Split(' ')[0]) != null)
                        {
                            Command.all.Find("setrank").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Player not found.");
                        }
                        break;

                    case "mute":
                        if (Player.Find(msg) != null)
                        {
                            Command.all.Find("mute").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Player not found.");
                        }
                        break;

                    case "joker":
                        if (Player.Find(msg) != null)
                        {
                            Command.all.Find("joker").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Player not found.");
                        }
                        break;

                    case "physics":
                        if (Level.Find(msg.Split(' ')[0]) != null)
                        {
                            Command.all.Find("physics").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Map not found.");
                        }
                        break;

                    case "load":
                        if (Level.Find(msg.Split(' ')[0]) != null)
                        {
                            Command.all.Find("load").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Map not found.");
                        }
                        break;

                    case "unload":
                        if (Level.Find(msg) != null || msg == "empty")
                        {
                            Command.all.Find("unload").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Map not found.");
                        }
                        break;

                    case "save":
                        if (Level.Find(msg) != null)
                        {
                            Command.all.Find("save").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Map not found.");
                        }
                        break;

                    case "map":
                        if (Level.Find(msg.Split(' ')[0]) != null)
                        {
                            Command.all.Find("map").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Map not found.");
                        }
                        break;

                    case "restart":
                        Player.GlobalMessage("Restart initiated by " + e.Data.Nick);
                        IRCBot.Say("Restart initiated by " + e.Data.Nick);
                        Command.all.Find("restart").Use(null, "");
                        break;

                    case "update":
                        Player.GlobalMessage("Update check initiated by " + e.Data.Nick);
                        IRCBot.Say("Update check initiated by " + e.Data.Nick);
                        Command.all.Find("update").Use(null, "");
                        break;

                    case "warn":
                        if (Player.Find(msg) != null)
                        {
                            Command.all.Find("warn").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Player not found.");
                        }
                        break;

                    case "slap":
                        if (Player.Find(msg) != null)
                        {
                            Command.all.Find("slap").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Player not found.");
                        }
                        break;

                    default:
                        irc.SendMessage(SendType.Message, e.Data.Nick, "Invalid command."); break;
                    }
                }
                else
                {
                    irc.SendMessage(SendType.Message, e.Data.Nick, "Invalid command format.");
                }
            }
        }
Ejemplo n.º 12
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                foreach (Level l in Server.levels)
                {
                    if (l.physics > 0)
                    {
                        Player.SendMessage(p, "&5" + l.name + Server.DefaultColor + " has physics at &b" + l.physics + Server.DefaultColor + ". &cChecks: " + l.lastCheck + "; Updates: " + l.lastUpdate);
                    }
                }
                return;
            }
            try
            {
                int temp = 0; Level level = null;
                if (message.Split(' ').Length == 1)
                {
                    temp = int.Parse(message);
                    if (p != null)
                    {
                        level = p.level;
                    }
                    else
                    {
                        level = Server.mainLevel;
                    }
                }
                else
                {
                    temp = System.Convert.ToInt16(message.Split(' ')[1]);
                    string nameStore = message.Split(' ')[0];
                    level = Level.Find(nameStore);
                }
                if (temp >= 0 && temp <= 5)
                {
                    level.setPhysics(temp);
                    switch (temp)
                    {
                    case 0:
                        level.ClearPhysics();
                        Player.GlobalMessage("Physics are now &cOFF" + Server.DefaultColor + " on &b" + level.name + Server.DefaultColor + ".");
                        Server.s.Log("Physics are now OFF on " + level.name + ".");
                        IRCBot.Say("Physics are now OFF on " + level.name + ".");
                        break;

                    case 1:
                        Player.GlobalMessage("Physics are now &aNormal" + Server.DefaultColor + " on &b" + level.name + Server.DefaultColor + ".");
                        Server.s.Log("Physics are now ON on " + level.name + ".");
                        IRCBot.Say("Physics are now ON on " + level.name + ".");
                        break;

                    case 2:
                        Player.GlobalMessage("Physics are now &aAdvanced" + Server.DefaultColor + " on &b" + level.name + Server.DefaultColor + ".");
                        Server.s.Log("Physics are now ADVANCED on " + level.name + ".");
                        IRCBot.Say("Physics are now ADVANCED on " + level.name + ".");
                        break;

                    case 3:
                        Player.GlobalMessage("Physics are now &aHardcore" + Server.DefaultColor + " on &b" + level.name + Server.DefaultColor + ".");
                        Server.s.Log("Physics are now HARDCORE on " + level.name + ".");
                        IRCBot.Say("Physics are now HARDCORE on " + level.name + ".");
                        break;

                    case 4:
                        Player.GlobalMessage("Physics are now &aInstant" + Server.DefaultColor + " on &b" + level.name + Server.DefaultColor + ".");
                        Server.s.Log("Physics are now INSTANT on " + level.name + ".");
                        IRCBot.Say("Physics are now INSTANT on " + level.name + ".");
                        break;

                    case 5:
                        Player.GlobalMessage("Physics are now &aDoors Only" + Server.DefaultColor + " on &b" + level.name + Server.DefaultColor + ".");
                        Server.s.Log("Physics are now DOORS ONLY on " + level.name + ".");
                        IRCBot.Say("Physics are now DOORS ONLY on " + level.name + ".");
                        break;
                    }

                    level.changed = true;
                }
                else
                {
                    Player.SendMessage(p, "Not a valid setting");
                }
            }
            catch
            {
                Player.SendMessage(p, "INVALID INPUT");
            }
        }
Ejemplo n.º 13
0
        public override void Use(Player p, string message)
        {
            try
            {
                List <groups> playerList = new List <groups>();

                foreach (Group grp in Group.GroupList)
                {
                    if (grp.name != "nobody")
                    {
                        if (String.IsNullOrEmpty(message) || !Group.Exists(message))
                        {
                            groups groups;
                            groups.group   = grp;
                            groups.players = new List <string>();
                            playerList.Add(groups);
                        }
                        else
                        {
                            Group grp2 = Group.Find(message);
                            if (grp2 != null && grp == grp2)
                            {
                                groups groups;
                                groups.group   = grp;
                                groups.players = new List <string>();
                                playerList.Add(groups);
                            }
                        }
                    }
                }

                string devs       = "";
                string unverified = "";
                //string devUnverified = "";
                int totalPlayers = 0;
                foreach (Player pl in Player.players)
                {
                    if (pl.group.Permission == LevelPermission.Nobody && !Server.devs.Contains(pl.name.ToLower()))
                    {
                        continue;
                    }
                    if (p == null || !pl.hidden || p.group.Permission >= pl.group.Permission || Server.devs.Contains(p.name.ToLower()))
                    {
                        totalPlayers++;
                        string foundName = pl.name;

                        if (Server.afkset.Contains(pl.name))
                        {
                            foundName = pl.name + "-afk";
                        }

                        if (Server.devs.Contains(pl.name.ToLower()) && !pl.devUnverified && !pl.unverified)
                        {
                            if (pl.voice)
                            {
                                devs += " " + "&f+&g" + foundName + " (" + pl.level.name + "),";
                            }
                            else
                            {
                                devs += " " + foundName + " (" + pl.level.name + "),";
                            }
                        }
                        else if (pl.unverified || pl.devUnverified)
                        {
                            if (pl.voice)
                            {
                                unverified += " " + "&f+&g" + foundName + " (" + pl.level.name + "),";
                            }
                            else
                            {
                                unverified += " " + foundName + " (" + pl.level.name + "),";
                            }
                        }
                        else
                        {
                            if (pl.voice)
                            {
                                playerList.Find(grp => grp.group == pl.group).players.Add("&f+&g" + foundName + " (" + pl.level.name + ")");
                            }
                            else
                            {
                                playerList.Find(grp => grp.group == pl.group).players.Add(foundName + " (" + pl.level.name + ")");
                            }
                        }
                    }
                }
                Player.SendMessage(p, "There are " + totalPlayers + " players online" +
                                   (Server.irc ? (" (" + IRCBot.GetChannelUsers(Server.ircChannel).Count + " users on IRC" +
                                                  ((p == null || (p != null && p.group.Permission > Server.opchatperm)) ? ", " +
                                                   IRCBot.GetChannelUsers(Server.ircOpChannel).Count + " users on OP IRC" : "") + ")") : "") + ".");
                if (devs.Length > 0)
                {
                    Player.SendMessage(p, ":&9Developers:&g" + devs.Trim(','));
                }
                for (int i = playerList.Count - 1; i >= 0; i--)
                {
                    groups groups       = playerList[i];
                    string appendString = "";

                    foreach (string player in groups.players)
                    {
                        appendString += ", " + player;
                    }

                    if (appendString != "")
                    {
                        appendString = appendString.Remove(0, 2);
                    }
                    appendString = ":" + groups.group.color + getPlural(groups.group.trueName) + ": " + appendString;

                    Player.SendMessage(p, appendString);
                }
                if (unverified.Length > 0)
                {
                    Player.SendMessage(p, ":&3Admin Security System:&g" + unverified.Trim(','));
                }
                //if (devUnverified.Length > 0) { Player.SendMessage(p, ":&3Developer Security System:&g" + unverified.Trim(',')); }
                if (Server.irc)
                {
                    Player.SendMessage(p, ":" + Server.IRCColour + "IRC: " + String.Join(", ", IRCBot.GetChannelUsers(Server.ircChannel).ToArray()).Trim());
                    if (p == null || (p != null && p.group.Permission > Server.opchatperm))
                    {
                        Player.SendMessage(p, ":" + Server.IRCColour + "OP IRC: " + String.Join(", ", IRCBot.GetChannelUsers(Server.ircOpChannel).ToArray()).Trim());
                    }
                }
            }
            catch (Exception e) { Server.ErrorLog(e); }
        }