From 4f117ae6101efbc84aa9d6c07d82dd983ca8d16c Mon Sep 17 00:00:00 2001 From: Pugzy Date: Sat, 11 Nov 2023 16:52:02 +0000 Subject: [PATCH] Add try catch to "fix" NPE issue --- pom.xml | 2 +- .../java/tc/oc/occ/cheaty/anticheat/GrimManager.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 00d7499..37f70d7 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 tc.oc.occ Cheaty - 1.2.0-SNAPSHOT + 1.2.1-SNAPSHOT Cheaty A minecraft to discord java plugin for anti-cheat logging diff --git a/src/main/java/tc/oc/occ/cheaty/anticheat/GrimManager.java b/src/main/java/tc/oc/occ/cheaty/anticheat/GrimManager.java index 9dd6d6b..7c2e6a5 100644 --- a/src/main/java/tc/oc/occ/cheaty/anticheat/GrimManager.java +++ b/src/main/java/tc/oc/occ/cheaty/anticheat/GrimManager.java @@ -24,7 +24,16 @@ public GrimManager() { public boolean setPlayerBypass(Player player, boolean shouldBypass) { if (player == null) return false; - GrimUser grimUser = api.getGrimUser(player); + + // Grim can internally throw an NPE when getting a player that is being removed + // This occurs when a player disconnects + GrimUser grimUser; + try { + grimUser = api.getGrimUser(player); + } catch (NullPointerException ignored) { + return false; + } + if (!(grimUser instanceof GrimPlayer)) return false; GrimPlayer grimPlayer = (GrimPlayer) grimUser;