public static string Append(Player p, string ai, string cmd, string[] args) { using (StreamWriter w = new StreamWriter("bots/" + ai, true)) { if (cmd.Length == 0) { cmd = "walk"; } if (cmd.CaselessEq("tp")) { cmd = "teleport"; } BotInstruction ins = BotInstruction.Find(cmd); if (ins == null) { p.Message("Could not find instruction \"" + cmd + "\""); return(null); } CommandExtraPerms killPerms = CommandExtraPerms.Find("BotSet", 1); if (ins.Name.CaselessEq("kill") && !killPerms.UsableBy(p.Rank)) { killPerms.MessageCannotUse(p); return(null); } try { ins.Output(p, args, w); } catch { p.Message("Invalid arguments given for instruction " + ins.Name); return(null); } return(ins.Name); } }
static void SetOldReview() { if (old.clearPerm == -1 && old.nextPerm == -1 && old.viewPerm == -1 && old.opchatPerm == -1 && old.adminchatPerm == -1) { return; } // Apply backwards compatibility if (old.viewPerm != -1) { CommandExtraPerms.Find("Review", 1).MinRank = (LevelPermission)old.viewPerm; } if (old.nextPerm != -1) { CommandExtraPerms.Find("Review", 2).MinRank = (LevelPermission)old.nextPerm; } if (old.clearPerm != -1) { CommandExtraPerms.Find("Review", 3).MinRank = (LevelPermission)old.clearPerm; } if (old.opchatPerm != -1) { Chat.OpchatPerms.MinRank = (LevelPermission)old.opchatPerm; } if (old.adminchatPerm != -1) { Chat.AdminchatPerms.MinRank = (LevelPermission)old.adminchatPerm; } CommandExtraPerms.Save(); }
// this doesn't check access for player vs model, // only checks if they can edit a certain field on this model public bool CanEdit(Player p, string modelName = null) { if (this.extra) { // you can edit these if you're op, if (CommandExtraPerms.Find("CustomModel", 1).UsableBy(p.Rank)) { return(true); } else { // or if it's not a primary personal model if (modelName != null && new StoredCustomModel(modelName, true).IsPersonalPrimary()) { // is a primary personal model return(false); } else { return(true); } } } else { return(true); } }
public override void Help(Player p) { p.Message("%T/Patrol"); ItemPerms except = CommandExtraPerms.Find(name, 1); p.Message("%HTeleports you to a random player. {0} %Hare not patrolled", except.Describe()); p.Message("%HPlayers patrolled within the last 15 seconds are ignored"); }
static void LogIPAction(ModAction e, string type) { ItemPerms perms = CommandExtraPerms.Find("WhoIs", 1); Chat.Message(ChatScope.Global, e.FormatMessage("An IP", type), perms, FilterNotItemPerms, true); Chat.Message(ChatScope.Global, e.FormatMessage(e.Target, type), perms, Chat.FilterPerms, true); }
protected bool CheckExtraPerm(Player p, CommandData data, int num) { if (HasExtraPerm(p, data.Rank, num)) { return(true); } CommandExtraPerms perms = CommandExtraPerms.Find(name, num); perms.MessageCannotUse(p); return(false); }
protected bool CheckExtraPerm(Player p, int num) { if (HasExtraPerm(p, num)) { return(true); } CommandExtraPerms perms = CommandExtraPerms.Find(name, num); Formatter.MessageNeedMinPerm(p, perms.Description, perms.MinRank); return(false); }
public static bool CanEditAny(Player p) { if (LevelInfo.IsRealmOwner(p.level, p.name)) { return(true); } ItemPerms perms = CommandExtraPerms.Find("Bot", 1) ?? new ItemPerms(LevelPermission.Operator); if (perms.UsableBy(p.Rank)) { return(true); } return(false); }
void HandleEnter(Player p, CommandData data) { if (p.IsSuper) { p.Message("{0} cannot enter the review queue.", p.SuperName); return; } TimeSpan delta = p.NextReviewTime - DateTime.UtcNow; if (delta.TotalSeconds >= 0) { p.Message("You must wait {0} before you can request another review", delta.Shorten(true, true)); return; } if (Server.reviewlist.CaselessContains(p.name)) { p.Message("You are already in the review queue!"); return; } bool opsOn = false; Player[] players = PlayerInfo.Online.Items; ItemPerms nextPerms = CommandExtraPerms.Find("Review", 2); foreach (Player pl in players) { if (nextPerms.UsableBy(pl.Rank) && Entities.CanSee(data, p, pl)) { opsOn = true; break; } } Server.reviewlist.Add(p.name); int pos = Server.reviewlist.IndexOf(p.name) + 1; p.Message("You entered the &creview %Squeue at &aposition #" + pos); string msg = opsOn ? "The online staff have been notified. Someone should be with you shortly." : "There are currently no staff online. Staff will be notified when they join the server."; p.Message(msg); Chat.MessageFrom(ChatScope.Perms, p, "λNICK %Srequested a review! &c(Total " + pos + " waiting)", nextPerms, null, true); p.NextReviewTime = DateTime.UtcNow.Add(ServerConfig.ReviewCooldown); }
void HandleAdd(Player p, string[] args) { if (args.Length != 2) { p.Message("You need to provide a reason for the report."); return; } string target = PlayerDB.MatchNames(p, args[0]); if (target == null) { return; } string nick = p.FormatNick(target); List <string> reports = new List <string>(); if (HasReports(target)) { reports = Utils.ReadAllLinesList(ReportPath(target)); } ItemPerms checkPerms = CommandExtraPerms.Find(name, 1); if (reports.Count >= 5) { p.Message("{0} &Walready has 5 reports! Please wait until an {1} &Whas reviewed these reports first!", nick, CommandExtraPerms.Find(name, 1).Describe()); return; } string reason = ModActionCmd.ExpandReason(p, args[1]); if (reason == null) { return; } reports.Add(reason + " - Reported by " + p.name + " at " + DateTime.Now); File.WriteAllLines(ReportPath(target), reports.ToArray()); p.Message("&aReport sent! It should be viewed when a {0} &ais online", checkPerms.Describe()); string opsMsg = "λNICK &Sreported " + nick + "&S. Reason: " + reason; Chat.MessageFrom(ChatScope.Perms, p, opsMsg, checkPerms, null, true); string allMsg = "Use &T/Report check " + target + " &Sto see all of their reports"; Chat.MessageFrom(ChatScope.Perms, p, allMsg, checkPerms, null, true); }
public static bool CanEditAny(Player p) { if (LevelInfo.IsRealmOwner(p.name, p.level.name)) { return(true); } ItemPerms perms = CommandExtraPerms.Find("EffectSpawner", 1); perms = perms == null ? new ItemPerms(LevelPermission.Operator, null, null) : perms; if (perms.UsableBy(p.Rank)) { return(true); } return(false); }
void HandleAdd(Player p, string[] args) { if (args.Length != 2) { p.Message("You need to provide a reason for the report."); return; } string target = PlayerDB.MatchNames(p, args[0]); if (target == null) { return; } List <string> reports = new List <string>(); if (File.Exists("extra/reported/" + target + ".txt")) { reports = Utils.ReadAllLinesList("extra/reported/" + target + ".txt"); } ItemPerms checkPerms = CommandExtraPerms.Find(name, 1); if (reports.Count >= 5) { p.Message("{0} %Walready has 5 reports! Please wait until an {1} %Whas reviewed these reports first!", p.FormatNick(target), checkPerms.Describe()); return; } string reason = args[1]; reason = ModActionCmd.ExpandReason(p, reason); if (reason == null) { return; } reports.Add(reason + " - Reported by " + p.name + " at " + DateTime.Now); File.WriteAllLines("extra/reported/" + target + ".txt", reports.ToArray()); p.Message("&aReport sent! It should be viewed when a {0} &ais online", checkPerms.Describe()); string opsMsg = "λNICK %Smade a report, view it with %T/Report check " + target; Chat.MessageFrom(ChatScope.Perms, p, opsMsg, checkPerms, null, true); }
public override void Use(Player p, string message, CommandData data) { string[] args = message.SplitSpaces(3); if (args.Length < 2) { Help(p); return; } string cmdName = args[0], cmdArgs = ""; Command.Search(ref cmdName, ref cmdArgs); Command cmd = Command.Find(cmdName); if (cmd == null) { p.Message("Could not find command entered"); return; } if (!p.CanUse(cmd)) { p.Message("Your rank cannot use this command."); return; } if (args.Length == 2) { CommandPerms perms = CommandPerms.Find(cmd.name); SetPerms(p, args, data, perms, "command"); } else { int num = 0; if (!CommandParser.GetInt(p, args[2], "Extra permission number", ref num)) { return; } CommandExtraPerms perms = CommandExtraPerms.Find(cmd.name, num); if (perms == null) { p.Message("This command has no extra permission by that number."); return; } SetPerms(p, args, data, perms, "extra permission"); } }
void HandleAdd(Player p, string[] args) { if (args.Length != 2) { Player.Message(p, "You need to provide a reason for the report."); return; } string target = PlayerInfo.FindOfflineNameMatches(p, args[0]); if (target == null) { return; } List <string> reports = new List <string>(); if (File.Exists("extra/reported/" + target + ".txt")) { reports = new List <string>(File.ReadAllLines("extra/reported/" + target + ".txt")); } if (reports.Count >= 5) { LevelPermission checkRank = CommandExtraPerms.Find(name, 1).MinRank; Player.Message(p, "{0} &calready has 5 pending reports! Please wait until an {1}%c+ has reviewed these reports first!", PlayerInfo.GetColoredName(p, target), Group.GetColoredName(checkRank)); return; } string reason = args[1]; reason = ModActionCmd.ExpandReason(p, reason); if (reason == null) { return; } reports.Add(reason + " - Reported by " + p.name + " at " + DateTime.Now); File.WriteAllLines("extra/reported/" + target + ".txt", reports.ToArray()); Player.Message(p, "%aYour report has been sent, it should be viewed when an operator is online!"); Chat.MessageOps(p.ColoredName + " %Shas made a report, view it with %T/Report check " + target); }
public void DisplayInfo(Player p) { p.Message("Bot {0} &S({1}) has:", ColoredName, name); p.Message(" Owner: &f{0}", string.IsNullOrEmpty(Owner) ? "no one" : p.FormatNick(Owner)); if (!String.IsNullOrEmpty(AIName)) { p.Message(" AI: &f{0}", AIName); } if (hunt || kill) { p.Message(" Hunt: &f{0}&S, Kill: %f{1}", hunt, kill); } if (SkinName != name) { p.Message(" Skin: &f{0}", SkinName); } if (Model != "humanoid") { p.Message(" Model: &f{0}", Model); } if (!(ScaleX == 0 && ScaleY == 0 && ScaleZ == 0)) { p.Message(" X scale: &a{0}&S, Y scale: &a{1}&S, Z scale: &a{2}", ScaleX == 0 ? "none" : ScaleX.ToString(), ScaleY == 0 ? "none" : ScaleY.ToString(), ScaleZ == 0 ? "none" : ScaleZ.ToString() ); } if (String.IsNullOrEmpty(ClickedOnText)) { return; } ItemPerms perms = CommandExtraPerms.Find("About", 1) ?? new ItemPerms(LevelPermission.AdvBuilder); if (!perms.UsableBy(p.Rank)) { return; //don't show bot's ClickedOnText if player isn't allowed to see message block contents } p.Message(" Clicked-on text: {0}", ClickedOnText); }
public AccessResult Check(string name, LevelPermission rank) { if (Blacklisted.CaselessContains(name)) { return(AccessResult.Blacklisted); } if (Whitelisted.CaselessContains(name)) { return(AccessResult.Whitelisted); } if (rank < Min) { return(AccessResult.BelowMinRank); } if (rank > Max && MaxCmd != null && !CommandExtraPerms.Find(MaxCmd, 1).UsableBy(rank)) { return(AccessResult.AboveMaxRank); } return(AccessResult.Allowed); }
public static void IPLine(Player p, string name, string ip) { ItemPerms seeIpPerms = CommandExtraPerms.Find("WhoIs", 1); if (!seeIpPerms.UsableBy(p.Rank)) { return; } string ipMsg = ip; if (Server.bannedIP.Contains(ip)) { ipMsg = "&8" + ip + ", which is banned"; } p.Message(" The IP of " + ipMsg); if (Server.Config.WhitelistedOnly && Server.whiteList.Contains(name)) { p.Message(" Player is &fWhitelisted"); } }
List <Player> GetPatrolCandidates(Player p, CommandData data) { List <Player> candidates = new List <Player>(); ItemPerms except = CommandExtraPerms.Find(name, 1); Player[] players = PlayerInfo.Online.Items; DateTime cutoff = DateTime.UtcNow.AddSeconds(-15); foreach (Player target in players) { if (except.UsableBy(target.Rank) || !Entities.CanSee(data, p, target)) { continue; } if (target == p || target.LastPatrol > cutoff) { continue; } candidates.Add(target); } return(candidates); }
void SaveCommands() { if (!CommandsChanged()) { LoadCommands(); return; } foreach (CommandPerms changed in commandPermsChanged) { CommandPerms.Set(changed.CmdName, changed.MinRank, changed.Allowed, changed.Disallowed); } foreach (CommandExtraPerms changed in commandExtraPermsChanged) { CommandExtraPerms orig = CommandExtraPerms.Find(changed.CmdName, changed.Num); orig.MinRank = changed.MinRank; } CommandExtraPerms.Save(); CommandPerms.Save(); CommandPerms.Load(); LoadCommands(); }
static void CheckReviewList(Player p) { if (!p.group.CanExecute("Review")) { return; } ItemPerms checkPerms = CommandExtraPerms.Find("Review", 1); if (!checkPerms.UsableBy(p.Rank)) { return; } int count = Server.reviewlist.Count; if (count == 0) { return; } string suffix = count == 1 ? " player is " : " players are "; p.Message(count + suffix + "waiting for a review. Type %T/Review view"); }
public static bool IsValid(string json, Player p, string modelName) { var jsonRoot = Parse(json); var parts = jsonRoot.ToParts(); if (!jsonRoot.IsValid(p)) { return(false); } if (parts.Length > Packet.MaxCustomModelParts) { p.Message( "%WNumber of model parts ({0}) exceeds max of {1}!", parts.Length, Packet.MaxCustomModelParts ); return(false); } // only do size check if they can't upload global models if (!CommandExtraPerms.Find("CustomModel", 1).UsableBy(p.Rank)) { for (int i = 0; i < parts.Length; i++) { // Models can be 1 block bigger if they aren't a purely personal model bool purePersonal = new StoredCustomModel(modelName).IsPersonalPrimary(); float graceLength = purePersonal ? 8.0f : 16.0f; if ( !SizeAllowed(parts[i].min, graceLength) || !SizeAllowed(parts[i].max, graceLength) ) { p.Message( "%WThe %b{0} cube in your list %Wis out of bounds.", ListicleNumber(i + 1) ); p.Message( "%WYour {0} may not be larger than %b{1}%W pixels tall or %b{2}%W pixels wide.", purePersonal ? "personal model" : "model", maxHeight + graceLength, maxWidth + (graceLength * 2), graceLength ); if (purePersonal) { p.Message("These limits only apply to your personal \"%b{0}%S\" model.", modelName); p.Message("Models you upload with other names (e.g, /cm {0}bike upload) can be slightly larger.", modelName); } return(false); } } } for (int i = 0; i < parts.Length; i++) { var part = parts[i]; if (part.anims.Length > Packet.MaxCustomModelAnims) { p.Message( "%WThe %b{0} cube in your list %Whas more than %b{1} %Wanimations.", ListicleNumber(i + 1), Packet.MaxCustomModelAnims ); break; } } return(true); }
protected bool HasExtraPerm(Player p, string cmd, LevelPermission plRank, int num) { return(CommandExtraPerms.Find(cmd, num).UsableBy(plRank)); }
public override void Use(Player p, string message) { string[] args = message.SplitSpaces(); if (args.Length == 1) { Help(p); return; } Command cmd = Command.all.Find(args[0]); if (cmd == null) { Player.Message(p, "Could not find command entered"); return; } if (p != null && !p.group.CanExecute(cmd)) { Player.Message(p, "Your rank cannot use this command."); return; } if (args.Length == 2 && args[1][0] == '+') { Group grp = GetGroup(p, args[1].Substring(1)); if (grp == null) { return; } CommandPerms perms = CommandPerms.Find(cmd.name); if (perms.Disallowed.Contains(grp.Permission)) { perms.Disallowed.Remove(grp.Permission); } else if (!perms.Allowed.Contains(grp.Permission)) { perms.Allowed.Add(grp.Permission); } UpdatePermissions(cmd, p, " can now be used by " + grp.ColoredName); } else if (args.Length == 2 && args[1][0] == '-') { Group grp = GetGroup(p, args[1].Substring(1)); if (grp == null) { return; } CommandPerms perms = CommandPerms.Find(cmd.name); if (p != null && p.Rank == grp.Permission) { Player.Message(p, "You cannot disallow your own rank from using a command."); return; } if (perms.Allowed.Contains(grp.Permission)) { perms.Allowed.Remove(grp.Permission); } else if (!perms.Disallowed.Contains(grp.Permission)) { perms.Disallowed.Add(grp.Permission); } UpdatePermissions(cmd, p, " is no longer usable by " + grp.ColoredName); } else if (args.Length == 2) { Group grp = GetGroup(p, args[1]); if (grp == null) { return; } CommandPerms perms = CommandPerms.Find(cmd.name); perms.MinRank = grp.Permission; UpdatePermissions(cmd, p, "'s permission was set to " + grp.ColoredName); } else { int otherPermIndex = 0; if (!CommandParser.GetInt(p, args[2], "Extra permission number", ref otherPermIndex)) { return; } CommandExtraPerms perms = CommandExtraPerms.Find(cmd.name, otherPermIndex); if (perms == null) { Player.Message(p, "This command has no extra permission by that number."); return; } if (p != null && p.Rank < perms.MinRank) { Player.Message(p, "Your rank cannot modify this extra permission."); return; } Group grp = GetGroup(p, args[1]); if (grp == null) { return; } perms.MinRank = grp.Permission; CommandExtraPerms.Save(); string permName = "extra permission " + otherPermIndex; Chat.MessageGlobal("&d{0}%S's {1} was set to {2}", cmd.name, permName, grp.ColoredName); if (Player.IsSuper(p)) { Player.Message(p, "{0}'s {1} was set to {2}", cmd.name, permName, grp.ColoredName); } } }