Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        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)";
            }
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
        public override void Use(Player p, string message)
        {
            TextFile newsText = TextFile.Files["News"];

            newsText.EnsureExists();

            string[] lines = newsText.GetText();
            Player.MessageLines(p, lines);
        }
Ejemplo n.º 8
0
        public override void Use(Player p, string message, CommandData data)
        {
            TextFile newsText = TextFile.Files["News"];

            newsText.EnsureExists();

            string[] lines = newsText.GetText();
            p.MessageLines(lines);
        }
Ejemplo n.º 9
0
        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();
        }
Ejemplo n.º 10
0
        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)]);
        }
Ejemplo n.º 11
0
        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);
            }
        }
Ejemplo n.º 12
0
        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);
            }
        }
Ejemplo n.º 13
0
        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);
            }
        }
Ejemplo n.º 14
0
        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));
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        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));
            });
        }
Ejemplo n.º 17
0
        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));
            }
        }
Ejemplo n.º 18
0
        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)));
        }
Ejemplo n.º 19
0
        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);
        }
Ejemplo n.º 20
0
        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.");
            }
        }
Ejemplo n.º 21
0
        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));
            }
        }