diff --git a/src/main/java/net/silentclient/client/Client.java b/src/main/java/net/silentclient/client/Client.java index 8be30c6..d411ac3 100644 --- a/src/main/java/net/silentclient/client/Client.java +++ b/src/main/java/net/silentclient/client/Client.java @@ -99,6 +99,7 @@ public class Client { public ServerData lastServerData; public TextUtils textUtils; private SkillIssue skillIssue; + private PlayerResponse.BanInfo banInfo; public static void memoryDebug(String paramString) { LogManager.getLogger().info("-- Start Memory Debug -- " + paramString); @@ -294,10 +295,11 @@ public class Client { Minecraft.getMinecraft().displayGuiScreen(new GuiError("Authorization Error. Try restarting the game")); return; } - if(Client.getInstance().getAccount().isBanned()) { + + if(banInfo != null && banInfo.banned && !banerror) { logger.info("STARTING > ERROR: " + "Account is banned"); - Minecraft.getMinecraft().displayGuiScreen(new GuiError("Your account is banned")); - return; + Minecraft.getMinecraft().displayGuiScreen(new GuiError("Your account is banned. Reason: " + banInfo.reason)); + banerror = true; } Client.logger.info("STARTING > mod-instances-post-init"); @@ -450,8 +452,11 @@ public class Client { GsonBuilder builder = new GsonBuilder(); Gson gson = builder.create(); + PlayerResponse playerResponse = gson.fromJson(content, PlayerResponse.class); - return gson.fromJson(content, PlayerResponse.class); + this.banInfo = playerResponse.banInfo; + + return playerResponse; } catch (Exception e) { e.printStackTrace(); return null; @@ -469,13 +474,13 @@ public class Client { } this.updateUserInformation(); } - if(Client.getInstance().getAccount() != null) { - if(Client.getInstance().getAccount().isBanned() && banerror == false) { + if(banInfo != null) { + if(banInfo.banned && !banerror) { if(Minecraft.getMinecraft().theWorld != null) { Minecraft.getMinecraft().theWorld.sendQuittingDisconnectingPacket(); Minecraft.getMinecraft().loadWorld(null); } - Minecraft.getMinecraft().displayGuiScreen(new GuiError("Your account is banned")); + Minecraft.getMinecraft().displayGuiScreen(new GuiError("Your account is banned. Reason: " + banInfo.reason)); banerror = true; } } diff --git a/src/main/java/net/silentclient/client/mixin/mixins/GuiContainerMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/GuiContainerMixin.java index 6b9a5f4..0ebed81 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/GuiContainerMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/GuiContainerMixin.java @@ -60,7 +60,7 @@ public abstract class GuiContainerMixin extends GuiScreen { @Inject(method = "mouseClicked", at = @At("TAIL")) private void silent$checkHotbarClicks(int mouseX, int mouseY, int mouseButton, CallbackInfo ci) { -// checkHotbarKeys(mouseButton - 100); + checkHotbarKeys(mouseButton - 100); } @Redirect(method = "drawScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/inventory/GuiContainer;drawDefaultBackground()V")) 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 e3f07f7..4bf268d 100644 --- a/src/main/java/net/silentclient/client/skillissue/detections/Detection.java +++ b/src/main/java/net/silentclient/client/skillissue/detections/Detection.java @@ -6,6 +6,8 @@ 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; public class Detection { protected Minecraft mc = Minecraft.getMinecraft(); @@ -24,6 +26,12 @@ public class Detection { 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(); } @EventTarget diff --git a/src/main/java/net/silentclient/client/utils/Players.java b/src/main/java/net/silentclient/client/utils/Players.java index 36052d1..39eaceb 100644 --- a/src/main/java/net/silentclient/client/utils/Players.java +++ b/src/main/java/net/silentclient/client/utils/Players.java @@ -147,7 +147,7 @@ public class Players { public static void unregister() { try { - String content = Requests.post("https://api.silentclient.net/account/set_online", new JSONObject().put("online", true).toString()); + String content = Requests.post("https://api.silentclient.net/account/set_online", new JSONObject().put("online", false).toString()); Client.logger.info("STOPPING > unregistering-player > response: " + content.toString()); } catch (Exception e) { diff --git a/src/main/java/net/silentclient/client/utils/types/PlayerResponse.java b/src/main/java/net/silentclient/client/utils/types/PlayerResponse.java index 0efb4f6..cbcf8a4 100644 --- a/src/main/java/net/silentclient/client/utils/types/PlayerResponse.java +++ b/src/main/java/net/silentclient/client/utils/types/PlayerResponse.java @@ -19,6 +19,7 @@ import java.util.concurrent.TimeUnit; public class PlayerResponse extends AbstractReply { public Account account; + public BanInfo banInfo; public Account getAccount() { return account; @@ -514,4 +515,9 @@ public class PlayerResponse extends AbstractReply { public ArrayList hats = new ArrayList(); public ArrayList shields = new ArrayList(); } + + public class BanInfo { + public boolean banned; + public String reason; + } } \ No newline at end of file