SteamWar/BauSystem2.0
Archiviert
12
0

Trace Refactor #233

Zusammengeführt
YoyoNow hat 121 Commits von TracerGUI nach master 2024-04-21 16:03:26 +02:00 zusammengeführt
Nur Änderungen aus Commit f2a957c88f werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -25,40 +25,24 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import de.steamwar.linkage.api.Enable; import de.steamwar.linkage.api.Enable;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryType;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@Linked @Linked
public class AntiCursorReCentering implements Enable { public class AntiCursorReCentering implements Enable {
private final Set<Player> CLOSE_PACKETS = new HashSet<>();
private final Set<Player> CLOSE_NOW = new HashSet<>();
@Override @Override
public void enable() { public void enable() {
Class<?> closeWindow = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutCloseWindow"); Class<?> closeWindow = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutCloseWindow");
TinyProtocol.instance.addFilter(closeWindow, (player, object) -> { TinyProtocol.instance.addFilter(closeWindow, (player, object) -> {
if (CLOSE_NOW.remove(player)) { if (player.getOpenInventory().getTopInventory().getType() == InventoryType.CRAFTING) {
return object; return object;
} }
CLOSE_PACKETS.add(player);
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
if (CLOSE_PACKETS.remove(player)) { if (player.getOpenInventory().getTopInventory().getType() == InventoryType.CRAFTING) {
CLOSE_NOW.add(player);
TinyProtocol.instance.sendPacket(player, object); TinyProtocol.instance.sendPacket(player, object);
} }
}, 0); }, 0);
return null; return null;
}); });
Class<?> openWindow = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutOpenWindow");
TinyProtocol.instance.addFilter(openWindow, (player, object) -> {
CLOSE_PACKETS.remove(player);
return object;
});
} }
} }