Skip to content

Commit

Permalink
Merge pull request #145 from SpigotBasics/dev
Browse files Browse the repository at this point in the history
Fixed aliases, deprecated RawCommandBuilder
  • Loading branch information
mfnalex authored Feb 17, 2024
2 parents eb25ec5 + a526c07 commit ef0822f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class BasicsCommand internal constructor(
permission = if (coreConfig.hideCommandsWhenNoPermission) permString else null
description = info.description ?: ""
usage = info.usage
aliases = info.aliases
permissionMessage = info.permissionMessage.tagParsed("permission", permString).toLegacyString()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class CommandFactory(
private val coreMessages: CoreMessages,
private val commandManager: BasicsCommandManager,
) {
@Deprecated("Use ParsedCommandBuilder instead")
fun rawCommandBuilder(
name: String,
permission: Permission,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class RawCommandBuilder(
@Deprecated("Ignored by Bukkit")
private fun permissionMessage(permissionMessage: Message) = apply { this.permissionMessage = permissionMessage }

@Deprecated("Will be registered automatically in the future")
fun aliases(aliases: List<String>) = apply { this.aliases = aliases }

fun executor(executor: BasicsCommandExecutor) = apply { this.executor = executor }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.spigotbasics.core.command.parsed.arguments

import com.github.spigotbasics.core.Basics
import com.github.spigotbasics.core.extensions.partialMatches
import com.github.spigotbasics.core.messages.Message
import org.bukkit.command.CommandSender

Expand All @@ -24,4 +25,11 @@ class IntRangeArg(name: String, private val min: () -> Int, private val max: ()
val given = value.toIntOrNull() ?: return Basics.messages.invalidValueForArgumentMustBeInteger(name, value)
return Basics.messages.invalidValueForArgumentNumberNotInRange(name, given, min(), max())
}

override fun tabComplete(
sender: CommandSender,
typing: String,
): List<String> {
return listOf(min().toString(), max().toString()).partialMatches(typing)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ open class ParsedCommandBuilder<T : CommandContext>(
this.usage = usage
}

fun aliases(aliases: List<String>) = apply { this.aliases = aliases }

fun path(argumentPath: ArgumentPath<T>) = apply { this.argumentPaths.add(argumentPath) }

fun path(argumentPathBuilder: ArgumentPathBuilder<T>) = apply { this.argumentPaths.add(argumentPathBuilder.build()) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class BasicsCoreModule(context: ModuleInstantiationContext) : AbstractBasicsModu
commandFactory.parsedCommandBuilder("module", modulePermission)
.mapContext {
usage = "<command> [module]"
aliases(listOf("mod"))

// module help
path {
Expand Down

0 comments on commit ef0822f

Please sign in to comment.