コード例 #1
0
ファイル: TChaloBeat.cs プロジェクト: OMARATION/mcforge
        public void Prepare()
        {
            if (Server.Hash == null)
            {
                throw new Exception("Hash not set");
            }



            // build list of current players in server
            if (Player.number > 0)
            {
                string players = "";
                int    hidden  = 0;
                foreach (Player p in Player.players)
                {
                    if (p.hidden)
                    {
                        hidden++;
                        continue;
                    }
                    players += p.name + ",";
                }
                if (Player.number - hidden > 0)
                {
                    Parameters += "&players=" + players.Substring(0, players.Length - 1);
                }
            }

            string worlds = "";

            foreach (Level l in Server.levels)
            {
                worlds     += l.name + ",";
                Parameters += "&worlds=" + worlds.Substring(0, worlds.Length - 1);
            }

            Parameters += "&motd=" + Heart.UrlEncode(Server.motd) +
                          "&hash=" + Server.Hash +
                          "&data=" + Server.Version + "," + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() +
                          "&server=MCForge" +
                          "&details=Running MCForge version " + Server.Version +
                          "&users=" + Player.number;
        }
コード例 #2
0
        public void Prepare()
        {
            if (String.IsNullOrEmpty(Server.Hash))
            {
                Server.Hash = "";
                // THIS IS TEMPORARILY COMMENTED OUT SO PEOPLE CAN STILL HEARTBEAT WITH US USING A SAVED HASH!!
                //throw new Exception("Hash not set");
            }

            int hidden = 0;

            if (Player.number > 0)
            {
                string players = "";

                foreach (Player p in Player.players)
                {
                    if (p.hidden)
                    {
                        hidden++;
                        continue;
                    }
                    players += p.name + " (" + p.group.name + ")" + ",";
                }
                if (Player.number - hidden > 0)
                {
                    Parameters += "&players=" + players.Substring(0, players.Length - 1);
                }
            }

            if (Server.levels != null && Server.levels.Count > 0)
            {
                IEnumerable <string> worlds = from l in Server.levels select l.name;
                Parameters += "&worlds=" + String.Join(", ", worlds.ToArray());
            }

            Parameters += "&motd=" + Heart.UrlEncode(Server.motd) +
                          "&lvlcount=" + (byte)Server.levels.Count +
                          "&serverversion=" + Server.Version /*.Replace(".0", "")*/ +
                          "&hash=" + Server.URL + // Don't mind this, the server list wants the whole URL now. Blame Mojang!
                          "&users=" + (Player.number - hidden) +
                          "&permalinkhash=" + Permalink.UniqueHash +
                          "&globalchat=" + (Server.UseGlobalChat ? Server.GlobalChatNick : String.Empty);
        }