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

Compare commits

...

31 Commits

Author SHA1 Message Date
Auxilor
202528681a libreforge-updater 2023-11-10 13:59:29 +00:00
Auxilor
7aa02b3a91 libreforge-updater 2023-11-05 13:42:08 +00:00
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
Auxilor
4b687e2c00 libreforge-updater 2023-08-19 15:32:52 +01:00
Auxilor
c01c86a592 libreforge-updater 2023-08-15 18:52:36 +01:00
Auxilor
438b118846 libreforge-updater 2023-08-13 14:42:52 +01:00
Auxilor
9c6cd8f467 Updated to 1.0.1 2023-08-11 15:01:54 +01:00
Auxilor
1db9b48579 Fixed quests being allowed on lrcdb (tasks only) 2023-08-11 15:01:36 +01:00
Auxilor
6b7380decd Added polymart / bstats IDs 2023-08-10 19:53:34 +01:00
13 changed files with 58 additions and 13 deletions

View File

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

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

@@ -7,6 +7,8 @@ import com.willfp.libreforge.loader.configs.ConfigCategory
import org.bukkit.entity.Player
object Quests : ConfigCategory("quest", "quests") {
override val supportsSharing = false
private val registry = Registry<Quest>()
override fun clear(plugin: LibreforgePlugin) {

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

@@ -4,6 +4,6 @@ environment:
options:
color: "&#eacda3"
resource-id: 0
bstats-id: 0
resource-id: 4600
bstats-id: 19455
uses-reflective-reload: false

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 09 14:37:41 BST 2023
#Fri Nov 10 13:59:29 GMT 2023
kotlin.code.style=official
libreforge-version=4.28.0
version=1.0.0
libreforge-version=4.41.0
version=1.13.0

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
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
zipStorePath=wrapper/dists

0
gradlew vendored Normal file → Executable file
View File