static void Toggle(Player p, Level lvl, ref bool target, string name, bool not = false) { target = !target; bool display = not ? !target : target; lvl.ChatLevel(name + ": " + GetBool(display)); if (p == null || p.level != lvl) { Player.Message(p, name + ": " + GetBool(display)); } }
static void Toggle(Player p, Level lvl, ref bool target, string name, bool not = false) { target = !target; bool display = not ? !target : target; string targetStr = display ? "&aON" : "&cOFF"; lvl.ChatLevel(name + ": " + targetStr); if (p == null || p.level != lvl) { Player.Message(p, name + ": " + targetStr); } }
static void SetMotd(Player p, Level lvl, string value) { lvl.motd = value == "" ? "ignore" : value; lvl.ChatLevel("Map's MOTD was changed to: &b" + lvl.motd); Player[] players = PlayerInfo.Online.Items; foreach (Player pl in players) { if (pl.level != lvl || !pl.HasCpeExt(CpeExt.HackControl)) { continue; } pl.Send(Hacks.MakeHackControl(pl)); } }
static void SetInt(Player p, Level lvl, ref int target, string value, string name, Func <Player, int, bool> validator = null) { if (value == "") { Player.Message(p, "You must provide an integer."); return; } int raw; if (!int.TryParse(value, out raw)) { Player.Message(p, "\"{0}\" is not a valid integer.", value); return; } if (validator != null && !validator(p, raw)) { return; } target = raw; lvl.ChatLevel(name + ": &b" + target); }
static void SetMotd(Player p, Level lvl, string value) { lvl.Config.MOTD = value.Length == 0 ? "ignore" : value; lvl.ChatLevel("Map's MOTD was changed to: &b" + lvl.Config.MOTD); Player[] players = PlayerInfo.Online.Items; foreach (Player pl in players) { // Some clients will freeze or crash if we send a MOTD packet, but don't follow it up by a new map. // Although checking for CPE extension support is preferred, also send to whitelisted clients for maximum compatibility bool motdOnly = pl.Supports(CpeExt.InstantMOTD) || (pl.appName != null && pl.appName.CaselessStarts("classicalsharp")); if (motdOnly) { pl.SendMapMotd(); } else { LevelActions.ReloadMap(p, pl, false); } } }
static void SetInt(Level lvl, int raw, ref int target, string name) { target = raw; lvl.ChatLevel(name + ": &b" + target); }