Skip to content

Commit 2dd60da

Browse files
committed
Fix potential for cheating users to cause an error, fixes #9
1 parent 8744b62 commit 2dd60da

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

spigot/src/main/java/com/convallyria/forcepack/spigot/listener/ResourcePackListener.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ private boolean tryValidateHacks(Player player, PlayerResourcePackStatusEvent.St
9797
return true;
9898
}
9999

100-
long time = now - sentAccept.remove(player.getUniqueId());
100+
// If a player is cheating and sends multiple status packets and tryPrevent is false, sentAccept may not contain the player
101+
// See issue https://github.com/SamB440/ForcePack/issues/9
102+
// Always set time to 11 if tryPrevent false to stop NullPointerException
103+
long time = !tryPrevent ? 11 : now - sentAccept.remove(player.getUniqueId());
101104
if (tryPrevent && time <= 10) {
102105
plugin.log("Kicked player " + player.getName() + " because they are sending fake resource pack statuses (sent too fast).");
103106
ensureMainThread(() -> player.kickPlayer(Translations.DOWNLOAD_FAILED.get(player)));

0 commit comments

Comments
 (0)