9
0
mirror of https://github.com/Auxilor/EcoQuests.git synced 2025-12-22 16:39:21 +00:00

Compare commits

..

6 Commits

Author SHA1 Message Date
Will FP
b61afeea44 libreforge-updater 2025-10-06 08:57:19 +01:00
Will FP
3a1ab8a62c libreforge-updater 2025-09-11 09:59:12 +01:00
Will FP
31f608eea5 libreforge-updater 2025-08-01 10:04:43 +01:00
Will FP
cdf83a9ba7 Merge pull request #5 from kiriharu/master
FEAT: Add addexp subcommand
2025-08-01 09:42:22 +01:00
kiriharu
a5dd2566f5 FIX: Forget to add description 2024-12-12 16:51:09 +03:00
kiriharu
66524ade50 FEAT: Add addexp subcommand 2024-12-12 16:39:21 +03:00
6 changed files with 96 additions and 5 deletions

View File

@@ -46,7 +46,7 @@ allprojects {
java { java {
withSourcesJar() withSourcesJar()
toolchain.languageVersion.set(JavaLanguageVersion.of(17)) toolchain.languageVersion.set(JavaLanguageVersion.of(21))
} }
tasks { tasks {
@@ -57,7 +57,7 @@ allprojects {
compileKotlin { compileKotlin {
compilerOptions { compilerOptions {
jvmTarget.set(JvmTarget.JVM_17) jvmTarget.set(JvmTarget.JVM_21)
} }
} }

View File

@@ -0,0 +1,83 @@
package com.willfp.ecoquests.commands
import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.command.impl.PluginCommand
import com.willfp.eco.core.commands.notifyNull
import com.willfp.eco.util.StringUtils
import com.willfp.ecoquests.quests.Quests
import com.willfp.ecoquests.tasks.Tasks
import org.bukkit.command.CommandSender
import org.bukkit.util.StringUtil
class CommandAddExp(plugin: EcoPlugin) : PluginCommand(
plugin,
"addexp",
"ecoquests.command.addexp",
false
) {
override fun onExecute(sender: CommandSender, args: List<String>) {
val player = notifyPlayerRequired(args.getOrNull(0), "invalid-player")
val quest = notifyNull(Quests[args.getOrNull(1)], "invalid-quest")
val taskTemplate = notifyNull(Tasks[args.getOrNull(2)], "invalid-task")
val task = notifyNull(quest.getTask(taskTemplate), "invalid-task")
if (args.size < 4) {
sender.sendMessage(plugin.langYml.getMessage("invalid-exp-value"))
return
}
val unparsedValue = args[3].notifyNull("invalid-exp-value")
val value: Double
try {
value = unparsedValue.toDouble()
} catch (_: NumberFormatException) {
sender.sendMessage(plugin.langYml.getMessage("invalid-exp-value"))
return
}
task.gainExperience(player, value)
sender.sendMessage(
plugin.langYml.getMessage("exp-added", StringUtils.FormatOption.WITHOUT_PLACEHOLDERS)
.replace("%xp%", value.toString())
.replace("%quest%", quest.name)
.replace("%task%", task.template.id)
.replace("%player%", player.name)
)
}
override fun tabComplete(sender: CommandSender, args: List<String>): List<String> {
val completions = mutableListOf<String>()
if (args.size == 1) {
StringUtil.copyPartialMatches(
args[0],
plugin.server.onlinePlayers.map { it.name },
completions
)
}
if (args.size == 2) {
StringUtil.copyPartialMatches(
args[1],
Quests.values().map { it.id },
completions
)
}
if (args.size == 3) {
val quest = Quests[args[1]]
if (quest != null) {
StringUtil.copyPartialMatches(
args[2],
quest.tasks.map { it.template.id } ,
completions
)
}
}
return completions
}
}

View File

@@ -15,6 +15,7 @@ class CommandEcoQuests(plugin: EcoPlugin) : PluginCommand(
.addSubcommand(CommandStart(plugin)) .addSubcommand(CommandStart(plugin))
.addSubcommand(CommandResetPlayer(plugin)) .addSubcommand(CommandResetPlayer(plugin))
.addSubcommand(CommandReset(plugin)) .addSubcommand(CommandReset(plugin))
.addSubcommand(CommandAddExp(plugin))
} }
override fun onExecute(sender: CommandSender, args: List<String>) { override fun onExecute(sender: CommandSender, args: List<String>) {

View File

@@ -7,12 +7,15 @@ messages:
invalid-player: "&cInvalid player!" invalid-player: "&cInvalid player!"
invalid-quest: "&cInvalid quest!" invalid-quest: "&cInvalid quest!"
invalid-task: "&cInvalid task! Should be exist in quest."
invalid-exp-value: "&cInvalid exp value! Should be a double (like 1.0)."
already-started: "&cThe player has already started this quest!" already-started: "&cThe player has already started this quest!"
started-quest: "&fStarted the &a%quest% &fquest for &a%player%&f!" started-quest: "&fStarted the &a%quest% &fquest for &a%player%&f!"
reset-quest-for-player: "&fReset the &a%quest% &fquest for &a%player%&f!" reset-quest-for-player: "&fReset the &a%quest% &fquest for &a%player%&f!"
reset-quest: "&fReset the &a%quest% &fquest!" reset-quest: "&fReset the &a%quest% &fquest!"
quest-not-resettable: "&cThis quest is not resettable!" quest-not-resettable: "&cThis quest is not resettable!"
exp-added: "&aAdded &f%xp% &aXP in quest &f%quest%&a, task &f%task%&a for &f%player%&a!"
time-since: time-since:
never: "&cNot started yet!" never: "&cNot started yet!"

View File

@@ -35,6 +35,7 @@ permissions:
ecoquests.command.start: true ecoquests.command.start: true
ecoquests.command.reset: true ecoquests.command.reset: true
ecoquests.command.resetplayer: true ecoquests.command.resetplayer: true
ecoquests.command.addexp: true
ecoquests.command.reload: ecoquests.command.reload:
description: Allows reloading the config description: Allows reloading the config
@@ -54,3 +55,6 @@ permissions:
ecoquests.command.resetplayer: ecoquests.command.resetplayer:
description: Allows using /ecoquests resetplayer. description: Allows using /ecoquests resetplayer.
default: op default: op
ecoquests.command.addexp:
description: Allows using /ecoquests addexp.
default: op

View File

@@ -1,5 +1,5 @@
#libreforge-updater #libreforge-updater
#Sat Jul 05 16:45:41 BST 2025 #Mon Oct 06 08:57:19 BST 2025
kotlin.code.style=official kotlin.code.style=official
libreforge-version=4.76.1 libreforge-version=4.79.0
version=1.47.1 version=1.50.0