blob: 653684d08757186915fc2c91bf7f4f49413dcba6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
package at.hannibal2.skyhanni.features.misc
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.features.commands.WikiManager
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class BetterWikiFromMenus {
private val config get() = SkyHanniMod.feature.misc.commands.betterWiki
@SubscribeEvent
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
event.move(6, "fandomWiki", "commands.fandomWiki")
}
@SubscribeEvent(priority = EventPriority.HIGH)
fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) {
if (!LorenzUtils.inSkyBlock) return
if (!isEnabled()) return
val chestName = InventoryUtils.openInventoryName()
if (chestName.isEmpty()) return
val itemClickedStack = event.slot?.stack ?: return
val itemClickedName = itemClickedStack.displayName
val isWiki = event.slotId == 11 && itemClickedName.contains("Wiki Command")
val isWikithis = event.slotId == 15 && itemClickedName.contains("Wikithis Command")
val inBiblioInventory = chestName == "SkyBlock Wiki" && (isWiki || isWikithis)
val inSBGuideInventory =
(itemClickedStack.getLore().let { it.any { line -> line == "§7§eClick to view on the SkyBlock Wiki!" } })
if (inBiblioInventory) {
if (isWiki) {
WikiManager.sendWikiMessage(useFandom = true)
return
}
if (isWikithis) {
WikiManager.otherWikiCommands(arrayOf(""), true, true)
return
}
}
if (inSBGuideInventory && config.sbGuide) {
val wikiSearch = itemClickedName.removeColor().replace("✔ ", "").replace("✖ ", "")
WikiManager.sendWikiMessage(wikiSearch, autoOpen = config.menuOpenWiki)
event.isCanceled = true
}
}
private fun isEnabled() = config.enabled
}
|