-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
204 lines (170 loc) · 7.9 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
using Newtonsoft.Json;
using System.Diagnostics;
using System.IO;
using System.Text.Json;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView;
namespace Infinity
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private async void button3_Click(object sender, EventArgs e)
{
// make a variable for the email and password
var email = EmailBox.Text;
var password = PasswordBox.Text;
var client = new HttpClient();
var url = "http://infinityapi.nekuzi.cf:43614/infinity/launcher/api/login/" + email + "/" + password;
var response = await client.GetAsync(url);
var responseContent = await response.Content.ReadAsStringAsync();
if (responseContent == "Err:404")
{
MessageBox.Show("This account does not exist", "Infinity");
return;
}
else if (responseContent == "Err:401")
{
MessageBox.Show("Email or Password is incorrect", "Infinity");
}
else
{
// Deserialize the response content into a JSON object
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
var jsonObject = System.Text.Json.JsonSerializer.Deserialize<JsonElement>(responseContent, options);
var displayName = jsonObject.GetProperty("displayName").GetString();
var id = jsonObject.GetProperty("id").GetString();
Infinity.Logic.Global.userId = id;
//MessageBox.Show("Welcome, " + displayName);
// Access the items property of the character object
var AthenaCharacter = jsonObject.GetProperty("profile")
.GetProperty("character")
.GetProperty("items").GetString();
var Vbucks = jsonObject.GetProperty("profile")
.GetProperty("vbucks").GetInt32();
string VbucksString = string.Format("{0:N0}", Vbucks);
var parts = AthenaCharacter.Split(':');
Infinity.Logic.Global.DisplayName = displayName;
Infinity.Logic.Global.Password = password;
if (parts.Length > 1)
{
Infinity.Logic.Global.Character = parts[1];
}
else
{
Infinity.Logic.Global.Character = "CID_001_Athena_Commando_F_Default";
}
Infinity.Logic.Global.Email = email;
Infinity.Logic.Global.vbucks = VbucksString;
var newCID = "";
// get skin icon
if (parts.Length > 1)
{
newCID = parts[1];
}
else
{
newCID = "CID_001_Athena_Commando_F_Default";
}
var client2 = new HttpClient();
var url2 = "https://fortnite-api.com/v2/cosmetics/br/" + newCID;
var response2 = await client2.GetAsync(url2);
var responseContent2 = await response2.Content.ReadAsStringAsync();
// Deserialize the response content into a JSON object
var options2 = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
var jsonObject2 = System.Text.Json.JsonSerializer.Deserialize<JsonElement>(responseContent2, options2);
var Icon = jsonObject2.GetProperty("data")
.GetProperty("images")
.GetProperty("smallIcon").GetString();
Infinity.Logic.Global.CharacterIcon = Icon;
if (RememberMe.Checked == true)
{
// Get the directory where the executable is located
string exeDirectory = AppDomain.CurrentDomain.BaseDirectory;
// Construct the path of the JSON file
string jsonPath = Path.Combine(exeDirectory, "config.json");
// Create an anonymous object to store the email and password
var credentials = new { Email = Infinity.Logic.Global.Email, Password = Infinity.Logic.Global.Password, FNPath = "" };
// Serialize the object to JSON
string json = JsonConvert.SerializeObject(credentials);
// Write the JSON to the file
File.WriteAllText(jsonPath, json);
//MessageBox.Show("Configuration saved successfully.");
}
Infinity.Logic.DiscordRPC.Init();
//Home home = new Home();
AprilFoolMan home = new AprilFoolMan();
home.Show();
this.Hide();
}
// DEBUG:
//Home home = new Home();
//home.Show();
}
private void Form1_Load(object sender, EventArgs e)
{
// Get the directory where the executable is located
string exeDirectory = AppDomain.CurrentDomain.BaseDirectory;
// Construct the path of the JSON file
string jsonPath = Path.Combine(exeDirectory, "config.json");
// Check if the JSON file exists
if (!File.Exists(jsonPath))
{
return;
}
// Read the JSON from the file
string json = File.ReadAllText(jsonPath);
// Deserialize the JSON to an object
var credentials = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(json);
// Set the email and password inputs
EmailBox.Text = credentials.Email;
PasswordBox.Text = credentials.Password;
Infinity.Logic.Global.FNPath = credentials.FNPath;
if (EmailBox.Text != "")
{
Infinity.Logic.Global.IsPrevSaved = true;
}
}
private void DiscordBtn_Click(object sender, EventArgs e)
{
// Set the URL you want to open in the browser
string url = "https://discord.gg/infinitymp";
// Create a ProcessStartInfo object with the URL as the argument
ProcessStartInfo psi = new ProcessStartInfo
{
FileName = url,
UseShellExecute = true
};
// Open the URL in the default browser
Process.Start(psi);
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
// Set the URL you want to open in the browser
string url = "http://infinityapi.nekuzi.cf:43614/forgotpassword";
// Create a ProcessStartInfo object with the URL as the argument
ProcessStartInfo psi = new ProcessStartInfo
{
FileName = url,
UseShellExecute = true
};
// Open the URL in the default browser
Process.Start(psi);
}
private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
// Set the URL you want to open in the browser
string url = "http://infinityapi.nekuzi.cf:43614/register";
// Create a ProcessStartInfo object with the URL as the argument
ProcessStartInfo psi = new ProcessStartInfo
{
FileName = url,
UseShellExecute = true
};
// Open the URL in the default browser
Process.Start(psi);
}
}
}