File tree Expand file tree Collapse file tree 6 files changed +48
-26
lines changed
src/java/com/tamashenning/forgeanalytics Expand file tree Collapse file tree 6 files changed +48
-26
lines changed Original file line number Diff line number Diff line change 2424
2525public class AnalyticsClient {
2626
27- public boolean UploadModel (AnalyticsModel model ) throws Exception {
27+ public boolean UploadModel (AnalyticsModel model , boolean isClient ) throws Exception {
2828
2929 model .Properties .putAll (ForgeAnalyticsConstants .CustomProperties );
3030
3131 Gson g = new Gson ();
3232 String json = g .toJson (model );
3333
34- return this .UploadModel (json );
34+ return this .UploadModel (json , isClient );
3535 }
3636
37- private boolean UploadModel (String json ) throws Exception {
37+ private boolean UploadModel (String json , boolean isClient ) throws Exception {
3838
39- // Respect snooper settings...
40- if (!Minecraft .getMinecraft ().isSnooperEnabled ()) {
41- return false ;
39+ if (isClient ) {
40+ // Respect snooper settings...
41+ if (!Minecraft .getMinecraft ().isSnooperEnabled ()) {
42+ return false ;
43+ }
44+ } else {
45+ // Respect snooper settings...
46+ if (!MinecraftServer .getServer ().isSnooperEnabled ()) {
47+ return false ;
48+ }
4249 }
4350
4451 System .out .println (json );
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ public void serverLoad(FMLServerStartingEvent e) {
4949 public void serverStarted (FMLServerStartedEvent e ) {
5050 AnalyticsClient ac = new AnalyticsClient ();
5151 try {
52- ac .UploadModel (ac .CreateServerStartupPing ());
52+ ac .UploadModel (ac .CreateServerStartupPing (), false );
5353 } catch (Exception e1 ) {
5454 // TODO Auto-generated catch block
5555 e1 .printStackTrace ();
@@ -60,19 +60,7 @@ public void serverStarted(FMLServerStartedEvent e) {
6060 public void serverStopped (FMLServerStoppedEvent e ) {
6161 AnalyticsClient ac = new AnalyticsClient ();
6262 try {
63- ac .UploadModel (ac .CreateServerStoppedPing ());
64- } catch (Exception e1 ) {
65- // TODO Auto-generated catch block
66- e1 .printStackTrace ();
67- }
68- }
69-
70- @ SideOnly (Side .CLIENT )
71- @ EventHandler
72- public void fmlLoaded (FMLLoadCompleteEvent e ) {
73- AnalyticsClient ac = new AnalyticsClient ();
74- try {
75- ac .UploadModel (ac .CreateClientStartupPing ());
63+ ac .UploadModel (ac .CreateServerStoppedPing (), false );
7664 } catch (Exception e1 ) {
7765 // TODO Auto-generated catch block
7866 e1 .printStackTrace ();
Original file line number Diff line number Diff line change @@ -39,19 +39,19 @@ public String CreateID() {
3939 return id ;
4040 }
4141
42- public void StartKeepAliveTimer () {
42+ public void StartKeepAliveTimer (final boolean isClient ) {
4343 Timer timer = new Timer ();
4444 timer .scheduleAtFixedRate (new TimerTask () {
4545 @ Override
4646 public void run () {
4747 try {
4848 // I'm running locally with no world loaded yet...
4949 if (Minecraft .getMinecraft ().theWorld == null ) {
50- ac .UploadModel (ac .CreateClientKeepAlivePing ());
50+ ac .UploadModel (ac .CreateClientKeepAlivePing (), isClient );
5151 } else if (!Minecraft .getMinecraft ().theWorld .isRemote ) {
52- ac .UploadModel (ac .CreateClientKeepAlivePing ());
52+ ac .UploadModel (ac .CreateClientKeepAlivePing (), isClient );
5353 } else {
54- ac .UploadModel (ac .CreateServerKeepAlivePing ());
54+ ac .UploadModel (ac .CreateServerKeepAlivePing (), isClient );
5555 }
5656 } catch (Exception e ) {
5757 //
@@ -61,5 +61,4 @@ public void run() {
6161 }
6262 }, ForgeAnalyticsConstants .KEEPALIVETIME , ForgeAnalyticsConstants .KEEPALIVETIME );
6363 }
64-
6564}
Original file line number Diff line number Diff line change 11package com .tamashenning .forgeanalytics .proxies ;
22
3+ import com .tamashenning .forgeanalytics .AnalyticsClient ;
4+ import com .tamashenning .forgeanalytics .client .ForgeAnalyticsSingleton ;
5+
36import net .minecraftforge .fml .common .event .FMLInitializationEvent ;
47import net .minecraftforge .fml .common .event .FMLPostInitializationEvent ;
58import net .minecraftforge .fml .common .event .FMLPreInitializationEvent ;
@@ -18,5 +21,16 @@ public void init(FMLInitializationEvent e) {
1821 @ Override
1922 public void postInit (FMLPostInitializationEvent e ) {
2023 super .postInit (e );
24+
25+ AnalyticsClient ac = new AnalyticsClient ();
26+ try {
27+ ac .UploadModel (ac .CreateClientStartupPing (), true );
28+ } catch (Exception e1 ) {
29+ // TODO Auto-generated catch block
30+ e1 .printStackTrace ();
31+ }
32+
33+ ForgeAnalyticsSingleton .getInstance ().StartKeepAliveTimer (true );
34+
2135 }
2236}
Original file line number Diff line number Diff line change @@ -54,6 +54,6 @@ public void init(FMLInitializationEvent e) {
5454 }
5555
5656 public void postInit (FMLPostInitializationEvent e ) {
57- ForgeAnalyticsSingleton . getInstance (). StartKeepAliveTimer ();
57+
5858 }
5959}
Original file line number Diff line number Diff line change 11package com .tamashenning .forgeanalytics .proxies ;
22
3+ import com .tamashenning .forgeanalytics .AnalyticsClient ;
4+ import com .tamashenning .forgeanalytics .client .ForgeAnalyticsSingleton ;
5+
36import net .minecraftforge .fml .common .event .FMLInitializationEvent ;
47import net .minecraftforge .fml .common .event .FMLPostInitializationEvent ;
58import net .minecraftforge .fml .common .event .FMLPreInitializationEvent ;
@@ -18,6 +21,17 @@ public void init(FMLInitializationEvent e) {
1821 @ Override
1922 public void postInit (FMLPostInitializationEvent e ) {
2023 super .postInit (e );
24+
25+ AnalyticsClient ac = new AnalyticsClient ();
26+ try {
27+ ac .UploadModel (ac .CreateClientStartupPing (), false );
28+ } catch (Exception e1 ) {
29+ // TODO Auto-generated catch block
30+ e1 .printStackTrace ();
31+ }
32+
33+ ForgeAnalyticsSingleton .getInstance ().StartKeepAliveTimer (false );
34+
2135 }
2236
2337}
You can’t perform that action at this time.
0 commit comments