The plugin configuration file is now included in internal bug reports

This commit is contained in:
David Berdik 2016-05-10 09:34:13 -04:00
parent a366018bdd
commit 2f44e8a631

View File

@ -35,67 +35,78 @@ public class BugReport {
playerUUID = "CONSOLE";
}
report = "Server IP Address: " + serverIP + "\r\n" +
"Submission UUID: " + playerUUID + "\r\n" +
"Server Port: " + Bukkit.getServer().getPort() + "\r\n" +
"Version: " + ConfigDB.pluginVersionNumber + "\r\n\r\n";
// Assemble the array of words in to a single message.
for(int x = 1; x < messageWords.length; x++) {
report += messageWords[x] + " ";
}
// Determine the MD5 hash of the plugin.
checksum = computeMD5();
// After all of the necessary information has been acquired, submit the report.
try {
String postData = URLEncoder.encode("report", "UTF-8") + "=" + URLEncoder.encode(report, "UTF-8") +
"&" + URLEncoder.encode("checksum", "UTF-8") + "=" + URLEncoder.encode(checksum, "UTF-8") +
"&" + URLEncoder.encode("ip", "UTF-8") + "=" + URLEncoder.encode(serverIP, "UTF-8") +
"&" + URLEncoder.encode("uuid", "UTF-8") + "=" + URLEncoder.encode(playerUUID, "UTF-8");
URL submitURL = new URL("https://theprogrammersworld.net/Herobrine/pluginBugReporter.php");
URLConnection urlConn = submitURL.openConnection();
urlConn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(urlConn.getOutputStream());
wr.write(postData);
wr.flush();
// Get the contents of the configuration file.
File configFile = new File("plugins" + File.separator + "Herobrine" + File.separator + "config.yml");
FileInputStream configFileInputStream = new FileInputStream(configFile);
byte[] configFileBytes = new byte[(int) configFile.length()];
configFileInputStream.read(configFileBytes);
configFileInputStream.close();
String configFileString = new String(configFileBytes, "UTF-8");
BufferedReader rd = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
String serverResponse;
while((serverResponse = rd.readLine()) != null) {
if(serverResponse.equals("1")) {
// Report Failed - Unofficial Version
rd.close();
wr.close();
return "1";
}
else if(serverResponse.equals("2")) {
// Report Failed - Unsupported Version
rd.close();
wr.close();
return "2";
}
else if(serverResponse.equals("3")) {
// Report Successful - Get the Report ID
String reportID = rd.readLine();
rd.close();
wr.close();
return reportID;
}
else if(serverResponse.equals("4")) {
// Report Failed - Server is Banned
rd.close();
wr.close();
return "4";
}
else if(serverResponse.equals("5")) {
// Report Failed - Player UUID is Banned
rd.close();
wr.close();
return "5";
}
report = "Server IP Address: " + serverIP + "\r\n" +
"Submission UUID: " + playerUUID + "\r\n" +
"Server Port: " + Bukkit.getServer().getPort() + "\r\n" +
"Version: " + ConfigDB.pluginVersionNumber + "\r\n\r\n" +
"Plugin Configuration File:\r\n" + configFileString + " \r\n\r\n";
// Assemble the array of words in to a single message.
for(int x = 1; x < messageWords.length; x++) {
report += messageWords[x] + " ";
}
// Determine the MD5 hash of the plugin.
checksum = computeMD5();
// After all of the necessary information has been acquired, submit the report.
try {
String postData = URLEncoder.encode("report", "UTF-8") + "=" + URLEncoder.encode(report, "UTF-8") +
"&" + URLEncoder.encode("checksum", "UTF-8") + "=" + URLEncoder.encode(checksum, "UTF-8") +
"&" + URLEncoder.encode("ip", "UTF-8") + "=" + URLEncoder.encode(serverIP, "UTF-8") +
"&" + URLEncoder.encode("uuid", "UTF-8") + "=" + URLEncoder.encode(playerUUID, "UTF-8");
URL submitURL = new URL("https://theprogrammersworld.net/Herobrine/pluginBugReporter.php");
URLConnection urlConn = submitURL.openConnection();
urlConn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(urlConn.getOutputStream());
wr.write(postData);
wr.flush();
BufferedReader rd = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
String serverResponse;
while((serverResponse = rd.readLine()) != null) {
if(serverResponse.equals("1")) {
// Report Failed - Unofficial Version
rd.close();
wr.close();
return "1";
}
else if(serverResponse.equals("2")) {
// Report Failed - Unsupported Version
rd.close();
wr.close();
return "2";
}
else if(serverResponse.equals("3")) {
// Report Successful - Get the Report ID
String reportID = rd.readLine();
rd.close();
wr.close();
return reportID;
}
else if(serverResponse.equals("4")) {
// Report Failed - Server is Banned
rd.close();
wr.close();
return "4";
}
else if(serverResponse.equals("5")) {
// Report Failed - Player UUID is Banned
rd.close();
wr.close();
return "5";
}
}
} catch (Exception e){}
} catch (Exception e){}
// The report failed because for some reason, the server could not be reached.
return "0";