Skip to content

Commit

Permalink
Added set_global_points and set_item_points
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed May 23, 2023
1 parent a8bd907 commit 810c4ea
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/src/main/kotlin/com/willfp/libreforge/effects/Effects.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -451,5 +453,7 @@ object Effects : Registry<Effect<*>>() {
register(EffectGiveItemPoints)
register(EffectLevelItem)
register(EffectMultiplyItemPoints)
register(EffectSetGlobalPoints)
register(EffectSetItemPoints)
}
}
Original file line number Diff line number Diff line change
@@ -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<NoCompileData>("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
}
}
Original file line number Diff line number Diff line change
@@ -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<NoCompileData>("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
}
}

0 comments on commit 810c4ea

Please sign in to comment.