9
0
mirror of https://github.com/Auxilor/Reforges.git synced 2025-12-22 16:39:34 +00:00

Compare commits

..

5 Commits

Author SHA1 Message Date
Auxilor
89c9935801 libreforge-updater 2023-11-10 13:58:55 +00:00
Auxilor
e15d6be301 libreforge-updater 2023-11-05 13:41:30 +00:00
Auxilor
d75a301cfa libreforge-updater 2023-10-30 13:30:36 +00:00
Auxilor
319afce452 Updated to 6.38.0 2023-10-30 13:10:08 +00:00
Auxilor
8932593683 Added on-reforge-effects 2023-10-30 13:08:17 +00:00
5 changed files with 32 additions and 4 deletions

View File

@@ -28,6 +28,7 @@ class CommandApply(
if (sender is Player) { if (sender is Player) {
val item = sender.inventory.itemInMainHand val item = sender.inventory.itemInMainHand
item.reforge = reforge item.reforge = reforge
reforge.runOnReforgeEffects(sender, item)
sender.sendMessage( sender.sendMessage(
plugin.langYml.getMessage("applied-reforge") plugin.langYml.getMessage("applied-reforge")
.replace("%reforge%", reforge.name) .replace("%reforge%", reforge.name)
@@ -45,7 +46,10 @@ class CommandApply(
return return
} }
player.inventory.itemInMainHand.reforge = reforge val item = player.inventory.itemInMainHand
item.reforge = reforge
reforge.runOnReforgeEffects(player, item)
sender.sendMessage( sender.sendMessage(
plugin.langYml.getMessage("applied-reforge") plugin.langYml.getMessage("applied-reforge")
.replace("%reforge%", reforge.name) .replace("%reforge%", reforge.name)

View File

@@ -150,6 +150,8 @@ private class ActivatorSlot(
item.timesReforged++ item.timesReforged++
item.reforge = reforge item.reforge = reforge
reforge.runOnReforgeEffects(player, item)
if (usedStone) { if (usedStone) {
val stone = reforgeStone[player] val stone = reforgeStone[player]
stone?.amount = stone?.amount?.minus(1) ?: 0 stone?.amount = stone?.amount?.minus(1) ?: 0

View File

@@ -11,12 +11,15 @@ import com.willfp.eco.core.recipe.Recipes
import com.willfp.eco.core.registry.Registrable import com.willfp.eco.core.registry.Registrable
import com.willfp.eco.util.StringUtils import com.willfp.eco.util.StringUtils
import com.willfp.libreforge.Holder import com.willfp.libreforge.Holder
import com.willfp.libreforge.ItemProvidedHolder
import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.ViolationContext
import com.willfp.libreforge.conditions.Conditions import com.willfp.libreforge.conditions.Conditions
import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.Effects
import com.willfp.libreforge.triggers.TriggerData
import com.willfp.reforges.ReforgesPlugin import com.willfp.reforges.ReforgesPlugin
import com.willfp.reforges.util.reforgeStone import com.willfp.reforges.util.reforgeStone
import net.kyori.adventure.text.format.TextDecoration import net.kyori.adventure.text.format.TextDecoration
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack import org.bukkit.inventory.ItemStack
import java.util.Objects import java.util.Objects
@@ -73,6 +76,11 @@ class Reforge(
} }
} else null } else null
private val onReforgeEffects = Effects.compileChain(
config.getSubsections("on-reforge-effects"),
ViolationContext(plugin, "Reforge $id").with("on-reforge-effects")
)
init { init {
stone.reforgeStone = this stone.reforgeStone = this
@@ -98,6 +106,17 @@ class Reforge(
return targets.any { target -> target.items.any { it.matches(item) } } return targets.any { target -> target.items.any { it.matches(item) } }
} }
fun runOnReforgeEffects(player: Player, item: ItemStack) {
onReforgeEffects?.trigger(
player,
TriggerData(
holder = ItemProvidedHolder(this, item),
player = player,
item = item
)
)
}
override fun getID(): String { override fun getID(): String {
return this.id.key return this.id.key
} }

View File

@@ -54,3 +54,6 @@ effects:
# The conditions required to use the reforge # The conditions required to use the reforge
conditions: [ ] conditions: [ ]
# Effects to run when the reforge is applied to an item.
on-reforge-effects: [ ]

View File

@@ -1,5 +1,5 @@
#libreforge-updater #libreforge-updater
#Sat Oct 28 14:15:02 BST 2023 #Fri Nov 10 13:58:55 GMT 2023
kotlin.code.style=official kotlin.code.style=official
libreforge-version=4.38.1 libreforge-version=4.41.0
version=6.37.1 version=6.41.0