static void ListHandler(Player p, Level lvl, string[] parts, bool global, string cmd) { string modifier = parts.Length > 1 ? parts[1] : ""; BlockDefinition[] defs = global ? BlockDefinition.GlobalDefs : lvl.CustomBlockDefs; List <BlockDefinition> defsInScope = new List <BlockDefinition>(); for (int i = 0; i < defs.Length; i++) { BlockDefinition def = defs[i]; if (def == null) { continue; } BlockID block = def.GetBlock(); if (!ExistsInScope(def, block, global)) { continue; } defsInScope.Add(def); } MultiPageOutput.Output(p, defsInScope, FormatBlock, cmd.Substring(1) + " list", "custom blocks", modifier, true); }
void HandleList(Player p, string[] args) { if (!CheckExtraPerm(p, 1)) { return; } string[] users = Directory.GetFiles("extra/reported", "*.txt"); for (int i = 0; i < users.Length; i++) { users[i] = Path.GetFileNameWithoutExtension(users[i]); } if (users.Length > 0) { Player.Message(p, "The following players have been reported:"); string modifier = args.Length > 1 ? args[1] : ""; MultiPageOutput.Output(p, users, pl => PlayerInfo.GetColoredName(p, pl), "Review list", "players", modifier, false); Player.Message(p, "Use %T/Report check [Player] %Sto view report details."); Player.Message(p, "Use %T/Report delete [Player] %Sto delete a report"); } else { Player.Message(p, "No reports were found."); } }
public override void Use(Player p, string message) { string[] files = Directory.GetFiles("levels", "*.lvl"); Player.Message(p, "Unloaded maps (&c[no] %Sif not visitable): "); MultiPageOutput.Output(p, GetMaps(files), (map, i) => FormatMap(p, map), "unloaded", "maps", message, false); }
public override void Use(Player p, string message) { string[] args = message.SplitSpaces(2); if (message == "") { Player.Message(p, "Available ranks: " + Group.concatList()); return; } string modifer = args.Length > 1 ? args[1] : ""; Group grp = message.CaselessEq("banned") ? Group.findPerm(LevelPermission.Banned) : Group.FindMatches(p, args[0]); if (grp == null) { return; } List <string> list = grp.playerList.All(); if (list.Count == 0) { Player.Message(p, "No one has the rank of " + grp.ColoredName); } else { Player.Message(p, "People with the rank of " + grp.ColoredName + ":"); MultiPageOutput.Output(p, list, (name, i) => name, "viewranks " + args[0], "players", modifer, false); } }
static void PrintAllCommands(Player p, string sort, string modifier) { List <Command> cmds = new List <Command>(); foreach (Command c in Command.all.commands) { if (c.name == null) { continue; } cmds.Add(c); } SortCommands(cmds, sort); Player.Message(p, "All commands:"); string type = "cmds all"; if (sort != "") { type += " " + sort; } MultiPageOutput.Output(p, cmds, (cmd, i) => CmdHelp.GetColor(cmd) + cmd.name, type, "commands", modifier, false); Player.Message(p, "Type %T/help <command> %Sfor more help on a command."); }
static void PrintHelpForGroup(Player p, string sort, string modifier, string type, string category) { List <Command> cmds = new List <Command>(); foreach (Command c in Command.all.commands) { string disabled = Command.GetDisabledReason(c.Enabled); if ((p == null || p.group.CanExecute(c)) && disabled == null) { if (!c.type.Contains(type) || c.name == null) { continue; } cmds.Add(c); } } if (cmds.Count == 0) { Player.Message(p, "You cannot use any of the " + category + " commands."); return; } SortCommands(cmds, sort); Player.Message(p, category + " commands you may use:"); type = "cmds " + category; if (sort != "") { type += " " + sort; } MultiPageOutput.Output(p, cmds, (cmd, i) => CmdHelp.GetColor(cmd) + cmd.name, type, "commands", modifier, false); Player.Message(p, "Type %T/help <command> %Sfor more help on a command."); }
void HandleList(Player p, string[] args) { string modifier = args.Length > 1 ? args[1] : ""; MultiPageOutput.Output(p, Team.Teams, team => team.Color + team.Name, "team list", "teams", modifier, false); }
public override void Use(Player p, string message) { string[] args = message.SplitSpaces(2); if (message.Length == 0) { Player.Message(p, "Available ranks: " + Group.GroupList.Join(g => g.ColoredName)); return; } string modifer = args.Length > 1 ? args[1] : ""; Group grp = message.CaselessEq("banned") ? Group.BannedRank : Matcher.FindRanks(p, args[0]); if (grp == null) { return; } List <string> list = grp.Players.All(); if (list.Count == 0) { Player.Message(p, "No one has the rank of " + grp.ColoredName); } else { Player.Message(p, "People with the rank of " + grp.ColoredName + ":"); MultiPageOutput.Output(p, list, (name) => name, "ViewRanks " + args[0], "players", modifer, false); } }
public override void Use(Player p, string message, CommandData data) { string[] files = LevelInfo.AllMapFiles(); p.Message("Maps (&c[no] %Sif not visitable): "); MultiPageOutput.Output(p, files, (file) => FormatMap(p, file), "Worlds", "maps", message, false); }
public override void Use(Player p, string message) { PlayerBot[] bots = PlayerBot.Bots.Items; Level lvl = null; string[] args = message.SplitSpaces(2); if (!(message == "" || args[0].CaselessEq("all"))) { lvl = LevelInfo.FindMatches(p, args[0]); if (lvl == null) { return; } } List <PlayerBot> inScope = new List <PlayerBot>(); foreach (PlayerBot bot in bots) { if (lvl != null && bot.level != lvl) { continue; } inScope.Add(bot); } string cmd = lvl == null ? "bots all" : "bots " + lvl.name; string modifier = args.Length > 1 ? args[1] : ""; MultiPageOutput.Output(p, inScope, FormatBot, cmd, "bots", modifier, false); }
public override void Use(Player p, string message, CommandData data) { Level[] loaded = LevelInfo.Loaded.Items; p.Message("Loaded levels [physics level] (&c[no] %Sif not visitable): "); MultiPageOutput.Output(p, loaded, (lvl) => FormatMap(p, lvl), "Levels", "levels", message, false); p.Message("Use %T/Levels %Sfor all levels."); }
public override void Use(Player p, string message) { Level[] loaded = LevelInfo.Loaded.Items; Player.Message(p, "Loaded maps [physics level] (&c[no] %Sif not visitable): "); MultiPageOutput.Output(p, loaded, (lvl) => FormatMap(p, lvl), "Levels", "maps", message, false); Player.Message(p, "Use %T/Worlds %Sfor all levels."); }
void ListProps(Player p, BlockProps[] scope, string[] args) { List <BlockID> filtered = FilterProps(scope); string cmd = "BlockProps " + args[0] + " list"; string modifier = args.Length > 2 ? args[2] : ""; MultiPageOutput.Output(p, filtered, b => BlockOptions.Name(scope, p, b), cmd, "modified blocks", modifier, false); }
void HandleList(Player p, string modifier) { string[] files = Directory.GetFiles("bots"); for (int i = 0; i < files.Length; i++) { files[i] = Path.GetFileNameWithoutExtension(files[i]); } MultiPageOutput.Output(p, files, f => f, "BotAI list", "bot AIs", modifier, false); }
public override void Use(Player p, string message, CommandData data) { string[] files = LevelInfo.AllMapFiles(); // Files list is not guaranteed to be in alphabetical order Array.Sort(files); p.Message("Levels (&c[no] &Sif not visitable): "); MultiPageOutput.Output(p, files, (file) => FormatMap(p, file), "Levels", "levels", message, false); }
static void OutputList(Player p, string keyword, string cmd, string type, string modifier, List <string> items) { if (items.Count == 0) { p.Message("No {0} found containing \"{1}\"", type, keyword); } else { MultiPageOutput.Output(p, items, item => item, cmd + " " + keyword, type, modifier, false); } }
static void PrintEmotes(Player p, string message) { char[] emotes = EmotesHandler.ControlCharReplacements.ToCharArray(); emotes[0] = EmotesHandler.ExtendedCharReplacements[0]; // replace NULL with house string[] args = message.SplitSpaces(2); string modifier = args.Length > 1 ? args[1] : ""; MultiPageOutput.Output(p, emotes, FormatEmote, "Help emotes", "emotes", modifier, true); }
static void OutputList <T>(Player p, string keyword, string cmd, string type, string modifier, List <T> items, Func <T, int, string> formatter) { if (items.Count == 0) { Player.Message(p, "No {0} found containing \"{1}\"", type, keyword); } else { MultiPageOutput.Output(p, items, formatter, cmd + " " + keyword, type, modifier, false); } }
public override void Use(Player p, string message) { string[] args = message.SplitSpaces(); if (args.Length > 2) { Help(p); return; } string plName = "", modifier = args[args.Length - 1]; int ignored; if (args.Length == 2) { plName = PlayerInfo.FindMatchesPreferOnline(p, args[0]); if (plName == null) { return; } } else if (message.Length > 0 && !message.CaselessEq("all")) { if (!int.TryParse(args[0], out ignored)) { modifier = ""; plName = PlayerInfo.FindMatchesPreferOnline(p, args[0]); if (plName == null) { return; } } } List <Awards.Award> awards = GetAwards(plName); if (awards.Count == 0) { if (plName.Length > 0) { Player.Message(p, "{0} %Shas no awards.", PlayerInfo.GetColoredName(p, plName)); } else { Player.Message(p, "This server has no awards yet."); } return; } string cmd = plName.Length == 0 ? "awards" : "awards " + plName; MultiPageOutput.Output(p, awards, FormatAward, cmd, "Awards", modifier, true); }
static void ListHandler(Player p, string cmd, string modifier) { List <ColorDesc> validCols = new List <ColorDesc>(Colors.List.Length); foreach (ColorDesc col in Colors.List) { if (col.IsModified()) { validCols.Add(col); } } MultiPageOutput.Output(p, validCols, FormatColor, cmd, "Colors", modifier, true); }
static void OutputBlocks(Player p, string type, string modifier, Predicate <BlockID> selector) { List <BlockID> blocks = new List <BlockID>(Block.ExtendedCount); for (BlockID b = 0; b < Block.ExtendedCount; b++) { if (Block.ExistsFor(p, b) && selector(b)) { blocks.Add(b); } } MultiPageOutput.Output(p, blocks, b => FormatBlockName(p, b), "Blocks " + type, "blocks", modifier, false); }
static void List(Player p, string modifier) { List <string> list = Server.vip.All(); if (list.Count == 0) { p.Message("There are no VIPs."); } else { p.Message("VIPs:"); MultiPageOutput.Output(p, list, (name) => PlayerInfo.GetColoredName(p, name), "VIP list", "players", modifier, false); } }
static void List(Player p, string[] args) { List <string> list = Server.whiteList.All(); string modifier = args.Length > 1 ? args[1] : ""; if (list.Count == 0) { Player.Message(p, "There are no whitelisted players."); } else { Player.Message(p, "Whitelisted players:"); MultiPageOutput.Output(p, list, (name, i) => PlayerInfo.GetColoredName(p, name), "whitelist list", "players", modifier, false); } }
public override void Use(Player p, string message, CommandData data) { string[] args = message.SplitSpaces(3); if (IsListCommand(args[0])) { string modifier = args.Length > 1 ? args[1] : ""; p.Message("Loaded plugins:"); MultiPageOutput.Output(p, Plugin.all, pl => pl.name, "Plugins", "plugins", modifier, false); return; } if (args.Length == 1) { Help(p); return; } string cmd = args[0], name = args[1]; if (!Formatter.ValidFilename(p, name)) { return; } string language = args.Length > 2 ? args[2] : ""; if (cmd.CaselessEq("load")) { LoadPlugin(p, name); } else if (cmd.CaselessEq("unload")) { UnloadPlugin(p, name); } else if (cmd.CaselessEq("create")) { CreatePlugin(p, name, language); } else if (cmd.CaselessEq("compile")) { CompilePlugin(p, name, language); } else { Help(p); } }
static void PrintAllCommands(Player p, string sort, string modifier) { List <Command> cmds = Command.CopyAll(); SortCommands(cmds, sort); p.Message("All commands:"); string type = "Commands all"; if (sort.Length > 0) { type += " " + sort; } MultiPageOutput.Output(p, cmds, (cmd) => CmdHelp.GetColor(cmd) + cmd.name, type, "commands", modifier, false); p.Message("Type &T/Help <command> &Sfor more help on a command."); }
static bool PrintCategoryCommands(Player p, string sort, string modifier, string type) { List <Command> cmds = new List <Command>(); string category = GetCategory(type); bool foundAny = false; foreach (Command c in Command.allCmds) { string disabled = Command.GetDisabledReason(c.Enabled); if (!c.type.CaselessEq(category)) { continue; } if (disabled == null && p.CanUse(c)) { cmds.Add(c); } foundAny = true; } if (!foundAny) { return(false); } if (cmds.Count == 0) { p.Message("You cannot use any of the " + category + " commands."); return(true); } SortCommands(cmds, sort); p.Message(category.Capitalize() + " commands you may use:"); type = "Commands " + type; if (sort.Length > 0) { type += " " + sort; } MultiPageOutput.Output(p, cmds, (cmd) => CmdHelp.GetColor(cmd) + cmd.name, type, "commands", modifier, false); p.Message("Type &T/Help <command> &Sfor more help on a command."); return(true); }
public override void Use(Player p, string message, CommandData data) { string[] args = message.SplitSpaces(); if (args.Length > 2) { Help(p); return; } int offset = 0; List <Awards.Award> awards = Awards.AwardsList; string name = ""; if (args.Length == 2 || (message.Length > 0 && !IsListModifier(args[0]))) { offset = 1; name = PlayerInfo.FindMatchesPreferOnline(p, args[0]); if (name == null) { return; } awards = AwardsHas(name); } if (awards.Count == 0) { if (name.Length > 0) { p.Message("{0} %Shas no awards.", PlayerInfo.GetColoredName(p, name)); } else { p.Message("This server has no awards yet."); } return; } string cmd = name.Length == 0 ? "awards" : "awards " + name; string modifier = args.Length > offset ? args[offset] : ""; MultiPageOutput.Output(p, awards, FormatAward, cmd, "Awards", modifier, true); }
void HandleEntries(Player p, string[] args) { if (args.Length < 2 || args.Length > 3) { Help(p); return; } ImagePalette palette = ImagePalette.Find(args[1]); if (palette == null) { p.Message("Palette {0} does not exist.", args[1]); return; } string modifer = args.Length > 2 ? args[2] : ""; MultiPageOutput.Output(p, palette.Entries, (e) => FormatEntry(e, p), "Palette entries", "entries", modifer, true); }
public override void Use(Player p, string message, CommandData data) { string[] args = message.SplitSpaces(); string modifier = args.Length > 1 ? args[1] : ""; string type = args[0]; BlockID block; if (type.Length == 0 || type.CaselessEq("basic")) { p.Message("Basic blocks: "); MultiPageOutput.Output(p, BasicBlocks(), b => FormatBlockName(p, b), "Blocks basic", "blocks", modifier, false); } else if (type.CaselessEq("all") || type.CaselessEq("complex")) { p.Message("Complex blocks: "); MultiPageOutput.Output(p, ComplexBlocks(), b => FormatBlockName(p, b), "Blocks complex", "blocks", modifier, false); } else if ((block = Block.Parse(p, type)) != Block.Invalid) { OutputBlockInfo(p, block); } else if (Group.Find(type) != null) { Group grp = Group.Find(type); p.Message("Blocks which {0} %Scan place: ", grp.ColoredName); MultiPageOutput.Output(p, RankBlocks(grp.Permission), b => FormatBlockName(p, b), "Blocks " + type, "blocks", modifier, false); } else if (args.Length > 1) { Help(p); } else { p.Message("Unable to find block or rank"); } }
static void PrintShortcuts(Player p, string modifier) { List <Command> shortcuts = new List <Command>(); foreach (Command cmd in Command.allCmds) { if (cmd.shortcut.Length == 0) { continue; } if (!p.CanUse(cmd)) { continue; } shortcuts.Add(cmd); } MultiPageOutput.Output(p, shortcuts, (cmd) => "&b" + cmd.shortcut + " &S[" + cmd.name + "]", "Commands shortcuts", "shortcuts", modifier, false); }