mirror of
https://github.com/plexusorg/plugin-yml.git
synced 2024-12-22 08:15:08 +00:00
Validate command names on Bukkit and Nukkit
This commit is contained in:
parent
c7169d6ad0
commit
6ef1128cd8
2 changed files with 14 additions and 0 deletions
|
@ -53,6 +53,13 @@ class BukkitPlugin : PlatformPlugin<BukkitPluginDescription>("Bukkit", "plugin.y
|
|||
val main = description.main ?: throw InvalidPluginDescriptionException("Main class is not defined")
|
||||
if (main.isEmpty()) throw InvalidPluginDescriptionException("Main class cannot be empty")
|
||||
if (main.startsWith("org.bukkit.")) throw InvalidPluginDescriptionException("Main may not be within the org.bukkit namespace")
|
||||
|
||||
for (command in description.commands) {
|
||||
if (command.name.contains(':')) throw InvalidPluginDescriptionException("Command '${command.name}' cannot contain ':'")
|
||||
command.aliases?.forEach { alias ->
|
||||
if (alias.contains(':')) throw InvalidPluginDescriptionException("Alias '$alias' of '${command.name}' cannot contain ':'")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,6 +48,13 @@ class NukkitPlugin : PlatformPlugin<NukkitPluginDescription>("Nukkit", "nukkit.y
|
|||
if (main.startsWith("cn.nukkit.")) throw InvalidPluginDescriptionException("Main class cannot be within cn.nukkit. package")
|
||||
|
||||
if (description.api?.isEmpty() != false) throw InvalidPluginDescriptionException("Nukkit API version is not set")
|
||||
|
||||
for (command in description.commands) {
|
||||
if (command.name.contains(':')) throw InvalidPluginDescriptionException("Command '${command.name}' cannot contain ':'")
|
||||
command.aliases?.forEach { alias ->
|
||||
if (alias.contains(':')) throw InvalidPluginDescriptionException("Alias '$alias' of '${command.name}' cannot contain ':'")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue