Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
0ffz committed Jun 5, 2024
2 parents 08d25a0 + ac3640f commit e6b9206
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.mineinabyss.idofront.events
import org.bukkit.Bukkit
import org.bukkit.event.Cancellable
import org.bukkit.event.Event
import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.ItemMeta
import org.bukkit.plugin.PluginManager

/**
Expand All @@ -23,3 +25,17 @@ inline fun Event.call(onSuccess: Event.() -> Unit) {
if (this !is Cancellable || !isCancelled)
onSuccess()
}

/**
* Calls this event and runs [onSuccess] if the event is an instance of [T] and isn't [cancelled][Cancellable.isCancelled] after the call
* is finished.
*
* @see [PluginManager.callEvent]
*/
@JvmName("callCast")
inline fun <reified T : Event> Event.call(onSuccess: T.() -> Unit) {
if (this !is T) return
Bukkit.getServer().pluginManager.callEvent(this)
if (this !is Cancellable || !isCancelled)
onSuccess()
}

0 comments on commit e6b9206

Please sign in to comment.