Skip to content

Commit

Permalink
spawnEntity Location.kt extension function
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen committed Nov 4, 2023
1 parent db63e6a commit dbafb1b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "gg.flyte"
version = "1.0.20"
version = "1.0.21"

repositories {
mavenCentral()
Expand Down
12 changes: 12 additions & 0 deletions src/main/kotlin/gg/flyte/twilight/extension/Location.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package gg.flyte.twilight.extension

import org.bukkit.Location
import org.bukkit.entity.Entity
import org.bukkit.entity.EntityType
import org.bukkit.inventory.ItemStack

/**
Expand All @@ -21,3 +23,13 @@ fun Location.dropItem(itemStack: ItemStack) {
fun Location.dropItemNaturally(itemStack: ItemStack) {
world!!.dropItemNaturally(this, itemStack)
}

/**
* Extension function for the Location class to spawn an entity of the specified type at the location.
*
* @param type The type of entity to spawn at this location.
* @return The entity that was spawned.
*/
fun Location.spawnEntity(type: EntityType): Entity {
return world!!.spawnEntity(this, type)
}

0 comments on commit dbafb1b

Please sign in to comment.