aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/commands/WikiCommand.kt35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/WikiCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/WikiCommand.kt
new file mode 100644
index 000000000..d4769e651
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/commands/WikiCommand.kt
@@ -0,0 +1,35 @@
+package at.hannibal2.skyhanni.features.commands
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.PacketEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.OSUtils
+import net.minecraft.network.play.client.C01PacketChatMessage
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class WikiCommand {
+
+ @SubscribeEvent
+ fun onSendPacket(event: PacketEvent.SendEvent) {
+ val packet = event.packet
+
+ if (!SkyHanniMod.feature.commands.useFandomWiki) return
+
+ if (packet is C01PacketChatMessage) {
+ val message = packet.message.lowercase()
+ if (message == "/wiki") {
+ event.isCanceled = true
+ OSUtils.openBrowser("https://hypixel-skyblock.fandom.com/wiki/Hypixel_SkyBlock_Wiki")
+ LorenzUtils.chat("§e[SkyHanni] Opening the Fandom Wiki..")
+ }
+ if (message.startsWith("/wiki ")) {
+ event.isCanceled = true
+ val search = packet.message.substring(6)
+ LorenzUtils.chat("§e[SkyHanni] Searching the Fandom Wiki for §c$search")
+
+ val url = "https://www.google.com/search?q=inurl%3Ahypixel-skyblock.fandom.com $search&hl=en"
+ OSUtils.openBrowser(url.replace(' ', '+'))
+ }
+ }
+ }
+} \ No newline at end of file