diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
3 files changed, 74 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index a92e2fb1b..abb16f732 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -128,6 +128,7 @@ import at.hannibal2.skyhanni.features.event.UniqueGiftingOpportunitiesFeatures import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryAPI import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryBarnManager import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryInventory +import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryShortcut import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryStats import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityCollectionStats import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityEggLocator @@ -624,6 +625,7 @@ class SkyHanniMod { loadModule(AreaMiniBossFeatures()) loadModule(MobHighlight()) loadModule(ChocolateFactoryBarnManager) + loadModule(ChocolateFactoryShortcut()) loadModule(ChocolateFactoryInventory) loadModule(ChocolateFactoryStats) loadModule(FactoryItemTooltipFeatures) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/ChocolateFactoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/ChocolateFactoryConfig.java index 2a0d47892..a15f399a5 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/event/ChocolateFactoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/ChocolateFactoryConfig.java @@ -91,6 +91,12 @@ public class ChocolateFactoryConfig { public boolean hoppityCollectionStats = true; @Expose + @ConfigOption(name = "Hoppity Menu Shortcut", desc = "Add a Chocolate Factory button in the SkyBlock Menu that runs /chocolatefactory on click.") + @ConfigEditorBoolean + @FeatureToggle + public boolean hoppityMenuShortcut = true; + + @Expose @ConfigLink(owner = ChocolateFactoryConfig.class, field = "statsDisplay") public Position position = new Position(183, 160, false, true); diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryShortcut.kt b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryShortcut.kt new file mode 100644 index 000000000..b28acd995 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryShortcut.kt @@ -0,0 +1,66 @@ +package at.hannibal2.skyhanni.features.event.chocolatefactory + +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.utils.HypixelCommands +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName +import at.hannibal2.skyhanni.utils.NEUItems.getItemStack +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import io.github.moulberry.notenoughupdates.events.ReplaceItemEvent +import io.github.moulberry.notenoughupdates.util.Utils +import net.minecraft.client.player.inventory.ContainerLocalMenu +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds + +class ChocolateFactoryShortcut { + + private val config get() = ChocolateFactoryAPI.config + private var showItem = false + private var lastClick = SimpleTimeMark.farPast() + + private val item by lazy { + val neuItem = "COOKIE".asInternalName().getItemStack() + Utils.createItemStack( + neuItem.item, + "§6Open Chocolate Factory", + "§8(From SkyHanni)", + "", + "§7Click here to run", + "§e/chocolatefactory" + ) + } + + @SubscribeEvent + fun onInventoryOpen(event: InventoryFullyOpenedEvent) { + if (RiftAPI.inRift()) return + if (!LorenzUtils.inSkyBlock) return + showItem = config.hoppityMenuShortcut && event.inventoryName == "SkyBlock Menu" + } + + @SubscribeEvent + fun onInventoryClose(event: InventoryCloseEvent) { + showItem = false + } + + @SubscribeEvent + fun replaceItem(event: ReplaceItemEvent) { + if (event.inventory is ContainerLocalMenu && showItem && event.slotNumber == 15) { + event.replaceWith(item) + } + } + + @SubscribeEvent(priority = EventPriority.HIGH) + fun onStackClick(event: GuiContainerEvent.SlotClickEvent) { + if (showItem && event.slotId == 15) { + event.cancel() + if (lastClick.passedSince() > 2.seconds) { + HypixelCommands.chocolateFactory() + lastClick = SimpleTimeMark.now() + } + } + } +} |