add config menu/command name & permission. also edit version number.

This commit is contained in:
alexcrea 2024-03-01 15:31:28 +01:00 committed by alexcrea
parent 321a2b1cc8
commit 6e0d1037bc
6 changed files with 54 additions and 14 deletions

View file

@ -5,7 +5,7 @@ import org.bukkit.Bukkit
import org.bukkit.configuration.file.YamlConfiguration
import org.bukkit.plugin.java.JavaPlugin
import xyz.alexcrea.cuanvil.command.ReloadExecutor
import xyz.alexcrea.cuanvil.command.TestExecutor
import xyz.alexcrea.cuanvil.command.EditConfigExecutor
import xyz.alexcrea.cuanvil.config.ConfigHolder
import xyz.alexcrea.cuanvil.util.Metrics
import xyz.alexcrea.cuanvil.util.MetricsUtil
@ -30,11 +30,13 @@ class CustomAnvil : JavaPlugin() {
const val bypassLevelPermission = "ca.bypass.level"
// Permission string required to reload the config
const val commandReloadPermission = "ca.command.reload"
// Permission string required to edit the plugin's config
const val editConfigPermission = "ca.config.edit"
// Command Name to reload the config
const val commandReloadName = "anvilconfigreload"
// Test command name
const val commandTestName = "test"
const val commandTestName = "customanvilconfig"
// Current plugin instance
lateinit var instance: CustomAnvil
@ -113,7 +115,7 @@ class CustomAnvil : JavaPlugin() {
command?.setExecutor(ReloadExecutor())
command = getCommand(commandTestName)
command?.setExecutor(TestExecutor())
command?.setExecutor(EditConfigExecutor())
}
}

View file

@ -1,15 +1,20 @@
package xyz.alexcrea.cuanvil.command
import io.delilaheve.CustomAnvil
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
import org.bukkit.entity.HumanEntity
import xyz.alexcrea.cuanvil.gui.MainConfigGui
import xyz.alexcrea.cuanvil.gui.utils.GuiGlobalActions
class TestExecutor : CommandExecutor {
class EditConfigExecutor : CommandExecutor {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
if(!sender.hasPermission(CustomAnvil.editConfigPermission)) {
sender.sendMessage(GuiGlobalActions.NO_EDIT_PERM)
return false
}
if(sender !is HumanEntity) return false
MainConfigGui.INSTANCE.show(sender)