예제 #1
0
        public override void Use(Player p, string message)
        {
            if (!File.Exists("text/faq.txt"))
            {
                CP437Writer.WriteAllText("text/faq.txt", "Example: What does this server run on? This server runs on &bMCGalaxy");
            }
            List <string> faq = CP437Reader.ReadAllLines("text/faq.txt");

            Player who = p;

            if (message != "")
            {
                if (!CheckAdditionalPerm(p))
                {
                    MessageNeedPerms(p, "can send the FAQ to a player."); return;
                }
                who = PlayerInfo.FindOrShowMatches(p, message);
                if (who == null)
                {
                    return;
                }
            }

            Player.SendMessage(who, "&cFAQ&f:");
            foreach (string line in faq)
            {
                Player.SendMessage(who, "&f" + line);
            }
        }
예제 #2
0
        public override void Use(Player p, string message)
        {
            if (!File.Exists("text/oprules.txt"))
            {
                CP437Writer.WriteAllText("text/oprules.txt", "No oprules entered yet!");
            }
            List <string> oprules = CP437Reader.ReadAllLines("text/oprules.txt");

            Player who = p;

            if (message != "")
            {
                who = PlayerInfo.FindMatches(p, message);
                if (who == null)
                {
                    return;
                }
                if (p != null && p.Rank < who.Rank)
                {
                    MessageTooHighRank(p, "send /oprules", false); return;
                }
            }

            Player.Message(who, "Server OPRules:");
            foreach (string s in oprules)
            {
                Player.Message(who, s);
            }
        }
예제 #3
0
        public override void Use(Player p, string message)
        {
            if (!File.Exists(newsFile))
            {
                CP437Writer.WriteAllText(newsFile, "News have not been created. Put News in '" + newsFile + "'."); return;
            }
            List <string> lines = CP437Reader.ReadAllLines(newsFile);

            Player.MessageLines(p, lines);
        }
예제 #4
0
 private void DiscardEdittxtBt_Click(object sender, EventArgs e)
 {
     if (loaded)
     {
         CP437Writer.WriteAllText("text/" + loadedfile + ".txt", oldtxt);
         EditTextTxtBox.Text = CP437Reader.ReadAllText("text/" + loadedfile + ".txt");
         MessageBox.Show("Discarded Text");
     }
     else
     {
         MessageBox.Show("No file is loaded!!");
         return;
     }
 }
예제 #5
0
파일: CmdFaq.cs 프로젝트: Benedani/MCGalaxy
        public override void Use(Player p, string message)
        {
            if (!File.Exists("text/faq.txt"))
            {
                CP437Writer.WriteAllText("text/faq.txt", "Example: What does this server run on? This server runs on &bMCGalaxy");
            }
            List <string> faq = CP437Reader.ReadAllLines("text/faq.txt");

            Player.Message(p, "&cFAQ&f:");
            foreach (string line in faq)
            {
                Player.Message(p, "&f" + line);
            }
        }
예제 #6
0
        void ShowRequirements(Player p, Group grp)
        {
            string path = "text/rankreqs/" + grp.name + ".txt";

            if (!File.Exists(path))
            {
                Player.SendMessage(p, "No rank requirements have been specified yet."); return;
            }

            List <string> lines = CP437Reader.ReadAllLines(path);

            Player.SendMessage(p, "Rank requirements for " + grp.ColoredName + "%S:");
            foreach (string line in lines)
            {
                Player.SendMessage(p, line);
            }
        }
예제 #7
0
        static Dictionary <int, string> GetRuleSections()
        {
            Dictionary <int, string> sections = new Dictionary <int, string>();

            if (!File.Exists("text/rules.txt"))
            {
                return(sections);
            }

            List <string> rules = CP437Reader.ReadAllLines("text/rules.txt");

            foreach (string rule in rules)
            {
                ParseRule(rule, sections);
            }
            return(sections);
        }
예제 #8
0
 public void LoadInfectMessages()
 {
     infectMessages.Clear();
     try {
         if (!File.Exists("text/infectmessages.txt"))
         {
             File.WriteAllLines("text/infectmessages.txt", defMessages);
         }
         infectMessages = CP437Reader.ReadAllLines("text/infectmessages.txt");
     } catch (Exception ex) {
         Server.ErrorLog(ex);
     }
     if (infectMessages.Count == 0)
     {
         infectMessages = new List <string>(defMessages);
     }
 }
