From 7227b4d7309b71c43aba8d4c8a2bfba0fbd9a0ba Mon Sep 17 00:00:00 2001
From: Madeleaan <70163122+Madeleaan@users.noreply.github.com>
Date: Fri, 31 May 2024 14:16:55 +0200
Subject: Add /neucheck command & check for enchant parsers (#1166)
---
.../notenoughupdates/commands/dev/CheckCommand.kt | 45 ++++++++++++
.../miscfeatures/checks/EnchantsCheck.kt | 83 ++++++++++++++++++++++
2 files changed, 128 insertions(+)
create mode 100644 src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/CheckCommand.kt
create mode 100644 src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/checks/EnchantsCheck.kt
(limited to 'src/main/kotlin')
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/CheckCommand.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/CheckCommand.kt
new file mode 100644
index 00000000..3452df5d
--- /dev/null
+++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/CheckCommand.kt
@@ -0,0 +1,45 @@
+/*
+ * 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 .
+ */
+
+package io.github.moulberry.notenoughupdates.commands.dev
+
+import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe
+import io.github.moulberry.notenoughupdates.events.RegisterBrigadierCommandEvent
+import io.github.moulberry.notenoughupdates.miscfeatures.checks.EnchantsCheck
+import io.github.moulberry.notenoughupdates.util.brigadier.reply
+import io.github.moulberry.notenoughupdates.util.brigadier.thenLiteralExecute
+import io.github.moulberry.notenoughupdates.util.brigadier.withHelp
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+@NEUAutoSubscribe
+class CheckCommand {
+
+ @SubscribeEvent
+ fun onCommands(event: RegisterBrigadierCommandEvent) {
+ event.command("neucheck") {
+ thenLiteralExecute("neuec") {
+ val check = EnchantsCheck()
+ val replies = check.getMessages()
+ replies.forEach { r ->
+ reply(r)
+ }
+ }.withHelp("Checks for /neuec incompatibilities")
+ }
+ }
+}
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/checks/EnchantsCheck.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/checks/EnchantsCheck.kt
new file mode 100644
index 00000000..8160fe7c
--- /dev/null
+++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/checks/EnchantsCheck.kt
@@ -0,0 +1,83 @@
+/*
+ * 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 .
+ */
+
+package io.github.moulberry.notenoughupdates.miscfeatures.checks
+
+import net.minecraft.event.ClickEvent
+import net.minecraft.event.HoverEvent
+import net.minecraft.util.ChatComponentText
+import net.minecraft.util.EnumChatFormatting.*
+import net.minecraft.util.IChatComponent
+import net.minecraftforge.fml.common.Loader
+
+class EnchantsCheck {
+
+ private val sbaMsg = "SkyblockAddons is installed and might break NEU enchants!"
+ private val shMsg = "SkyHanni is installed and might break NEU enchants!"
+ private val dsmMsg = "DSM is installed and might break NEU enchants!"
+ private val sbeMsg = "SBE is installed and might break NEU enchants!"
+
+ private val sbaHelp = "${LIGHT_PURPLE}/sba${YELLOW} -> ${LIGHT_PURPLE}Parse Enchant Tooltips${YELLOW} -> " +
+ "${LIGHT_PURPLE}Second Page${YELLOW} -> ${LIGHT_PURPLE}Highlight Special Enchantments${YELLOW} -> ${RED}${BOLD}DISABLE"
+ private val shHelp = "${LIGHT_PURPLE}/sh enchant parsing${YELLOW} -> ${LIGHT_PURPLE}Inventory${YELLOW} -> " +
+ "${LIGHT_PURPLE}Enchant Parsing${YELLOW} -> ${RED}${BOLD}DISABLE"
+ private val dsmHelp = "${LIGHT_PURPLE}/dsm${YELLOW} -> ${LIGHT_PURPLE}General${YELLOW} -> " +
+ "${LIGHT_PURPLE}Golden ... Enchantments${YELLOW} -> ${RED}${BOLD}DISABLE"
+ private val sbeHelp =
+ "${LIGHT_PURPLE}/sbe${YELLOW} -> ${LIGHT_PURPLE}Color Enchants${YELLOW} -> ${RED}${BOLD}DISABLE"
+
+ fun getMessages(): List {
+ val messages = mutableListOf()
+ if (Loader.isModLoaded("skyblockaddons")) messages.add(modMessage(sbaMsg, sbaHelp, "/sba"))
+ if (Loader.isModLoaded("skyhanni")) messages.add(modMessage(shMsg, shHelp, "/sh enchant parsing"))
+ if (Loader.isModLoaded("Danker's Skyblock Mod")) messages.add(modMessage(dsmMsg, dsmHelp, "/dsm"))
+ if (Loader.isModLoaded("SkyblockExtras")) messages.add(modMessage(sbeMsg, sbeHelp, "/sbe"))
+ if (messages.isNotEmpty()) {
+ messages.addAll(
+ listOf(
+ ChatComponentText(""),
+ ChatComponentText("${YELLOW}One or more mods conflicting with /neuec found!"),
+ ChatComponentText("${LIGHT_PURPLE}Hover${YELLOW} over the above messages to check the solutions."),
+ ChatComponentText("${LIGHT_PURPLE}Click${YELLOW} on the above messages to run the command mentioned.")
+ )
+ )
+ } else {
+ val discordHover = HoverEvent(HoverEvent.Action.SHOW_TEXT, ChatComponentText("${BLUE}discord.gg/moulberry"))
+ val discordClick = ClickEvent(ClickEvent.Action.OPEN_URL, "https://discord.gg/moulberry")
+ messages.addAll(
+ listOf(
+ ChatComponentText("${GREEN}Your enchant colors should not be overriden by any mods!"),
+ ChatComponentText("${YELLOW}If any of your mods override them, please let us know on ${BLUE}NEU Discord")
+ .also { it.chatStyle.setChatHoverEvent(discordHover).setChatClickEvent(discordClick) })
+ )
+ }
+ return messages
+ }
+
+ private fun modMessage(msg: String, help: String, cmd: String): IChatComponent {
+ val mainComponent = ChatComponentText("$RED$msg")
+ val hoverComponent = ChatComponentText(help)
+
+ val hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent)
+ val clickEvent = ClickEvent(ClickEvent.Action.RUN_COMMAND, cmd)
+ mainComponent.chatStyle.setChatHoverEvent(hoverEvent).setChatClickEvent(clickEvent)
+
+ return mainComponent
+ }
+}
--
cgit