command is finally registering and executing properly
This commit is contained in:
parent
812e2361c9
commit
99f3eef4f8
@ -5,11 +5,15 @@ import io.ktor.client.engine.cio.*
|
|||||||
import io.ktor.client.plugins.*
|
import io.ktor.client.plugins.*
|
||||||
import io.ktor.client.plugins.contentnegotiation.*
|
import io.ktor.client.plugins.contentnegotiation.*
|
||||||
import io.ktor.serialization.kotlinx.json.*
|
import io.ktor.serialization.kotlinx.json.*
|
||||||
|
import io.papermc.paper.command.brigadier.Commands
|
||||||
|
import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager
|
||||||
|
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import org.bukkit.Server
|
import org.bukkit.Server
|
||||||
import org.bukkit.command.CommandExecutor
|
import org.bukkit.command.CommandExecutor
|
||||||
import org.bukkit.command.PluginCommand
|
import org.bukkit.command.PluginCommand
|
||||||
import org.bukkit.command.TabCompleter
|
import org.bukkit.command.TabCompleter
|
||||||
|
import org.bukkit.plugin.Plugin
|
||||||
import org.bukkit.plugin.PluginManager
|
import org.bukkit.plugin.PluginManager
|
||||||
import org.bukkit.plugin.java.JavaPlugin
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
import org.bukkit.scheduler.BukkitScheduler
|
import org.bukkit.scheduler.BukkitScheduler
|
||||||
@ -23,11 +27,9 @@ class Platinum : JavaPlugin() {
|
|||||||
lateinit var pluginManager: PluginManager
|
lateinit var pluginManager: PluginManager
|
||||||
lateinit var logger: Logger
|
lateinit var logger: Logger
|
||||||
lateinit var server: Server
|
lateinit var server: Server
|
||||||
lateinit var scheduler: BukkitScheduler
|
|
||||||
lateinit var props: Properties
|
lateinit var props: Properties
|
||||||
lateinit var version: String
|
lateinit var version: String
|
||||||
lateinit var hash: String
|
lateinit var hash: String
|
||||||
|
|
||||||
lateinit var webClient: HttpClient
|
lateinit var webClient: HttpClient
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +56,9 @@ class Platinum : JavaPlugin() {
|
|||||||
agent = "https://git.jansel.moe/jreimers/Platinum v$version(jansel@jansel.moe)"
|
agent = "https://git.jansel.moe/jreimers/Platinum v$version(jansel@jansel.moe)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Companion.server = server
|
||||||
|
pluginManager = server.pluginManager
|
||||||
|
instance = this
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDisable() {
|
override fun onDisable() {
|
||||||
@ -61,9 +66,7 @@ class Platinum : JavaPlugin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun registerCommands() {
|
private fun registerCommands() {
|
||||||
"platinum".cmd() execs CommandExecutor { commandSender, command, name, args ->
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun String.cmd() = instance.getCommand(this) ?: throw NullPointerException("Command '$name' not found!")
|
private fun String.cmd() = instance.getCommand(this) ?: throw NullPointerException("Command '$name' not found!")
|
||||||
|
18
src/main/kotlin/moe/jansel/platinum/PlatinumBootstrap.kt
Normal file
18
src/main/kotlin/moe/jansel/platinum/PlatinumBootstrap.kt
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package moe.jansel.platinum
|
||||||
|
|
||||||
|
import io.papermc.paper.command.brigadier.Commands
|
||||||
|
import io.papermc.paper.plugin.bootstrap.BootstrapContext
|
||||||
|
import io.papermc.paper.plugin.bootstrap.PluginBootstrap
|
||||||
|
import io.papermc.paper.plugin.lifecycle.event.registrar.ReloadableRegistrarEvent
|
||||||
|
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents
|
||||||
|
import moe.jansel.platinum.commands.PlatinumCommand
|
||||||
|
|
||||||
|
class PlatinumBootstrap : PluginBootstrap {
|
||||||
|
override fun bootstrap(context: BootstrapContext) {
|
||||||
|
val manager = context.lifecycleManager
|
||||||
|
manager.registerEventHandler(LifecycleEvents.COMMANDS) { event: ReloadableRegistrarEvent<Commands?> ->
|
||||||
|
val commands = event.registrar()
|
||||||
|
commands.register("platinum", "Platinum Main Command", PlatinumCommand())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package moe.jansel.platinum.commands
|
||||||
|
|
||||||
|
import io.papermc.paper.command.brigadier.BasicCommand
|
||||||
|
import io.papermc.paper.command.brigadier.CommandSourceStack
|
||||||
|
|
||||||
|
class PlatinumCommand: BasicCommand {
|
||||||
|
override fun execute(stack: CommandSourceStack, args: Array<out String>?) {
|
||||||
|
if (args?.size == 1 && args[0].lowercase() == "start") {
|
||||||
|
stack.getSender().sendRichMessage("<rainbow>Fun activated!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -6,11 +6,7 @@ prefix: platinum
|
|||||||
authors: [ Jansel ]
|
authors: [ Jansel ]
|
||||||
description: Yet another rewrite of my old datasync Plugin
|
description: Yet another rewrite of my old datasync Plugin
|
||||||
website: https://git.jansel.moe/jreimers/platinum
|
website: https://git.jansel.moe/jreimers/platinum
|
||||||
|
bootstrapper: moe.jansel.platinum.PlatinumBootstrap
|
||||||
commands:
|
|
||||||
platinum:
|
|
||||||
usage: /platinum <command> [args]
|
|
||||||
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
platinum.download:
|
platinum.download:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user