diff options
Diffstat (limited to 'src')
5 files changed, 98 insertions, 1 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java index 6130bc9f..eee396c9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -437,7 +437,7 @@ public class NEUConfig extends Config { @Expose @Category( name = "AH Tweaks", - desc = "Tweaks for Hypixel's (Not NEU's) Auction House" + desc = "Tweaks for The Auction House" ) public AHTweaks ahTweaks = new AHTweaks(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/AHTweaks.java b/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/AHTweaks.java index c1297175..f11a9dde 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/AHTweaks.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/AHTweaks.java @@ -146,4 +146,11 @@ public class AHTweaks { @ConfigEditorBoolean public boolean enableAhSellValue = true; + @Expose + @ConfigOption( + name = "CTRL+F for search", + desc = "Open search GUI when pressing CTRL + F in the AH" + ) + @ConfigEditorBoolean() + public boolean ctrlFSearch = true; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/BazaarTweaks.java b/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/BazaarTweaks.java index 35f000ec..ee49fa7a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/BazaarTweaks.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/BazaarTweaks.java @@ -79,4 +79,12 @@ public class BazaarTweaks { ) @ConfigEditorSlider(minValue = 0, maxValue = 500_000_000, minStep = 1) public double bazaarOverpayWarning = 10_000_000; + + @Expose + @ConfigOption( + name = "CTRL+F for search", + desc = "Open search GUI when pressing CTRL + F in the bazzar" + ) + @ConfigEditorBoolean() + public boolean ctrlFSearch = true; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index f13462bc..14a5072b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -2393,6 +2393,13 @@ public class Utils { ); } + public static void sendMiddleMouseClick(int windowId, int slot) { + Minecraft.getMinecraft().playerController.windowClick( + windowId, + slot, 2, 3, Minecraft.getMinecraft().thePlayer + ); + } + public static String timeSinceMillisecond(long time) { Instant lastSave = Instant.ofEpochMilli(time); LocalDateTime lastSaveTime = LocalDateTime.ofInstant(lastSave, TimeZone.getDefault().toZoneId()); diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/BazaarAHCtrlF.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/BazaarAHCtrlF.kt new file mode 100644 index 00000000..e843a7e3 --- /dev/null +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/BazaarAHCtrlF.kt @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2024 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.miscfeatures + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates +import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe +import io.github.moulberry.notenoughupdates.options.NEUConfig +import io.github.moulberry.notenoughupdates.util.Utils +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.init.Items +import net.minecraftforge.client.event.GuiScreenEvent +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import org.lwjgl.input.Keyboard + +@NEUAutoSubscribe +class BazaarAHCtrlF { + + val config: NEUConfig = NotEnoughUpdates.INSTANCE.config + + + @SubscribeEvent(priority = EventPriority.HIGH) + fun onGuiScreenKeyboard(event: GuiScreenEvent.KeyboardInputEvent.Pre) { + if (event.gui !is GuiChest) return + val chestName = Utils.getOpenChestName() + val inBZ = inBZ(chestName) + val inAH = inAH(chestName) + if (!inBZ && !inAH) return + val openSlots = Minecraft.getMinecraft().thePlayer?.openContainer?.inventorySlots ?: return + + var slotId = 0; + if (inBZ) { + slotId = 45 + } else if (inAH) { + slotId = 48 + } + + val gui = event.gui as GuiChest + val signStack = openSlots[slotId]?.stack ?: return + if (signStack.item == Items.sign && signStack.displayName == "§aSearch") { + if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && Keyboard.isKeyDown(Keyboard.KEY_F)) { + Utils.sendMiddleMouseClick(gui.inventorySlots.windowId, slotId) + event.isCanceled = true + } + } + } + + private fun inAH(chestName: String): Boolean { + if (!config.ahTweaks.ctrlFSearch) return false + return (chestName.startsWith("Auctions")) + } + + private fun inBZ(chestName: String): Boolean { + if (!config.bazaarTweaks.ctrlFSearch) return false + return (chestName.startsWith("Bazaar")) + } +} |