Skip to content

Commit

Permalink
improve nocom patch
Browse files Browse the repository at this point in the history
xGinko committed Mar 10, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent bd845d8 commit 7fdffe5
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -19,12 +19,10 @@

public class AntiNoCom extends PacketListenerAbstract implements AEFModule {

private final AnarchyExploitFixes plugin;
private final double maxDistanceSquared;

public AntiNoCom() {
super(PacketListenerPriority.HIGHEST);
this.plugin = AnarchyExploitFixes.getInstance();
Config config = AnarchyExploitFixes.getConfiguration();
config.addComment("patches.prevent-nocom-coordinate-exploit.enable", "Prevent the NoCom Coordinate exploit.");
this.maxDistanceSquared = NumberConversions.square(config.getInt("patches.prevent-nocom-coordinate-exploit.nocom-max-distance", 24));
@@ -65,7 +63,12 @@ public void onPacketReceive(PacketReceiveEvent event) {
final Player player = (Player) event.getPlayer();
if (player == null) return;

if (distanceSquared(new WrapperPlayClientPlayerDigging(event).getBlockPosition(), player.getLocation()) > maxDistanceSquared) {
final double distanceSquared = distanceSquared(
new WrapperPlayClientPlayerDigging(event).getBlockPosition(),
player.getLocation()
);

if (distanceSquared > maxDistanceSquared) {
event.setCancelled(true);
}
}

0 comments on commit 7fdffe5

Please sign in to comment.