Skip to content

Commit

Permalink
add data to armor generate event
Browse files Browse the repository at this point in the history
  • Loading branch information
CJCrafter committed Feb 3, 2024
1 parent aff0cb2 commit ed0ab98
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

group = "com.cjcrafter"
version = "3.0.1"
version = "3.0.2"

plugins {
`java-library`
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/cjcrafter/armormechanics/commands/Command.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ object Command {
default = HashMap()
}
executeAny { sender, args ->
give(sender, args[0] as List<Entity>, args[1] as String, args[2] as Map<String?, Any>)
give(sender, args[0] as List<Entity>, args[1] as String, args[2] as Map<String, Any>)
}
}

Expand All @@ -90,7 +90,7 @@ object Command {
default = HashMap()
}
executeEntity { entity, args ->
give(entity, listOf(entity as LivingEntity), args[0] as String, args[1] as Map<String?, Any>)
give(entity, listOf(entity as LivingEntity), args[0] as String, args[1] as Map<String, Any>)
}
}

Expand All @@ -117,7 +117,7 @@ object Command {
}

val targets = args[0] as List<Entity>
val data = args[2] as Map<String?, Any>
val data = args[2] as Map<String, Any>
set.helmet?.let { give(sender, targets, it, data) }
set.chestplate?.let { give(sender, targets, it, data) }
set.leggings?.let { give(sender, targets, it, data) }
Expand Down Expand Up @@ -156,7 +156,7 @@ object Command {
command.register()
}

fun give(sender: CommandSender, entities: List<Entity>, title: String, data: Map<String?, Any>) {
fun give(sender: CommandSender, entities: List<Entity>, title: String, data: Map<String, Any>) {

// Since we want to ignore spelling/capitalization errors, we should
// make sure the given 'title' matches to an actual armor-title.
Expand Down Expand Up @@ -186,7 +186,7 @@ object Command {

// Let other plugins modify generated armor
val clone = armor.clone()
val event = ArmorGenerateEvent(sender, entity, clone, title)
val event = ArmorGenerateEvent(sender, entity, clone, title, data)
Bukkit.getPluginManager().callEvent(event)

AdventureUtil.updatePlaceholders(entity as? Player, clone)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class ArmorGenerateEvent(
val sender: CommandSender,
val entity: LivingEntity,
val armor: ItemStack,
val armorTitle: String
val armorTitle: String,
val data: Map<String, Any>,
) : EntityEvent(entity) {

override fun getHandlers(): HandlerList {
Expand Down

0 comments on commit ed0ab98

Please # to comment.