Ejemplo n.º 1
0
        private PlayerUuid GetPlayerUuid(string PlayerName)
        {
            string FunnyUrl = "https://api.mojang.com/users/profiles/minecraft/";

            WebClient web            = new WebClient();
            string    PlayerUuidJson = web.DownloadString(FunnyUrl + PlayerName);

            web.Dispose();
            if (PlayerUuidJson == "")
            {
                throw new PlayerNotFoundException();
            }
            PlayerUuid deserPlayerUuid = JsonConvert.DeserializeObject <PlayerUuid>(PlayerUuidJson);

            return(deserPlayerUuid);
        }
Ejemplo n.º 2
0
        private string DoOpsJsonShit()
        {
            if (OpPlayerList_User.Text != "")
            {
                List <UuidPlayer> opsJson = new List <UuidPlayer>();
                opsJson = new List <UuidPlayer>();
                try
                {
                    string[] Usernames = OpPlayerList_User.Text.Split(',');

                    foreach (string Username in Usernames)
                    {
                        PlayerUuid PlayerUuidJson = GetPlayerUuid(Username);

                        UuidPlayer uuidPlayer = new UuidPlayer
                        {
                            name  = PlayerUuidJson.Name,
                            uuid  = TrimmedUuidToFull(PlayerUuidJson.Id),
                            level = 4,
                            bypassesPlayerLimit = false
                        };

                        opsJson.Add(uuidPlayer);
                    }
                    string SerOpsJson = JsonConvert.SerializeObject(opsJson, Formatting.Indented);
                    return(SerOpsJson);
                }
                catch
                {
                    MessageBox.Show("Player not found nerd");
                    return("[]");
                }
            }
            else
            {
                return("[]");
            }
        }