Skip to content

Commit da9833d

Browse files
committed
feat: Add CommandAPI version check
1 parent 35f2594 commit da9833d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- [Documentation](https://endlesscodegroup.github.io/ECInventory/docs/intro)
66
- Support of Mimic PlayerInventory API to integrate with other plugins
7+
- Check minimal required version of Mimic and CommandAPI on plugin enable
78

89
### Changed
910

core/src/main/kotlin/ECInventoryPlugin.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package ru.endlesscode.inventory
2222
import org.bukkit.command.CommandSender
2323
import org.bukkit.plugin.java.JavaPlugin
2424
import ru.endlesscode.inventory.internal.compat.BukkitVersion
25+
import ru.endlesscode.inventory.internal.compat.Version
2526
import ru.endlesscode.inventory.internal.di.DI
2627
import ru.endlesscode.inventory.internal.di.DataModule
2728
import ru.endlesscode.inventory.internal.hooks.EcInventoryPlayerInventory
@@ -99,6 +100,7 @@ public class ECInventoryPlugin : JavaPlugin() {
99100

100101
private fun initHooks() {
101102
hookMimic()
103+
checkCommandApiVersion()
102104
PlaceholderApiPlaceholders.hook(server.pluginManager)
103105
}
104106

@@ -112,6 +114,19 @@ public class ECInventoryPlugin : JavaPlugin() {
112114
EcInventoryPlayerInventory.hook(this)
113115
}
114116

117+
private fun checkCommandApiVersion() {
118+
val commandApi = server.pluginManager.getPlugin("CommandAPI")
119+
checkNotNull(commandApi) { "CommandAPI not found. Please install it: https://github.com/JorelAli/CommandAPI" }
120+
121+
val version = Version.parseVersion(commandApi.description.version)
122+
check(version >= 8_00_00) {
123+
"""
124+
At least CommandAPI 8.0.0 is required.
125+
Please install latest version: https://github.com/JorelAli/CommandAPI
126+
""".trimIndent()
127+
}
128+
}
129+
115130
private fun makeSure(action: () -> Boolean): Boolean {
116131
return try {
117132
action()

0 commit comments

Comments
 (0)