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

Compare commits

..

23 Commits

Author SHA1 Message Date
Auxilor
070d25de67 libreforge-updater 2023-10-30 13:31:07 +00:00
Auxilor
3ab99c9237 libreforge-updater 2023-10-28 14:15:35 +01:00
Auxilor
3ee10633fb libreforge-updater 2023-10-24 15:39:35 +01:00
Auxilor
49c77396ea libreforge-updater 2023-10-19 12:52:36 +01:00
Auxilor
09fb8d2109 libreforge-updater 2023-10-14 14:20:33 +01:00
Auxilor
9623f1c427 libreforge-updater 2023-10-14 14:19:14 +01:00
Auxilor
39eaef3856 libreforge-updater 2023-10-02 11:54:25 +01:00
Auxilor
bf085b4ea5 libreforge-updater 2023-09-26 14:46:03 +01:00
Auxilor
1a1433f84f libreforge-updater 2023-09-20 15:33:56 +01:00
Auxilor
571b4c05e2 Fixed a small amount of stupidity 2023-09-17 11:29:16 +01:00
Auxilor
58aa2fd81d graddel 2023-09-17 11:28:35 +01:00
Auxilor
335524a2da libreforge-updater 2023-09-17 11:20:21 +01:00
Auxilor
73d748d445 libreforge-updater 2023-09-13 15:08:56 +01:00
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
Auxilor
03110e36b1 libreforge-updater 2023-08-23 15:31:59 +01:00
11 changed files with 54 additions and 11 deletions

View File

@@ -3,8 +3,6 @@ package com.willfp.ecoquests.commands
import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.command.impl.PluginCommand import com.willfp.eco.core.command.impl.PluginCommand
import com.willfp.ecoquests.gui.QuestsGUI import com.willfp.ecoquests.gui.QuestsGUI
import com.willfp.libreforge.commands.CommandReload
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player import org.bukkit.entity.Player
class CommandQuests(plugin: EcoPlugin) : PluginCommand( class CommandQuests(plugin: EcoPlugin) : PluginCommand(

View File

@@ -3,11 +3,8 @@ package com.willfp.ecoquests.commands
import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.command.impl.PluginCommand import com.willfp.eco.core.command.impl.PluginCommand
import com.willfp.eco.util.StringUtils import com.willfp.eco.util.StringUtils
import com.willfp.ecoquests.gui.QuestsGUI
import com.willfp.ecoquests.quests.Quests import com.willfp.ecoquests.quests.Quests
import com.willfp.libreforge.commands.CommandReload
import org.bukkit.command.CommandSender import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
import org.bukkit.util.StringUtil import org.bukkit.util.StringUtil
class CommandStart(plugin: EcoPlugin) : PluginCommand( class CommandStart(plugin: EcoPlugin) : PluginCommand(

View File

@@ -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
) )

View File

@@ -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))
} }

View File

@@ -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))

View File

@@ -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)
} }

View File

@@ -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:

View File

@@ -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!"

View File

@@ -1,5 +1,5 @@
#libreforge-updater #libreforge-updater
#Sat Aug 19 15:32:52 BST 2023 #Mon Oct 30 13:31:07 GMT 2023
kotlin.code.style=official kotlin.code.style=official
libreforge-version=4.29.1 libreforge-version=4.39.0
version=1.2.1 version=1.11.0

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

0
gradlew vendored Normal file → Executable file
View File