Added player key tracking option

This commit is contained in:
Auxilor
2022-03-20 17:43:28 +00:00
parent 4eeaf7e755
commit 18ad48ff6c
2 changed files with 14 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ import com.willfp.ecocrates.crate.Crates
import org.bukkit.Bukkit
import org.bukkit.command.CommandSender
import org.bukkit.inventory.ItemStack
import org.bukkit.persistence.PersistentDataType
import org.bukkit.util.StringUtil
class CommandGive(plugin: EcoPlugin) : Subcommand(
@@ -48,6 +49,18 @@ class CommandGive(plugin: EcoPlugin) : Subcommand(
if (physical) {
val items = mutableListOf<ItemStack>().apply { repeat(amount) { add(crate.key.item) } }
if (plugin.configYml.getBool("track-player-keys")) {
items.map {
val meta = it.itemMeta!!
meta.persistentDataContainer.set(
plugin.namespacedKeyFactory.create("player"),
PersistentDataType.STRING,
player.uniqueId.toString()
)
it.itemMeta = meta
}
}
DropQueue(player)
.addItems(items)
.forceTelekinesis()

View File

@@ -4,6 +4,7 @@
#
no-key-velocity: 1.5 # The speed at which a player should be launched away from a crate if they try to open it without a key. Set to 0 to disable.
track-player-keys: false # If an NBT tag should be added to keys that links them to a player - will prevent stacking some keys.
# If a reward allows permission multipliers, the weights
# will be multiplied by highest-priority multiplier that a player