mirror of
https://github.com/Auxilor/EcoQuests.git
synced 2025-12-21 16:09:16 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73d748d445 | ||
|
|
e0e0804cce | ||
|
|
c00d5eb7d2 | ||
|
|
f7fab37555 | ||
|
|
a93aac6b6f | ||
|
|
025a74048a | ||
|
|
9db9f542c9 | ||
|
|
75a091624c | ||
|
|
17c81ea5b8 | ||
|
|
81d4faaf0c |
@@ -12,7 +12,7 @@ class PositionedPageChanger(
|
|||||||
direction: PageChanger.Direction
|
direction: PageChanger.Direction
|
||||||
): PositionedComponent {
|
): PositionedComponent {
|
||||||
private val pageChanger = PageChanger(
|
private val pageChanger = PageChanger(
|
||||||
Items.lookup("item").item,
|
Items.lookup(config.getString("item")).item,
|
||||||
direction
|
direction
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -286,6 +286,11 @@ class Quest(
|
|||||||
player.profile.write(hasStartedKey, true)
|
player.profile.write(hasStartedKey, true)
|
||||||
player.profile.write(startedTimeKey, currentTimeMinutes)
|
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))
|
Bukkit.getPluginManager().callEvent(PlayerQuestStartEvent(player, this))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,12 @@ class Task(
|
|||||||
0.0
|
0.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val xpRequiredKey = PersistentDataKey(
|
||||||
|
plugin.createNamespacedKey("${quest.id}_task_${template.id}_xp_required"),
|
||||||
|
PersistentDataKeyType.DOUBLE,
|
||||||
|
0.0
|
||||||
|
)
|
||||||
|
|
||||||
private val hasCompletedKey = PersistentDataKey(
|
private val hasCompletedKey = PersistentDataKey(
|
||||||
plugin.createNamespacedKey("${quest.id}_task_${template.id}_has_completed"),
|
plugin.createNamespacedKey("${quest.id}_task_${template.id}_has_completed"),
|
||||||
PersistentDataKeyType.BOOLEAN,
|
PersistentDataKeyType.BOOLEAN,
|
||||||
@@ -89,7 +95,7 @@ class Task(
|
|||||||
return player.profile.read(hasCompletedKey)
|
return player.profile.read(hasCompletedKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getExperienceRequired(player: Player): Double {
|
private fun generateExperienceRequired(player: Player): Double {
|
||||||
return evaluateExpression(
|
return evaluateExpression(
|
||||||
xpExpr,
|
xpExpr,
|
||||||
placeholderContext(
|
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 {
|
fun getExperience(player: OfflinePlayer): Double {
|
||||||
return player.profile.read(xpKey)
|
return player.profile.read(xpKey)
|
||||||
}
|
}
|
||||||
@@ -128,6 +152,7 @@ class Task(
|
|||||||
|
|
||||||
if (newXp >= requiredXp) {
|
if (newXp >= requiredXp) {
|
||||||
player.profile.write(hasCompletedKey, true)
|
player.profile.write(hasCompletedKey, true)
|
||||||
|
template.onComplete?.trigger(player)
|
||||||
|
|
||||||
Bukkit.getPluginManager().callEvent(PlayerTaskCompleteEvent(player, template, quest))
|
Bukkit.getPluginManager().callEvent(PlayerTaskCompleteEvent(player, template, quest))
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.willfp.eco.core.registry.KRegistrable
|
|||||||
import com.willfp.ecoquests.quests.Quest
|
import com.willfp.ecoquests.quests.Quest
|
||||||
import com.willfp.libreforge.ViolationContext
|
import com.willfp.libreforge.ViolationContext
|
||||||
import com.willfp.libreforge.counters.Counters
|
import com.willfp.libreforge.counters.Counters
|
||||||
|
import com.willfp.libreforge.effects.Effects
|
||||||
|
|
||||||
class TaskTemplate(
|
class TaskTemplate(
|
||||||
private val plugin: EcoPlugin,
|
private val plugin: EcoPlugin,
|
||||||
@@ -16,6 +17,11 @@ class TaskTemplate(
|
|||||||
Counters.compile(it, ViolationContext(plugin, "task $id tasks"))
|
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) =
|
fun create(quest: Quest, xpExpr: String) =
|
||||||
Task(plugin, this, quest, xpExpr)
|
Task(plugin, this, quest, xpExpr)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,11 @@
|
|||||||
# by Auxilor
|
# 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)
|
scan-interval: 20 # How often to scan for quests auto-starting (in ticks)
|
||||||
|
|
||||||
gui:
|
gui:
|
||||||
|
|||||||
@@ -21,3 +21,10 @@ xp-gain-methods:
|
|||||||
filters:
|
filters:
|
||||||
blocks:
|
blocks:
|
||||||
- stone
|
- 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!"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#libreforge-updater
|
#libreforge-updater
|
||||||
#Wed Aug 23 15:31:59 BST 2023
|
#Wed Sep 13 15:08:56 BST 2023
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
libreforge-version=4.29.2
|
libreforge-version=4.33.4
|
||||||
version=1.2.2
|
version=1.5.3
|
||||||
|
|||||||
Reference in New Issue
Block a user