예제 #9
0
        public override void Use(Player p, string message)
        {
            if (!File.Exists("text/rules.txt"))
            {
                CP437Writer.WriteAllText("text/rules.txt", "No rules entered yet!");
            }
            if (message.CaselessEq("agree"))
            {
                Agree(p); return;
            }
            if (message.CaselessEq("disagree"))
            {
                Disagree(p); return;
            }

            List <string> rules = CP437Reader.ReadAllLines("text/rules.txt");

            Player who = p;

            if (message != "")
            {
                if (!CheckExtraPerm(p))
                {
                    MessageNeedExtra(p, "send the rules to a player."); return;
                }
                who = PlayerInfo.FindMatches(p, message);
                if (who == null)
                {
                    return;
                }
            }

            if (who != null)
            {
                who.hasreadrules = true;
            }
            Player.Message(who, "Server Rules:");
            Player.MessageLines(p, rules);

            if (who != null && who.name != p.name)
            {
                Player.Message(p, "Sent the rules to " + who.ColoredName + "%S.");
                Player.Message(who, p.ColoredName + " %Ssent you the rules.");
            }
        }
예제 #10
0
        public override void Use(Player p, string message)
        {
            if (!File.Exists(newsFile))
            {
                CP437Writer.WriteAllText(newsFile, "News have not been created. Put News in '" + newsFile + "'."); return;
            }

            List <string> lines = CP437Reader.ReadAllLines(newsFile);

            if (message == "")
            {
                foreach (string line in lines)
                {
                    Player.SendMessage(p, line);
                }
                return;
            }

            string[] args = message.Split(' ');
            if (args[0] == "all")
            {
                if (!CheckAdditionalPerm(p))
                {
                    MessageNeedPerms(p, "can send the server news to all players."); return;
                }
                foreach (string line in lines)
                {
                    Player.GlobalMessage(line);
                }
                return;
            }

            Player who = PlayerInfo.FindOrShowMatches(p, args[0]);

            if (who == null)
            {
                return;
            }
            foreach (string line in lines)
            {
                Player.SendMessage(who, line);
            }
            Player.SendMessage(p, "The News were successfully sent to " + who.name + ".");
        }
예제 #11
0
        public override void Use(Player p, string message)
        {
            if (!File.Exists("text/rules.txt"))
            {
                CP437Writer.WriteAllText("text/rules.txt", "No rules entered yet!");
            }
            List <string> rules = CP437Reader.ReadAllLines("text/rules.txt");

            Player who = p;

            if (message != "")
            {
                if (!CheckAdditionalPerm(p))
                {
                    MessageNeedPerms(p, "can send the rules to a player."); return;
                }
                who = PlayerInfo.FindOrShowMatches(p, message);
                if (who == null)
                {
                    return;
                }
            }

            if (who != null)
            {
                who.hasreadrules = true;
                if (who.level == Server.mainLevel && Server.mainLevel.permissionbuild == LevelPermission.Guest)
                {
                    Player.SendMessage(who, "You are currently on the guest map where anyone can build");
                }
            }
            Player.SendMessage(who, "Server Rules:");
            foreach (string s in rules)
            {
                Player.SendMessage(who, s);
            }

            if (who != null && who.name != p.name)
            {
                Player.SendMessage(p, "Sent the rules to " + who.color + who.DisplayName + "%S.");
                Player.SendMessage(who, p.ColoredName + " %Ssent you the rules.");
            }
        }
예제 #12
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                if (Player.IsSuper(p))
                {
                    SuperRequiresArgs(p, "player name"); return;
                }
                message = p.name;
            }
            Player who    = PlayerInfo.Find(message);
            string target = who == null ? message : who.name;

            Player.Message(p, "  Rank information for {0}:",
                           PlayerInfo.GetColoredName(p, target));
            bool     found = false;
            DateTime now   = DateTime.Now;

            foreach (string line in Server.RankInfo.Find(target))
            {
                string[] parts = line.Split(' ');
                Group    newRank = Group.Find(parts[7]), oldRank = Group.Find(parts[8]);
                string   newRankName = newRank == null ? parts[7] : newRank.ColoredName;
                string   oldRankName = oldRank == null ? parts[8] : oldRank.ColoredName;

                int      min = int.Parse(parts[2]), hour = int.Parse(parts[3]);
                int      day = int.Parse(parts[4]), month = int.Parse(parts[5]), year = int.Parse(parts[6]);
                DateTime timeRanked = new DateTime(year, month, day, hour, min, 0);

                string reason = parts.Length <= 9 ? "(no reason given)" :
                                CP437Reader.ConvertToRaw(parts[9].Replace("%20", " "));
                TimeSpan delta = now - timeRanked;

                Player.Message(p, "&aFrom {0} &ato {1} &a{2} ago",
                               oldRankName, newRankName, delta.Shorten(true, false));
                Player.Message(p, "&aBy %S{0}&a, reason: %S{1}", parts[1], reason);
                found = true;
            }
            if (!found)
            {
                Player.Message(p, "&cPlayer has not been ranked yet.");
            }
        }
