
var hats = 
['\"1980s is Calling\"',
'\"Abraham Lincoln Hat\"',
'\"Anvilhead\"',
'\"AppleHat\"',
'\"Bowler Hat\"',
'\"Brain\"',
'\"Bread\"',
'\"Bright Hat\"',
'\"Cap\"',
'\"Cat in the Hat\"',
'\"Chest\"',
'\"Clip on Rabbit Ears\"',
'\"Cloudy Overhead\"',
'\"Contributors\"',
'\"Coonskin Cap\"',
'\"Cute Ocelot Hat\"',
'\"Cute Walrus\"',
'\"Fez\"',
'\"Flat Hat\"',
'\"Fro Hat\"',
'\"Furry Hat\"',
'\"Glasses\"',
'\"Glove World\"',
'\"Hot Dogger\"',
'\"Inhaler\"',
'\"Italian Plumber\"',
'\"Miner Hat\"',
'\"Mini Rail\"',
'\"Moviemaker\'s Beginner Setup\"',
'\"Mr.Hazard\'s Mask\"',
'\"Nyan Hat\"',
'\"PahiHat\"',
'\"Party Hat\"',
'\"PetRock\"',
'\"Pickaxe in Head\"',
'\"Pig Ears\"',
'\"Pig Hat\"',
'\"Pistontop\"',
'\"PlatformHead\"',
'\"Pool Toy Hat\"',
'\"Portable Jukebox\"',
'\"Portal Hat\"',
'\"Redstoner\'s Hat\"',
'\"Shrek Beanie\"',
'\"Skycrane\"',
'\"Skyrim Hat\"',
'\"Squid\"',
'\"Stainless Pot\"',
'\"The Lever\"',
'\"The Prick\"',
'\"This Is My Happy Face\"',
'\"Top Hat\"',
'\"Towering Pillar of Hats\"',
'\"Trail Mix Mascot\"',
'\"Upside Down Hat\"',
'\"Vanilla Masks\"',
'\"Viking Hat\"',
'\"WitherBoss\"',
'\"Woodhat\"',
'\"5G for Everyone\"',
'\"Aerwhale Hat\"',
'\"Arrow Head\"',
'\"Australian Minecart\"',
'\"Axehead\"',
'\"Baby Turtle\"',
'\"Bane Mask\"',
'\"Blame The Community\"',
'\"Boy of Silence Hat\"',
'\"BSOD\"',
'\"Cage Hat\"',
'\"CheeseHat\"',
'\"Clip-On Halo\"',
'\"Computer\"',
'\"Crown\"',
'\"Dalek Hat\"',
'\"Encouragement\"',
'\"Facehugger\"',
'\"Foam Finger\"',
'\"Frankenstein\"',
'\"Frog Hat\"',
'\"Ghastly Gibus\"',
'\"GlassHat\"',
'\"Googly Eyes\"',
'\"Hair Bow\"',
'\"Hard Hat\"',
'\"Hatpants\"',
'\"Haunted Hat\"',
'\"Headcrab\"',
'\"Headphones\"',
'\"Headset\"',
'\"HUD Hat\"',
'\"I\'m Different\"',
'\"Jeremy\"',
'\"Jester\"',
'\"Lego Hat\"',
'\"Leprechaun Hat\"',
'\"Mooshroom Hat\"',
'\"Mr. T\"',
'\"Norwegian Flag\"',
'\"Overdose\"',
'\"Panda Ushanka\"',
'\"Pillar Hat\"',
'\"PlumBob\"',
'\"Plunger Hat\"',
'\"Ponytail\"',
'\"Poolhat\"',
'\"Present Hat\"',
'\"Safe N\' Sound\"',
'\"Shady Baguette\"',
'\"Slime Hat\"',
'\"Small Dog\"',
'\"Solar Helmet\"',
'\"Sombrero\"',
'\"Straw Hat\"',
'\"Tardis\"',
'\"TentaCool\"',
'\"The Crown of the Ice King\"',
'\"Treehat\"',
'\"T-Rex\"',
'\"Turkey Hat\"',
'\"Twilight Squirrel\"',
'\"Universe Pumpkin\"',
'\"Ushanka\"',
'\"Welding Helmet\"',
'\"Winter Cap\"',
'\"Wizard Hat\"'
]

events.listen("item.right_click", function(event) {
	if (event.item == 'kubejs:hats_case') {
		var hat = hats[random(hats.length - 1)];
		var player = event.player;

		event.server.tell(text.green(`§e${player} §aоткрыл §eКейс с шапками§a и получил §e${hat}`))
		event.server.runCommand(`/hats addCount ${player} ${hat} 1`);

		event.item.count--;
		event.cancel();
	}
});

// Рандомайзер предметов
random = function(count) {
    var rand = Math.random()*count;
	return Math.round(rand);
};