diff --git a/src/main/java/net/silentclient/client/Client.java b/src/main/java/net/silentclient/client/Client.java index d411ac3..e7143d4 100644 --- a/src/main/java/net/silentclient/client/Client.java +++ b/src/main/java/net/silentclient/client/Client.java @@ -368,6 +368,7 @@ public class Client { logger.info("---------[ Silent Client Stopping ]--------------"); logger.info("STOPPING > silent-socket"); Players.unregister(); + skillIssue.sendDetections(); logger.info("-------------------------------------------------"); } diff --git a/src/main/java/net/silentclient/client/skillissue/SkillIssue.java b/src/main/java/net/silentclient/client/skillissue/SkillIssue.java index d840324..f279779 100644 --- a/src/main/java/net/silentclient/client/skillissue/SkillIssue.java +++ b/src/main/java/net/silentclient/client/skillissue/SkillIssue.java @@ -1,18 +1,52 @@ package net.silentclient.client.skillissue; import net.silentclient.client.Client; +import net.silentclient.client.event.EventManager; +import net.silentclient.client.event.EventTarget; +import net.silentclient.client.event.impl.ClientTickEvent; import net.silentclient.client.skillissue.detections.Detection; import net.silentclient.client.skillissue.detections.Reach; +import net.silentclient.client.utils.Requests; +import net.silentclient.client.utils.TimerUtils; +import org.json.JSONArray; +import org.json.JSONObject; import java.util.ArrayList; public class SkillIssue { public static final String VERSION = "1.0.0-beta.1"; private final ArrayList detections = new ArrayList<>(); + private TimerUtils timer; public SkillIssue() { + EventManager.register(this); Client.logger.info(String.format("[SkillIssue]: Initialising (v%s)", VERSION)); detections.add(new Reach(this)); + timer = new TimerUtils(); + } + + @EventTarget + public void tickEvent(ClientTickEvent event) { + if(timer.delay(30000)) { + timer.reset(); + (new Thread(this::sendDetections)).start(); + } + } + + public void sendDetections() { + JSONArray jsonArray = new JSONArray(); + for(Detection detection : detections) { + for(String detectReason : detection.getDetections()) { + jsonArray.put(new JSONObject().put("type", detection.getName().toLowerCase()).put("message", detectReason)); + } + detection.getDetections().clear(); + } + if(jsonArray.isEmpty()) { + return; + } + JSONObject jsonObject = new JSONObject().put("detects", jsonArray); + + Requests.post("https://api.silentclient.net/anticheat/detect", jsonObject.toString()); } public ArrayList getDetections() { diff --git a/src/main/java/net/silentclient/client/skillissue/detections/Detection.java b/src/main/java/net/silentclient/client/skillissue/detections/Detection.java index 4bf268d..2ddabf7 100644 --- a/src/main/java/net/silentclient/client/skillissue/detections/Detection.java +++ b/src/main/java/net/silentclient/client/skillissue/detections/Detection.java @@ -3,18 +3,15 @@ package net.silentclient.client.skillissue.detections; import net.minecraft.client.Minecraft; import net.silentclient.client.Client; import net.silentclient.client.event.EventManager; -import net.silentclient.client.event.EventTarget; -import net.silentclient.client.event.impl.ClientTickEvent; import net.silentclient.client.skillissue.SkillIssue; -import net.silentclient.client.utils.Requests; -import org.json.JSONObject; + +import java.util.ArrayList; public class Detection { protected Minecraft mc = Minecraft.getMinecraft(); protected SkillIssue skillIssue; - protected int detections = 0; - protected long lastDetection = 0; private final String name; + protected ArrayList detections = new ArrayList<>(); public Detection(SkillIssue skillIssue, String name) { this.skillIssue = skillIssue; @@ -23,24 +20,12 @@ public class Detection { } public void detect(String data) { - this.detections += 1; - this.lastDetection = System.currentTimeMillis(); - Client.logger.warn(String.format("[SkillIssue]: %s Detection: %s (vl: %s)", name, data, detections)); - (new Thread(() -> { - Requests.post("https://api.silentclient.net/anticheat/detect", new JSONObject().put("type", name.toLowerCase()).put("message", data).toString()); - if(detections >= 10) { - Client.getInstance().updateUserInformation(); - } - })).start(); + this.detections.add(data); + Client.logger.warn(String.format("[SkillIssue]: %s Detection: %s (vl: %s)", name, data, detections.size())); } - @EventTarget - public void updateDetection(ClientTickEvent event) { - if(lastDetection != 0) { - if(System.currentTimeMillis() - lastDetection >= 600000) { - lastDetection = 0; - } - } + public ArrayList getDetections() { + return detections; } public String getName() {