From 051eb37dd6b4138fc4ff262ba477d1576d271a56 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 8 Aug 2023 19:34:45 +0100 Subject: [PATCH] Added commands --- .../com/willfp/ecoquests/EcoQuestsPlugin.kt | 10 ++++++ .../ecoquests/commands/CommandEcoQuests.kt | 22 ++++++++++++ .../ecoquests/commands/CommandQuests.kt | 26 ++++++++++++++ .../ecoquests/commands/CommandReload.kt | 17 +++++++++ .../core-plugin/src/main/resources/plugin.yml | 35 +++++++++++++++++++ .../src/main/resources/tasks/_example.yml | 2 +- .../main/resources/tasks/break_100_stone.yml | 2 +- 7 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/commands/CommandEcoQuests.kt create mode 100644 eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/commands/CommandQuests.kt create mode 100644 eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/commands/CommandReload.kt diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/EcoQuestsPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/EcoQuestsPlugin.kt index 54ef6a2..8a2dedb 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/EcoQuestsPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/EcoQuestsPlugin.kt @@ -1,5 +1,8 @@ package com.willfp.ecoquests +import com.willfp.eco.core.command.impl.PluginCommand +import com.willfp.ecoquests.commands.CommandEcoQuests +import com.willfp.ecoquests.commands.CommandQuests import com.willfp.ecoquests.quests.Quests import com.willfp.ecoquests.tasks.Tasks import com.willfp.libreforge.loader.LibreforgePlugin @@ -21,6 +24,13 @@ class EcoQuestsPlugin : LibreforgePlugin() { } } + override fun loadPluginCommands(): List { + return listOf( + CommandEcoQuests(this), + CommandQuests(this) + ) + } + override fun loadConfigCategories(): List { return listOf( Tasks, diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/commands/CommandEcoQuests.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/commands/CommandEcoQuests.kt new file mode 100644 index 0000000..33d3c0a --- /dev/null +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/commands/CommandEcoQuests.kt @@ -0,0 +1,22 @@ +package com.willfp.ecoquests.commands + +import com.willfp.eco.core.EcoPlugin +import com.willfp.eco.core.command.impl.PluginCommand +import org.bukkit.command.CommandSender + +class CommandEcoQuests(plugin: EcoPlugin) : PluginCommand( + plugin, + "ecoquests", + "ecoquests.command.ecoquests", + false +) { + init { + this.addSubcommand(CommandReload(plugin)) + } + + override fun onExecute(sender: CommandSender, args: List) { + sender.sendMessage( + plugin.langYml.getMessage("invalid-command") + ) + } +} diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/commands/CommandQuests.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/commands/CommandQuests.kt new file mode 100644 index 0000000..9d2ff94 --- /dev/null +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/commands/CommandQuests.kt @@ -0,0 +1,26 @@ +package com.willfp.ecoquests.commands + +import com.willfp.eco.core.EcoPlugin +import com.willfp.eco.core.command.impl.PluginCommand +import com.willfp.ecoquests.gui.QuestsGUI +import com.willfp.libreforge.commands.CommandReload +import org.bukkit.command.CommandSender +import org.bukkit.entity.Player + +class CommandQuests(plugin: EcoPlugin) : PluginCommand( + plugin, + "quests", + "ecoquests.command.quests", + true +) { + override fun getAliases(): List { + return listOf( + "q", + "quest" + ) + } + + override fun onExecute(sender: Player, args: List) { + QuestsGUI.open(sender) + } +} diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/commands/CommandReload.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/commands/CommandReload.kt new file mode 100644 index 0000000..a220df8 --- /dev/null +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/commands/CommandReload.kt @@ -0,0 +1,17 @@ +package com.willfp.ecoquests.commands + +import com.willfp.eco.core.EcoPlugin +import com.willfp.eco.core.command.impl.Subcommand +import org.bukkit.command.CommandSender + +class CommandReload(plugin: EcoPlugin) : Subcommand( + plugin, + "reload", + "ecoquests.command.reload", + false +) { + override fun onExecute(sender: CommandSender, args: List) { + plugin.reload() + sender.sendMessage(plugin.langYml.getMessage("reloaded")) + } +} \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/plugin.yml b/eco-core/core-plugin/src/main/resources/plugin.yml index f5db055..7b7fbf4 100644 --- a/eco-core/core-plugin/src/main/resources/plugin.yml +++ b/eco-core/core-plugin/src/main/resources/plugin.yml @@ -7,3 +7,38 @@ website: willfp.com load: STARTUP depend: - eco + + +commands: + ecoquests: + description: Base Command + permission: ecoquests.command.ecoquests + quests: + aliases: + - q + - quest + description: Open the quests menu + permission: ecoquests.command.quests + +permissions: + ecoquests.*: + description: All ecoquests permissions + default: op + children: + ecoquests.command.*: true + ecoquests.command.*: + description: All commands + default: op + children: + ecoquests.command.reload: true + ecoquests.command.quests: true + + ecoquests.command.reload: + description: Allows reloading the config + default: op + ecoquests.command.ecoquests: + description: Allows the use of /ecoquests. + default: true + ecoquests.command.quests: + description: Allows the use of /quests. + default: true \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/tasks/_example.yml b/eco-core/core-plugin/src/main/resources/tasks/_example.yml index 322b3e7..54886be 100644 --- a/eco-core/core-plugin/src/main/resources/tasks/_example.yml +++ b/eco-core/core-plugin/src/main/resources/tasks/_example.yml @@ -11,7 +11,7 @@ required-xp: 100 # The multiplier takes the value produced by the trigger and multiplies it # by some value to calculate the experience that should be given. tasks: - - trigger: break_block + - trigger: mine_block multiplier: 1 filters: blocks: diff --git a/eco-core/core-plugin/src/main/resources/tasks/break_100_stone.yml b/eco-core/core-plugin/src/main/resources/tasks/break_100_stone.yml index 322b3e7..54886be 100644 --- a/eco-core/core-plugin/src/main/resources/tasks/break_100_stone.yml +++ b/eco-core/core-plugin/src/main/resources/tasks/break_100_stone.yml @@ -11,7 +11,7 @@ required-xp: 100 # The multiplier takes the value produced by the trigger and multiplies it # by some value to calculate the experience that should be given. tasks: - - trigger: break_block + - trigger: mine_block multiplier: 1 filters: blocks: