void DoIPBan(Player player, IPAddress address, string reason, string playerName, bool banAll, bool unban) { Player other; if (unban) { if (world.bans.Remove(address)) { player.Message(address.ToString() + " has been removed from the IP ban list."); } else { player.Message(address.ToString() + " is not currently banned."); } if (banAll) { foreach (PlayerInfo otherInfo in world.db.FindPlayersByIP(address)) { if (otherInfo.ProcessUnBan(player.name, reason + "~UnBanAll")) { player.Message(otherInfo.name + " matched the IP and was also unbanned."); } } } } else { if (world.bans.Add(new IPBanInfo(address, playerName, player.name, reason))) { player.Message(address.ToString() + " has been added to the IP ban list."); } else { player.Message(address.ToString() + " is already banned."); } foreach (PlayerInfo otherInfo in world.db.FindPlayersByIP(address)) { if (banAll && otherInfo.ProcessBan(player.name, reason + "~BanAll")) { player.Message(otherInfo.name + " matched the IP and was also banned."); } other = world.FindPlayerExact(otherInfo.name); if (other != null) { other.session.Kick("Your IP was just banned by " + player.name); } } } }
// Player information display. // When used without arguments, shows players's own stats. // An optional argument allows to look at other people's stats. void Info(Player player, Command cmd) { string name = cmd.Next(); if (name == null) { name = player.name; } else if (!player.Can(Permissions.ViewOthersInfo)) { world.NoAccessMessage(player); return; } PlayerInfo info; if (!world.db.FindPlayerInfo(name, out info)) { world.ManyPlayersMessage(player, name); } else if (info != null) { if (DateTime.Now.Subtract(info.lastLoginDate).TotalDays < 1) { player.Message(String.Format("About {0}: Last login {1:F1} hours ago from {2}", info.name, DateTime.Now.Subtract(info.lastLoginDate).TotalHours, info.lastIP)); } else { player.Message(String.Format("About {0}: Last login {1:F1} days ago from {2}", info.name, DateTime.Now.Subtract(info.lastLoginDate).TotalDays, info.lastIP)); } player.Message(String.Format(" Logged in {0} time(s) since {1:dd MMM yyyy}.", info.timesVisited, info.firstLoginDate)); player.Message(String.Format(" Built {0} and deleted {1} blocks, and wrote {2} messages.", info.blocksBuilt, info.blocksDeleted, info.linesWritten)); if (player.info.classChangedBy != "-") { player.Message(String.Format(" Promoted to {0} by {1} on {2:dd MMM yyyy}.", info.playerClass.name, info.classChangedBy, info.classChangeDate)); } else { player.Message(String.Format(" Class is {0} (default).", info.playerClass.name)); } TimeSpan totalTime = info.totalTimeOnServer; if (world.FindPlayerExact(name) != null) { totalTime = totalTime.Add(DateTime.Now.Subtract(info.lastLoginDate)); } player.Message(String.Format(" Spent a total of {0:F1} hours ({1:F1} minutes) here.", totalTime.TotalHours, totalTime.TotalMinutes)); } else { world.NoPlayerMessage(player, name); } }