From f2a957c88fcfecce6dbdbf9cb455a00f2ed1e7f6 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 24 Oct 2023 18:23:12 +0200 Subject: [PATCH] Hotfix AntiCursorReCentering --- .../features/world/AntiCursorReCentering.java | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/AntiCursorReCentering.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/AntiCursorReCentering.java index 7cf5c4c7..ff04aa5f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/AntiCursorReCentering.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/AntiCursorReCentering.java @@ -25,40 +25,24 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.linkage.Linked; import de.steamwar.linkage.api.Enable; import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import org.bukkit.event.inventory.InventoryType; @Linked public class AntiCursorReCentering implements Enable { - private final Set CLOSE_PACKETS = new HashSet<>(); - private final Set CLOSE_NOW = new HashSet<>(); - @Override public void enable() { Class closeWindow = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutCloseWindow"); TinyProtocol.instance.addFilter(closeWindow, (player, object) -> { - if (CLOSE_NOW.remove(player)) { + if (player.getOpenInventory().getTopInventory().getType() == InventoryType.CRAFTING) { return object; } - CLOSE_PACKETS.add(player); Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { - if (CLOSE_PACKETS.remove(player)) { - CLOSE_NOW.add(player); + if (player.getOpenInventory().getTopInventory().getType() == InventoryType.CRAFTING) { TinyProtocol.instance.sendPacket(player, object); } }, 0); return null; }); - - Class openWindow = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutOpenWindow"); - TinyProtocol.instance.addFilter(openWindow, (player, object) -> { - CLOSE_PACKETS.remove(player); - return object; - }); } }