#
# Two /item commands that accept aliases as arguments and are thus extremely versatile.
# E.g. you can use the command like "/item birch plank, 5 red wool and 17 iron ore" and you will receive all 3.
# If you add translated aliases to your aliases.sk your players will be able to use those aliases as well.
#
# Please note that an <items> argument accepts enchantments as well, and only the second example command
# in this script restricts spawing of enchanted items.
#

aliases:
	blacklisted = TNT, bedrock, obsidian, mob spawner, lava, lava bucket

# This version of the command requires that the player has the permission skript.give,
# and blacklisted items are only allowed if the player has the permission skript.give.bypassblacklist
command /item <items>:
	description: Give yourself some items
	usage: /item <item(s)>
	aliases: i
	executable by: players
	permission: skript.give
	trigger:
		player has permission "skript.give.bypassblacklist":
			give arguments to player
		else:
			loop arguments:
				loop-item is not blacklisted:
					give loop-item to player
				else:
					message "<red>%loop-item%<reset> is blacklisted and thus cannot be spawned"

# This version of the command checks whether the player has permission to spawn the desired item.
# A player needs the "skript.give.<ID>" permission to spawn an item of the desired type
# and the permission "skript.give.enchanted" to spawn enchanted items.
command /item2 <items>:
	description: Give yourself some items
	usage: /item2 <item(s)>
	aliases: i2
	executable by: players
	permission: skript.give
	trigger:
		loop arguments:
			loop-item is enchanted:
				player does not have the permission "skript.give.enchanted":
					message "You don't have permission to spawn enchanted items!"
					stop
			player has permission "skript.give.%ID of loop-item%":
				give loop-item to player
			else:
				message "You don't have permission to spawn <red>%loop-item%<reset>!"


command /give <item types> to <player>:
	description: Give someone else some items
	usage: /give <item(s)> to <player>
	permission: skript.give
	trigger:
		send "Giving %argument 1% to %argument 2%" to player
		loop argument 1:
			player has permission "skript.give.%ID of loop-item%":
				give loop-item to argument 2
				send "You recieved %loop-item% from %player%" to argument 2
			else:
				message "<red>You don't have permission to give away free <red>%loop-item%<reset>!"
