From 810c4eab03bda66d8d9c6b6d638578d078ba789b Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 23 May 2023 15:20:52 +0100 Subject: [PATCH] Added set_global_points and set_item_points --- .../com/willfp/libreforge/effects/Effects.kt | 4 +++ .../effects/impl/EffectSetGlobalPoints.kt | 24 ++++++++++++++++ .../effects/impl/EffectSetItemPoints.kt | 28 +++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSetGlobalPoints.kt create mode 100644 core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSetItemPoints.kt diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/Effects.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/Effects.kt index a3c488303..7d6ab39c9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/Effects.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/Effects.kt @@ -113,6 +113,8 @@ import com.willfp.libreforge.effects.impl.EffectSendMessage import com.willfp.libreforge.effects.impl.EffectSendTitle import com.willfp.libreforge.effects.impl.EffectSetBlock import com.willfp.libreforge.effects.impl.EffectSetFreezeTicks +import com.willfp.libreforge.effects.impl.EffectSetGlobalPoints +import com.willfp.libreforge.effects.impl.EffectSetItemPoints import com.willfp.libreforge.effects.impl.EffectSetPoints import com.willfp.libreforge.effects.impl.EffectSetVelocity import com.willfp.libreforge.effects.impl.EffectSetVictimVelocity @@ -451,5 +453,7 @@ object Effects : Registry>() { register(EffectGiveItemPoints) register(EffectLevelItem) register(EffectMultiplyItemPoints) + register(EffectSetGlobalPoints) + register(EffectSetItemPoints) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSetGlobalPoints.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSetGlobalPoints.kt new file mode 100644 index 000000000..03f3892ae --- /dev/null +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSetGlobalPoints.kt @@ -0,0 +1,24 @@ +package com.willfp.libreforge.effects.impl + +import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.arguments +import com.willfp.libreforge.effects.Effect +import com.willfp.libreforge.getDoubleFromExpression +import com.willfp.libreforge.globalPoints +import com.willfp.libreforge.triggers.TriggerData + +object EffectSetGlobalPoints : Effect("set_global_points") { + override val isPermanent = false + + override val arguments = arguments { + require("type", "You must specify the type of points!") + require("amount", "You must specify the amount of points!") + } + + override fun onTrigger(config: Config, data: TriggerData, compileData: NoCompileData): Boolean { + globalPoints[config.getString("type")] = config.getDoubleFromExpression("amount", data) + + return true + } +} diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSetItemPoints.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSetItemPoints.kt new file mode 100644 index 000000000..f7ba3a09f --- /dev/null +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSetItemPoints.kt @@ -0,0 +1,28 @@ +package com.willfp.libreforge.effects.impl + +import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.arguments +import com.willfp.libreforge.effects.Effect +import com.willfp.libreforge.getDoubleFromExpression +import com.willfp.libreforge.points +import com.willfp.libreforge.triggers.TriggerData +import com.willfp.libreforge.triggers.TriggerParameter + +object EffectSetItemPoints : Effect("set_item_points") { + override val parameters = setOf( + TriggerParameter.ITEM + ) + + override val arguments = arguments { + require("type", "You must specify the type of points!") + require("amount", "You must specify the amount of points!") + } + + override fun onTrigger(config: Config, data: TriggerData, compileData: NoCompileData): Boolean { + val item = data.item ?: return false + item.points[config.getString("type")] = config.getDoubleFromExpression("amount", data) + + return true + } +}