feat: Add command argument to apply components with a specific tier level.
This commit is contained in:
parent
2f441e334d
commit
9bb631df74
|
|
@ -164,7 +164,36 @@ object CommandRegistrar {
|
|||
component.apply(item)
|
||||
sender.sendMessage("Applied component '${component.displayName}' to held item.")
|
||||
}
|
||||
}
|
||||
integer("tier", min = 1, max = 100) {
|
||||
executes {
|
||||
val sender = sender
|
||||
if (sender !is Player) {
|
||||
sender.sendMessage("Only players can use this command.")
|
||||
return@executes
|
||||
}
|
||||
|
||||
val item = sender.inventory.itemInMainHand
|
||||
if (item.type.isAir) {
|
||||
sender.sendMessage("You must be holding an item.")
|
||||
return@executes
|
||||
}
|
||||
|
||||
val componentId = argument<String>("componentId")
|
||||
val tierLevel = argument<Int>("tier")
|
||||
|
||||
val component = ComponentRegistry.getAll()
|
||||
.find { it.key.key == componentId }
|
||||
|
||||
if (component == null) {
|
||||
sender.sendMessage("Unknown component: $componentId")
|
||||
return@executes
|
||||
}
|
||||
|
||||
val tier = Tier.fromLevel(tierLevel)
|
||||
component.apply(item, tier)
|
||||
sender.sendMessage("Applied component '${component.displayName}' (Tier ${tier.level}) to held item.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user