on inventory close:
name of player's current inventory is "&lIROTHAI CAVERNS LOOTBOX":
loop all items in player's current inventory:
slot 32, 31, 30, 23, 22, 21, 14, 13 and 12 of player's current inventory is ender chest named "&6&l???" with lore "&7Click to redeem a random item" and "&7from the Irothai Caverns&7 Lootbox!":
wait 1 tick
give 1 ender chest named "&4&l-=+> &c&k::&7 Irothai Caverns Lootbox &c&k::&4&l <+=-" with lore "&7A mysterious box found in the depths of", "&7the Irothai Caverns, there may be more", "&7down there, but this is the first of it's", "&7kind to see the light of day...", "&k", "&f&lNORMAL REWARDS:", "&7 - x32 Diamond Blocks", "&7 - x256 Bottles of Enchanting", "&7 - x2 Beacons", "&7 - x1 Irothian Pickaxe", "&7 - x64 Golden Apples", "&k", "&5&lEPIC REWARDS:", "&7 - &5x1 Reward Loot Crate &7(Tier 1 - 3)", "&7 - &5x2 Enchanted Golden Apples", "&7 - &5x1 Shulker Box", "&7 - &5x1 Mending Enchanted Book", "&7 - &5x3 Random Custom Enchants", "&k", "&6&lLEGENDARY REWARDS:", "&7 - &ex3 Random Loot Crates &7(Tier 2 - 4)", "&7 - &ex1 Experience Booster &7(4 Hours)", "&7 - &ex1 Command Access: &7/sethome, /home", "&7 - &ex5 Random Custom Enchants", "&7 - &ex1 Dragon Egg", "&7 - &ex1 Elytra", "&k", "&4&lDIVINE REWARDS:", "&7 - &cx1 &k::&7&l Irothian Knight VKit Access &c&k::", "&7 - &cx1 &k::&7&l Irothai Caverns Key &c&k::", "&7 - &cx1 Potion of Unlimited Buffs &7(3 Uses)", "&7 - &cx2 Totems of Undying", "&7 - &cx1 Random Divine Custom Enchant" and "&7 - &cx1 Admin Item" to player
stop
slot 49 of player's current inventory is red stained glass pane named "&4&lDIVINE REWARD" with lore "&7Click to receive a guaranteed", "&6&lLEGENDARY&7 tier reward or higher!", "&k" and "&6Legendary&e and &4Divine&e reward", "&echances are increased!", "&k", "&4You must open your main rewards before" and "&4you can open your &nDIVINE&4 reward!":
wait 1 tick
open event-inventory to player
stop
slot 49 of player's current inventory is not red stained glass pane named "&4&lDIVINE REWARD" with lore "&7Click to receive a guaranteed", "&6&lLEGENDARY&7 tier reward or higher!", "&k" and "&6Legendary&e and &4Divine&e reward", "&echances are increased!", "&k", "&4You must open your main rewards before" and "&4you can open your &nDIVINE&4 reward!":
slot 49 of player's current inventory is glowing chorus flower named "&4&lDIVINE REWARD" with lore "&7Click to receive a guaranteed", "&6&lLEGENDARY&7 tier reward or higher!", "&k" and "&6Legendary&e and &4Divine&e reward", "&echances are increased!":
wait 1 tick
open event-inventory to player
stop
slot 49 of player's current inventory is not red stained glass pane named "&4&lDIVINE REWARD" with lore "&7Click to receive a guaranteed", "&6&lLEGENDARY&7 tier reward or higher!", "&k" and "&6Legendary&e and &4Divine&e reward", "&echances are increased!", "&k", "&4You must open your main rewards before" and "&4you can open your &nDIVINE&4 reward!":
slot 49 of player's current inventory is not glowing chorus flower named "&4&lDIVINE REWARD" with lore "&7Click to receive a guaranteed", "&6&lLEGENDARY&7 tier reward or higher!", "&k" and "&6Legendary&e and &4Divine&e reward", "&echances are increased!":
{_item}
stop