Modified code of mcmod.info
[
{
"modid": "gamesense",
"name": "GameSense Mod",
"description": "This is a mod that sends events to SteelSeries Engine 3 GameSense.",
"version": "1.11",
"mcversion": "1.12.2",
"url": "",
"updateUrl": "",
"authorList": ["David Tibbetts"],
"credits": "Thanks to MinecraftForge for providing the framework.",
"logoFile": "",
"screenshots": [],
"dependencies": []
}
]
Modified code of GameSenseMod.class
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.sse3.gamesense;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatComponentText;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import org.apache.http.HttpResponse;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicHeader;
import org.json.JSONException;
import org.json.JSONObject;
@Mod(
modid = "gamesense",
name = "gamesense",
version = "1.11",
acceptedMinecraftVersions = "[1.12.2]"
)
public class GameSenseMod {
public static final String MODID = "gamesense";
public static final String VERSION = "1.11";
@Instance("gamesense")
public static GameSenseMod instance;
private CloseableHttpClient sseClient = null;
private HttpPost ssePost = null;
private String sse3Address = "";
private Boolean isConnected = false;
private long lastTick = 0L;
public GameSenseMod() {
}
public void SendGameEvent(String eventName, int data, EntityPlayer player) {
JSONObject eventData = new JSONObject();
eventData.put("value", data);
this.SendGameEvent(eventName, eventData, player);
}
public void SendGameEvent(String eventName, Boolean data, EntityPlayer player) {
JSONObject eventData = new JSONObject();
eventData.put("value", data);
this.SendGameEvent(eventName, eventData, player);
}
public void SendGameEvent(String eventName, String data, EntityPlayer player) {
JSONObject eventData = new JSONObject();
eventData.put("value", data);
this.SendGameEvent(eventName, eventData, player);
}
public void SendGameEvent(String eventName, JSONObject dataObject, EntityPlayer player) {
JSONObject event = new JSONObject();
event.put("game", "SSMCMOD");
event.put("event", eventName);
event.put("data", dataObject.toString());
this.executePost(event.toString(), player);
}
private void executePost(String urlParameters, EntityPlayer player) {
try {
if (!this.isConnected) {
if (System.currentTimeMillis() - this.lastTick < 5000L) {
return;
}
this.lastTick = System.currentTimeMillis();
}
this.isConnected = true;
StringEntity se = new StringEntity(urlParameters);
se.setContentType(new BasicHeader("Content-Type", "application/json"));
this.ssePost.setEntity(se);
HttpResponse response = this.sseClient.execute(this.ssePost);
if (response != null) {
this.ssePost.reset();
}
} catch (ConnectTimeoutException var5) {
this.isConnected = false;
if (player != null) {
player.func_145747_a(new ChatComponentText("There was an error connecting to SteelSeries Engine 3"));
}
} catch (Exception var6) {
;
}
}
private void ConnectToSSE3() {
String jsonAddress = "";
String corePropsFileName;
BufferedReader coreProps;
try {
corePropsFileName = System.getenv("PROGRAMDATA") + "\\SteelSeries\\SteelSeries Engine 3\\coreProps.json";
coreProps = new BufferedReader(new FileReader(corePropsFileName));
jsonAddress = coreProps.readLine();
System.out.println("Opened coreprops.json and read: " + jsonAddress);
coreProps.close();
} catch (FileNotFoundException var7) {
System.out.println("coreprops.json not found (Mac check)");
} catch (IOException var8) {
var8.printStackTrace();
System.out.println("Something terrible happened looking for coreProps.json");
}
if (jsonAddress == "") {
try {
corePropsFileName = "/Library/Application Support/SteelSeries Engine 3/coreProps.json";
coreProps = new BufferedReader(new FileReader(corePropsFileName));
jsonAddress = coreProps.readLine();
System.out.println("Opened coreprops.json and read: " + jsonAddress);
coreProps.close();
} catch (FileNotFoundException var5) {
System.out.println("coreprops.json not found (Windows check)");
} catch (IOException var6) {
var6.printStackTrace();
System.out.println("Something terrible happened looking for coreProps.json");
}
}
try {
if (jsonAddress != "") {
JSONObject obj = new JSONObject(jsonAddress);
this.sse3Address = "http://" + obj.getString("address") + "/game_event";
} else {
this.sse3Address = "http://localhost:3000/game_event";
}
this.sseClient = HttpClients.createDefault();
RequestConfig sseReqCfg = RequestConfig.custom().setSocketTimeout(10).setConnectTimeout(10).setConnectionRequestTimeout(50).build();
this.ssePost = new HttpPost(this.sse3Address);
this.ssePost.setConfig(sseReqCfg);
} catch (JSONException var4) {
var4.printStackTrace();
System.out.println("Something terrible happened creating JSONObject from coreProps.json.");
}
}
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
}
@EventHandler
public void init(FMLInitializationEvent event) {
this.ConnectToSSE3();
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(new GameSenseEventReceiver(Minecraft.func_71410_x()));
}
}
If you need any more info just tell me.