Skip to content

Commit 382aa5b

Browse files
committed
ignore gui item interactions in illegal listeners
1 parent 132d99d commit 382aa5b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/illegals/items/IllegalItemModule.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ public abstract class IllegalItemModule extends AEFModule implements Listener {
5454

5555
protected final AEFPermission bypassPermission;
5656
protected final IllegalHandling handling;
57+
5758
protected final Set<Listener> optionalListeners;
59+
protected final boolean guiPluginsSupported;
60+
5861
private final Cache<Class<? extends Event>, ExpiringSet<Object>> listenerCooldowns;
5962
private final Function<Class<? extends Event>, @PolyNull ExpiringSet<Object>> createIfAbsent;
6063

@@ -80,7 +83,7 @@ public IllegalItemModule(String configPath, boolean defEnabled, AEFPermission by
8083
}
8184
this.handling = handling;
8285

83-
final boolean guiPluginsSupported = config.getBoolean(configPath + ".gui-plugins-supported", false, """
86+
this.guiPluginsSupported = config.getBoolean(configPath + ".gui-plugins-supported", false, """
8487
Enable this if you have problems with the plugin removing items from chest guis.""");
8588
if (this.handling == IllegalHandling.STRICT) {
8689
optionalListeners.add(new Listener() {
@@ -237,6 +240,8 @@ public void onPlayerArmorChange(PlayerArmorChangeEvent event) {
237240

238241
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
239242
public void onInventoryClick(InventoryClickEvent event) {
243+
if (guiPluginsSupported && event.getInventory().getLocation() == null) return;
244+
240245
if (listenerCooldowns.get(event.getClass(), createIfAbsent).contains(event.getWhoClicked().getUniqueId())) {
241246
event.setCancelled(true);
242247
return;
@@ -261,6 +266,8 @@ public void onInventoryClick(InventoryClickEvent event) {
261266

262267
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
263268
public void onInventoryInteract(InventoryInteractEvent event) {
269+
if (guiPluginsSupported && event.getInventory().getLocation() == null) return;
270+
264271
if (listenerCooldowns.get(event.getClass(), createIfAbsent).contains(event.getWhoClicked().getUniqueId())) {
265272
event.setCancelled(true);
266273
return;

AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/illegals/items/IllegalItemModule.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ public abstract class IllegalItemModule extends AEFModule implements Listener {
5454

5555
protected final AEFPermission bypassPermission;
5656
protected final IllegalHandling handling;
57+
5758
protected final Set<Listener> optionalListeners;
59+
protected final boolean guiPluginsSupported;
60+
5861
private final Cache<Class<? extends Event>, ExpiringSet<Object>> listenerCooldowns;
5962
private final Function<Class<? extends Event>, @PolyNull ExpiringSet<Object>> createIfAbsent;
6063

@@ -80,7 +83,7 @@ public IllegalItemModule(String configPath, boolean defEnabled, AEFPermission by
8083
}
8184
this.handling = handling;
8285

83-
final boolean guiPluginsSupported = config.getBoolean(configPath + ".gui-plugins-supported", false,
86+
this.guiPluginsSupported = config.getBoolean(configPath + ".gui-plugins-supported", false,
8487
"Enable this if you have problems with the plugin removing items from chest guis.");
8588
if (this.handling == IllegalHandling.STRICT) {
8689
optionalListeners.add(new Listener() {
@@ -236,6 +239,8 @@ public void onPlayerArmorChange(PlayerArmorChangeEvent event) {
236239

237240
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
238241
public void onInventoryClick(InventoryClickEvent event) {
242+
if (guiPluginsSupported && event.getInventory().getLocation() == null) return;
243+
239244
if (listenerCooldowns.get(event.getClass(), createIfAbsent).contains(event.getWhoClicked().getUniqueId())) {
240245
event.setCancelled(true);
241246
return;
@@ -260,6 +265,8 @@ public void onInventoryClick(InventoryClickEvent event) {
260265

261266
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
262267
public void onInventoryInteract(InventoryInteractEvent event) {
268+
if (guiPluginsSupported && event.getInventory().getLocation() == null) return;
269+
263270
if (listenerCooldowns.get(event.getClass(), createIfAbsent).contains(event.getWhoClicked().getUniqueId())) {
264271
event.setCancelled(true);
265272
return;

0 commit comments

Comments
 (0)