Skip to content
This repository was archived by the owner on Dec 7, 2024. It is now read-only.

Commit 121032b

Browse files
Account for minor versions from 1.20.5 onwards
1 parent a8ca486 commit 121032b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/main/kotlin/net/minecrell/pluginyml/bukkit/BukkitPlugin.kt

+14-3
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ class BukkitPlugin : PlatformPlugin<BukkitPluginDescription>("Bukkit", "plugin.y
3535
companion object {
3636
@JvmStatic
3737
private val VALID_NAME = Regex("^[A-Za-z0-9 _.-]+$")
38+
3839
@JvmStatic
3940
private val VALID_API_VERSION = Regex("^1\\.[0-9]+$")
41+
4042
@JvmStatic
41-
private val INVALID_NAMESPACES = listOf("net.minecraft.", "org.bukkit.", "io.papermc.", "com.destroystokoyo.paper.", "org.spigotmc")
43+
private val INVALID_NAMESPACES =
44+
listOf("net.minecraft.", "org.bukkit.", "io.papermc.", "com.destroystokoyo.paper.", "org.spigotmc")
4245
}
4346

4447
override fun createExtension(project: Project) = BukkitPluginDescription(project)
@@ -60,8 +63,16 @@ class BukkitPlugin : PlatformPlugin<BukkitPluginDescription>("Bukkit", "plugin.y
6063
if (!VALID_NAME.matches(name)) throw InvalidPluginDescriptionException("Invalid plugin name: should match $VALID_NAME")
6164
if (description.apiVersion != null) {
6265
val apiVersion = description.apiVersion!!
63-
if (!VALID_API_VERSION.matches(apiVersion)) throw InvalidPluginDescriptionException("Invalid api version: should match $VALID_API_VERSION")
64-
if (apiVersion < "1.13") throw InvalidPluginDescriptionException("Invalid api version: should be at least 1.13")
66+
val splitVersion = apiVersion.split("\\.").map { v -> v.toInt() }
67+
if (splitVersion.size == 2) {
68+
if (!VALID_API_VERSION.matches(apiVersion)) throw InvalidPluginDescriptionException("Invalid api version: should match $VALID_API_VERSION")
69+
if (apiVersion < "1.13") throw InvalidPluginDescriptionException("Invalid api version: should be at least 1.13")
70+
} else if (splitVersion.size == 3) {
71+
if (splitVersion[1] < 20) throw InvalidPluginDescriptionException("Invalid api version: Minor versions are not supported before 1.20.5")
72+
if (splitVersion[1] == 20 && splitVersion[2] < 5) throw InvalidPluginDescriptionException("Invalid api version: Minor versions are not supported before 1.20.5")
73+
} else {
74+
throw InvalidPluginDescriptionException("Invalid api version: $VALID_API_VERSION")
75+
}
6576
}
6677

6778
if (description.version.isNullOrEmpty()) throw InvalidPluginDescriptionException("Plugin version is not set")

0 commit comments

Comments
 (0)