mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-04 16:49:04 +00:00
Players Online On Website, Changed packaging a little & added SettingsLoader (#44)
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package redone.integrations;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import redone.integrations.discord.JavaCord;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SettingsLoader {
|
||||
private static void initialize() {
|
||||
JSONObject main = new JSONObject();
|
||||
main
|
||||
.put("bot-token", "")
|
||||
.put("powpass", "");
|
||||
try {
|
||||
BufferedWriter br = new BufferedWriter(new FileWriter("data/secrets.json"));
|
||||
br.write(main.toString());
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadSettings() throws IOException {
|
||||
if (!new File("data/secrets.json").exists()) {
|
||||
initialize();
|
||||
System.out.println("Please open \"data/secrets.json\" file and enter your discord token bot there!");
|
||||
System.out.println("Please open \"data/secrets.json\" file and enter your Players Online On Website Password there!");
|
||||
|
||||
} else {
|
||||
BufferedReader br = new BufferedReader(new FileReader("data/secrets.json"));
|
||||
String out = br.lines().collect(Collectors.joining("\n"));
|
||||
JSONObject obj = new JSONObject(out);
|
||||
|
||||
JavaCord.token = obj.getString("bot-token");
|
||||
PlayersOnlineWebsite.password = obj.getString("powpass");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user