Skip to content

Commit 3b9cfd6

Browse files
author
Tamas Henning
committed
1.8.9 Server crash fix
1 parent 4d2a852 commit 3b9cfd6

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/java/com/tamashenning/forgeanalytics/AnalyticsClient.java

+13-8
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public boolean UploadModel(AnalyticsModel model, boolean isClient) throws Except
7474
dataForge.add(entry.getKey(), new JsonPrimitive(entry.getValue()));
7575
}
7676
}
77-
77+
// System.out.println(json);
7878
this.UploadForge(dataForge.toString());
7979
return this.UploadModel(json, isClient);
8080
}
@@ -187,19 +187,25 @@ public boolean FireEvent(boolean isClient) {
187187

188188
} else {
189189
// Respect snooper settings...
190-
if (!MinecraftServer.getServer().isSnooperEnabled()) {
190+
try {
191+
if (!MinecraftServer.getServer().isSnooperEnabled()) {
192+
return false;
193+
}
194+
MinecraftForge.EVENT_BUS.post(new AnalyticsEvent(net.minecraftforge.fml.relauncher.Side.SERVER));
195+
} catch (Exception e) {
196+
// First time server init???
191197
return false;
192198
}
193-
194-
MinecraftForge.EVENT_BUS.post(new AnalyticsEvent(net.minecraftforge.fml.relauncher.Side.SERVER));
199+
195200
}
196201
return true;
197202
}
198203

199204
private Map<String, String> getCommonValues() {
200205
Map<String, String> commonValues = new HashMap<String, String>();
201-
202-
String activeModListCount = Integer.toString(net.minecraftforge.fml.common.Loader.instance().getActiveModList().size());
206+
207+
String activeModListCount = Integer
208+
.toString(net.minecraftforge.fml.common.Loader.instance().getActiveModList().size());
203209

204210
String modListCount = Integer.toString(net.minecraftforge.fml.common.Loader.instance().getModList().size());
205211
// String modList = "";
@@ -240,7 +246,6 @@ private boolean UploadModel(String json, boolean isClient) throws Exception {
240246
request.addHeader("content-type", "application/json");
241247
request.setEntity(params);
242248
HttpResponse response = httpClient.execute(request);
243-
244249

245250
} catch (Exception ex) {
246251
ex.printStackTrace();
@@ -261,7 +266,7 @@ private void UploadForge(String json) throws Exception {
261266

262267
request.setEntity(new UrlEncodedFormEntity(nvp));
263268
HttpResponse response = httpClient.execute(request);
264-
269+
265270
} catch (Exception ex) {
266271
// handle exception here
267272
ex.printStackTrace();

src/resources/mcmod.info

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"modid": "forgeanalytics",
55
"name": "Forge Analytics",
66
"description": "Basic analytics mod sending data for Forge. All sent data can be viewed under the config section and individually opted out. To fully disable remove the mod or disable snooper.",
7-
"version": "0.0.0.14",
8-
"mcversion": "1.7.10",
7+
"version": "0.0.0.16",
8+
"mcversion": "1.8.9",
99
"url": "http://files.minecraftforge.net/",
1010
"updateUrl": "",
1111
"authorList": [ "TamasHenning" ],

0 commit comments

Comments
 (0)