예제 #13
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }
            Player who    = PlayerInfo.Find(message);
            string target = who == null ? message : who.name;

            Player.SendMessage(p, "&1Rank information for " + target);
            bool found = false;

            foreach (string line in File.ReadAllLines("text/rankinfo.txt"))
            {
                if (!line.CaselessStarts(target))
                {
                    continue;
                }
                string[] parts = line.Split(' ');
                if (!parts[0].CaselessEq(target))
                {
                    continue;
                }

                Group    newRank = Group.Find(parts[7]), oldRank = Group.Find(parts[8]);
                int      minutes = Convert.ToInt32(parts[2]), hours = Convert.ToInt32(parts[3]);
                int      days = Convert.ToInt32(parts[4]), months = Convert.ToInt32(parts[5]);
                int      years      = Convert.ToInt32(parts[6]);
                DateTime timeRanked = new DateTime(years, months, days, hours, minutes, 0);
                string   reason     = parts.Length <= 9 ? "(no reason given)" :
                                      CP437Reader.ConvertToRaw(parts[9].Replace("%20", " "));

                Player.SendMessage(p, "&aFrom " + oldRank.ColoredName
                                   + " &ato " + newRank.ColoredName + " &aon %S" + timeRanked);
                Player.SendMessage(p, "&aBy %S" + parts[1] + " &awith reason: %S" + reason);
                found = true;
            }
            if (!found)
            {
                Player.SendMessage(p, "&cPlayer &a" + target + "&c has not been ranked yet.");
            }
        }
예제 #14
0
파일: CmdEat.cs 프로젝트: Peteys93/MCGalaxy
        public override void Use(Player p, string message)
        {
            if (p == null)
            {
                MessageInGameOnly(p); return;
            }

            if (DateTime.UtcNow < p.NextEat)
            {
                Player.SendMessage(p, "You're still full - you need to wait at least " +
                                   "10 seconds between snacks."); return;
            }
            if (Economy.Enabled && p.money < 1)
            {
                Player.SendMessage(p, "You need to have at least 1 &3" + Server.moneys +
                                   " %Sto purchase a snack."); return;
            }
            if (p.muted)
            {
                Player.SendMessage(p, "You cannot use this command while muted."); return;
            }

            p.NextEat = DateTime.UtcNow.AddSeconds(10);
            if (Economy.Enabled)
            {
                p.money -= 1; p.OnMoneyChanged();
            }
            if (!File.Exists("text/eatmessages.txt"))
            {
                File.WriteAllLines("text/eatmessages.txt", defMessages);
            }

            List <string> actions = CP437Reader.ReadAllLines("text/eatmessages.txt");
            string        action  = "ate some food";

            if (actions.Count > 0)
            {
                action = actions[new Random().Next(actions.Count)];
            }
            Player.GlobalMessage(p.color + p.DisplayName + " %S" + action);
        }
예제 #15
0
파일: CmdEat.cs 프로젝트: Benedani/MCGalaxy
        public override void Use(Player p, string message)
        {
            if (p == null)
            {
                MessageInGameOnly(p); return;
            }

            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" + Server.moneys +
                               " %Sto purchase a snack."); return;
            }

            if (!File.Exists("text/eatmessages.txt"))
            {
                File.WriteAllLines("text/eatmessages.txt", defMessages);
            }

            List <string> actions = CP437Reader.ReadAllLines("text/eatmessages.txt");
            string        action  = "ate some food";

            if (actions.Count > 0)
            {
                action = actions[new Random().Next(actions.Count)];
            }

            if (!TryMessage(p, p.ColoredName + " %S" + action))
            {
                return;
            }
            p.NextEat = DateTime.UtcNow.AddSeconds(10);
            if (Economy.Enabled)
            {
                p.SetMoney(p.money - 1);
            }
        }
예제 #16
0
        static void Combine(string envFile)
        {
            string        name     = Path.GetFileNameWithoutExtension(envFile);
            string        propFile = LevelInfo.FindPropertiesFile(name);
            List <string> lines    = new List <string>();

            if (propFile != null)
            {
                lines = CP437Reader.ReadAllLines(propFile);
            }

            using (StreamReader r = new StreamReader(envFile)) {
                string line = null;
                while ((line = r.ReadLine()) != null)
                {
                    lines.Add(line);
                }
            }

            propFile = LevelInfo.PropertiesPath(name);
            CP437Writer.WriteAllLines(propFile, lines.ToArray());
            File.Delete(envFile);
        }