Skip to content

Commit

Permalink
patch remaining bypasses
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Jan 22, 2024
1 parent c380ef9 commit 8bd29d3
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;
import me.moomoo.anarchyexploitfixes.utils.LogUtil;

import java.util.logging.Level;

public class WindowClickListener extends PacketAdapter {

Expand All @@ -21,25 +24,42 @@ protected void register() {
@Override
public void onPacketReceiving(PacketEvent event) {
final PacketContainer packet = event.getPacket();
if (this.getClickType(packet) != InventoryClickType.SWAP) return;

final int button = this.getButton(packet);
try {
final int button = this.getButton(packet);

if (button < 0 || button > 9 && button != 40) {
event.setCancelled(true);
return;
}
if (button < 0 || button > 9 && button != 40) {
event.setCancelled(true);
return;
}

final int slot = this.getSlot(packet);
final int slot = this.getSlot(packet);

if (slot != -999 && slot != -1) {
if (slot < 0) {
event.setCancelled(true);
if (slot != -999 && slot != -1) {
event.setCancelled(slot < 0);
return;
}
} else {

if (button == 40) {
event.setCancelled(true);
return;
}

switch (this.getClickType(packet)) {
case PICKUP, CLONE -> {
event.setCancelled(true);
}
case QUICK_MOVE -> {
event.setCancelled(slot == -1);
}
case QUICK_CRAFT, THROW -> {
event.setCancelled(slot == -999);
}
}
} catch (Exception e) {
LogUtil.moduleLog(Level.WARNING, "window-click-crash-patch",
"Error reading ClickSlotC2SPacket - " + e.getLocalizedMessage() + "\n" +
"This might be due to version incompatibilities.\n" +
"Packet in question: " + packet.toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;
import me.moomoo.anarchyexploitfixes.utils.LogUtil;

import java.util.logging.Level;

public class WindowClickListener extends PacketAdapter {

Expand All @@ -26,25 +29,41 @@ protected void register() {
@Override
public void onPacketReceiving(PacketEvent event) {
final PacketContainer packet = event.getPacket();
if (this.getClickType(packet) != InventoryClickType.SWAP) return;

final int button = this.getButton(packet);
try {
final int button = this.getButton(packet);

if (button < 0 || button > 9 && button != 40) {
event.setCancelled(true);
return;
}
if (button < 0 || button > 9 && button != 40) {
event.setCancelled(true);
return;
}

final int slot = this.getSlot(packet);
final int slot = this.getSlot(packet);

if (slot != -999 && slot != -1) {
if (slot < 0) {
event.setCancelled(true);
if (slot != -999 && slot != -1) {
event.setCancelled(slot < 0);
return;
}
} else {

if (button == 40) {
event.setCancelled(true);
return;
}

switch (this.getClickType(packet)) {
case PICKUP:
case CLONE:
event.setCancelled(true);
case QUICK_MOVE:
event.setCancelled(slot == -1);
case QUICK_CRAFT:
case THROW:
event.setCancelled(slot == -999);
}
} catch (Exception e) {
LogUtil.moduleLog(Level.WARNING, "window-click-crash-patch",
"Error reading ClickSlotC2SPacket - " + e.getLocalizedMessage() + "\n" +
"This might be due to version incompatibilities.\n" +
"Packet in question: " + packet.toString());
}
}

Expand Down

0 comments on commit 8bd29d3

Please sign in to comment.