mirror of
https://github.com/Auxilor/EcoQuests.git
synced 2025-12-21 16:09:16 +00:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
202528681a | ||
|
|
7aa02b3a91 | ||
|
|
070d25de67 | ||
|
|
3ab99c9237 | ||
|
|
3ee10633fb | ||
|
|
49c77396ea | ||
|
|
09fb8d2109 | ||
|
|
9623f1c427 | ||
|
|
39eaef3856 | ||
|
|
bf085b4ea5 | ||
|
|
1a1433f84f | ||
|
|
571b4c05e2 | ||
|
|
58aa2fd81d | ||
|
|
335524a2da | ||
|
|
73d748d445 | ||
|
|
e0e0804cce | ||
|
|
c00d5eb7d2 | ||
|
|
f7fab37555 | ||
|
|
a93aac6b6f | ||
|
|
025a74048a | ||
|
|
9db9f542c9 | ||
|
|
75a091624c | ||
|
|
17c81ea5b8 | ||
|
|
81d4faaf0c | ||
|
|
03110e36b1 | ||
|
|
4b687e2c00 | ||
|
|
c01c86a592 | ||
|
|
438b118846 | ||
|
|
9c6cd8f467 | ||
|
|
1db9b48579 | ||
|
|
6b7380decd |
@@ -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(
|
||||||
|
|||||||
@@ -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(
|
||||||
|
|||||||
@@ -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))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import com.willfp.libreforge.loader.configs.ConfigCategory
|
|||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
|
|
||||||
object Quests : ConfigCategory("quest", "quests") {
|
object Quests : ConfigCategory("quest", "quests") {
|
||||||
|
override val supportsSharing = false
|
||||||
|
|
||||||
private val registry = Registry<Quest>()
|
private val registry = Registry<Quest>()
|
||||||
|
|
||||||
override fun clear(plugin: LibreforgePlugin) {
|
override fun clear(plugin: LibreforgePlugin) {
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ environment:
|
|||||||
|
|
||||||
options:
|
options:
|
||||||
color: "&#eacda3"
|
color: "&#eacda3"
|
||||||
resource-id: 0
|
resource-id: 4600
|
||||||
bstats-id: 0
|
bstats-id: 19455
|
||||||
uses-reflective-reload: false
|
uses-reflective-reload: false
|
||||||
@@ -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 09 14:37:41 BST 2023
|
#Fri Nov 10 13:59:29 GMT 2023
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
libreforge-version=4.28.0
|
libreforge-version=4.41.0
|
||||||
version=1.0.0
|
version=1.13.0
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user