mirror of
https://github.com/Auxilor/EcoQuests.git
synced 2025-12-20 15:39:21 +00:00
Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b61afeea44 | ||
|
|
3a1ab8a62c | ||
|
|
31f608eea5 | ||
|
|
cdf83a9ba7 | ||
|
|
86550af579 | ||
|
|
0ea4e3cd20 | ||
|
|
779f942454 | ||
|
|
abad5bdfbd | ||
|
|
588839fc97 | ||
|
|
1c36c4b18f | ||
|
|
0460f1f6bf | ||
|
|
a5dd2566f5 | ||
|
|
66524ade50 | ||
|
|
5814587ed5 | ||
|
|
f4682214cc | ||
|
|
3c0d5651d8 | ||
|
|
c86651df9b | ||
|
|
26ccae38b1 | ||
|
|
c1c985d638 | ||
|
|
ed947b354f | ||
|
|
5e51c369bb | ||
|
|
67a2e2fb4f | ||
|
|
f94e79bc92 | ||
|
|
9cf8d465b9 |
@@ -1,9 +1,11 @@
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
|
||||
plugins {
|
||||
java
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
kotlin("jvm") version "1.9.20"
|
||||
id("io.github.goooler.shadow") version "8.1.7"
|
||||
kotlin("jvm") version "2.1.0"
|
||||
id("com.gradleup.shadow") version "8.3.0"
|
||||
id("com.willfp.libreforge-gradle-plugin") version "1.0.0"
|
||||
}
|
||||
|
||||
@@ -25,7 +27,7 @@ allprojects {
|
||||
apply(plugin = "java")
|
||||
apply(plugin = "kotlin")
|
||||
apply(plugin = "maven-publish")
|
||||
apply(plugin = "io.github.goooler.shadow")
|
||||
apply(plugin = "com.gradleup.shadow")
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
@@ -39,12 +41,12 @@ allprojects {
|
||||
dependencies {
|
||||
compileOnly("com.willfp:eco:6.65.0")
|
||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||
compileOnly("org.jetbrains.kotlin:kotlin-stdlib:1.9.20")
|
||||
compileOnly("org.jetbrains.kotlin:kotlin-stdlib:2.1.0")
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
|
||||
tasks {
|
||||
@@ -54,8 +56,8 @@ allprojects {
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions {
|
||||
jvmTarget = "17"
|
||||
compilerOptions {
|
||||
jvmTarget.set(JvmTarget.JVM_21)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@ class CommandEcoQuests(plugin: EcoPlugin) : PluginCommand(
|
||||
.addSubcommand(CommandStart(plugin))
|
||||
.addSubcommand(CommandResetPlayer(plugin))
|
||||
.addSubcommand(CommandReset(plugin))
|
||||
.addSubcommand(CommandAddExp(plugin))
|
||||
}
|
||||
|
||||
override fun onExecute(sender: CommandSender, args: List<String>) {
|
||||
|
||||
@@ -101,10 +101,20 @@ class Quest(
|
||||
|
||||
// The tasks that are actually in use
|
||||
var tasks = run {
|
||||
if (isResettable) {
|
||||
loadTasks() ?: availableTasks.randomlyPick(taskAmount)
|
||||
if (taskAmount == availableTasks.size) {
|
||||
// If taskAmount is equal to availableTasks.size then tasks are ordered as configured
|
||||
if (isResettable) {
|
||||
availableTasks.take(taskAmount)
|
||||
} else {
|
||||
availableTasks.shuffled().take(taskAmount)
|
||||
}
|
||||
} else {
|
||||
availableTasks.randomlyPick(taskAmount)
|
||||
// If taskAmount is less than availableTasks.size then tasks are selected and ordered randomly.
|
||||
if (isResettable) {
|
||||
loadTasks() ?: availableTasks.randomlyPick(taskAmount)
|
||||
} else {
|
||||
availableTasks.randomlyPick(taskAmount)
|
||||
}
|
||||
}
|
||||
}
|
||||
private set
|
||||
@@ -268,7 +278,8 @@ class Quest(
|
||||
}
|
||||
|
||||
fun getDescription(player: Player): List<String> {
|
||||
return addPlaceholdersInto(listOf(config.getString("description")), player)
|
||||
val descriptions = config.getStrings("description")
|
||||
return addPlaceholdersInto(descriptions, player)
|
||||
}
|
||||
|
||||
fun hasActive(player: OfflinePlayer): Boolean {
|
||||
|
||||
@@ -146,6 +146,11 @@ class Task(
|
||||
* Give experience directly
|
||||
*/
|
||||
fun giveExperience(player: Player, amount: Double) {
|
||||
|
||||
if (player.profile.read(hasCompletedKey)) {
|
||||
return
|
||||
}
|
||||
|
||||
val requiredXp = getExperienceRequired(player)
|
||||
val newXp = player.profile.read(xpKey) + amount
|
||||
|
||||
|
||||
@@ -7,12 +7,15 @@ messages:
|
||||
|
||||
invalid-player: "&cInvalid player!"
|
||||
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!"
|
||||
|
||||
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: "&fReset the &a%quest% &fquest!"
|
||||
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:
|
||||
never: "&cNot started yet!"
|
||||
|
||||
@@ -35,6 +35,7 @@ permissions:
|
||||
ecoquests.command.start: true
|
||||
ecoquests.command.reset: true
|
||||
ecoquests.command.resetplayer: true
|
||||
ecoquests.command.addexp: true
|
||||
|
||||
ecoquests.command.reload:
|
||||
description: Allows reloading the config
|
||||
@@ -53,4 +54,7 @@ permissions:
|
||||
default: op
|
||||
ecoquests.command.resetplayer:
|
||||
description: Allows using /ecoquests resetplayer.
|
||||
default: op
|
||||
ecoquests.command.addexp:
|
||||
description: Allows using /ecoquests addexp.
|
||||
default: op
|
||||
@@ -1,5 +1,5 @@
|
||||
#libreforge-updater
|
||||
#Wed Aug 21 18:58:25 BST 2024
|
||||
#Mon Oct 06 08:57:19 BST 2025
|
||||
kotlin.code.style=official
|
||||
libreforge-version=4.71.2
|
||||
version=1.42.2
|
||||
libreforge-version=4.79.0
|
||||
version=1.50.0
|
||||
|
||||
Reference in New Issue
Block a user