|
19 | 19 |
|
20 | 20 | public class PhaseBot {
|
21 | 21 |
|
22 |
| - @Getter @Setter private static String prefix = "owk, "; |
| 22 | + @Getter @Setter private static String prefix = "."; |
23 | 23 | @Getter private static String[] owners = { "Phase", "Voltz" };
|
24 | 24 | private static String USERNAME = "username";
|
25 | 25 | private static String PASSWORD = "password";
|
@@ -84,34 +84,48 @@ public static void loadConfig() {
|
84 | 84 | }
|
85 | 85 | if (config.createNewFile()) {
|
86 | 86 | BufferedWriter w = new BufferedWriter(new FileWriter(config));
|
87 |
| - w.write("PhaseBot Configuration File\r\n"); |
88 |
| - w.write("Username: Notch\r\n"); |
89 |
| - w.write("Password: Derp"); |
| 87 | + //@formatter:off |
| 88 | + w.write("PhaseBot Configuration File :O\r\n" |
| 89 | + + "https://github.com/phase/phasebot\r\n" |
| 90 | + + "Username: Notch\r\n" |
| 91 | + + "Password: Derp\r\n" |
| 92 | + + "Server: github.orgs:25565\r\n" |
| 93 | + + "Owners: Phase,Voltz\r\n"); |
| 94 | + //@formatter:on |
90 | 95 | w.close();
|
91 | 96 | }
|
92 | 97 | }
|
93 | 98 | else {
|
94 | 99 | BufferedReader br = new BufferedReader(new FileReader(config));
|
95 | 100 | String line = br.readLine();
|
96 | 101 | while (line != null) {
|
97 |
| - if (line.startsWith("Username: ")) { // Username:Notch |
98 |
| - USERNAME = line.split(": ")[1]; |
99 |
| - } |
100 |
| - else if (line.startsWith("Password: ")) { // Password:Derp |
101 |
| - PASSWORD = line.split(": ")[1]; |
102 |
| - } |
103 |
| - else if (line.startsWith("Server: ")) { // Server:minecraft.net:25565 |
104 |
| - HOST = line.split(": ")[1].split(":")[0]; |
105 |
| - PORT = Integer.parseInt(line.split(": ")[1].split(":")[1]); |
106 |
| - } |
107 |
| - else if (line.startsWith("Proxy")) { // Proxy:123.456.789:860 |
108 |
| - PROXY = new Proxy(Proxy.Type.HTTP, |
109 |
| - new InetSocketAddress(line.split(":")[1], Integer.parseInt(line.split(":")[2]))); |
110 |
| - } |
111 |
| - else if (line.startsWith("Owners")) { |
112 |
| - String o = line.split(": ")[1]; |
113 |
| - owners = o.contains(",") ? o.split(",") : new String[] { o }; |
| 102 | + try { |
| 103 | + if (line.startsWith("Username: ")) { // Username:Notch |
| 104 | + USERNAME = line.split(": ")[1]; |
| 105 | + } |
| 106 | + else if (line.startsWith("Password: ")) { // Password:Derp |
| 107 | + PASSWORD = line.split(": ")[1]; |
| 108 | + } |
| 109 | + else if (line.startsWith("Server: ")) { // Server:minecraft.net:25565 |
| 110 | + HOST = line.split(": ")[1].split(":")[0]; |
| 111 | + PORT = Integer.parseInt(line.split(": ")[1].split(":")[1]); |
| 112 | + } |
| 113 | + else if (line.startsWith("Proxy: ")) { // Proxy:123.456.789:860 |
| 114 | + PROXY = new Proxy(Proxy.Type.HTTP, |
| 115 | + new InetSocketAddress(line.split(":")[1], Integer.parseInt(line.split(":")[2]))); |
| 116 | + } |
| 117 | + else if (line.startsWith("Owners: ")) { |
| 118 | + String o = line.split(": ")[1]; |
| 119 | + owners = o.contains(",") ? o.split(",") : new String[] { o }; |
| 120 | + } |
| 121 | + else if (line.startsWith("Prefix: ")) { |
| 122 | + prefix = line.split(": ")[1]; |
| 123 | + } |
| 124 | + else if (line.startsWith("Online: ")) { |
| 125 | + VERIFY_USERS = Boolean.parseBoolean(line.split(": ")[1].toLowerCase()); |
| 126 | + } |
114 | 127 | }
|
| 128 | + catch (Exception e) {} |
115 | 129 | line = br.readLine();
|
116 | 130 | }
|
117 | 131 | br.close();
|
|
0 commit comments