-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added set_global_points and set_item_points
- Loading branch information
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSetGlobalPoints.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSetItemPoints.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |