diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchants.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchants.kt index 5a8801c9..a8db0d8c 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchants.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/EcoEnchants.kt @@ -107,11 +107,13 @@ object EcoEnchants { plugin ) } catch (e: MissingDependencyException) { - promptPluginInstall(plugin, id, e.plugins.toMutableList()) + addPluginPrompt(plugin, e.plugins.toMutableList()) } } } + sendPrompts(plugin) + registerHardcodedEnchantments(plugin) } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/MissingDependencyException.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/MissingDependencyException.kt index a9bdd7d6..4ed71197 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/MissingDependencyException.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoenchants/enchants/MissingDependencyException.kt @@ -8,28 +8,26 @@ class MissingDependencyException( override val message = "Missing the following plugins: ${plugins.joinToString(", ")}" } -fun promptPluginInstall(plugin: EcoEnchantsPlugin, enchant: String, plugins: MutableList) { +// Plugin names mapped to enchants not installed. +private val prompts = mutableMapOf() + +fun addPluginPrompt(plugin: EcoEnchantsPlugin, plugins: MutableList) { if (!plugin.isLoaded) { return } - val formatted = StringBuilder() + for (pluginName in plugins) { + prompts[pluginName] = prompts.getOrDefault(pluginName, 0) + 1 + } +} - when (plugins.size) { - 1 -> formatted.append(plugins.first()) - 2 -> formatted.append(plugins[0]) - .append(" and ") - .append(plugins[1]) - else -> { - val last = plugins.removeLast() - formatted.append(plugins.joinToString(", ")) - .append(", and ") - .append(last) +fun sendPrompts(plugin: EcoEnchantsPlugin) { + for ((pl, amount) in prompts) { + plugin.logger.apply { + warning("$amount enchantments were not loaded because they need $pl to be installed") + warning("Either download $pl or delete the folder with their names (/plugins/EcoEnchants/enchants/) to remove this message!") } } - plugin.logger.apply { - warning("Can't load the $enchant enchantment because you need $formatted installed") - warning("Either download $formatted or delete the folders with their names (/plugins/EcoEnchants/enchants/) to remove this message!") - } + prompts.clear() }