From 2124d803977453bf070660360b62a4ce3f2c9452 Mon Sep 17 00:00:00 2001 From: datejer Date: Mon, 24 Aug 2020 11:53:44 +0200 Subject: [PATCH] Add check wether name is available or taken, if not dropping --- NameChecker/Program.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/NameChecker/Program.cs b/NameChecker/Program.cs index 4f68efc..42b39c5 100644 --- a/NameChecker/Program.cs +++ b/NameChecker/Program.cs @@ -48,8 +48,23 @@ static void Main(string[] args) } catch { - Console.ReadKey(); - return; + string currentOwner = client.GetStringAsync($"https://api.mojang.com/users/profiles/minecraft/{name}") + .Result; + + if (currentOwner == "") + { + Console.Title = $"{name} is available!"; + Console.WriteLine("The name is available!"); + Console.ReadKey(); + return; + } + else + { + Console.Title = $"{name} is not available :("; + Console.WriteLine("The name is not available :("); + Console.ReadKey(); + return; + } } }