Skip to content

Commit

Permalink
feat: Add support for more Paper-added plugin.yml fields
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Aug 25, 2024
1 parent 7430390 commit 94e2a6b
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import xyz.jpenilla.resourcefactory.util.getValidating
import xyz.jpenilla.resourcefactory.util.nullAction
import xyz.jpenilla.resourcefactory.util.nullIfEmpty
import xyz.jpenilla.resourcefactory.util.nullIfEmptyValidating
import xyz.jpenilla.resourcefactory.util.orNullValidating
import javax.inject.Inject

/**
Expand Down Expand Up @@ -55,6 +56,7 @@ class BukkitPluginYaml(

companion object {
private const val PLUGIN_NAME_PATTERN: String = "^[A-Za-z0-9_\\.-]+$"
private const val PLUGIN_CLASS_PATTERN: String = "^(?!org\\.bukkit\\.)([a-zA-Z_$][a-zA-Z\\d_$]*\\.)*[a-zA-Z_$][a-zA-Z\\d_$]*$"
private const val FILE_NAME: String = "plugin.yml"
}

Expand All @@ -69,7 +71,7 @@ class BukkitPluginYaml(
@get:Input
val version: Property<String> = objects.property()

@Pattern("^(?!org\\.bukkit\\.)([a-zA-Z_$][a-zA-Z\\d_$]*\\.)*[a-zA-Z_$][a-zA-Z\\d_$]*$", "Bukkit plugin main class name")
@Pattern(PLUGIN_CLASS_PATTERN, "Bukkit plugin main class name")
@get:Input
val main: Property<String> = objects.property()

Expand Down Expand Up @@ -135,6 +137,15 @@ class BukkitPluginYaml(
@get:Optional
val foliaSupported: Property<Boolean> = objects.property()

@get:Input
@get:Optional
@Pattern(PLUGIN_CLASS_PATTERN, "Paper plugin loader class name")
val paperPluginLoader: Property<String> = objects.property()

@get:Input
@get:Optional
val paperSkipLibraries: Property<Boolean> = objects.property()

enum class PluginLoadOrder {
STARTUP,
POSTWORLD
Expand Down Expand Up @@ -219,5 +230,7 @@ class BukkitPluginYaml(
val commands = yaml.commands.nullIfEmpty()?.mapValues { (_, v) -> Command.Serializable(v) }
val permissions = yaml.permissions.nullIfEmpty()?.mapValues { Permission.Serializable(it.value) }
val foliaSupported = yaml.foliaSupported.orNull
val paperPluginLoader = yaml::paperPluginLoader.orNullValidating()
val paperSkipLibraries = yaml.paperSkipLibraries.orNull
}
}

0 comments on commit 94e2a6b

Please sign in to comment.