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

Compare commits

..

9 Commits
1.2.2 ... 1.5.2

Author SHA1 Message Date
Auxilor
e0e0804cce libreforge-updater 2023-09-07 16:01:57 +01:00
Auxilor
c00d5eb7d2 libreforge-updater 2023-09-02 17:34:44 +01:00
Will FP
f7fab37555 Fixed page changers 2023-09-01 12:32:17 +01:00
Auxilor
a93aac6b6f libreforge-updater 2023-08-31 16:59:46 +01:00
Auxilor
025a74048a Added on-complete 2023-08-31 16:57:13 +01:00
Auxilor
9db9f542c9 libreforge-updater 2023-08-30 11:31:41 +01:00
Auxilor
75a091624c Dynamic experience requirements now lock in when a task starts 2023-08-30 11:09:09 +01:00
Auxilor
17c81ea5b8 Added use-local-storage 2023-08-30 09:50:00 +01:00
Auxilor
81d4faaf0c libreforge-updater 2023-08-26 18:11:44 +01:00
7 changed files with 53 additions and 5 deletions

View File

@@ -12,7 +12,7 @@ class PositionedPageChanger(
direction: PageChanger.Direction
): PositionedComponent {
private val pageChanger = PageChanger(
Items.lookup("item").item,
Items.lookup(config.getString("item")).item,
direction
)

View File

@@ -286,6 +286,11 @@ class Quest(
player.profile.write(hasStartedKey, true)
player.profile.write(startedTimeKey, currentTimeMinutes)
// Reset tasks to generate new xp requirements
for (task in tasks) {
task.reset(player)
}
Bukkit.getPluginManager().callEvent(PlayerQuestStartEvent(player, this))
}

View File

@@ -32,6 +32,12 @@ class Task(
0.0
)
private val xpRequiredKey = PersistentDataKey(
plugin.createNamespacedKey("${quest.id}_task_${template.id}_xp_required"),
PersistentDataKeyType.DOUBLE,
0.0
)
private val hasCompletedKey = PersistentDataKey(
plugin.createNamespacedKey("${quest.id}_task_${template.id}_has_completed"),
PersistentDataKeyType.BOOLEAN,
@@ -89,7 +95,7 @@ class Task(
return player.profile.read(hasCompletedKey)
}
fun getExperienceRequired(player: Player): Double {
private fun generateExperienceRequired(player: Player): Double {
return evaluateExpression(
xpExpr,
placeholderContext(
@@ -98,6 +104,24 @@ class Task(
)
}
fun getExperienceRequired(player: Player): Double {
val required = player.profile.read(xpRequiredKey)
return if (required <= 0) {
val newRequired = generateExperienceRequired(player)
if (newRequired <= 0) {
throw IllegalStateException("Invalid XP Required for task ${template.id} in quest ${quest.id}" +
"(Requirement was $newRequired, which is less than or equal to 0)")
}
player.profile.write(xpRequiredKey, newRequired)
newRequired
} else {
required
}
}
fun getExperience(player: OfflinePlayer): Double {
return player.profile.read(xpKey)
}
@@ -128,6 +152,7 @@ class Task(
if (newXp >= requiredXp) {
player.profile.write(hasCompletedKey, true)
template.onComplete?.trigger(player)
Bukkit.getPluginManager().callEvent(PlayerTaskCompleteEvent(player, template, quest))

View File

@@ -6,6 +6,7 @@ import com.willfp.eco.core.registry.KRegistrable
import com.willfp.ecoquests.quests.Quest
import com.willfp.libreforge.ViolationContext
import com.willfp.libreforge.counters.Counters
import com.willfp.libreforge.effects.Effects
class TaskTemplate(
private val plugin: EcoPlugin,
@@ -16,6 +17,11 @@ class TaskTemplate(
Counters.compile(it, ViolationContext(plugin, "task $id tasks"))
}
val onComplete = Effects.compileChain(
config.getSubsections("on-complete"),
ViolationContext(plugin, "task $id on-complete")
)
fun create(quest: Quest, xpExpr: String) =
Task(plugin, this, quest, xpExpr)
}

View File

@@ -3,6 +3,11 @@
# by Auxilor
#
# Even if eco is set up to use a database, you can
# force EcoQuests to save to local storage to disable
# cross-server sync.
use-local-storage: false
scan-interval: 20 # How often to scan for quests auto-starting (in ticks)
gui:

View File

@@ -21,3 +21,10 @@ xp-gain-methods:
filters:
blocks:
- stone
# An optional list of effects to run when a player completes the task
# Read here: https://plugins.auxilor.io/effects/configuring-an-effect
on-complete:
- id: send_message
args:
message: "Task Completed!"

View File

@@ -1,5 +1,5 @@
#libreforge-updater
#Wed Aug 23 15:31:59 BST 2023
#Thu Sep 07 16:01:57 BST 2023
kotlin.code.style=official
libreforge-version=4.29.2
version=1.2.2
libreforge-version=4.33.3
version=1.5.2