From 9b3672d5446540b41eeb8f217cfc352dfb45c2d5 Mon Sep 17 00:00:00 2001 From: Lulonaut Date: Wed, 25 Jan 2023 19:34:16 +0100 Subject: Cancel wardrobe hotkey inputs (#563) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Lulonaut Co-authored-by: Roman / Linnea Gräf --- .../miscfeatures/WardrobeMouseButtons.kt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/WardrobeMouseButtons.kt b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/WardrobeMouseButtons.kt index 4e99f5a7..d34f3b5e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/WardrobeMouseButtons.kt +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/WardrobeMouseButtons.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -41,8 +41,17 @@ class WardrobeMouseButtons { private var lastClick = -1L @SubscribeEvent - fun onGui(event: GuiScreenEvent) { - if (!NotEnoughUpdates.INSTANCE.config.wardrobeKeybinds.enableWardrobeKeybinds) return + fun onGuiKeyboardInput(event: GuiScreenEvent.KeyboardInputEvent.Pre) { + checkKeybinds(event) + } + + @SubscribeEvent + fun onGuiMouseInput(event: GuiScreenEvent.MouseInputEvent.Pre) { + checkKeybinds(event) + } + + private fun checkKeybinds(event: GuiScreenEvent) { + if (!NotEnoughUpdates.INSTANCE.config.wardrobeKeybinds.enableWardrobeKeybinds || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return val gui = event.gui as? GuiChest ?: return if (!Utils.getOpenChestName().contains("Wardrobe")) return @@ -51,9 +60,11 @@ class WardrobeMouseButtons { if (System.currentTimeMillis() - lastClick > 300) { Utils.sendLeftMouseClick(gui.inventorySlots.windowId, 36 + i) lastClick = System.currentTimeMillis() + event.isCanceled = true } break } } } + } -- cgit