mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 14:38:46 +00:00
Debug report improvements
This commit is contained in:
1 parent
c3b77764ba
commit
87b81fbf88
4 files changed
+94
-118
No files matched your search
@@ -120,9 +120,14 @@ public class AnticheatManager {
|
|||||||
|
|
||||||
public String getEventChainReport() {
|
public String getEventChainReport() {
|
||||||
String gen = "";
|
String gen = "";
|
||||||
if (!configuration.eventChains())
|
if (!configuration.eventChains()) {
|
||||||
return "Event Chains is disabled by the configuration.\n";
|
return "Event Chains is disabled by the configuration." + '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(eventchains.entrySet().size() == 0) {
|
||||||
|
return "No event chains found." + '\n';
|
||||||
|
}
|
||||||
|
|
||||||
for (Entry<String, RegisteredListener[]> e : eventchains.entrySet()) {
|
for (Entry<String, RegisteredListener[]> e : eventchains.entrySet()) {
|
||||||
String toadd = "";
|
String toadd = "";
|
||||||
String ename = e.getKey();
|
String ename = e.getKey();
|
||||||
|
|||||||
@@ -432,7 +432,14 @@ public class Magic {
|
|||||||
TIMER_TIMEMIN = getLong("TIMER_TIMEMIN");
|
TIMER_TIMEMIN = getLong("TIMER_TIMEMIN");
|
||||||
TELEPORT_MIN = getLong("TELEPORT_MIN");
|
TELEPORT_MIN = getLong("TELEPORT_MIN");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileConfiguration getDefaults() {
|
||||||
|
return defaults;
|
||||||
|
}
|
||||||
private int getInt(String path) {
|
private int getInt(String path) {
|
||||||
if (magic.contains(path)) {
|
if (magic.contains(path)) {
|
||||||
return magic.getInt(path);
|
return magic.getInt(path);
|
||||||
|
|||||||
@@ -19,15 +19,21 @@
|
|||||||
package net.h31ix.anticheat.util;
|
package net.h31ix.anticheat.util;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import net.h31ix.anticheat.Anticheat;
|
import net.h31ix.anticheat.Anticheat;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class PastebinReport {
|
public class PastebinReport {
|
||||||
@@ -35,15 +41,13 @@ public class PastebinReport {
|
|||||||
private String url = "";
|
private String url = "";
|
||||||
private Date date = new Date();
|
private Date date = new Date();
|
||||||
private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd kk:mm Z");
|
private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd kk:mm Z");
|
||||||
|
|
||||||
|
|
||||||
public PastebinReport(CommandSender cs) {
|
public PastebinReport(CommandSender cs) {
|
||||||
Player player = null;
|
Player player = null;
|
||||||
try {
|
if(cs instanceof Player) {
|
||||||
player = (Player) cs;
|
player = (Player) cs;
|
||||||
} catch (Exception e) {
|
|
||||||
cs.sendMessage(ChatColor.RED + "We were unable to detect a player when making this report. Skipping permstester");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createReport(player);
|
createReport(player);
|
||||||
try {
|
try {
|
||||||
writeReport();
|
writeReport();
|
||||||
@@ -65,6 +69,7 @@ public class PastebinReport {
|
|||||||
|
|
||||||
private void appendPermissionsTester(Player player) {
|
private void appendPermissionsTester(Player player) {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
|
append("No player defined.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,50 +81,82 @@ public class PastebinReport {
|
|||||||
report.append('\n');
|
report.append('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Not working at the moment.
|
|
||||||
private void dumpConfiguration() {
|
|
||||||
report.append("------------Main Configuration (differences only)-----------" + '\n');
|
|
||||||
report.append(writeDifferencesByLine(Anticheat.getManager().getConfiguration().getMainConfigurationDump(), getDataFromURL("https://raw.github.com/h31ix/AntiCheat/master/src/main/resources/config.yml")));
|
|
||||||
report.append("------------Magic Configuration (differences only)-----------" + '\n');
|
|
||||||
report.append(writeDifferencesByLine(Anticheat.getManager().getConfiguration().getMagic().saveToString(), getDataFromURL("https://raw.github.com/h31ix/AntiCheat/master/src/main/resources/magic.yml")));
|
|
||||||
} */
|
|
||||||
|
|
||||||
private void createReport(Player player) {
|
private void createReport(Player player) {
|
||||||
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
|
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
|
||||||
report.append("------------ WARNING! ------------");
|
append("------------ WARNING! ------------");
|
||||||
report.append("This report was run with NoCheatPlus enabled. Results may be inaccurate." + '\n' + '\n');
|
append("This report was run with NoCheatPlus enabled. Results may be inaccurate." + '\n');
|
||||||
}
|
}
|
||||||
report.append("------------ AntiCheat Report - " + format.format(date) + " ------------" + '\n');
|
append("------------ AntiCheat Report - " + format.format(date) + " ------------");
|
||||||
report.append("Version: " + Anticheat.getVersion() + (Anticheat.isUpdated() ? "" : " (OUTDATED)") + '\n');
|
|
||||||
report.append("CraftBukkit: " + Bukkit.getVersion() + '\n');
|
|
||||||
report.append("Plugin Count: " + Bukkit.getPluginManager().getPlugins().length + '\n');
|
|
||||||
appendSystemInfo();
|
appendSystemInfo();
|
||||||
report.append("------------Last 30 logs------------" + '\n');
|
append("------------Last 30 logs------------");
|
||||||
for (String log : Anticheat.getManager().getLastLogs()) {
|
appendLogs();
|
||||||
report.append("[AntiCheat] " + log + '\n');
|
append("------------Permission Tester------------");
|
||||||
}
|
|
||||||
report.append("------------Permission Tester------------" + '\n');
|
|
||||||
appendPermissionsTester(player);
|
appendPermissionsTester(player);
|
||||||
//dumpConfiguration();
|
append("------------Event Chains------------");
|
||||||
report.append("------------Event Chains------------" + '\n');
|
appendEventHandlers();
|
||||||
eventHandlersDump();
|
append("------------Magic Diff------------");
|
||||||
report.append("-----------End Of Report------------");
|
appendMagicDiff();
|
||||||
|
append("-----------End Of Report------------");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void appendLogs() {
|
||||||
|
List<String> logs = Anticheat.getManager().getLastLogs();
|
||||||
|
if(logs.size() == 0) {
|
||||||
|
append("No recent logs.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(String log : logs) {
|
||||||
|
append(log);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void appendSystemInfo() {
|
private void appendSystemInfo() {
|
||||||
Runtime runtime = Runtime.getRuntime();
|
Runtime runtime = Runtime.getRuntime();
|
||||||
report.append("Java: " + System.getProperty("java.vendor") + " " + System.getProperty("java.version") + '\n');
|
append("AntiCheat Version: " + Anticheat.getVersion() + (Anticheat.isUpdated() ? "" : " (OUTDATED)"));
|
||||||
report.append("OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version") + '\n');
|
append("Server Version: " + Bukkit.getVersion());
|
||||||
report.append("Free Memory: " + runtime.freeMemory() / 1024 / 1024 + "MB" + '\n');
|
append("Server Implementation: " + Bukkit.getName());
|
||||||
report.append("Max Memory: " + runtime.maxMemory() / 1024 / 1024 + "MB" + '\n');
|
append("Server ID: " + Bukkit.getServerId());
|
||||||
report.append("Total Memory: " + runtime.totalMemory() / 1024 / 1024 + "MB" + '\n');
|
append("Java Version: " + System.getProperty("java.vendor") + " " + System.getProperty("java.version"));
|
||||||
report.append("Server ID + Name: " + Bukkit.getServerId() + " - " + Bukkit.getName() + '\n');
|
append("OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version"));
|
||||||
report.append("Online Mode: " + String.valueOf(Bukkit.getOnlineMode()).toUpperCase() + '\n');
|
append("Free Memory: " + runtime.freeMemory() / 1024 / 1024 + "MB");
|
||||||
report.append("Players: " + Bukkit.getOnlinePlayers().length + "/" + Bukkit.getMaxPlayers() + '\n');
|
append("Max Memory: " + runtime.maxMemory() / 1024 / 1024 + "MB");
|
||||||
|
append("Total Memory: " + runtime.totalMemory() / 1024 / 1024 + "MB");
|
||||||
|
append("Online Mode: " + String.valueOf(Bukkit.getOnlineMode()).toUpperCase());
|
||||||
|
append("Players: " + Bukkit.getOnlinePlayers().length + "/" + Bukkit.getMaxPlayers());
|
||||||
|
append("Plugin Count: " + Bukkit.getPluginManager().getPlugins().length);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void appendMagicDiff() {
|
||||||
|
// This is hacky, and I like it
|
||||||
|
Magic magic = Anticheat.getManager().getConfiguration().getMagicInstance();
|
||||||
|
FileConfiguration file = magic.getDefaults();
|
||||||
|
append("Version: " + magic.getVersion());
|
||||||
|
boolean changed = false;
|
||||||
|
for(Field field : Magic.class.getFields()) {
|
||||||
|
Object defaultValue = file.get(field.getName());
|
||||||
|
try {
|
||||||
|
Field value = magic.getClass().getDeclaredField(field.getName());
|
||||||
|
boolean x = false;
|
||||||
|
String s1 = value.get(magic).toString();
|
||||||
|
String s2 = defaultValue.toString();
|
||||||
|
if(!s1.equals(s2) && !s1.equals(s2 + ".0")) {
|
||||||
|
changed = true;
|
||||||
|
append(field.getName() + ": " + s1 + " (Default: " + s2 + ")");
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
} catch(NoSuchFieldException ex) {
|
||||||
|
|
||||||
|
} catch(IllegalAccessException ex) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!changed) {
|
||||||
|
append("No changes from default.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void eventHandlersDump() {
|
private void appendEventHandlers() {
|
||||||
// TODO: Get a list of plugins hooking into AntiCheat events.
|
|
||||||
report.append(Anticheat.getManager().getEventChainReport());
|
report.append(Anticheat.getManager().getEventChainReport());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,81 +209,8 @@ public class PastebinReport {
|
|||||||
url = "Failed to post. Check report.txt";
|
url = "Failed to post. Check report.txt";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getDataFromURL(String url) {
|
private void append(String s) {
|
||||||
try {
|
report.append(s + '\n');
|
||||||
URL urls = new URL(url);
|
|
||||||
HttpURLConnection conn = (HttpURLConnection) urls.openConnection();
|
|
||||||
conn.setConnectTimeout(5000);
|
|
||||||
conn.setReadTimeout(5000);
|
|
||||||
conn.setRequestMethod("GET");
|
|
||||||
conn.setInstanceFollowRedirects(false);
|
|
||||||
conn.setDoOutput(true);
|
|
||||||
OutputStream out = conn.getOutputStream();
|
|
||||||
|
|
||||||
out.flush();
|
|
||||||
out.close();
|
|
||||||
|
|
||||||
if (conn.getResponseCode() == 200) {
|
|
||||||
InputStream receive = conn.getInputStream();
|
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(receive));
|
|
||||||
String line;
|
|
||||||
StringBuffer response = new StringBuffer();
|
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
response.append(line);
|
|
||||||
response.append("\n");
|
|
||||||
}
|
|
||||||
reader.close();
|
|
||||||
|
|
||||||
String result = response.toString().trim();
|
|
||||||
//System.out.println(result);
|
|
||||||
url = result;
|
|
||||||
} else {
|
|
||||||
url = "Failed to get";
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
url = "Failed to get";
|
|
||||||
}
|
|
||||||
|
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String writeDifferencesByLine(String one, String two) {
|
|
||||||
String diff = "";
|
|
||||||
String[] diff1 = one.split("\n");
|
|
||||||
String[] diff2 = two.split("\n");
|
|
||||||
int i = 0;
|
|
||||||
while (true) {
|
|
||||||
if (i >= diff1.length) {
|
|
||||||
for(int g = i; g < diff2.length; g++) {
|
|
||||||
diff += diff2[g] + " (End of File)" + '\n';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
} else if (i >= diff2.length) {
|
|
||||||
for(int g = i; g < diff1.length; g++) {
|
|
||||||
diff += diff1[g] + " (End of File)" + '\n';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
String d1 = diff1[i];
|
|
||||||
String d2 = diff2[i];
|
|
||||||
|
|
||||||
if (d1.startsWith("#") || d2.startsWith("#"))
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!d1.equalsIgnoreCase(d2)) {
|
|
||||||
diff += d1 + " (" + d2 + ")" + '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return two;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ DAMAGE_TIME: 3000
|
|||||||
DROP_CHECK: 10
|
DROP_CHECK: 10
|
||||||
DROPPED_ITEM_TIME: 100
|
DROPPED_ITEM_TIME: 100
|
||||||
DROP_TIME_MIN: 800
|
DROP_TIME_MIN: 800
|
||||||
EAT_TIME_MIN: 1000L
|
EAT_TIME_MIN: 1000
|
||||||
ENTERED_EXITED_TIME: 1000
|
ENTERED_EXITED_TIME: 1000
|
||||||
ENTITY_MAX_DISTANCE: 5.5
|
ENTITY_MAX_DISTANCE: 5.5
|
||||||
ENTITY_MAX_DISTANCE_CREATIVE: 6.0
|
ENTITY_MAX_DISTANCE_CREATIVE: 6.0
|
||||||
@@ -37,7 +37,7 @@ FASTPLACE_TIMEMIN: 50
|
|||||||
FASTPLACE_ZEROLIMIT: 3
|
FASTPLACE_ZEROLIMIT: 3
|
||||||
FLIGHT_BLOCK_LIMIT: 15.0
|
FLIGHT_BLOCK_LIMIT: 15.0
|
||||||
FLIGHT_LIMIT: 150
|
FLIGHT_LIMIT: 150
|
||||||
HEAL_TIME_MIN: 2000L
|
HEAL_TIME_MIN: 2000
|
||||||
INSTANT_BREAK_TIME: 2
|
INSTANT_BREAK_TIME: 2
|
||||||
INVENTORY_CHECK: 10
|
INVENTORY_CHECK: 10
|
||||||
INVENTORY_TIMEMIN: 50
|
INVENTORY_TIMEMIN: 50
|
||||||
|
|||||||
Reference in new issue
Block a user