remove legacy command

This commit is contained in:
alexcrea 2026-06-30 23:47:16 +02:00
parent 0e65575c2b
commit 5a6962b1c4
Signed by: alexcrea
GPG key ID: E59DF23EE2A2266C
8 changed files with 43 additions and 68 deletions

View file

@ -145,7 +145,7 @@ open class CustomAnvil : JavaPlugin() {
// Add commands
try {
prepareCommand()
CustomAnvilCommand(this)
} catch (e: Exception) {
logger.log(Level.SEVERE, "error trying to register commands", e)
MetricsUtil.trackError(e)
@ -330,14 +330,4 @@ open class CustomAnvil : JavaPlugin() {
return yamlConfig
}
fun prepareCommand() {
var command = getCommand(commandReloadName)
command?.setExecutor(ReloadExecutor())
command = getCommand(commandConfigName)
command?.setExecutor(EditConfigExecutor())
CustomAnvilCommand(this)
}
}

View file

@ -1,52 +1,27 @@
package xyz.alexcrea.cuanvil.command
import org.bukkit.ChatColor
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
import xyz.alexcrea.cuanvil.enchant.CAEnchantmentRegistry
abstract class CASubCommand : CommandExecutor {
interface CASubCommand {
private var alreadySaid = false;
override fun onCommand(
sender: CommandSender,
cmd: Command,
cmdstr: String,
args: Array<out String>
): Boolean {
if (!alreadySaid) {
sender.sendMessage(
ChatColor.RED.toString() +
"Please not that this command will be replaced as a subcommand of `/customanvil` or `/ca`"
)
alreadySaid = true
}
return executeCommand(sender, cmd, cmdstr, args)
}
abstract fun executeCommand(
fun executeCommand(
sender: CommandSender,
cmd: Command,
cmdstr: String,
args: Array<out String>
): Boolean
open fun allowed(sender: CommandSender): Boolean {
return true
}
fun allowed(sender: CommandSender): Boolean
open fun tabCompleter(
fun tabCompleter(
sender: CommandSender,
args: Array<out String>,
list: MutableList<String>
) {
}
)
open fun description(): String {
return "no description"
}
fun description(): String
protected fun allEnchantmentsByName(): Collection<String> {
val names = mutableSetOf<String>()

View file

@ -12,7 +12,7 @@ import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.command.DiagnosticExecutor.Companion.NO_DIAG_PERM
class DebugToggleExecutor : CASubCommand() {
class DebugToggleExecutor : CASubCommand {
override fun description(): String {
return "Used to toggle debug logs and retrieve it"

View file

@ -30,8 +30,7 @@ import xyz.alexcrea.cuanvil.util.MetricsUtil
import java.util.*
import java.util.stream.Collectors
class DiagnosticExecutor : CASubCommand() {
class DiagnosticExecutor : CASubCommand {
companion object {
const val NO_DIAG_PERM = "You do not have permission to diagnostic this server"
@ -327,10 +326,10 @@ class DiagnosticExecutor : CASubCommand() {
stb.append(
"\nNamespaces: ${
map.entries.stream()
.map { (key, value) -> "$key ($value)" }
.reduce { a, b -> "$a, $b" }.get()
}"
map.entries.stream()
.map { (key, value) -> "$key ($value)" }
.reduce { a, b -> "$a, $b" }.get()
}"
)
}

View file

@ -14,16 +14,12 @@ import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions
import xyz.alexcrea.cuanvil.util.MaterialUtil.customType
import xyz.alexcrea.cuanvil.util.MaterialUtil.isAir
class EditConfigExecutor : CASubCommand() {
class EditConfigExecutor : CASubCommand {
override fun allowed(sender: CommandSender): Boolean {
return sender.hasPermission(CustomAnvil.editConfigPermission)
}
override fun description(): String {
return "Gui to edit the plugin's config"
}
override fun executeCommand(
sender: CommandSender,
cmd: Command,
@ -116,6 +112,15 @@ class EditConfigExecutor : CASubCommand() {
else -> listOf()
}
)
override fun tabCompleter(
sender: CommandSender,
args: Array<out String>,
list: MutableList<String>
) {
}
override fun description(): String {
return "Gui to edit the plugin's config"
}
}

View file

@ -4,7 +4,7 @@ import com.google.common.collect.ImmutableMap
import org.bukkit.command.Command
import org.bukkit.command.CommandSender
class HelpExecutor : CASubCommand() {
class HelpExecutor : CASubCommand {
lateinit var commands: ImmutableMap<String, CASubCommand>
@ -27,6 +27,17 @@ class HelpExecutor : CASubCommand() {
return true
}
override fun allowed(sender: CommandSender): Boolean {
return true
}
override fun tabCompleter(
sender: CommandSender,
args: Array<out String>,
list: MutableList<String>
) {
}
override fun description(): String {
return "Help command"
}

View file

@ -10,7 +10,7 @@ import xyz.alexcrea.cuanvil.dependency.DependencyManager
import xyz.alexcrea.cuanvil.gui.config.global.*
import xyz.alexcrea.cuanvil.update.UpdateHandler
class ReloadExecutor : CASubCommand() {
class ReloadExecutor : CASubCommand {
override fun executeCommand(
sender: CommandSender,
@ -40,6 +40,13 @@ class ReloadExecutor : CASubCommand() {
return sender.hasPermission(CustomAnvil.commandReloadPermission)
}
override fun tabCompleter(
sender: CommandSender,
args: Array<out String>,
list: MutableList<String>
) {
}
override fun description(): String {
return "Reload the configuration of this plugin"
}

View file

@ -14,18 +14,6 @@ commands:
description: Generic command for custom anvil
aliases:
- ca
anvilconfigreload:
description: Reload every config of this plugin
permission: ca.command.reload
aliases:
#- acreload # anvil config reload
#- careload # custom anvil reload
- carl # custom anvil reload
customanvilconfig:
description: open a menu for administrator to edit plugin's config in game
permission: ca.config.edit
aliases:
- configanvil
permissions:
ca.affected: