Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* NavAuth
* Copyright © 2026 Oliwier Fijas (Navio1430)
*
* NavAuth is free software; You can redistribute it and/or modify it under the terms of:
* the GNU Affero General Public License version 3 as published by the Free Software Foundation.
*
* NavAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with NavAuth. If not, see <https://www.gnu.org/licenses/>
* and navigate to version 3 of the GNU Affero General Public License.
*
*/

package pl.spcode.navauth.common.command.configurer

import eu.okaeri.configs.OkaeriConfig
import java.util.Collections.emptyList

class CommandConfig(
var name: String? = null, // new command name
var enabled: Boolean = true,
var aliases: List<String> = emptyList(),
) : OkaeriConfig() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* NavAuth
* Copyright © 2026 Oliwier Fijas (Navio1430)
*
* NavAuth is free software; You can redistribute it and/or modify it under the terms of:
* the GNU Affero General Public License version 3 as published by the Free Software Foundation.
*
* NavAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with NavAuth. If not, see <https://www.gnu.org/licenses/>
* and navigate to version 3 of the GNU Affero General Public License.
*
*/

package pl.spcode.navauth.common.config

import eu.okaeri.configs.OkaeriConfig
import eu.okaeri.configs.annotation.Comment
import pl.spcode.navauth.common.command.configurer.CommandConfig

class CommandsConfig : OkaeriConfig() {

@Comment(
"This property allows you to configure commands definitions.",
"You can toggle the command and update its name or aliases.",
"",
"You can find command names in docs:",
"https://navio1430.github.io/NavAuth/docs/general/commands.html#available-commands",
"Remember to use command names without the leading slash '/'.",
)
var commands: MutableMap<String, CommandConfig> =
mutableMapOf(
"navauth" to CommandConfig(name = "navauth", aliases = mutableListOf("na"), enabled = true),
"login" to CommandConfig(name = "login", aliases = mutableListOf("l"), enabled = true),
"register" to CommandConfig(name = "register", aliases = mutableListOf("reg"), enabled = true),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ open class GeneralConfig : OkaeriConfig() {

var sessionsConfig = SessionsConfig()

var commandsConfig: CommandsConfig = CommandsConfig()

@Variable("CONFIG_VERSION")
@Comment("Config version. DO NOT CHANGE this property!")
var configVersion: Int = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import pl.spcode.navauth.common.config.MigrationConfig
import pl.spcode.navauth.common.infra.database.DatabaseManager
import pl.spcode.navauth.common.module.*
import pl.spcode.navauth.velocity.command.CommandsRegistry
import pl.spcode.navauth.velocity.command.configurer.CommandConfigurer
import pl.spcode.navauth.velocity.infra.command.VelocityInvalidUsageHandler
import pl.spcode.navauth.velocity.infra.command.VelocityMissingPermissionExceptionHandler
import pl.spcode.navauth.velocity.infra.command.VelocityMissingPermissionHandler
Expand Down Expand Up @@ -163,6 +164,7 @@ constructor(
UserResolveException::class.java,
UserResolveExceptionHandler(VelocityAudienceProvider(proxyServer)),
)
.editorGlobal(injector.getInstance(CommandConfigurer::class.java))
.exception(
MissingPermissionException::class.java,
injector.getInstance(VelocityMissingPermissionExceptionHandler::class.java),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* NavAuth
* Copyright © 2026 Oliwier Fijas (Navio1430)
*
* NavAuth is free software; You can redistribute it and/or modify it under the terms of:
* the GNU Affero General Public License version 3 as published by the Free Software Foundation.
*
* NavAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with NavAuth. If not, see <https://www.gnu.org/licenses/>
* and navigate to version 3 of the GNU Affero General Public License.
*
*/

package pl.spcode.navauth.velocity.command.configurer

import com.google.inject.Inject
import com.velocitypowered.api.command.CommandSource
import dev.rollczi.litecommands.command.builder.CommandBuilder
import dev.rollczi.litecommands.editor.Editor
import pl.spcode.navauth.common.config.CommandsConfig

class CommandConfigurer @Inject constructor(private val commandConfiguration: CommandsConfig) :
Editor<CommandSource> {

override fun edit(context: CommandBuilder<CommandSource>): CommandBuilder<CommandSource> {
val command = commandConfiguration.commands[context.name()] ?: return context

var newContext = context

if (!command.name.isNullOrEmpty()) {
newContext = context.name(command.name)
}

val aliasesFiltered = command.aliases.filter { it.isNotEmpty() }

return newContext.aliases(aliasesFiltered).enabled(command.enabled)
}
}
Loading