From eb6513e8180c3e2fa54bd6018f09dd30d168d9db Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Mon, 1 Jan 2024 16:22:21 +0600 Subject: [PATCH 1/2] better --- .../java/net/silentclient/client/Client.java | 1 + .../client/skillissue/SkillIssue.java | 31 +++++++++++++++++++ .../skillissue/detections/Detection.java | 29 +++++------------ 3 files changed, 39 insertions(+), 22 deletions(-) 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..d1f5b34 100644 --- a/src/main/java/net/silentclient/client/skillissue/SkillIssue.java +++ b/src/main/java/net/silentclient/client/skillissue/SkillIssue.java @@ -1,18 +1,49 @@ 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(); + } + 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() { From 9a8573621a3e87f0b903e067cb68e483f2ce6de1 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Mon, 1 Jan 2024 16:24:25 +0600 Subject: [PATCH 2/2] Update SkillIssue.java --- .../java/net/silentclient/client/skillissue/SkillIssue.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/net/silentclient/client/skillissue/SkillIssue.java b/src/main/java/net/silentclient/client/skillissue/SkillIssue.java index d1f5b34..f279779 100644 --- a/src/main/java/net/silentclient/client/skillissue/SkillIssue.java +++ b/src/main/java/net/silentclient/client/skillissue/SkillIssue.java @@ -41,6 +41,9 @@ public class SkillIssue { } detection.getDetections().clear(); } + if(jsonArray.isEmpty()) { + return; + } JSONObject jsonObject = new JSONObject().put("detects", jsonArray); Requests.post("https://api.silentclient.net/anticheat/detect", jsonObject.toString());