public override void Use(Player p, string message) { TextFile oprulesFile = TextFile.Files["OpRules"]; oprulesFile.EnsureExists(); Player who = p; if (message.Length > 0) { who = PlayerInfo.FindMatches(p, message); if (who == null) { return; } if (p != null && p.Rank < who.Rank) { MessageTooHighRank(p, "send oprules to", false); return; } } string[] oprules = oprulesFile.GetText(); Player.Message(who, "Server OPRules:"); Player.MessageLines(who, oprules); }
public override void Use(Player p, string message, CommandData data) { TextFile oprulesFile = TextFile.Files["OpRules"]; oprulesFile.EnsureExists(); Player who = p; if (message.Length > 0) { who = PlayerInfo.FindMatches(p, message); if (who == null) { return; } if (!CheckRank(p, data, who, "send oprules to", false)) { return; } } string[] oprules = oprulesFile.GetText(); who.Message("Server OPRules:"); who.MessageLines(oprules); }
protected internal override void OnPurchase(Player p, string args) { if (DateTime.UtcNow < p.NextEat) { p.Message("You're still full - you need to wait at least " + "10 seconds between snacks."); return; } if (!CheckPrice(p)) { return; } TextFile eatFile = TextFile.Files["Eat"]; eatFile.EnsureExists(); string[] actions = eatFile.GetText(); string action = "ate some food"; if (actions.Length > 0) { action = actions[new Random().Next(actions.Length)]; } if (!p.CheckCanSpeak("eat a snack")) { return; } Chat.MessageFrom(p, "λNICK &S" + action, null); p.CheckForMessageSpam(); p.NextEat = DateTime.UtcNow.AddSeconds(10); // intentionally not using Economy.MakePurchase here p.SetMoney(p.money - Price); }
static void LoadBadWords() { TextFile filterFile = TextFile.Files["Profanity filter"]; filterFile.EnsureExists(); if (!hookedFilter) { hookedFilter = true; filterFile.OnTextChanged += LoadBadWords; } string[] lines = filterFile.GetText(); filters = new List <string>(); // Run the badwords through the reducer to ensure things like Ls become Is and everything is lowercase foreach (string line in lines) { if (line.StartsWith("#") || line.Trim().Length == 0) { continue; } string word = Reduce(line); filters.Add(word); } }
void cmbList_SelectedIndexChanged(object sender, EventArgs e) { if (cmbList.SelectedIndex == -1) { return; } SaveCurrentFile(); string selectedName = cmbList.SelectedItem.ToString(); curFile = TextFile.Files[selectedName]; try { curFile.EnsureExists(); txtEdit.Lines = curFile.GetText(); Text = "Editing " + curFile.Filename; } catch (Exception ex) { Logger.LogError(ex); MessageBox.Show("Failed to read text from " + curFile.Filename); curFile = null; cmbList.Text = ""; Text = "Editing (none)"; } }
public override void Use(Player p, string message) { if (DateTime.UtcNow < p.NextEat) { Player.Message(p, "You're still full - you need to wait at least " + "10 seconds between snacks."); return; } if (Economy.Enabled && p.money < 1) { Player.Message(p, "You need to have at least 1 &3" + ServerConfig.Currency + " %Sto purchase a snack."); return; } TextFile eatFile = TextFile.Files["Eat"]; eatFile.EnsureExists(); string[] actions = eatFile.GetText(); string action = "ate some food"; if (actions.Length > 0) { action = actions[new Random().Next(actions.Length)]; } if (!TryMessage(p, p.ColoredName + " %S" + action)) { return; } p.NextEat = DateTime.UtcNow.AddSeconds(10); if (Economy.Enabled) { p.SetMoney(p.money - 1); } }
public override void Use(Player p, string message) { TextFile newsText = TextFile.Files["News"]; newsText.EnsureExists(); string[] lines = newsText.GetText(); Player.MessageLines(p, lines); }
public override void Use(Player p, string message, CommandData data) { TextFile newsText = TextFile.Files["News"]; newsText.EnsureExists(); string[] lines = newsText.GetText(); p.MessageLines(lines); }
public static void LoadAllSettings() { // Unload custom plugins List <Plugin> plugins = new List <Plugin>(Plugin.all); foreach (Plugin p in plugins) { if (Plugin.core.Contains(p)) { continue; } Plugin.Unload(p, false); } ZSGame.Instance.infectMessages = ZSConfig.LoadInfectMessages(); Colors.Load(); Alias.Load(); BlockDefinition.LoadGlobal(); ImagePalette.Load(); SrvProperties.Load(); AuthService.ReloadDefault(); Group.LoadAll(); CommandPerms.Load(); Command.InitAll(); Block.SetBlocks(); AwardsList.Load(); PlayerAwards.Load(); Economy.Load(); WarpList.Global.Filename = "extra/warps.save"; WarpList.Global.Load(); CommandExtraPerms.Load(); ProfanityFilter.Init(); Team.LoadList(); ChatTokens.LoadCustom(); SrvProperties.FixupOldPerms(); CpeExtension.LoadDisabledList(); TextFile announcementsFile = TextFile.Files["Announcements"]; announcementsFile.EnsureExists(); announcements = announcementsFile.GetText(); // Reload custom plugins foreach (Plugin p in plugins) { if (Plugin.core.Contains(p)) { continue; } Plugin.Load(p, false); } OnConfigUpdatedEvent.Call(); }
static void EightBallCallback(SchedulerTask task) { string final = (string)task.State; Random random = new Random(final.ToLower().GetHashCode()); TextFile file = TextFile.Files["8ball"]; file.EnsureExists(); string[] messages = file.GetText(); Chat.MessageWhere("The &b8-Ball %Ssays: &f{0}", Sees8Ball, messages[random.Next(messages.Length)]); }
public override void Use(Player p, string message) { TextFile faqFile = TextFile.Files["FAQ"]; faqFile.EnsureExists(); string[] faq = faqFile.GetText(); Player.Message(p, "&cFAQ&f:"); foreach (string line in faq) { Player.Message(p, "&f" + line); } }
public override void Use(Player p, string message, CommandData data) { TextFile faqFile = TextFile.Files["FAQ"]; faqFile.EnsureExists(); string[] faq = faqFile.GetText(); p.Message("&cFAQ&f:"); foreach (string line in faq) { p.Message("&f" + line); } }
void ShowWelcome() { LastAction = DateTime.UtcNow; TextFile welcomeFile = TextFile.Files["Welcome"]; try { welcomeFile.EnsureExists(); string[] welcome = welcomeFile.GetText(); Player.MessageLines(this, welcome); } catch (Exception ex) { Logger.LogError(ex); } }
static void InitTimers(SchedulerTask task) { TextFile announcementsFile = TextFile.Files["Announcements"]; announcementsFile.EnsureExists(); string[] lines = announcementsFile.GetText(); messages = new List <string>(lines); MainScheduler.QueueRepeat(RandomMessage, null, TimeSpan.FromMinutes(5)); Critical.QueueRepeat(ServerTasks.UpdateEntityPositions, null, TimeSpan.FromMilliseconds(ServerConfig.PositionUpdateInterval)); }
static void EightBallCallback(SchedulerTask task) { string final = (string)task.State; Random random = new Random(final.ToLower().GetHashCode()); TextFile file = TextFile.Files["8ball"]; file.EnsureExists(); string[] messages = file.GetText(); string msg = "The &b8-Ball %Ssays: &f" + messages[random.Next(messages.Length)]; Chat.Message(ChatScope.Global, msg, null, Filter8Ball); }
void LoadReplacements() { replacementsFile.EnsureExists(); string[] lines = replacementsFile.GetText(); filter_triggers.Clear(); filter_replacements.Clear(); ChatTokens.LoadTokens(lines, (phrase, replacement) => { filter_triggers.Add(phrase); filter_replacements.Add(MarkdownToSpecial(replacement)); }); }
internal static void LoadCustom() { Custom.Clear(); TextFile tokensFile = TextFile.Files["Custom $s"]; tokensFile.EnsureExists(); if (!hookedCustom) { hookedCustom = true; tokensFile.OnTextChanged += LoadCustom; } string[] lines = tokensFile.GetText(); char[] colon = new char[] { ':' }; foreach (string line in lines) { if (line.StartsWith("//") || line.Length == 0) { continue; } // Need to handle special case of :discord: emotes int offset = 0; if (line[0] == ':') { int emoteEnd = line.IndexOf(':', 1); if (emoteEnd == -1) { continue; } offset = emoteEnd + 1; } int separator = line.IndexOf(':', offset); if (separator == -1) { continue; // not a proper line } string key = line.Substring(0, separator).Trim(); string value = line.Substring(separator + 1).Trim(); if (key.Length == 0) { continue; } Custom.Add(new ChatToken(key, value, null)); } }
internal static void LoadCustom() { TextFile tokensFile = TextFile.Files["Custom $s"]; tokensFile.EnsureExists(); if (!hookedCustom) { hookedCustom = true; tokensFile.OnTextChanged += LoadCustom; } string[] lines = tokensFile.GetText(); Custom.Clear(); LoadTokens(lines, (key, value) => Custom.Add(new ChatToken(key, value, null))); }
string HandleJoker(string text) { if (!joker) { return(text); } Logger.Log(LogType.PlayerChat, "<JOKER>: {0}: {1}", name, text); Chat.MessageOps("%S<&aJ&bO&cK&5E&9R%S>: " + ColoredName + ":&f " + text); TextFile jokerFile = TextFile.Files["Joker"]; jokerFile.EnsureExists(); string[] lines = jokerFile.GetText(); Random rnd = new Random(); return(lines.Length > 0 ? lines[rnd.Next(lines.Length)] : text); }
public override void Use(Player p, string message) { TextFile rulesFile = TextFile.Files["Rules"]; rulesFile.EnsureExists(); if (message.CaselessEq("agree")) { Agree(p); return; } if (message.CaselessEq("disagree")) { Disagree(p); return; } Player who = p; if (message.Length > 0) { if (!CheckExtraPerm(p, 1)) { return; } who = PlayerInfo.FindMatches(p, message); if (who == null) { return; } } if (who != null) { who.hasreadrules = true; } string[] rules = rulesFile.GetText(); Player.Message(who, "Server Rules:"); Player.MessageLines(who, rules); if (who != null && p != who) { Player.Message(p, "Sent the rules to " + who.ColoredName + "%S."); Player.Message(who, p.ColoredName + " %Ssent you the rules."); } }
public override void Use(Player p, string message, CommandData data) { TextFile rulesFile = TextFile.Files["Rules"]; rulesFile.EnsureExists(); if (message.CaselessEq("agree")) { Agree(p); return; } if (message.CaselessEq("disagree")) { Disagree(p, data); return; } Player target = p; if (message.Length > 0) { if (!CheckExtraPerm(p, data, 1)) { return; } target = PlayerInfo.FindMatches(p, message); if (target == null) { return; } } if (target != null) { target.hasreadrules = true; } string[] rules = rulesFile.GetText(); target.Message("Server Rules:"); target.MessageLines(rules); if (target != null && p != target) { p.Message("Sent the rules to {0}&S.", p.FormatNick(target)); target.Message("{0} &Ssent you the rules.", target.FormatNick(p)); } }