Skip to content

Commit 815371b

Browse files
lel
1 parent 82e78fc commit 815371b

File tree

83 files changed

+5623
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+5623
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
3+
4+
5+
package com.gamesense.api.config;
6+
7+
import com.gamesense.client.*;
8+
import java.io.*;
9+
10+
public class ConfigStopper extends Thread
11+
{
12+
@Override
13+
public void run() {
14+
saveConfig();
15+
}
16+
17+
public static void saveConfig() {
18+
try {
19+
GameSense.getInstance().saveConfig.saveConfig();
20+
GameSense.getInstance().saveConfig.saveModules();
21+
GameSense.getInstance().saveConfig.saveEnabledModules();
22+
GameSense.getInstance().saveConfig.saveModuleKeybinds();
23+
GameSense.getInstance().saveConfig.saveDrawnModules();
24+
GameSense.getInstance().saveConfig.saveCommandPrefix();
25+
GameSense.getInstance().saveConfig.saveCustomFont();
26+
GameSense.getInstance().saveConfig.saveFriendsList();
27+
GameSense.getInstance().saveConfig.saveEnemiesList();
28+
GameSense.getInstance().saveConfig.saveClickGUIPositions();
29+
GameSense.getInstance().saveConfig.saveAutoGG();
30+
GameSense.getInstance().saveConfig.saveAutoReply();
31+
GameSense.getInstance().saveConfig.saveAutoRespawn();
32+
GameSense.LOGGER.info("Saved Config!");
33+
}
34+
catch (IOException e) {
35+
e.printStackTrace();
36+
}
37+
}
38+
}
Lines changed: 311 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,311 @@
1+
2+
3+
4+
5+
package com.gamesense.api.config;
6+
7+
import com.gamesense.client.module.*;
8+
import java.util.*;
9+
import java.nio.file.*;
10+
import com.gamesense.client.*;
11+
import com.gamesense.api.setting.*;
12+
import java.io.*;
13+
import com.gamesense.client.command.*;
14+
import java.awt.*;
15+
import com.gamesense.api.util.font.*;
16+
import com.gamesense.api.util.player.friend.*;
17+
import com.google.gson.*;
18+
import com.gamesense.api.util.player.enemy.*;
19+
import com.gamesense.client.clickgui.*;
20+
import com.lukflug.panelstudio.*;
21+
import com.gamesense.client.module.modules.misc.*;
22+
23+
public class LoadConfig
24+
{
25+
String fileName;
26+
String moduleName;
27+
String mainName;
28+
String miscName;
29+
30+
public LoadConfig() {
31+
this.fileName = "KiefSense/";
32+
this.moduleName = "Modules/";
33+
this.mainName = "Main/";
34+
this.miscName = "Misc/";
35+
try {
36+
this.loadConfig();
37+
}
38+
catch (IOException e) {
39+
e.printStackTrace();
40+
}
41+
}
42+
43+
public void loadConfig() throws IOException {
44+
this.loadModules();
45+
this.loadEnabledModules();
46+
this.loadModuleKeybinds();
47+
this.loadDrawnModules();
48+
this.loadCommandPrefix();
49+
this.loadCustomFont();
50+
this.loadFriendsList();
51+
this.loadEnemiesList();
52+
this.loadClickGUIPositions();
53+
this.loadAutoGG();
54+
this.loadAutoReply();
55+
this.loadAutoRespawn();
56+
}
57+
58+
public void loadModules() {
59+
final String moduleLocation = this.fileName + this.moduleName;
60+
for (final Module module : ModuleManager.getModules()) {
61+
try {
62+
this.loadModuleDirect(moduleLocation, module);
63+
}
64+
catch (IOException e) {
65+
System.out.println(module.getName());
66+
e.printStackTrace();
67+
}
68+
}
69+
}
70+
71+
public void loadModuleDirect(final String moduleLocation, final Module module) throws IOException {
72+
if (!Files.exists(Paths.get(moduleLocation + module.getName() + ".json", new String[0]), new LinkOption[0])) {
73+
return;
74+
}
75+
final InputStream inputStream = Files.newInputStream(Paths.get(moduleLocation + module.getName() + ".json", new String[0]), new OpenOption[0]);
76+
final JsonObject moduleObject = new JsonParser().parse((Reader)new InputStreamReader(inputStream)).getAsJsonObject();
77+
if (moduleObject.get("Module") == null) {
78+
return;
79+
}
80+
final JsonObject settingObject = moduleObject.get("Settings").getAsJsonObject();
81+
for (final Setting setting : GameSense.getInstance().settingsManager.getSettingsForMod(module)) {
82+
final JsonElement dataObject = settingObject.get(setting.getConfigName());
83+
try {
84+
if (dataObject == null || !dataObject.isJsonPrimitive()) {
85+
continue;
86+
}
87+
switch (setting.getType()) {
88+
case BOOLEAN: {
89+
((Setting.Boolean)setting).setValue(dataObject.getAsBoolean());
90+
continue;
91+
}
92+
case INTEGER: {
93+
((Setting.Integer)setting).setValue(dataObject.getAsInt());
94+
continue;
95+
}
96+
case DOUBLE: {
97+
((Setting.Double)setting).setValue(dataObject.getAsDouble());
98+
continue;
99+
}
100+
case COLOR: {
101+
((Setting.ColorSetting)setting).fromInteger(dataObject.getAsInt());
102+
continue;
103+
}
104+
case MODE: {
105+
((Setting.Mode)setting).setValue(dataObject.getAsString());
106+
continue;
107+
}
108+
}
109+
}
110+
catch (NumberFormatException e) {
111+
System.out.println(setting.getConfigName() + " " + module.getName());
112+
System.out.println(dataObject);
113+
}
114+
}
115+
inputStream.close();
116+
}
117+
118+
public void loadEnabledModules() throws IOException {
119+
final String enabledLocation = this.fileName + this.mainName;
120+
if (!Files.exists(Paths.get(enabledLocation + "Toggle.json", new String[0]), new LinkOption[0])) {
121+
return;
122+
}
123+
final InputStream inputStream = Files.newInputStream(Paths.get(enabledLocation + "Toggle.json", new String[0]), new OpenOption[0]);
124+
final JsonObject moduleObject = new JsonParser().parse((Reader)new InputStreamReader(inputStream)).getAsJsonObject();
125+
if (moduleObject.get("Modules") == null) {
126+
return;
127+
}
128+
final JsonObject settingObject = moduleObject.get("Modules").getAsJsonObject();
129+
for (final Module module : ModuleManager.getModules()) {
130+
final JsonElement dataObject = settingObject.get(module.getName());
131+
if (dataObject != null && dataObject.isJsonPrimitive() && dataObject.getAsBoolean()) {
132+
try {
133+
module.enable();
134+
}
135+
catch (NullPointerException ex) {}
136+
}
137+
}
138+
inputStream.close();
139+
}
140+
141+
public void loadModuleKeybinds() throws IOException {
142+
final String bindLocation = this.fileName + this.mainName;
143+
if (!Files.exists(Paths.get(bindLocation + "Bind.json", new String[0]), new LinkOption[0])) {
144+
return;
145+
}
146+
final InputStream inputStream = Files.newInputStream(Paths.get(bindLocation + "Bind.json", new String[0]), new OpenOption[0]);
147+
final JsonObject moduleObject = new JsonParser().parse((Reader)new InputStreamReader(inputStream)).getAsJsonObject();
148+
if (moduleObject.get("Modules") == null) {
149+
return;
150+
}
151+
final JsonObject settingObject = moduleObject.get("Modules").getAsJsonObject();
152+
for (final Module module : ModuleManager.getModules()) {
153+
final JsonElement dataObject = settingObject.get(module.getName());
154+
if (dataObject != null && dataObject.isJsonPrimitive()) {
155+
module.setBind(dataObject.getAsInt());
156+
}
157+
}
158+
inputStream.close();
159+
}
160+
161+
public void loadDrawnModules() throws IOException {
162+
final String drawnLocation = this.fileName + this.mainName;
163+
if (!Files.exists(Paths.get(drawnLocation + "Drawn.json", new String[0]), new LinkOption[0])) {
164+
return;
165+
}
166+
final InputStream inputStream = Files.newInputStream(Paths.get(drawnLocation + "Drawn.json", new String[0]), new OpenOption[0]);
167+
final JsonObject moduleObject = new JsonParser().parse((Reader)new InputStreamReader(inputStream)).getAsJsonObject();
168+
if (moduleObject.get("Modules") == null) {
169+
return;
170+
}
171+
final JsonObject settingObject = moduleObject.get("Modules").getAsJsonObject();
172+
for (final Module module : ModuleManager.getModules()) {
173+
final JsonElement dataObject = settingObject.get(module.getName());
174+
if (dataObject != null && dataObject.isJsonPrimitive()) {
175+
module.setDrawn(dataObject.getAsBoolean());
176+
}
177+
}
178+
inputStream.close();
179+
}
180+
181+
public void loadCommandPrefix() throws IOException {
182+
final String prefixLocation = this.fileName + this.mainName;
183+
if (!Files.exists(Paths.get(prefixLocation + "CommandPrefix.json", new String[0]), new LinkOption[0])) {
184+
return;
185+
}
186+
final InputStream inputStream = Files.newInputStream(Paths.get(prefixLocation + "CommandPrefix.json", new String[0]), new OpenOption[0]);
187+
final JsonObject mainObject = new JsonParser().parse((Reader)new InputStreamReader(inputStream)).getAsJsonObject();
188+
if (mainObject.get("Prefix") == null) {
189+
return;
190+
}
191+
final JsonElement prefixObject = mainObject.get("Prefix");
192+
if (prefixObject != null && prefixObject.isJsonPrimitive()) {
193+
Command.setCommandPrefix(prefixObject.getAsString());
194+
}
195+
inputStream.close();
196+
}
197+
198+
public void loadCustomFont() throws IOException {
199+
final String fontLocation = this.fileName + this.miscName;
200+
if (!Files.exists(Paths.get(fontLocation + "CustomFont.json", new String[0]), new LinkOption[0])) {
201+
return;
202+
}
203+
final InputStream inputStream = Files.newInputStream(Paths.get(fontLocation + "CustomFont.json", new String[0]), new OpenOption[0]);
204+
final JsonObject mainObject = new JsonParser().parse((Reader)new InputStreamReader(inputStream)).getAsJsonObject();
205+
if (mainObject.get("Font Name") == null || mainObject.get("Font Size") == null) {
206+
return;
207+
}
208+
final JsonElement fontNameObject = mainObject.get("Font Name");
209+
String name = null;
210+
if (fontNameObject != null && fontNameObject.isJsonPrimitive()) {
211+
name = fontNameObject.getAsString();
212+
}
213+
final JsonElement fontSizeObject = mainObject.get("Font Size");
214+
int size = -1;
215+
if (fontSizeObject != null && fontSizeObject.isJsonPrimitive()) {
216+
size = fontSizeObject.getAsInt();
217+
}
218+
if (name != null && size != -1) {
219+
(GameSense.getInstance().cFontRenderer = new CFontRenderer(new Font(name, 0, size), true, true)).setFont(new Font(name, 0, size));
220+
GameSense.getInstance().cFontRenderer.setAntiAlias(true);
221+
GameSense.getInstance().cFontRenderer.setFractionalMetrics(true);
222+
GameSense.getInstance().cFontRenderer.setFontName(name);
223+
GameSense.getInstance().cFontRenderer.setFontSize(size);
224+
}
225+
inputStream.close();
226+
}
227+
228+
public void loadFriendsList() throws IOException {
229+
final String friendLocation = this.fileName + this.miscName;
230+
if (!Files.exists(Paths.get(friendLocation + "Friends.json", new String[0]), new LinkOption[0])) {
231+
return;
232+
}
233+
final InputStream inputStream = Files.newInputStream(Paths.get(friendLocation + "Friends.json", new String[0]), new OpenOption[0]);
234+
final JsonObject mainObject = new JsonParser().parse((Reader)new InputStreamReader(inputStream)).getAsJsonObject();
235+
if (mainObject.get("Friends") == null) {
236+
return;
237+
}
238+
final JsonArray friendObject = mainObject.get("Friends").getAsJsonArray();
239+
friendObject.forEach(object -> Friends.addFriend(object.getAsString()));
240+
inputStream.close();
241+
}
242+
243+
public void loadEnemiesList() throws IOException {
244+
final String enemyLocation = this.fileName + this.miscName;
245+
if (!Files.exists(Paths.get(enemyLocation + "Enemies.json", new String[0]), new LinkOption[0])) {
246+
return;
247+
}
248+
final InputStream inputStream = Files.newInputStream(Paths.get(enemyLocation + "Enemies.json", new String[0]), new OpenOption[0]);
249+
final JsonObject mainObject = new JsonParser().parse((Reader)new InputStreamReader(inputStream)).getAsJsonObject();
250+
if (mainObject.get("Enemies") == null) {
251+
return;
252+
}
253+
final JsonArray enemyObject = mainObject.get("Enemies").getAsJsonArray();
254+
enemyObject.forEach(object -> Enemies.addEnemy(object.getAsString()));
255+
inputStream.close();
256+
}
257+
258+
public void loadClickGUIPositions() throws IOException {
259+
GameSense.getInstance().gameSenseGUI.gui.loadConfig(new GuiConfig(this.fileName + this.mainName));
260+
}
261+
262+
public void loadAutoGG() throws IOException {
263+
final String fileLocation = this.fileName + this.miscName;
264+
if (!Files.exists(Paths.get(fileLocation + "AutoGG.json", new String[0]), new LinkOption[0])) {
265+
return;
266+
}
267+
final InputStream inputStream = Files.newInputStream(Paths.get(fileLocation + "AutoGG.json", new String[0]), new OpenOption[0]);
268+
final JsonObject mainObject = new JsonParser().parse((Reader)new InputStreamReader(inputStream)).getAsJsonObject();
269+
if (mainObject.get("Messages") == null) {
270+
return;
271+
}
272+
final JsonArray messageObject = mainObject.get("Messages").getAsJsonArray();
273+
messageObject.forEach(object -> AutoGG.addAutoGgMessage(object.getAsString()));
274+
inputStream.close();
275+
}
276+
277+
public void loadAutoReply() throws IOException {
278+
final String fileLocation = this.fileName + this.miscName;
279+
if (!Files.exists(Paths.get(fileLocation + "AutoReply.json", new String[0]), new LinkOption[0])) {
280+
return;
281+
}
282+
final InputStream inputStream = Files.newInputStream(Paths.get(fileLocation + "AutoReply.json", new String[0]), new OpenOption[0]);
283+
final JsonObject mainObject = new JsonParser().parse((Reader)new InputStreamReader(inputStream)).getAsJsonObject();
284+
if (mainObject.get("AutoReply") == null) {
285+
return;
286+
}
287+
final JsonObject arObject = mainObject.get("AutoReply").getAsJsonObject();
288+
final JsonElement dataObject = arObject.get("Message");
289+
if (dataObject != null && dataObject.isJsonPrimitive()) {
290+
AutoReply.setReply(dataObject.getAsString());
291+
}
292+
inputStream.close();
293+
}
294+
295+
public void loadAutoRespawn() throws IOException {
296+
final String fileLocation = this.fileName + this.miscName;
297+
if (!Files.exists(Paths.get(fileLocation + "AutoRespawn.json", new String[0]), new LinkOption[0])) {
298+
return;
299+
}
300+
final InputStream inputStream = Files.newInputStream(Paths.get(fileLocation + "AutoRespawn.json", new String[0]), new OpenOption[0]);
301+
final JsonObject mainObject = new JsonParser().parse((Reader)new InputStreamReader(inputStream)).getAsJsonObject();
302+
if (mainObject.get("Message") == null) {
303+
return;
304+
}
305+
final JsonElement dataObject = mainObject.get("Message");
306+
if (dataObject != null && dataObject.isJsonPrimitive()) {
307+
AutoRespawn.setAutoRespawnMessage(dataObject.getAsString());
308+
}
309+
inputStream.close();
310+
}
311+
}

0 commit comments

Comments
 (0)