public override void Use(Player p, string message) { if (message == "") { Help(p); return; } if (message[0] == '@') { message = message.Remove(0, 1).Trim(); Player who = Player.Find(message); if (Server.devs.Contains(message.ToLower())) { Player.SendMessage(p, "You can't ban a MCForge Developer!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " attempted to ban a MCForge Developer!"); } else { Player.GlobalMessage(Server.DefaultColor + "The Console attempted to ban a MCForge Developer!"); } return; } if (who == null) { DataTable ip; int tryCounter = 0; rerun : try { ip = Server.useMySQL ? MySQL.fillData("SELECT IP FROM Players WHERE Name = '" + message + "'") : SQLite.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.Equals("127.0.0.1")) { 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.name).ToList(); // Next, add names from the database DataTable dbnames = Server.useMySQL ? MySQL.fillData("SELECT Name FROM Players WHERE IP = '" + message + "'") : SQLite.fillData("SELECT Name FROM Players WHERE IP = '" + message + "'"); foreach (DataRow row in dbnames.Rows) { opNamesWithThatIP.Add(row[0].ToString()); } 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, "You can't ban a MCForge Developer!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " attempted to ban a MCForge Developer!"); } else { Player.GlobalMessage(Server.DefaultColor + "The Console attempted to ban a MCForge Developer!"); } 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 ipban IPs used by players with a lower rank."); Player.SendMessage(p, Server.DefaultColor + opname + "(" + grp.color + grp.name + Server.DefaultColor + ") uses that IP."); Server.s.Log(p.name + "failed to ipban " + message + " - IP is also used by: " + opname + "(" + grp.name + ")"); return; } } } } } if (p != null) { Server.IRC.Say(message.ToLower() + " was ip-banned by " + p.name + "."); Server.s.Log("IP-BANNED: " + message.ToLower() + " by " + p.name + "."); Player.GlobalMessage(message + " was &8ip-banned" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + "."); } else { Server.IRC.Say(message.ToLower() + " was ip-banned by console."); Server.s.Log("IP-BANNED: " + message.ToLower() + " by console."); Player.GlobalMessage(message + " was &8ip-banned" + Server.DefaultColor + " by console."); } Server.bannedIP.Add(message); Server.bannedIP.Save("banned-ip.txt", false); /* * foreach (Player pl in Player.players) { * if (message == pl.ip) { pl.Kick("Kicked by ipban"); } * }*/ }
public override void Use(Player p, string message) { try { if (message == "") { Help(p); return; } bool stealth = false; bool totalBan = false; if (message[0] == '#') { if (p == null) { message = message.Remove(0, 1).Trim(); stealth = true; Server.s.Log("Stealth Ban Attempted by Console"); } else { message = message.Remove(0, 1).Trim(); stealth = true; Server.s.Log("Stealth Ban Attempted by " + p.name); } } else if (message[0] == '@') { if (p == null) { message = message.Remove(0, 1).Trim(); stealth = true; Server.s.Log("Total Ban Attempted by Console"); } else { totalBan = true; message = message.Remove(0, 1).Trim(); Server.s.Log("Total Ban Attempted by " + p.name); } } string reason = "-"; if (message.Split(' ').Length > 1) { reason = message; string newreason = reason.Remove(0, reason.Split(' ')[0].Length + 1); int removetrim = newreason.Length + 1; string newmessage = message.Remove(message.Length - removetrim, removetrim); reason = newreason; message = newmessage; } if (reason == "-") { reason = "&c-"; } reason = reason.Replace(" ", "%20"); Player who = Player.Find(message); if (who == null) { if (!Player.ValidName(message)) { Player.SendMessage(p, "Invalid name \"" + message + "\"."); return; } if (Server.devs.Contains(message.ToLower())) { Player.SendMessage(p, "You can't ban a MCForge Developer!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " attempted to ban a MCForge Developer!"); } else { Player.GlobalMessage(Server.DefaultColor + "The Console attempted to ban a MCForge Developer!"); } return; } Group foundGroup = Group.findPlayerGroup(message); if ((int)foundGroup.Permission >= CommandOtherPerms.GetPerm(this)) { Player.SendMessage(p, "You can't ban a " + foundGroup.name + "!"); return; } if (foundGroup.Permission == LevelPermission.Banned) { Player.SendMessage(p, message + " 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; } string oldgroup = foundGroup.name.ToString(); foundGroup.playerList.Remove(message); foundGroup.playerList.Save(); if (p != null) { Player.GlobalMessage(message + " &f(offline)" + Server.DefaultColor + " was &8banned" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + "."); } else { Player.GlobalMessage(message + " &f(offline)" + Server.DefaultColor + " was &8banned" + Server.DefaultColor + " by console."); } Group.findPerm(LevelPermission.Banned).playerList.Add(message); Ban.Banplayer(p, message, reason, stealth, oldgroup); } else { if (!Player.ValidName(who.name)) { Player.SendMessage(p, "Invalid name \"" + who.name + "\"."); return; } if (Server.devs.Contains(who.name.ToLower())) { Player.SendMessage(p, "You can't ban an MCForge Developer!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " attempted to ban an MCForge Developer!"); } else { Player.GlobalMessage(Server.DefaultColor + "The Console attempted to ban an MCForge Developer!"); } return; } if ((int)who.group.Permission >= CommandOtherPerms.GetPerm(this)) { Player.SendMessage(p, "You can't ban a " + who.group.name + "!"); return; } if (who.group.Permission == LevelPermission.Banned) { Player.SendMessage(p, message + " is already banned."); return; } if (p != null && who.group.Permission >= p.group.Permission) { Player.SendMessage(p, "You cannot ban a person ranked equal or higher than you."); return; } string oldgroup = who.group.name.ToString(); who.group.playerList.Remove(message); who.group.playerList.Save(); if (p != null) { if (stealth) { Player.GlobalMessageOps(who.color + who.name + Server.DefaultColor + " was STEALTH &8banned" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + "!"); } else { Player.GlobalMessage(who.color + who.name + Server.DefaultColor + " was &8banned" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + "!"); } } else { if (stealth) { Player.GlobalMessageOps(who.color + who.name + Server.DefaultColor + " was STEALTH &8banned" + Server.DefaultColor + " by console."); } else { Player.GlobalMessage(who.color + who.name + Server.DefaultColor + " was &8banned" + Server.DefaultColor + " by console."); } } 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); Ban.Banplayer(p, who.name, reason, stealth, oldgroup); } Group.findPerm(LevelPermission.Banned).playerList.Save(); if (p != null) { Server.IRC.Say(message + " was banned by " + p.name + "."); Server.s.Log("BANNED: " + message.ToLower() + " by " + p.name); } else { Server.IRC.Say(message + " was banned by console."); Server.s.Log("BANNED: " + message.ToLower() + " by console."); } if (totalBan == true) { Command.all.Find("undo").Use(p, message + " 0"); Command.all.Find("banip").Use(p, "@ " + message); } } catch (Exception e) { Server.ErrorLog(e); } }
public override void Use(Player p, string message) { if (message == "") { Help(p); return; } bool totalUnban = false; if (message[0] == '@') { totalUnban = true; message = message.Remove(0, 1).Trim(); } Player who = Player.Find(message); if (who == null) { if (Group.findPlayerGroup(message) != Group.findPerm(LevelPermission.Banned)) { foreach (Server.TempBan tban in Server.tempBans) { if (tban.name.ToLower() == message.ToLower()) { Server.tempBans.Remove(tban); Player.GlobalMessage(message + " has had their temporary ban lifted."); return; } } Player.SendMessage(p, "Player is not banned."); return; } Player.GlobalMessage(message + " &8(banned)" + Server.DefaultColor + " is now " + Group.standard.color + Group.standard.name + Server.DefaultColor + "!"); Group.findPerm(LevelPermission.Banned).playerList.Remove(message); } else { if (Group.findPlayerGroup(message) != Group.findPerm(LevelPermission.Banned)) { foreach (Server.TempBan tban in Server.tempBans) { if (tban.name == who.name) { Server.tempBans.Remove(tban); Player.GlobalMessage(who.color + who.prefix + who.name + Server.DefaultColor + "has had their temporary ban lifted."); return; } } Player.SendMessage(p, "Player is not banned."); return; } Player.GlobalChat(who, who.color + who.prefix + who.name + Server.DefaultColor + " is now " + Group.standard.color + Group.standard.name + Server.DefaultColor + "!", false); who.group = Group.standard; 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.Remove(message); } Group.findPerm(LevelPermission.Banned).playerList.Save(); if (totalUnban) { Command.all.Find("unbanip").Use(p, "@" + message); } }
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); if (who == null) { if (!Player.ValidName(message)) { Player.SendMessage(p, "Invalid name \"" + message + "\"."); return; } if (Server.devs.Contains(message.ToLower())) { Player.SendMessage(p, "You can't ban a MCForge Developer!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " attempted to ban a MCForge Developer!"); } else { Player.GlobalMessage(Server.DefaultColor + "The Console attempted to ban a MCForge Developer!"); } return; } Group foundGroup = Group.findPlayerGroup(message); 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 + " is already banned."); return; } foundGroup.playerList.Remove(message); foundGroup.playerList.Save(); Player.GlobalMessage(message + " &f(offline)" + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + "!"); Group.findPerm(LevelPermission.Banned).playerList.Add(message); } else { if (!Player.ValidName(who.name)) { Player.SendMessage(p, "Invalid name \"" + who.name + "\"."); return; } if (Server.devs.Contains(who.name.ToLower())) { Player.SendMessage(p, "You can't ban a MCForge Developer!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " attempted to ban a MCForge Developer!"); } else { Player.GlobalMessage(Server.DefaultColor + "The Console attempted to ban a MCForge Developer!"); } 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, message + " is already banned."); return; } who.group.playerList.Remove(message); who.group.playerList.Save(); if (stealth) { Player.GlobalMessageOps(who.color + who.name + Server.DefaultColor + " is now STEALTH &8banned" + Server.DefaultColor + "!"); } else { Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + "!", false); } 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); } Group.findPerm(LevelPermission.Banned).playerList.Save(); IRCBot.Say(message + " was banned."); Server.s.Log("BANNED: " + message.ToLower()); if (totalBan == true) { Command.all.Find("undo").Use(p, message + " 0"); Command.all.Find("banip").Use(p, "@ " + message); } } catch (Exception e) { Server.ErrorLog(e); } }
public override void Use(Player p, string message) { if (message.Split(' ').Length < 2) { Help(p); return; } Player who = Player.Find(message.Split(' ')[0]); Group newRank = Group.Find(message.Split(' ')[1]); string msgGave; if (message.Split(' ').Length > 2) { msgGave = message.Substring(message.IndexOf(' ', message.IndexOf(' ') + 1)); } else { msgGave = "Congratulations!"; } if (newRank == null) { Player.SendMessage(p, "Could not find specified rank."); return; } Group bannedGroup = Group.findPerm(LevelPermission.Banned); if (who == null) { string foundName = message.Split(' ')[0]; if (Group.findPlayerGroup(foundName) == bannedGroup || newRank == bannedGroup) { Player.SendMessage(p, "Cannot change the rank to or from \"" + bannedGroup.name + "\"."); return; } if (p != null) { if (Group.findPlayerGroup(foundName).Permission >= p.group.Permission || newRank.Permission >= p.group.Permission) { Player.SendMessage(p, "Cannot change the rank of someone equal or higher than you"); return; } } Group oldGroup = Group.findPlayerGroup(foundName); oldGroup.playerList.Remove(foundName); oldGroup.playerList.Save(); newRank.playerList.Add(foundName); newRank.playerList.Save(); Player.GlobalMessage(foundName + " &f(offline)" + Server.DefaultColor + "'s rank was set to " + newRank.color + newRank.name); } else if (who == p) { Player.SendMessage(p, "Cannot change your own rank."); return; } else { if (p != null) { if (who.group == bannedGroup || newRank == bannedGroup) { Player.SendMessage(p, "Cannot change the rank to or from \"" + bannedGroup.name + "\"."); return; } if (who.group.Permission >= p.group.Permission || newRank.Permission >= p.group.Permission) { Player.SendMessage(p, "Cannot change the rank of someone equal or higher to yourself."); return; } } who.group.playerList.Remove(who.name); who.group.playerList.Save(); newRank.playerList.Add(who.name); newRank.playerList.Save(); Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + "'s rank was set to " + newRank.color + newRank.name, false); Player.GlobalChat(null, "&6" + msgGave, false); who.group = newRank; who.color = who.group.color; Player.GlobalDie(who, false); who.SendMessage("You are now ranked " + newRank.color + newRank.name + Server.DefaultColor + ", type /help for your new set of commands."); Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false); } }
public override void Use(Player p, string message) { if ((message == "")) { this.Help(p); } else { Player player = Player.Find(message.Split(' ')[0]); if (player != null) { if (p == null) { this.SendIt(p, message, player); } else { if (player == p) { this.SendIt(p, message, player); } else { if (p.group.Permission > player.group.Permission) { this.SendIt(p, message, player); } else { Player.SendMessage(p, "You cannot impersonate a player of equal or greater rank."); } } } } else { if (p != null) { if (p.group.Permission >= LevelPermission.Admin) { if (Group.findPlayerGroup(message.Split(' ')[0]).Permission < p.group.Permission) { this.SendIt(p, message, null); } else { Player.SendMessage(p, "You cannot impersonate a player of equal or greater rank."); } } else { Player.SendMessage(p, "You are not allowed to impersonate offline players"); } } else { this.SendIt(p, message, null); } } } }
public override void Use(Player p, string message) { if (message == "") { Help(p); return; } bool totalUnban = false; if (message[0] == '@') { totalUnban = true; message = message.Remove(0, 1).Trim(); } Player who = Player.Find(message); if (who == null) { if (Group.findPlayerGroup(message) != Group.findPerm(LevelPermission.Banned)) { foreach (Server.TempBan tban in Server.tempBans) { if (tban.name.ToLower() == message.ToLower()) { if (p != null) { Server.tempBans.Remove(tban); Player.GlobalMessage(message + " has had their temporary ban lifted by " + p.color + p.name + Server.DefaultColor + "."); Server.s.Log("UNBANNED: by " + p.name); Server.IRC.Say(message + " was unbanned by " + p.name + "."); return; } else { Server.tempBans.Remove(tban); Player.GlobalMessage(message + " has had their temporary ban lifted by console."); Server.s.Log("UNBANNED: by console"); Server.IRC.Say(message + " was unbanned by console."); return; } } } Player.SendMessage(p, "Player is not banned."); return; } if (Group.findPlayerGroup(message) == Group.findPerm(LevelPermission.Banned)) { if (p != null) { Player.GlobalMessage(message + " was &8(unbanned)" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + "."); Server.s.Log("UNBANNED: by " + p.name); Server.IRC.Say(message + " was unbanned by " + p.name + "."); } else { Player.GlobalMessage(message + " was &8(unbanned)" + Server.DefaultColor + " by console."); Server.s.Log("UNBANNED: by console"); Server.IRC.Say(message + " was unbanned by console."); } Group.findPerm(LevelPermission.Banned).playerList.Remove(message); if (Ban.Deleteban(message)) { Player.SendMessage(p, "deleted ban information about " + message + "."); } else { Player.SendMessage(p, "no info found about " + message + "."); } } } else { if (Group.findPlayerGroup(message) != Group.findPerm(LevelPermission.Banned)) { foreach (Server.TempBan tban in Server.tempBans) { if (tban.name == who.name) { if (p != null) { Server.tempBans.Remove(tban); Player.GlobalMessage(message + " has had their temporary ban lifted by " + p.color + p.name + Server.DefaultColor + "."); Server.s.Log("UNBANNED: by " + p.name); Server.IRC.Say(message + " was unbanned by " + p.name + "."); return; } else { Server.tempBans.Remove(tban); Player.GlobalMessage(message + " has had their temporary ban lifted by console."); Server.s.Log("UNBANNED: by console"); Server.IRC.Say(message + " was unbanned by console."); return; } } } Player.SendMessage(p, "Player is not banned."); return; } if (Group.findPlayerGroup(message) == Group.findPerm(LevelPermission.Banned)) { if (p != null) { Player.GlobalMessage(message + " was &8(unbanned)" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + "."); Server.s.Log("UNBANNED: by " + p.name); Server.IRC.Say(message + " was unbanned by " + p.name + "."); } else { Player.GlobalMessage(message + " was &8(unbanned)" + Server.DefaultColor + " by console."); Server.s.Log("UNBANNED: by console"); Server.IRC.Say(message + " was unbanned by console."); } who.group = Group.standard; 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.Remove(message); } } Group.findPerm(LevelPermission.Banned).playerList.Save(); if (totalUnban) { Command.all.Find("unbanip").Use(p, "@" + message); } }