public override void Use(Player p, string message) { if (message.Split(' ').Length != 2) { Help(p); return; } int newLimit; try { newLimit = int.Parse(message.Split(' ')[1]); } catch { Player.SendMessage(p, "Invalid limit amount"); return; } if (newLimit < 1) { Player.SendMessage(p, "Cannot set below 1."); return; } Group foundGroup = Group.Find(message.Split(' ')[0]); if (foundGroup != null) { foundGroup.maxBlocks = newLimit; Player.GlobalChat(null, foundGroup.color + foundGroup.name + "&g's building limits were set to &b" + newLimit, false); Group.saveGroups(Group.GroupList); } else { switch (message.Split(' ')[0].ToLower()) { case "rp": case "restartphysics": Server.rpLimit = newLimit; Player.GlobalMessage("Custom /rp's limit was changed to &b" + newLimit.ToString()); break; case "rpnorm": case "rpnormal": Server.rpNormLimit = newLimit; Player.GlobalMessage("Normal /rp's limit was changed to &b" + newLimit.ToString()); break; default: Player.SendMessage(p, "No supported /limit"); break; } } }
public override void Use(Player p, string message) { if (!Server.useMySQL) { p.SendMessage("MySQL has not been configured! Please configure MySQL to use Zones!"); return; } if (message == "") { Help(p); return; } string[] split = message.Split(' '); string target = split[0]; string zoneOwner; if (split.Length == 2) { Level level = Level.Find(target); if (!File.Exists("levels/" + target.ToLower() + ".lvl")) { Player.SendMessage(p, "No such level \"" + target + "\"!"); return; } if (Group.Find(split[1]) != null) { zoneOwner = "grp" + Group.Find(split[1]).name; } else if (Player.Find(split[1]) != null) { zoneOwner = Player.Find(split[1]).name; } else { zoneOwner = split[1]; } MySQL.executeQuery("INSERT INTO `Zone" + target + "` (SmallX, SmallY, SmallZ, BigX, BigY, BigZ, Owner) VALUES (" + 0 + ", " + 0 + ", " + 0 + ", " + (p.level.width - 1) + ", " + (p.level.depth - 1) + ", " + (p.level.height - 1) + ", '" + zoneOwner + "')"); Player.SendMessage(p, "Zoned entire level " + target + " for &b" + zoneOwner); if (level != null) { Level.Zone Zn; Zn.smallX = 0; Zn.smallY = 0; Zn.smallZ = 0; Zn.bigX = (ushort)(p.level.width - 1); Zn.bigY = (ushort)(p.level.depth - 1); Zn.bigZ = (ushort)(p.level.height - 1); Zn.Owner = zoneOwner; level.ZoneList.Add(Zn); } } else if (split.Length == 1) { if (Group.Find(split[0]) != null) { zoneOwner = "grp" + Group.Find(split[0]).name; } else if (Player.Find(split[0]) != null) { zoneOwner = Player.Find(split[0]).name; } else { zoneOwner = split[0]; } MySQL.executeQuery("INSERT INTO `Zone" + p.level.name + "` (SmallX, SmallY, SmallZ, BigX, BigY, BigZ, Owner) VALUES (" + 0 + ", " + 0 + ", " + 0 + ", " + (p.level.width - 1) + ", " + (p.level.depth - 1) + ", " + (p.level.height - 1) + ", '" + zoneOwner + "')"); Player.SendMessage(p, "Zoned entire level " + p.level.name + " for &b" + zoneOwner); Level.Zone Zn; Zn.smallX = 0; Zn.smallY = 0; Zn.smallZ = 0; Zn.bigX = (ushort)(p.level.width - 1); Zn.bigY = (ushort)(p.level.depth - 1); Zn.bigZ = (ushort)(p.level.height - 1); Zn.Owner = zoneOwner; p.level.ZoneList.Add(Zn); } else { Help(p); return; } }
public override void Use(Player p, string message) { if (!Server.useMySQL) { p.SendMessage("MySQL has not been configured! Please configure MySQL to use Zones!"); return; } CatchPos cpos; if (message == "") { p.ZoneCheck = true; Player.SendMessage(p, "Place a block where you would like to check for zones."); return; } else if (p.group.Permission < LevelPermission.Operator && p.level.name != Server.HomePrefix.ToLower() + p.name.ToLower()) { Player.SendMessage(p, "Reserved for OP+"); return; } if (message.IndexOf(' ') == -1) { if (p.canBuild == true) { switch (message.ToLower()) { case "del": p.zoneDel = true; Player.SendMessage(p, "Place a block where you would like to delete a zone."); return; default: Help(p); return; } } else { Player.SendMessage(p, "Cannot delete zone of higher rank."); return; } } if (message.ToLower() == "del all") { if (p.group.Permission < LevelPermission.Admin) { Player.SendMessage(p, "Only a " + Group.findPerm(LevelPermission.Admin).name + " may delete all zones at once"); return; } else { for (int i = 0; i < p.level.ZoneList.Count; i++) { Level.Zone Zn = p.level.ZoneList[i]; MySQL.executeQuery("DELETE FROM `Zone" + p.level.name + "` WHERE Owner='" + Zn.Owner + "' AND SmallX='" + Zn.smallX + "' AND SMALLY='" + Zn.smallY + "' AND SMALLZ='" + Zn.smallZ + "' AND BIGX='" + Zn.bigX + "' AND BIGY='" + Zn.bigY + "' AND BIGZ='" + Zn.bigZ + "'"); Player.SendMessage(p, "Zone deleted for &b" + Zn.Owner); p.level.ZoneList.Remove(p.level.ZoneList[i]); if (i == p.level.ZoneList.Count) { Player.SendMessage(p, "Finished removing all zones"); return; } i--; } } } if (p.group.Permission < LevelPermission.Operator && p.level.name != Server.HomePrefix + p.name.ToLower()) { Player.SendMessage(p, "Setting zones is reserved for OP+"); return; } if (Group.Find(message.Split(' ')[1]) != null) { message = message.Split(' ')[0] + " grp" + Group.Find(message.Split(' ')[1]).name; } if (message.Split(' ')[0].ToLower() == "add") { Player foundPlayer = Player.Find(message.Split(' ')[1]); if (foundPlayer == null) { cpos.Owner = message.Split(' ')[1].ToString(); } else { cpos.Owner = foundPlayer.name; } } else { Help(p); return; } if (!Player.ValidName(cpos.Owner)) { Player.SendMessage(p, "INVALID NAME."); return; } cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos; Player.SendMessage(p, "Place two blocks to determine the edges."); Player.SendMessage(p, "Zone for: &b" + cpos.Owner + "."); p.ClearBlockchange(); p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); }
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 (p != null) { if (message.Split(' ').Length > 2) { msgGave = message.Substring(message.IndexOf(' ', message.IndexOf(' ') + 1)) + " (" + p.name + ")"; } else { msgGave = "No reason given. (" + p.name + ")."; } } else if (message.Split(' ').Length > 2) { msgGave = message.Substring(message.IndexOf(' ', message.IndexOf(' ') + 1)) + " (Console)"; } else { msgGave = "No reason given. (Console)."; } 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 (newRank == bannedGroup) { if (p != null) { Player.GlobalMessage(foundName + " &f(offline)" + "&g is now &8banned" + "&g by " + p.color + p.name + "&g."); } else { Player.GlobalMessage(foundName + " &f(offline)" + "&g is now &8banned" + "&g by Console."); } return; } Group oldGroup = Group.findPlayerGroup(foundName); Player.GlobalMessage(foundName + " &f(offline)" + "&g's rank was set to " + newRank.color + newRank.name); Player.GlobalChat(null, "&6Reason: &f" + msgGave, false); } else { if (newRank == bannedGroup) { if (p != null) { Player.GlobalChat(who, who.color + who.name + "&g is now &8banned" + "&g by " + p.color + p.name + "&g.", false); } else { Player.GlobalChat(who, who.color + who.name + "&g is now &8banned" + "&g by Console.", false); } Player.GlobalChat(null, "&6Reason: &f" + msgGave, false); return; } Player.GlobalChat(who, who.color + who.name + "&g's rank was set to " + newRank.color + newRank.name, false); Player.GlobalChat(null, "&6Reason: &f" + msgGave, false); who.color = who.group.color; Player.GlobalDie(who, false); who.SendMessage("You are now ranked " + newRank.color + newRank.name + "&g, 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 (!Directory.Exists("extra/text/")) { Directory.CreateDirectory("extra/text"); } if (message == "") { DirectoryInfo di = new DirectoryInfo("extra/text/"); string allFiles = ""; foreach (FileInfo fi in di.GetFiles("*.txt")) { try { string firstLine = File.ReadAllLines("extra/text/" + fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length) + ".txt")[0]; if (firstLine[0] == '#') { if (Group.Find(firstLine.Substring(1)).Permission <= p.group.Permission) { allFiles += ", " + fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length); } } else { allFiles += ", " + fi.Name; } } catch (Exception e) { Server.ErrorLog(e); Player.SendMessage(p, "Error"); } } if (allFiles == "") { Player.SendMessage(p, "No files are viewable by you"); } else { Player.SendMessage(p, "Available files:"); Player.SendMessage(p, allFiles.Remove(0, 2)); } } else { if (!IsValid(message)) { Player.SendMessage(p, "File name is invalid. Please only use the following characters in your file name:"); Player.SendMessage(p, this.toLowerDictionary); return; } Player who = null; if (message.IndexOf(' ') != -1) { who = Player.Find(message.Split(' ')[message.Split(' ').Length - 1]); if (who != null) { message = message.Substring(0, message.LastIndexOf(' ')); } } if (who == null) { who = p; } if (File.Exists("extra/text/" + message + ".txt")) { try { string[] allLines = File.ReadAllLines("extra/text/" + message + ".txt"); if (allLines[0][0] == '#') { if (Group.Find(allLines[0].Substring(1)).Permission <= p.group.Permission) { for (int i = 1; i < allLines.Length; i++) { Player.SendMessage(who, allLines[i]); } } else { Player.SendMessage(p, "You cannot view this file"); } } else { for (int i = 1; i < allLines.Length; i++) { Player.SendMessage(who, allLines[i]); } } } catch { Player.SendMessage(p, "An error occurred when retrieving the file"); } } else { Player.SendMessage(p, "File specified doesn't exist"); } } }
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 (p != null) { if (message.Split(' ').Length > 2) { msgGave = message.Substring(message.IndexOf(' ', message.IndexOf(' ') + 1)) + " (" + p.name + ")"; } else { msgGave = "No reason given. (" + p.name + ")."; } } else if (message.Split(' ').Length > 2) { msgGave = message.Substring(message.IndexOf(' ', message.IndexOf(' ') + 1)) + " (Console)"; } else { msgGave = "No reason given. (Console)."; } if (newRank == null) { Player.SendMessage(p, "Could not find specified rank."); return; } Group bannedGroup = Group.findPerm(LevelPermission.Banned); if (who == null) { //if (Server.devs.Contains(message.ToLower())) { p.SendMessage("Can't let you do that, Starfox."); return; } 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(); msgGave = msgGave.Trim(); Player.GlobalMessage(foundName + " &f(offline)" + "&g's rank was set to " + newRank.color + newRank.name); MySQL.executeQuery("UPDATE Players SET lastRankReason = '[" + DateTime.Now.ToString() + "] " + msgGave.Replace("'", "\\'") + "' WHERE Name = '" + foundName + "'"); Player.GlobalChat(null, "&6Reason: &f" + msgGave, false); } else { //if (!Server.devs.Contains(p.name) && Server.devs.Contains(who.name)) { p.SendMessage("Can't let you do that, Starfox."); return; } 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(); msgGave = msgGave.Trim(); Player.GlobalChat(who, who.color + who.name + "&g's rank was set to " + newRank.color + newRank.name, false); Player.GlobalChat(null, "&6Reason: &f" + msgGave, false); who.group = newRank; who.color = who.group.color; Player.GlobalDie(who, false); who.SendMessage("You are now ranked " + newRank.color + newRank.name + "&g, 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); try { if (!Server.cli) { MCDawn.Gui.Window.thisWindow.UpdateClientList(Player.players); } } catch { } MySQL.executeQuery("UPDATE Players SET lastRankReason = '[" + DateTime.Now.ToString() + "] " + msgGave.Replace("'", "\\'") + "' WHERE Name = '" + who.originalName + "'"); who.lastRankReason = "[" + DateTime.Now.ToString() + "] " + msgGave; } }
public override void Use(Player p, string message) { if (message == "") { Help(p); return; } Level l; Group g; if (message.Split(' ').Length > 1) { if (message.Split(' ').Length > 2) { Help(p); return; } l = Level.Find(message.Split(' ')[0]); if (l == null) { Player.SendMessage(p, "Level could not be found."); return; } g = Group.Find(message.Split(' ')[1]); if (g == null) { Player.SendMessage(p, "Rank could not be found."); return; } if (p.group.Permission < g.Permission && p != null) { Player.SendMessage(p, "Cannot change SpeedHack rank to a higher rank."); return; } if (p.group.Permission < l.speedHackRank.Permission && p != null) { Player.SendMessage(p, "Cannot change SpeedHack rank of a higher rank."); return; } l.speedHackRank = g; l.Save(); Player.GlobalMessage("SpeedHack rank on " + l.name + " changed to " + g.name); } else { if (p == null) { Player.SendMessage(p, "Please specify a level if you are using this from Console."); return; } l = p.level; g = Group.Find(message); if (g == null) { Player.SendMessage(p, "Rank could not be found."); return; } if (p.group.Permission < g.Permission) { Player.SendMessage(p, "Cannot change SpeedHack rank to a higher rank."); return; } if (p.group.Permission < l.speedHackRank.Permission) { Player.SendMessage(p, "Cannot change SpeedHack rank of a higher rank."); return; } l.speedHackRank = g; l.Save(); Player.GlobalMessage("SpeedHack rank on " + l.name + " changed to " + g.name); } }
public override void Use(Player p, string message) { try { if (message == "") { Player.SendMessage(p, "Basic blocks: "); for (byte i = 0; i < 50; i++) { message += ", " + Block.Name(i); } Player.SendMessage(p, message.Remove(0, 2)); Player.SendMessage(p, "&d/blocks all <0/1/2/3/4> " + Server.DefaultColor + "will show the rest."); } else if (message.ToLower() == "all") { Player.SendMessage(p, "Complex blocks: "); for (byte i = 50; i < 255; i++) { if (Block.Name(i).ToLower() != "unknown") { message += ", " + Block.Name(i); } } Player.SendMessage(p, message.Remove(0, 2)); Player.SendMessage(p, "Use &d/blocks all <0/1/2/3/4> " + Server.DefaultColor + "for a readable list."); } else if (message.ToLower().IndexOf(' ') != -1 && message.Split(' ')[0] == "all") { int foundRange = 0; try { foundRange = int.Parse(message.Split(' ')[1]); } catch { Player.SendMessage(p, "Incorrect syntax"); return; } if (foundRange >= 5 || foundRange < 0) { Player.SendMessage(p, "Number must be between 0 and 4"); return; } message = ""; Player.SendMessage(p, "Blocks between " + foundRange * 51 + " and " + (foundRange + 1) * 51); for (byte i = (byte)(foundRange * 51); i < (byte)((foundRange + 1) * 51); i++) { if (Block.Name(i).ToLower() != "unknown") { message += ", " + Block.Name(i); } } Player.SendMessage(p, message.Remove(0, 2)); } else { string printMessage = ">>>&b"; if (Block.Byte(message) != Block.Zero) { byte b = Block.Byte(message); if (b < 51) { for (byte i = 51; i < 255; i++) { if (Block.Convert(i) == b) { printMessage += Block.Name(i) + ", "; } } if (printMessage != ">>>&b") { Player.SendMessage(p, "Blocks which look like \"" + message + "\":"); Player.SendMessage(p, printMessage.Remove(printMessage.Length - 2)); } else { Player.SendMessage(p, "No Complex Blocks look like \"" + message + "\""); } } else { Player.SendMessage(p, "&bComplex information for \"" + message + "\":"); Player.SendMessage(p, "&cBlock will appear as a \"" + Block.Name(Block.Convert(b)) + "\" block"); if (Block.LightPass(b)) { Player.SendMessage(p, "Block will allow light through"); } if (Block.Physics(b)) { Player.SendMessage(p, "Block effects physics in some way"); } else { Player.SendMessage(p, "Block will not effect physics in any way"); } if (Block.NeedRestart(b)) { Player.SendMessage(p, "The block's physics will auto-start"); } if (Block.OPBlocks(b)) { Player.SendMessage(p, "Block is unaffected by explosions"); } if (Block.AllowBreak(b)) { Player.SendMessage(p, "Anybody can activate the block"); } if (Block.Walkthrough(b)) { Player.SendMessage(p, "Block can be walked through"); } if (Block.Death(b)) { Player.SendMessage(p, "Walking through block will kill you"); } if (Block.DoorAirs(b) != (byte)0) { Player.SendMessage(p, "Block is an ordinary door"); } if (Block.tDoor(b)) { Player.SendMessage(p, "Block is a tdoor, which allows other blocks through when open"); } if (Block.odoor(b) != Block.Zero) { Player.SendMessage(p, "Block is an odoor, which toggles (GLITCHY)"); } if (Block.Mover(b)) { Player.SendMessage(p, "Block can be activated by walking through it"); } } } else if (Group.Find(message) != null) { LevelPermission Perm = Group.Find(message).Permission; foreach (Block.Blocks bL in Block.BlockList) { if (Block.canPlace(Perm, bL.type) && Block.Name(bL.type).ToLower() != "unknown") { printMessage += Block.Name(bL.type) + ", "; } } if (printMessage != ">>>&b") { Player.SendMessage(p, "Blocks which " + Group.Find(message).color + Group.Find(message).name + Server.DefaultColor + " can place: "); Player.SendMessage(p, printMessage.Remove(printMessage.Length - 2)); } else { Player.SendMessage(p, "No blocks are specific to this rank"); } } else if (message.IndexOf(' ') == -1) { if (message.ToLower() == "count") { Player.SendMessage(p, "Blocks in this map: " + p.level.blocks.Length); } else { Help(p); } } else if (message.Split(' ')[0].ToLower() == "count") { int foundNum = 0; byte foundBlock = Block.Byte(message.Split(' ')[1]); if (foundBlock == Block.Zero) { Player.SendMessage(p, "Could not find block specified"); return; } for (int i = 0; i < p.level.blocks.Length; i++) { if (foundBlock == p.level.blocks[i]) { foundNum++; } } if (foundNum == 0) { Player.SendMessage(p, "No blocks were of type \"" + message.Split(' ')[1] + "\""); } else if (foundNum == 1) { Player.SendMessage(p, "1 block was of type \"" + message.Split(' ')[1] + "\""); } else { Player.SendMessage(p, foundNum.ToString() + " blocks were of type \"" + message.Split(' ')[1] + "\""); } } else { Player.SendMessage(p, "Unable to find block or rank"); } } } catch (Exception e) { Server.ErrorLog(e); Help(p); } }
public override void Use(Player p, string message) { switch (message.Split(' ')[0].ToLower().Trim()) { case "on": if (Server.useDiscourager) { Player.SendMessage(p, "Discourager is already enabled."); return; } Server.useDiscourager = true; Properties.Save("properties/server.properties"); Player.SendMessage(p, "Discourager enabled."); break; case "off": if (!Server.useDiscourager) { Player.SendMessage(p, "Discourager is already disabled."); return; } Server.useDiscourager = false; Properties.Save("properties/server.properties"); Player.SendMessage(p, "Discourager disabled."); break; case "add": if (!Server.useDiscourager) { Player.SendMessage(p, "Discourager is currently disabled."); return; } Discourager.AddDiscouraged(message.Split(' ')[1]); Discourager.SaveDiscouraged(); Discourager.LoadDiscouraged(); if (Group.Find(Group.findPlayer(message.Split(' ')[1])).Permission > Server.opchatperm) { Player.SendMessage(p, "Cannot discourage OP+."); return; } if (Group.Find(Group.findPlayer(message.Split(' ')[1])).Permission >= p.group.Permission && p != null) { Player.SendMessage(p, "Cannot discourage player of equal or higher rank."); return; } if (Player.Find(message.Split(' ')[1]) != null) { if (Server.hasProtection(Player.Find(message.Split(' ')[1]).name)) { Player.SendMessage(p, "Cannot discourage player of equal or higher rank."); return; } message.Split(' ')[1] = Player.Find(message.Split(' ')[1]).name; } Player.SendMessage(p, message.Split(' ')[1] + " added to discouraged users list."); break; case "remove": if (!Server.useDiscourager) { Player.SendMessage(p, "Discourager is currently disabled."); return; } Discourager.RemoveDiscouraged(message.Split(' ')[1]); Discourager.SaveDiscouraged(); Discourager.LoadDiscouraged(); if (Player.Find(message.Split(' ')[1]) != null) { message.Split(' ')[1] = Player.Find(message.Split(' ')[1]).name; } Player.SendMessage(p, message.Split(' ')[1] + " removed from discouraged users list."); break; case "list": if (!Server.useDiscourager) { Player.SendMessage(p, "Discourager is currently disabled."); return; } if (Discourager.discouraged.Count <= 0) { Player.SendMessage(p, "Discouraged Users: None."); return; } else { string list = String.Join(", ", Discourager.discouraged.ToArray()); Player.SendMessage(p, "Discouraged Users: " + list.Remove(list.Length - 2)); } break; default: Help(p); return; } }
public static void InitAll() { GroupList = new List <Group>(); if (File.Exists("properties/ranks.properties")) { string[] lines = File.ReadAllLines("properties/ranks.properties"); Group thisGroup = new Group(); int gots = 0; foreach (string s in lines) { try { if (s != "" && s[0] != '#') { if (s.Split('=').Length == 2) { string property = s.Split('=')[0].Trim(); string value = s.Split('=')[1].Trim(); if (thisGroup.name == "" && property.ToLower() != "rankname") { Server.s.Log("Hitting an error at " + s + " of ranks.properties"); } else { switch (property.ToLower()) { case "rankname": gots = 0; thisGroup = new Group(); if (value.ToLower() == "developers" || value.ToLower() == "devs" || value.ToLower() == "developer" || value.ToLower() == "dev") { Server.s.Log("You are not a developer. Stop pretending you are."); } else if (GroupList.Find(grp => grp.name == value.ToLower()) == null) { thisGroup.trueName = value; } else { Server.s.Log("Cannot add the rank " + value + " twice"); } break; case "permission": int foundPermission; try { foundPermission = int.Parse(value); } catch { Server.s.Log("Invalid permission on " + s); break; } if (thisGroup.Permission != LevelPermission.Null) { Server.s.Log("Setting permission again on " + s); gots--; } bool allowed = true; if (GroupList.Find(grp => grp.Permission == (LevelPermission)foundPermission) != null) { allowed = false; } if (foundPermission > 119 || foundPermission < -50) { Server.s.Log("Permission must be between -50 and 119 for ranks"); break; } if (allowed) { gots++; thisGroup.Permission = (LevelPermission)foundPermission; } else { Server.s.Log("Cannot have 2 ranks set at permission level " + value); } break; case "limit": int foundLimit; try { foundLimit = int.Parse(value); } catch { Server.s.Log("Invalid limit on " + s); break; } gots++; thisGroup.maxBlocks = foundLimit; break; case "color": char foundChar; try { foundChar = char.Parse(value); } catch { Server.s.Log("Incorrect color on " + s); break; } if ((foundChar >= '0' && foundChar <= '9') || (foundChar >= 'a' && foundChar <= 'f')) { gots++; thisGroup.color = foundChar.ToString(); } else { Server.s.Log("Invalid color code at " + s); } break; case "filename": if (value.Contains("\\") || value.Contains("/")) { Server.s.Log("Invalid filename on " + s); break; } gots++; thisGroup.fileName = value; break; case "reqhours": int foundHours; try { foundHours = int.Parse(value); } catch { Server.s.Log("Invalid limit on " + s); break; } gots++; thisGroup.reqHours = foundHours; break; } if (gots >= 5) { GroupList.Add(new Group(thisGroup.Permission, thisGroup.maxBlocks, thisGroup.trueName, thisGroup.color[0], thisGroup.fileName, thisGroup.reqHours)); } } } else { Server.s.Log("In ranks.properties, the line " + s + " is wrongly formatted"); } } } catch { } } } if (GroupList.Find(grp => grp.Permission == LevelPermission.Banned) == null) { GroupList.Add(new Group(LevelPermission.Banned, 1, "Banned", '8', "banned.txt", 0)); } if (Server.useGriefer) { if (GroupList.Find(grp => grp.Permission == LevelPermission.Griefer) == null) { GroupList.Add(new Group(LevelPermission.Griefer, 1, "Griefer", 'f', "griefer.txt", 0)); } } if (GroupList.Find(grp => grp.Permission == LevelPermission.Guest) == null) { GroupList.Add(new Group(LevelPermission.Guest, 1, "Guest", '7', "guest.txt", 0)); } if (GroupList.Find(grp => grp.Permission == LevelPermission.Builder) == null) { GroupList.Add(new Group(LevelPermission.Builder, 400, "Builder", '2', "builders.txt", 0)); } if (GroupList.Find(grp => grp.Permission == LevelPermission.AdvBuilder) == null) { GroupList.Add(new Group(LevelPermission.AdvBuilder, 1200, "AdvBuilder", '3', "advbuilders.txt", 0)); } if (GroupList.Find(grp => grp.Permission == LevelPermission.Operator) == null) { GroupList.Add(new Group(LevelPermission.Operator, 2500, "Operator", 'c', "operators.txt", 0)); } if (GroupList.Find(grp => grp.Permission == LevelPermission.Admin) == null) { GroupList.Add(new Group(LevelPermission.Admin, 65536, "SuperOP", 'e', "uberOps.txt", 0)); } GroupList.Add(new Group(LevelPermission.Nobody, Int32.MaxValue, "Nobody", '1', "nobody.txt", 0)); bool swap = true; Group storedGroup; while (swap) { swap = false; for (int i = 0; i < GroupList.Count - 1; i++) { if (GroupList[i].Permission > GroupList[i + 1].Permission) { swap = true; storedGroup = GroupList[i]; GroupList[i] = GroupList[i + 1]; GroupList[i + 1] = storedGroup; } } } if (Group.Find(Server.defaultRank) != null) { standard = Group.Find(Server.defaultRank); } else { standard = Group.findPerm(LevelPermission.Guest); } foreach (Player pl in Player.players) { pl.group = GroupList.Find(g => g.name == pl.group.name); } saveGroups(GroupList); }
public override void Use(Player p, string message) { if (message == "") { Help(p); return; } Player pl = Player.Find(message); if (pl != null && !pl.hidden) { Player.SendMessage(p, pl.color + pl.name + "&g is online, using /whois instead."); Command.all.Find("whois").Use(p, message); return; } if (message.IndexOf("'") != -1) { Player.SendMessage(p, "Cannot parse request."); return; } string FoundRank = Group.findPlayer(message.ToLower()); DataTable playerDb = MySQL.fillData("SELECT * FROM Players WHERE Name='" + message + "'"); if (playerDb.Rows.Count == 0) { Player.SendMessage(p, Group.Find(FoundRank).color + message + "&g has the rank of " + Group.Find(FoundRank).color + FoundRank); return; } Player.SendMessage(p, Group.Find(FoundRank).color + playerDb.Rows[0]["Title"] + " " + message + "&g has :"); Player.SendMessage(p, "> > the rank of \"" + Group.Find(FoundRank).color + FoundRank); Player.SendMessage(p, "> > the display name of " + playerDb.Rows[0]["displayName"]); Player.SendMessage(p, "> > &a" + playerDb.Rows[0]["Money"] + "&g " + Server.moneys); Player.SendMessage(p, "> > &cdied &a" + playerDb.Rows[0]["TotalDeaths"] + "&g times"); Player.SendMessage(p, "> > &bmodified &a" + playerDb.Rows[0]["totalBlocks"] + "&g blocks."); //int ratio = (int)(Math.Round((decimal)(1 / (Math.Min(Convert.ToInt64(playerDb.Rows[0]["destroyedBlocks"].ToString()), (Convert.ToInt64(playerDb.Rows[0]["totalBlocks"].ToString()) - Convert.ToInt64(playerDb.Rows[0]["destroyedBlocks"].ToString()))) / Math.Max(Convert.ToInt64(playerDb.Rows[0]["destroyedBlocks"].ToString()), (Convert.ToInt64(playerDb.Rows[0]["totalBlocks"].ToString()) - Convert.ToInt64(playerDb.Rows[0]["destroyedBlocks"].ToString()))))))); Int64 builtBlocks = 0; try { builtBlocks = Convert.ToInt64(playerDb.Rows[0]["totalBlocks"].ToString()) - Convert.ToInt64(playerDb.Rows[0]["destroyedBlocks"].ToString()); } catch { builtBlocks = 0; } if (builtBlocks < 0) { builtBlocks = 0; } try { Player.SendMessage(p, "> > destroyed &a" + playerDb.Rows[0]["destroyedBlocks"].ToString() + "&g blocks, and built &a" + builtBlocks + "&g."); } catch { } Player.SendMessage(p, "> > was last seen on &a" + playerDb.Rows[0]["LastLogin"]); try { if (Server.useMaxMind) { Player.SendMessage(p, "> > last logged in from country &a" + playerDb.Rows[0]["countryName"]); } } catch { } Player.SendMessage(p, "> > " + TimeSpent(playerDb.Rows[0]["TimeSpent"].ToString())); Player.SendMessage(p, "> > first logged into the server on &a" + playerDb.Rows[0]["FirstLogin"]); Player.SendMessage(p, "> > logged in &a" + playerDb.Rows[0]["totalLogin"] + "&g times, &c" + playerDb.Rows[0]["totalKicked"] + "&g of which ended in a kick."); Player.SendMessage(p, "> > " + Awards.awardAmount(message) + " awards"); if (playerDb.Rows[0]["HasWOM"].ToString().Trim() == "") { Player.SendMessage(p, "> > last logged in without &cWOM Game Client" + "&g."); } else { Player.SendMessage(p, "> > last logged in using &aWOM Game Client" + "&g, Version &a" + playerDb.Rows[0]["HasWOM"].ToString().Trim() + "&g."); } // Last ranked/banned reason: string lastRankReason = playerDb.Rows[0]["lastRankReason"].ToString(); if (lastRankReason.ToLower() != "none" && !String.IsNullOrEmpty(lastRankReason)) { if (Group.findPerm(LevelPermission.Banned).playerList.Contains(message)) { Player.SendMessage(p, "> > last &8banned&g at &a" + lastRankReason.Split(']')[0].Substring(1) + "&g; Reason: &a" + lastRankReason.Substring(lastRankReason.IndexOf("]") + 1).Trim()); } else { Player.SendMessage(p, "> > last &branked&g at &a" + lastRankReason.Split(']')[0].Substring(1) + "&g; Reason: &a" + lastRankReason.Substring(lastRankReason.IndexOf("]") + 1).Trim()); } } bool skip = false; if (p != null) { if (p.group.Permission <= LevelPermission.Operator) { skip = true; } } if (!skip) { if (Server.bannedIP.Contains(playerDb.Rows[0]["IP"].ToString())) { playerDb.Rows[0]["IP"] = "&8" + playerDb.Rows[0]["IP"] + ", which is banned"; } Player.SendMessage(p, "> > the IP of " + playerDb.Rows[0]["IP"]); } if (Server.useWhitelist) { if (Server.whiteList.Contains(message.ToLower())) { Player.SendMessage(p, "> > Player is &fWhitelisted"); } } if (Server.devs.Contains(message.ToLower())) { Player.SendMessage(p, "&g> > Player is a &9Developer"); } if (Server.staff.Contains(message.ToLower())) { Player.SendMessage(p, "&g> > Player is a member of &4MCDawn Staff"); } if (Server.administration.Contains(message.ToLower())) { Player.SendMessage(p, "&g> > Player is a &6MCDawn Administrator"); } playerDb.Dispose(); }
public override void Use(Player p, string message) { if (!Directory.Exists("extra/text/")) { Directory.CreateDirectory("extra/text"); } if (message.IndexOf(' ') == -1) { Help(p); return; } try { if (message.Split(' ')[0].ToLower() == "delete") { if (!IsValid(message.Split(' ')[0])) { Player.SendMessage(p, "File name is invalid. The file name can only contain the following characters:"); Player.SendMessage(p, this.toLowerDictionary); return; } if (File.Exists("extra/text/" + message.Split(' ')[1] + ".txt")) { File.Delete("extra/text/" + message.Split(' ')[1] + ".txt"); Player.SendMessage(p, "Deleted file"); } else { Player.SendMessage(p, "Could not find file specified"); } } else { if (!IsValid(message.Split(' ')[0])) { Player.SendMessage(p, "File name is invalid. Please only use the following characters in your file name:"); Player.SendMessage(p, this.toLowerDictionary); return; } bool again = false; string fileName = "extra/text/" + message.Split(' ')[0] + ".txt"; string group = Group.findPerm(LevelPermission.Guest).name; if (Group.Find(message.Split(' ')[1]) != null) { group = Group.Find(message.Split(' ')[1]).name; again = true; } message = message.Substring(message.IndexOf(' ') + 1); if (again) { message = message.Substring(message.IndexOf(' ') + 1); } string contents = message; if (contents == "") { Help(p); return; } if (!File.Exists(fileName)) { contents = "#" + group + System.Environment.NewLine + contents; } else { contents = " " + contents; } File.AppendAllText(fileName, contents); Player.SendMessage(p, "Added text"); } } catch { Help(p); } }
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+" + Server.DefaultColor + foundName + " (" + pl.level.name + "),"; } else { devs += " " + foundName + " (" + pl.level.name + "),"; } } else if (pl.unverified || pl.devUnverified) { if (pl.voice) { unverified += " " + "&f+" + Server.DefaultColor + foundName + " (" + pl.level.name + "),"; } else { unverified += " " + foundName + " (" + pl.level.name + "),"; } } else { if (pl.voice) { playerList.Find(grp => grp.group == pl.group).players.Add("&f+" + Server.DefaultColor + 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."); if (devs.Length > 0) { Player.SendMessage(p, ":&9Developers:" + Server.DefaultColor + 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:" + Server.DefaultColor + unverified.Trim(',')); } //if (devUnverified.Length > 0) { Player.SendMessage(p, ":&3Developer Security System:" + Server.DefaultColor + unverified.Trim(',')); } } catch (Exception e) { Server.ErrorLog(e); } }