Rename package

This commit is contained in:
redtea committed 2024-07-06 19:49:44 +03:00
1 parent de48207907
commit 5549235e1c
177 files changed
+469 -469

No files matched your search

+2 -2
View File
@@ -9,8 +9,8 @@ plugins {
}
group = "tech.carcadex"
val globalArtifactId = "kotlinbukkitkit-commands"
val globalName = "kotlinbukkitkit-commands"
val globalArtifactId = "kbk-commands"
val globalName = "kbk-commands"
repositories {
mavenCentral()
@@ -1,7 +1,7 @@
package tech.carcadex.kotlinbukkitkit.commands
package tech.carcadex.kbk.commands
import org.bukkit.plugin.Plugin
import tech.carcadex.kotlinbukkitkit.commands.dsl.builder.simpleCommand
import tech.carcadex.kbk.commands.dsl.builder.simpleCommand
fun Plugin.cmd() {
simpleCommand("test") {
@@ -1,7 +1,7 @@
package tech.carcadex.kotlinbukkitkit.commands.dsl
package tech.carcadex.kbk.commands.dsl
import org.bukkit.command.CommandSender
import tech.carcadex.kotlinbukkitkit.commands.service.MessagesService
import tech.carcadex.kbk.commands.service.MessagesService
/**
* Interface for SubCommand and Command
@@ -1,4 +1,4 @@
package tech.carcadex.kotlinbukkitkit.commands.dsl
package tech.carcadex.kbk.commands.dsl
/**
* Class that contains command data
@@ -0,0 +1,7 @@
package tech.carcadex.kbk.commands.dsl
import tech.carcadex.kbk.commands.dsl.Command
interface CommandNode : Command {
fun add(command: Command)
}
@@ -1,12 +1,12 @@
package tech.carcadex.kotlinbukkitkit.commands.dsl
package tech.carcadex.kbk.commands.dsl
import org.bukkit.Bukkit
import org.bukkit.Material
import org.bukkit.OfflinePlayer
import org.bukkit.World
import org.bukkit.entity.Player
import tech.carcadex.kotlinbukkitkit.commands.exceptions.ArgumentNotFoundException
import tech.carcadex.kotlinbukkitkit.commands.exceptions.CommandExecuteException
import tech.carcadex.kbk.commands.exceptions.ArgumentNotFoundException
import tech.carcadex.kbk.commands.exceptions.CommandExecuteException
fun ExecutorContext.string(index: Int): String = argument(index) ?: throw ArgumentNotFoundException(index)
fun ExecutorContext.stringOrNull(index: Int): String? = argument(index)
@@ -1,8 +1,8 @@
package tech.carcadex.kotlinbukkitkit.commands.dsl
package tech.carcadex.kbk.commands.dsl
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
import tech.carcadex.kotlinbukkitkit.commands.exceptions.NotPlayerException
import tech.carcadex.kbk.commands.exceptions.NotPlayerException
class ExecutorContext(val sender: CommandSender, val args: Array<String>) {
val player: Player
@@ -1,19 +1,19 @@
package tech.carcadex.kotlinbukkitkit.commands.dsl.builder
package tech.carcadex.kbk.commands.dsl.builder
import org.bukkit.command.CommandSender
import org.bukkit.plugin.Plugin
import tech.carcadex.kotlinbukkitkit.commands.dsl.Command
import tech.carcadex.kotlinbukkitkit.commands.dsl.CommandContext
import tech.carcadex.kotlinbukkitkit.commands.dsl.ExecutorContext
import tech.carcadex.kotlinbukkitkit.commands.dsl.leaf.CommandLeaf
import tech.carcadex.kotlinbukkitkit.commands.dsl.node.CommandNodeImpl
import tech.carcadex.kotlinbukkitkit.commands.exceptions.CommandExecuteException
import tech.carcadex.kotlinbukkitkit.commands.exceptions.LeafCommandHasNotExecutorException
import tech.carcadex.kotlinbukkitkit.commands.manager.CommandManagerInternal
import tech.carcadex.kotlinbukkitkit.commands.manager.commandManager
import tech.carcadex.kotlinbukkitkit.commands.manager.commandManagerInternal
import tech.carcadex.kotlinbukkitkit.commands.register.CommandRegister
import tech.carcadex.kotlinbukkitkit.commands.service.TabCompleteService
import tech.carcadex.kbk.commands.dsl.Command
import tech.carcadex.kbk.commands.dsl.CommandContext
import tech.carcadex.kbk.commands.dsl.ExecutorContext
import tech.carcadex.kbk.commands.dsl.leaf.CommandLeaf
import tech.carcadex.kbk.commands.dsl.node.CommandNodeImpl
import tech.carcadex.kbk.commands.exceptions.CommandExecuteException
import tech.carcadex.kbk.commands.exceptions.LeafCommandHasNotExecutorException
import tech.carcadex.kbk.commands.manager.CommandManagerInternal
import tech.carcadex.kbk.commands.manager.commandManager
import tech.carcadex.kbk.commands.manager.commandManagerInternal
import tech.carcadex.kbk.commands.register.CommandRegister
import tech.carcadex.kbk.commands.service.TabCompleteService
class CommandBuilder(
val context: CommandContext,
@@ -1,8 +1,8 @@
package tech.carcadex.kotlinbukkitkit.commands.dsl.builder
package tech.carcadex.kbk.commands.dsl.builder
import org.bukkit.plugin.Plugin
import tech.carcadex.kotlinbukkitkit.commands.dsl.ExecutorContext
import tech.carcadex.kotlinbukkitkit.commands.register.CommandRegister
import tech.carcadex.kbk.commands.dsl.ExecutorContext
import tech.carcadex.kbk.commands.register.CommandRegister
fun Plugin.command(name: String, invoke: CommandBuilder.() -> Unit) {
@@ -1,11 +1,11 @@
package tech.carcadex.kotlinbukkitkit.commands.dsl.leaf
package tech.carcadex.kbk.commands.dsl.leaf
import org.bukkit.command.CommandSender
import tech.carcadex.kotlinbukkitkit.commands.dsl.Command
import tech.carcadex.kotlinbukkitkit.commands.dsl.CommandContext
import tech.carcadex.kotlinbukkitkit.commands.dsl.ExecutorContext
import tech.carcadex.kotlinbukkitkit.commands.exceptions.ArgumentNotFoundException
import tech.carcadex.kotlinbukkitkit.commands.exceptions.CommandExecuteException
import tech.carcadex.kbk.commands.dsl.Command
import tech.carcadex.kbk.commands.dsl.CommandContext
import tech.carcadex.kbk.commands.dsl.ExecutorContext
import tech.carcadex.kbk.commands.exceptions.ArgumentNotFoundException
import tech.carcadex.kbk.commands.exceptions.CommandExecuteException
class CommandLeaf(
override val context: CommandContext,
@@ -1,12 +1,12 @@
package tech.carcadex.kotlinbukkitkit.commands.dsl.node
package tech.carcadex.kbk.commands.dsl.node
import org.bukkit.command.CommandSender
import tech.carcadex.kotlinbukkitkit.commands.dsl.Command
import tech.carcadex.kotlinbukkitkit.commands.dsl.CommandContext
import tech.carcadex.kotlinbukkitkit.commands.dsl.CommandNode
import tech.carcadex.kotlinbukkitkit.commands.dsl.ExecutorContext
import tech.carcadex.kotlinbukkitkit.commands.exceptions.CommandExecuteException
import tech.carcadex.kotlinbukkitkit.commands.service.MessagesService
import tech.carcadex.kbk.commands.dsl.Command
import tech.carcadex.kbk.commands.dsl.CommandContext
import tech.carcadex.kbk.commands.dsl.CommandNode
import tech.carcadex.kbk.commands.dsl.ExecutorContext
import tech.carcadex.kbk.commands.exceptions.CommandExecuteException
import tech.carcadex.kbk.commands.service.MessagesService
class CommandNodeImpl(
override val context: CommandContext,
@@ -1,4 +1,4 @@
package tech.carcadex.kotlinbukkitkit.commands.exceptions
package tech.carcadex.kbk.commands.exceptions
class ArgumentNotFoundException(index: Int) : NoSuchElementException("Argument with index $index not found! Args array out of bounds") {
}
@@ -1,4 +1,4 @@
package tech.carcadex.kotlinbukkitkit.commands.exceptions
package tech.carcadex.kbk.commands.exceptions
open class CommandExecuteException(val messageTag: String) : RuntimeException() {
}
@@ -1,4 +1,4 @@
package tech.carcadex.kotlinbukkitkit.commands.exceptions
package tech.carcadex.kbk.commands.exceptions
class LeafCommandHasNotExecutorException(commandName: String)
: IllegalArgumentException("Command $commandName has not subcommands or default executor!") {
@@ -1,4 +1,4 @@
package tech.carcadex.kotlinbukkitkit.commands.exceptions
package tech.carcadex.kbk.commands.exceptions
class NotPlayerException() : CommandExecuteException(messageTag = "#for-player-only") {
}
@@ -1,4 +1,4 @@
package tech.carcadex.kotlinbukkitkit.commands.exceptions
package tech.carcadex.kbk.commands.exceptions
class UnknownCompleteException(val msg: String) : RuntimeException(msg) {
}
@@ -1,3 +1,3 @@
package tech.carcadex.kotlinbukkitkit.commands.exceptions
package tech.carcadex.kbk.commands.exceptions
class UnsupportedTypeException(msg: String) : RuntimeException(msg)
@@ -1,4 +1,4 @@
package tech.carcadex.kotlinbukkitkit.commands.extensions
package tech.carcadex.kbk.commands.extensions
import org.bukkit.command.CommandSender
@@ -1,4 +1,4 @@
package tech.carcadex.kotlinbukkitkit.commands.manager
package tech.carcadex.kbk.commands.manager
import org.bukkit.command.CommandSender
import org.bukkit.plugin.Plugin
@@ -1,18 +1,18 @@
package tech.carcadex.kotlinbukkitkit.commands.manager
package tech.carcadex.kbk.commands.manager
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
import org.bukkit.command.TabCompleter
import org.bukkit.plugin.Plugin
import tech.carcadex.kotlinbukkitkit.commands.reflection.CommandParams
import tech.carcadex.kotlinbukkitkit.commands.reflection.Parser
import tech.carcadex.kotlinbukkitkit.commands.reflection.Parser.paramsFromAnnotations
import tech.carcadex.kotlinbukkitkit.commands.reflection.annotations.Command
import tech.carcadex.kotlinbukkitkit.commands.exceptions.CommandExecuteException
import tech.carcadex.kotlinbukkitkit.commands.register.CommandRegister
import tech.carcadex.kotlinbukkitkit.commands.service.MessagesService
import tech.carcadex.kotlinbukkitkit.commands.reflection.service.SubCommandsService
import tech.carcadex.kotlinbukkitkit.commands.service.TabCompleteService
import tech.carcadex.kbk.commands.reflection.CommandParams
import tech.carcadex.kbk.commands.reflection.Parser
import tech.carcadex.kbk.commands.reflection.Parser.paramsFromAnnotations
import tech.carcadex.kbk.commands.reflection.annotations.Command
import tech.carcadex.kbk.commands.exceptions.CommandExecuteException
import tech.carcadex.kbk.commands.register.CommandRegister
import tech.carcadex.kbk.commands.service.MessagesService
import tech.carcadex.kbk.commands.reflection.service.SubCommandsService
import tech.carcadex.kbk.commands.service.TabCompleteService
import kotlin.reflect.KFunction
import kotlin.reflect.full.createType
import kotlin.reflect.full.findAnnotations
@@ -1,4 +1,4 @@
package tech.carcadex.kotlinbukkitkit.commands.reflection
package tech.carcadex.kbk.commands.reflection
data class CommandParams(
val name: String,
@@ -1,11 +1,11 @@
package tech.carcadex.kotlinbukkitkit.commands.reflection
package tech.carcadex.kbk.commands.reflection
import org.bukkit.command.CommandSender
import tech.carcadex.kotlinbukkitkit.commands.exceptions.CommandExecuteException
import tech.carcadex.kotlinbukkitkit.commands.exceptions.UnsupportedTypeException
import tech.carcadex.kotlinbukkitkit.commands.reflection.annotations.*
import tech.carcadex.kotlinbukkitkit.commands.service.MessagesService
import tech.carcadex.kotlinbukkitkit.commands.reflection.service.TypeService
import tech.carcadex.kbk.commands.exceptions.CommandExecuteException
import tech.carcadex.kbk.commands.exceptions.UnsupportedTypeException
import tech.carcadex.kbk.commands.reflection.annotations.*
import tech.carcadex.kbk.commands.service.MessagesService
import tech.carcadex.kbk.commands.reflection.service.TypeService
import kotlin.reflect.KClass
import kotlin.reflect.KFunction
import kotlin.reflect.KParameter
@@ -0,0 +1,3 @@
package tech.carcadex.kbk.commands.reflection.annotations
annotation class Aliases(val aliases: Array<String>)
@@ -1,4 +1,4 @@
package tech.carcadex.kotlinbukkitkit.commands.reflection.annotations
package tech.carcadex.kbk.commands.reflection.annotations
@Retention(AnnotationRetention.RUNTIME)
annotation class Command(val name: String)
@@ -0,0 +1,4 @@
package tech.carcadex.kbk.commands.reflection.annotations
@Retention(AnnotationRetention.RUNTIME)
annotation class Default()
@@ -1,4 +1,4 @@
package tech.carcadex.kotlinbukkitkit.commands.reflection.annotations
package tech.carcadex.kbk.commands.reflection.annotations
@Retention(AnnotationRetention.RUNTIME)
annotation class Description(val desc: String)
@@ -0,0 +1,4 @@
package tech.carcadex.kbk.commands.reflection.annotations
@Retention(AnnotationRetention.RUNTIME)
annotation class Optional()
@@ -1,4 +1,4 @@
package tech.carcadex.kotlinbukkitkit.commands.reflection.annotations
package tech.carcadex.kbk.commands.reflection.annotations
@Retention(AnnotationRetention.RUNTIME)
annotation class Permission(val perm: String)
@@ -1,4 +1,4 @@
package tech.carcadex.kotlinbukkitkit.commands.reflection.annotations
package tech.carcadex.kbk.commands.reflection.annotations
@Retention(AnnotationRetention.RUNTIME)
annotation class SubCommand(val name: String)
@@ -1,4 +1,4 @@
package tech.carcadex.kotlinbukkitkit.commands.reflection.annotations
package tech.carcadex.kbk.commands.reflection.annotations
@Retention(AnnotationRetention.RUNTIME)
annotation class TabComplete(val complete: Array<String>)
@@ -1,4 +1,4 @@
package tech.carcadex.kotlinbukkitkit.commands.reflection.annotations
package tech.carcadex.kbk.commands.reflection.annotations
@Retention(AnnotationRetention.RUNTIME)
annotation class Usage(val usage: String)
@@ -1,15 +1,15 @@
package tech.carcadex.kotlinbukkitkit.commands.reflection.service
package tech.carcadex.kbk.commands.reflection.service
import org.bukkit.command.CommandSender
import org.bukkit.command.TabCompleter
import tech.carcadex.kotlinbukkitkit.commands.exceptions.NotPlayerException
import tech.carcadex.kotlinbukkitkit.commands.service.MessagesService
import tech.carcadex.kotlinbukkitkit.commands.service.TabCompleteService
import tech.carcadex.kotlinbukkitkit.commands.reflection.CommandParams
import tech.carcadex.kotlinbukkitkit.commands.reflection.Parser
import tech.carcadex.kotlinbukkitkit.commands.reflection.annotations.Command
import tech.carcadex.kotlinbukkitkit.commands.reflection.annotations.Default
import tech.carcadex.kotlinbukkitkit.commands.exceptions.CommandExecuteException
import tech.carcadex.kbk.commands.exceptions.NotPlayerException
import tech.carcadex.kbk.commands.service.MessagesService
import tech.carcadex.kbk.commands.service.TabCompleteService
import tech.carcadex.kbk.commands.reflection.CommandParams
import tech.carcadex.kbk.commands.reflection.Parser
import tech.carcadex.kbk.commands.reflection.annotations.Command
import tech.carcadex.kbk.commands.reflection.annotations.Default
import tech.carcadex.kbk.commands.exceptions.CommandExecuteException
import kotlin.reflect.KFunction
import kotlin.reflect.full.*
import kotlin.reflect.jvm.javaType
@@ -29,7 +29,7 @@ class SubCommandsService(private val messagesService: MessagesService, private v
val res = mutableListOf<SubCommand>()
for(func in clazz.functions) {
if(func.hasAnnotation<tech.carcadex.kotlinbukkitkit.commands.reflection.annotations.SubCommand>()) {
if(func.hasAnnotation<tech.carcadex.kbk.commands.reflection.annotations.SubCommand>()) {
res.add(parseSubCommand(func, command))
} else if(func.hasAnnotation<Default>()) {
defaults[name] = parseSubCommand(func, command)
@@ -58,7 +58,7 @@ class SubCommandsService(private val messagesService: MessagesService, private v
private fun parseSubCommand(func: KFunction<*>, rootCommand: Any): SubCommand {
val name = if(func.hasAnnotation<Default>()) "default" else func.findAnnotations(tech.carcadex.kotlinbukkitkit.commands.reflection.annotations.SubCommand::class).first().name
val name = if(func.hasAnnotation<Default>()) "default" else func.findAnnotations(tech.carcadex.kbk.commands.reflection.annotations.SubCommand::class).first().name
val context = Parser.paramsFromAnnotations(func)
val argsParsers = Parser.parseParam(func.parameters.toTypedArray().copyOfRange(1, func.parameters.size).toList())
var argsSize = func.parameters.size
@@ -1,4 +1,4 @@
package tech.carcadex.kotlinbukkitkit.commands.reflection.service
package tech.carcadex.kbk.commands.reflection.service
import org.bukkit.Bukkit
import org.bukkit.Material
@@ -6,8 +6,8 @@ import org.bukkit.OfflinePlayer
import org.bukkit.World
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
import tech.carcadex.kotlinbukkitkit.commands.exceptions.UnsupportedTypeException
import tech.carcadex.kotlinbukkitkit.extensions.offlinePlayerOrNull
import tech.carcadex.kbk.commands.exceptions.UnsupportedTypeException
import tech.carcadex.kbk.extensions.offlinePlayerOrNull
import java.lang.reflect.Type
import kotlin.reflect.KClass
import kotlin.reflect.KType
@@ -1,4 +1,4 @@
package tech.carcadex.kotlinbukkitkit.commands.register
package tech.carcadex.kbk.commands.register
import org.bukkit.Bukkit
import org.bukkit.command.*
@@ -1,4 +1,4 @@
package tech.carcadex.kotlinbukkitkit.commands.service
package tech.carcadex.kbk.commands.service
import org.bukkit.ChatColor
import org.bukkit.command.CommandSender
@@ -1,4 +1,4 @@
package tech.carcadex.kotlinbukkitkit.commands.service
package tech.carcadex.kbk.commands.service
import org.bukkit.Bukkit
import org.bukkit.command.CommandSender
@@ -1,7 +0,0 @@
package tech.carcadex.kotlinbukkitkit.commands.dsl
import tech.carcadex.kotlinbukkitkit.commands.dsl.Command
interface CommandNode : Command {
fun add(command: Command)
}
@@ -1,3 +0,0 @@
package tech.carcadex.kotlinbukkitkit.commands.reflection.annotations
annotation class Aliases(val aliases: Array<String>)
@@ -1,4 +0,0 @@
package tech.carcadex.kotlinbukkitkit.commands.reflection.annotations
@Retention(AnnotationRetention.RUNTIME)
annotation class Default()
@@ -1,4 +0,0 @@
package tech.carcadex.kotlinbukkitkit.commands.reflection.annotations
@Retention(AnnotationRetention.RUNTIME)
annotation class Optional()