Skip to content

Commit

Permalink
Add try catch to "fix" NPE issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Pugzy committed Nov 11, 2023
1 parent d5f89ab commit 4f117ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>tc.oc.occ</groupId>
<artifactId>Cheaty</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.1-SNAPSHOT</version>
<name>Cheaty</name>
<description>A minecraft to discord java plugin for anti-cheat logging</description>

Expand Down
11 changes: 10 additions & 1 deletion src/main/java/tc/oc/occ/cheaty/anticheat/GrimManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4f117ae

Please sign in to comment.