shoppingchaos.txt 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880
  1. rankingtable = "shoppingranks";
  2. game_short = "sc";
  3. game_tab = "§eSC";
  4. specific_lobby_handling = true;
  5. no_core_reset = true;
  6. air = "minecraft:air";
  7. air_item = read.item(air);
  8. emerald = read.item("minecraft:emerald");
  9. emerald10 = read.item("minecraft:emerald", 10);
  10. gamename = "§eShoppingChaos";
  11. start_sound = sound.get("minecraft:block.note_block.harp");
  12. wall_signs_tag = block.getTag("minecraft:wall_signs");
  13. facing_prop = block.getProperty("horizontal_facing");
  14. players = map.new(); //Alle player_uuids mit Verweis auf die Team-Nr
  15. playersinteam = map.new(); //Anzahl der Spieler im Team
  16. teamidtolist = map.new(); //Team-Nr mit Verweis auf die Spielerlisten
  17. allteams = list.new(); //Alle Teams, die noch im Spiel sind
  18. items_list = list.new(); //Array-List: Alle Items mit Rezepten
  19. points = map.new(); //Punktestand der Teams
  20. sales_map = map.new(); //Key Entity. Value Item
  21. recipe_menus = map.new(); //Rezept-Menüs für jeden Spieler
  22. removed_perms = list.new(); //Spieler-Uuids, denen Building-Perms entfernt wurden
  23. waiters = list.new(); //Spieler in der Lobby ohne Teamzugehörigkeit
  24. colorcodes = map.new();
  25. map.add(colorcodes, 0, "§9");
  26. map.add(colorcodes, 1, "§c");
  27. map.add(colorcodes, 2, "§e");
  28. map.add(colorcodes, 3, "§2");
  29. teamcolortext = map.new();
  30. map.add(teamcolortext, 0, "§9blue");
  31. map.add(teamcolortext, 1, "§cred");
  32. map.add(teamcolortext, 2, "§eyellow");
  33. map.add(teamcolortext, 3, "§2green");
  34. iron_block = "minecraft:iron_block";
  35. iron_ingot = "minecraft:iron_ingot";
  36. gold_ingot = "minecraft:gold_ingot";
  37. diamond = "minecraft:diamond";
  38. ink_sac = "minecraft:ink_sac";
  39. book = "minecraft:book";
  40. stick = "minecraft:stick";
  41. oak_planks = "minecraft:oak_planks";
  42. quartz_block = "minecraft:quartz_block";
  43. glass = "minecraft:glass";
  44. apple = "minecraft:apple";
  45. cobble = "minecraft:cobblestone";
  46. redstone = "minecraft:redstone";
  47. glowstone = "minecraft:glowstone";
  48. gold_nugget = "minecraft:gold_nugget";
  49. obsidian = "minecraft:obsidian";
  50. ender_eye = "minecraft:ender_eye";
  51. melon_slice = "minecraft:melon_slice";
  52. carrot = "minecraft:carrot";
  53. chest = "minecraft:chest";
  54. coal = "minecraft:coal";
  55. string = "minecraft:string";
  56. furnace = "minecraft:furnace";
  57. compass = "minecraft:compass";
  58. blaze_powder = "minecraft:blaze_powder";
  59. slime_ball = "minecraft:slime_ball";
  60. blaze_rod = "minecraft:blaze_rod";
  61. sugar_cane = "minecraft:sugar_cane";
  62. sugar = "minecraft:sugar";
  63. milk = "minecraft:milk_bucket";
  64. egg = "minecraft:egg";
  65. white_wool= "minecraft:white_wool";
  66. wheat = "minecraft:wheat";
  67. gunpowder = "minecraft:gunpowder";
  68. sand = "minecraft:sand";
  69. ender_pearl = "minecraft:ender_pearl";
  70. leather = "minecraft:leather";
  71. stone = "minecraft:stone";
  72. smooth_stone = "minecraft:smooth_stone";
  73. bow = "minecraft:bow";
  74. flint = "minecraft:flint";
  75. feather = "minecraft:feather";
  76. pumpkin = "minecraft:pumpkin";
  77. sugar = "minecraft:sugar";
  78. egg = "minecraft:egg";
  79. beef = "minecraft:beef";
  80. porkchop = "minecraft:porkchop";
  81. paper = "minecraft:paper";
  82. brown_mushroom = "minecraft:brown_mushroom";
  83. red_mushroom = "minecraft:red_mushroom";
  84. bowl = "minecraft:bowl";
  85. redstone_torch = "minecraft:redstone_torch";
  86. quartz = "minecraft:quartz";
  87. oak_slab = "minecraft:oak_slab";
  88. cod = "minecraft:cod";
  89. piston = "minecraft:piston";
  90. tnt = "minecraft:tnt";
  91. minecart = "minecraft:minecart";
  92. stone_bricks = "minecraft:stone_bricks";
  93. stone_pressure_plate = "minecraft:stone_pressure_plate";
  94. addItem("minecraft:rail", iron_ingot, air, iron_ingot, iron_ingot, stick, iron_ingot, iron_ingot, air, iron_ingot);
  95. addItem("minecraft:oak_fence", air, air, air, oak_planks, stick, oak_planks, oak_planks, stick, oak_planks);
  96. addItem("minecraft:glass_bottle", glass, air, glass, air, glass, air, air, air, air);
  97. addItem("minecraft:dropper", cobble, cobble, cobble, cobble, air, cobble, cobble, redstone, cobble);
  98. addItem("minecraft:iron_sword", air, iron_ingot, air, air, iron_ingot, air, air, stick, air);
  99. addItem("minecraft:ladder", stick, air, stick, stick, stick, stick, stick, air, stick);
  100. addItem("minecraft:minecart", air, air, air, iron_ingot, air, iron_ingot, iron_ingot, iron_ingot, iron_ingot);
  101. addItem("minecraft:hopper", iron_ingot, air, iron_ingot, iron_ingot, chest, iron_ingot, air, iron_ingot, air);
  102. addItem("minecraft:redstone_torch", air, air, air, air, redstone, air, air, stick, air);
  103. addItem("minecraft:torch", air, air, air, air, coal, air, air, stick, air);
  104. addItem("minecraft:bow", air, stick, string, stick, air, string, air, stick, string);
  105. addItem("minecraft:cobblestone_wall", air, air, air, cobble, cobble, cobble, cobble, cobble, cobble);
  106. addItem("minecraft:stone", air, air, air, furnace, cobble, air, air, air, air);
  107. addItem("minecraft:oak_door", oak_planks, oak_planks, air, oak_planks, oak_planks, air, oak_planks, oak_planks, air);
  108. addItem("minecraft:oak_fence_gate", air, air, air, stick, oak_planks, stick, stick, oak_planks, stick);
  109. addItem("minecraft:stone_pressure_plate", air, air, air, stone, stone, air, air, air, air);
  110. addItem("minecraft:oak_pressure_plate", air, air, air, oak_planks, oak_planks, air, air, air, air);
  111. addItem("minecraft:oak_trapdoor", air, air, air, oak_planks, oak_planks, oak_planks, oak_planks, oak_planks, oak_planks);
  112. addItem("minecraft:bucket", iron_ingot, air, iron_ingot, air, iron_ingot, air, air, air, air);
  113. addItem("minecraft:iron_bars", iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot, air, air, air);
  114. addItem("minecraft:oak_sign", oak_planks, oak_planks, oak_planks, oak_planks, oak_planks, oak_planks, air, stick, air);
  115. addItem("minecraft:shears", air, iron_ingot, air, iron_ingot, air, air, air, air, air);
  116. addItem("minecraft:fishing_rod", air, air, stick, air, stick, string, stick, air, string);
  117. addItem("minecraft:compass", air, iron_ingot, air, iron_ingot, redstone, iron_ingot, air, iron_ingot, air);
  118. addItem("minecraft:oak_boat", oak_planks, air, oak_planks, oak_planks, oak_planks, oak_planks, air, air, air);
  119. addItem("minecraft:bowl", oak_planks, air, oak_planks, air, oak_planks, air, air, air, air);
  120. addItem("minecraft:white_wool", string, string, air, string, string, air, air, air, air);
  121. addItem("minecraft:wooden_sword", air, oak_planks, air, air, oak_planks, air, air, stick, air);
  122. addItem("minecraft:tripwire_hook", air, iron_ingot, air, air, stick, air, air, oak_planks, air);
  123. addItem("minecraft:chest_minecart", air, chest, air, air, minecart, air, air, air, air);
  124. addItem("minecraft:iron_door", iron_ingot, iron_ingot, air, iron_ingot, iron_ingot, air, iron_ingot, iron_ingot, air);
  125. addItem("minecraft:smooth_stone_slab", smooth_stone, smooth_stone, smooth_stone, air, air, air, air, air, air);
  126. addItem("minecraft:activator_rail", iron_ingot, stick, iron_ingot, iron_ingot, redstone_torch, iron_ingot, iron_ingot, stick, iron_ingot);
  127. addItem("minecraft:detector_rail", iron_ingot, air, iron_ingot, iron_ingot, stone_pressure_plate, iron_ingot, iron_ingot, redstone, iron_ingot);
  128. addItem("minecraft:dispenser", cobble, cobble, cobble, cobble, bow, cobble, cobble, redstone, cobble);
  129. addItem("minecraft:piston", oak_planks, oak_planks, oak_planks, cobble, iron_ingot, cobble, cobble, redstone, cobble);
  130. addItem("minecraft:repeater", redstone_torch, redstone, redstone_torch, stone, stone, stone, air, air, air);
  131. addItem("minecraft:comparator", air, redstone_torch, air, redstone_torch, quartz, redstone_torch, stone, stone, stone);
  132. addItem("minecraft:heavy_weighted_pressure_plate", air, air, air, iron_ingot, iron_ingot, air, air, air, air);
  133. addItem("minecraft:arrow", air, flint, air, air, stick, air, air, feather, air);
  134. addItem("minecraft:bookshelf", oak_planks, oak_planks, oak_planks, paper, paper, paper, oak_planks, oak_planks, oak_planks);
  135. addItem("minecraft:mushroom_stew", brown_mushroom, red_mushroom, bowl, air, air, air, air, air, air);
  136. addItem("minecraft:pumpkin_pie", pumpkin, sugar, egg, air, air, air, air, air, air);
  137. addItem("minecraft:cooked_beef", air, air, air, furnace, beef, air, air, air, air);
  138. addItem("minecraft:cooked_porkchop", air, air, air, furnace, porkchop, air, air, air, air);
  139. //Page2
  140. addItem("minecraft:book", paper, paper, paper, leather, air, air, air, air, air);
  141. addItem("minecraft:map", paper, paper, paper, paper, compass, paper, paper, paper, paper);
  142. addItem("minecraft:ender_eye", ender_pearl, blaze_powder, air, air, air, air, air, air, air);
  143. addItem("minecraft:lead", air, string, string, air, slime_ball, string, string, air, air);
  144. addItem("minecraft:stone_brick_slab", stone_bricks, stone_bricks, stone_bricks, air, air, air, air, air, air);
  145. addItem("minecraft:brewing_stand", air, air, air, air, blaze_rod, air, cobble, cobble, cobble);
  146. addItem("minecraft:leather_helmet", leather, leather, leather, leather, air, leather, air, air, air);
  147. addItem("minecraft:leather_chestplate", leather, air, leather, leather, leather, leather, leather, leather, leather);
  148. addItem("minecraft:leather_leggings", leather, leather, leather, leather, air, leather, leather, air, leather);
  149. addItem("minecraft:leather_boots", air, air, air, leather, air, leather, leather, air, leather);
  150. addItem("minecraft:cauldron", iron_ingot, air, iron_ingot, iron_ingot, air, iron_ingot, iron_ingot, iron_ingot, iron_ingot);
  151. addItem("minecraft:clock", air, gold_ingot, air, gold_ingot, redstone, gold_ingot, air, gold_ingot, air);
  152. addItem("minecraft:paper", sugar_cane, sugar_cane, sugar_cane, air, air, air, air, air, air);
  153. addItem("minecraft:tnt", gunpowder, sand, gunpowder, sand, gunpowder, sand, gunpowder, sand, gunpowder);
  154. addItem("minecraft:magma_cream", air, air, air, slime_ball, blaze_powder, air, air, air, air);
  155. addItem("minecraft:bread", air, air, air, wheat, wheat, wheat, air, air, air);
  156. addItem("minecraft:white_bed", air, air, air, white_wool, white_wool, white_wool, oak_planks, oak_planks, oak_planks);
  157. addItem("minecraft:cake", milk, milk, milk, sugar, egg, sugar, wheat, wheat, wheat);
  158. addItem("minecraft:cooked_cod", air, air, air, furnace, cod, air, air, air, air);
  159. addItem("minecraft:tnt_minecart", air, air, air, air, tnt, air, air, minecart, air);
  160. addItem("minecraft:melon", melon_slice, melon_slice, melon_slice, melon_slice, melon_slice, melon_slice, melon_slice, melon_slice, melon_slice);
  161. addItem("minecraft:hay_block", wheat, wheat, wheat, wheat, wheat, wheat, wheat, wheat, wheat);
  162. addItem("minecraft:ender_chest", obsidian, obsidian, obsidian, obsidian, ender_eye, obsidian, obsidian, obsidian, obsidian);
  163. addItem("minecraft:sticky_piston", air, air, air, air, slime_ball, air, air, piston, air);
  164. addItem("minecraft:daylight_detector", glass, glass, glass, quartz, quartz, quartz, oak_slab, oak_slab, oak_slab);
  165. addItem("minecraft:golden_apple", gold_ingot, gold_ingot, gold_ingot, gold_ingot, apple, gold_ingot, gold_ingot, gold_ingot, gold_ingot);
  166. addItem("minecraft:jukebox", oak_planks, oak_planks, oak_planks, oak_planks, diamond, oak_planks, oak_planks, oak_planks, oak_planks);
  167. addItem("minecraft:anvil", iron_block, iron_block, iron_block, air, iron_ingot, air, iron_ingot, iron_ingot, iron_ingot);
  168. addItem("minecraft:quartz_stairs", quartz_block, air, air, quartz_block, quartz_block, air, quartz_block, quartz_block, quartz_block);
  169. addItem("minecraft:enchanting_table", air, book, air, diamond, obsidian, diamond, obsidian, obsidian, obsidian);
  170. addItem("minecraft:golden_carrot", gold_nugget, gold_nugget, gold_nugget, gold_nugget, carrot, gold_nugget, gold_nugget, gold_nugget, gold_nugget);
  171. addItem("minecraft:glistering_melon_slice", gold_nugget, gold_nugget, gold_nugget, gold_nugget, melon_slice, gold_nugget, gold_nugget, gold_nugget, gold_nugget);
  172. addItem("minecraft:redstone_lamp", air, redstone, air, redstone, glowstone, redstone, air, redstone, air);
  173. addItem("minecraft:writable_book", book, feather, ink_sac, air, air, air, air, air, air);
  174. addItem("minecraft:powered_rail", gold_ingot, air, gold_ingot, gold_ingot, stick, gold_ingot, gold_ingot, redstone, gold_ingot);
  175. addItem("minecraft:stick", air, iron_ingot, air, air, iron_ingot, air, air, air, air);
  176. addItem("minecraft:wooden_pickaxe", oak_planks, oak_planks, oak_planks, air, stick, air, air, stick, air);
  177. addItem("minecraft:iron_pickaxe", iron_ingot, iron_ingot, iron_ingot, air, stick, air, air, stick, air);
  178. addItem("minecraft:golden_pickaxe", gold_ingot, gold_ingot, gold_ingot, air, stick, air, air, stick, air);
  179. addItem("minecraft:wooden_hoe", oak_planks, oak_planks, air, air, stick, air, air, stick, air);
  180. addItem("minecraft:diamond_hoe", diamond, diamond, air, air, stick, air, air, stick, air);
  181. addItem("minecraft:golden_hoe", gold_ingot, gold_ingot, air, air, stick, air, air, stick, air);
  182. addItem("minecraft:diamond_chestplate", diamond, air, diamond, diamond, diamond, diamond, diamond, diamond, diamond);
  183. addItem("minecraft:iron_chestplate", iron_ingot, air, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot);
  184. addItem("minecraft:golden_boots", air, air, air, gold_ingot, air, gold_ingot, gold_ingot, air, gold_ingot);
  185. //Page3
  186. addItem("minecraft:diamond_boots", air, air, air, diamond, air, diamond, diamond, air, diamond);
  187. addItem("minecraft:iron_helmet", iron_ingot, iron_ingot, iron_ingot, iron_ingot, air, iron_ingot, air, air, air);
  188. addItem("minecraft:iron_leggings", iron_ingot, iron_ingot, iron_ingot, iron_ingot, air, iron_ingot, iron_ingot, air, iron_ingot);
  189. addItem("minecraft:iron_boots", air, air, air, iron_ingot, air, iron_ingot, iron_ingot, air, iron_ingot);
  190. addItem("minecraft:golden_leggings", iron_ingot, iron_ingot, iron_ingot, iron_ingot, air, iron_ingot, iron_ingot, air, iron_ingot);
  191. addItem("minecraft:golden_helmet", iron_ingot, air, iron_ingot, iron_ingot, iron_ingot, iron_ingot, air, air, air);
  192. addItem("minecraft:golden_chestplate", iron_ingot, air, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot, iron_ingot);
  193. gosub("setstart");
  194. for(team = 0; team < numberofteams; team++) {
  195. map.add(playersinteam, team, 0);
  196. map.add(teamidtolist, team, list.new());
  197. }
  198. goto("simplelobby");
  199. @specificLobbyHandling
  200. if(event == "player_join") {
  201. list.add(waiters, player.getUuid(player));
  202. entity.cleareffects(player);
  203. living.setHealth(player, 20);
  204. player.setHunger(player, 20);
  205. player.setSaturation(player, 5);
  206. player.clearInventory(player);
  207. display.reset(player);
  208. display.add(player, 0, gamename);
  209. display.add(player, 1, "§7Map:");
  210. display.add(player, 2, "§3", mapname);
  211. return;
  212. }
  213. if(event == "player_giveup" || event == "player_logout") {
  214. list.remove(waiters, player.getUuid(player));
  215. return;
  216. }
  217. if(event == "block_click") {
  218. player_uuid = player.getUuid(player);
  219. if(map.contains(join_blocks, block_loc)) {
  220. newteam = map.get(join_blocks, block_loc);
  221. newteamlist = map.get(teamidtolist, newteam);
  222. if(list.contains(newteamlist, player_uuid)) {
  223. msg.prefix(player, gamename, "You already choosed a team.");
  224. return;
  225. }
  226. if(list.getSize(newteamlist) >= teamsize) {
  227. msg.prefix(player, gamename, "Not enough space in this team.");
  228. return;
  229. }
  230. list.remove(waiters, player_uuid);
  231. yetteam = map.get(players, player_uuid);
  232. if(yetteam != null) {
  233. yetteamlist = map.get(teamidtolist, yetteam);
  234. list.remove(yetteamlist, player_uuid);
  235. map.add(playersinteam, yetteam, map.get(playersinteam, yetteam) - 1);
  236. }
  237. map.add(playersinteam, newteam, map.get(playersinteam, newteam) + 1);
  238. list.add(newteamlist, player_uuid);
  239. map.add(players, player_uuid, newteam);
  240. msg.prefix(player, gamename, concat("You joined the ", map.get(teamcolortext, newteam), " §rteam."));
  241. entity.setName(player, concat(map.get(colorcodes, newteam), player.getName(player)));
  242. }
  243. }
  244. return;
  245. @finalstart
  246. player_list = minigame.getPlayers(script_id);
  247. entity.removeAll("net.minecraft.entity.item.ItemEntity", middleloc, radius);
  248. while(list.getSize(waiters) != 0) {
  249. team = getTeamWithLowestPeople(teamidtolist, numberofteams);
  250. teamlist = map.get(teamidtolist, team);
  251. p_uuid = list.getIndex(waiters, 0);
  252. map.add(playersinteam, team, map.get(playersinteam, team) + 1);
  253. list.add(teamlist, p_uuid);
  254. list.remove(waiters, p_uuid);
  255. map.add(players, p_uuid, team);
  256. color = map.get(colorcodes, team);
  257. p = player.get(p_uuid);
  258. entity.setName(p, concat(color, player.getName(p_uuid)));
  259. minigame.setTabName(p, game_tab, color);
  260. }
  261. event.load("player_post_respawn");
  262. event.load("item_air_click");
  263. event.load("entity_click");
  264. event.load("inv_click");
  265. event.load("human_hurt");
  266. for(i = 0; i < list.getSize(player_list); i++) {
  267. p_uuid = list.getIndex(player_list, i);
  268. team = map.get(players, p_uuid);
  269. p = player.get(p_uuid);
  270. msg.prefix(p, gamename, "The game has started.");
  271. entity.teleport(p, map.get(spawn_locs, team));
  272. //Recipe-Menus für jeden Spieler erstellen
  273. menu = inv.new("222222222222222222222222222222222222222222222000000022");
  274. map.add(recipe_menus, p_uuid, menu);
  275. //Gamemode und Fly deaktivieren
  276. if(player.isSurvival(p)) {
  277. if(player.isAdventure(p)) {
  278. player.setGamemode(p, "survival");
  279. }
  280. } else {
  281. player.setGamemode(p, "survival");
  282. }
  283. if(player.hasFly(p)) {
  284. player.setFly(p, false);
  285. }
  286. player.clearInventory(p);
  287. //Building-Perms entfernen
  288. if(perm.has(p, "plot.bypass")) {
  289. perm.unregisterPlayer(p_uuid, 1);
  290. perm.unregisterPlayer(p_uuid, 15);
  291. list.add(removed_perms, p_uuid);
  292. }
  293. }
  294. humans_list = getAllEntites();
  295. resetSigns();
  296. resetFrames();
  297. resetContainers();
  298. for(team = 0; team < numberofteams; team++) {
  299. teamsize = map.get(playersinteam, team);
  300. if(teamsize != 0) {
  301. list.add(allteams, team);
  302. map.add(points, team, 0);
  303. }
  304. }
  305. //Sales erstellen
  306. for(i = 0; i < list.getSize(allteams); i++) {
  307. team = list.getIndex(allteams, i);
  308. step = list.getSize(sell_frame_locs) / numberofteams;
  309. index = team * step;
  310. direction = map.get(sell_frame_directions, team);
  311. frame_loc = list.getIndex(sell_frame_locs, index);
  312. entity = list.getIndex(humans_list, index);
  313. entity.removeAll("net.minecraft.entity.item.ItemFrameEntity", frame_loc, 1.5);
  314. item = getItem(getRandomIndex());
  315. entity.spawnItemFrame(frame_loc, direction, item);
  316. map.add(sales_map, entity, item);
  317. time = math.random(30, 60);
  318. entity.setName(entity, text.number(time));
  319. }
  320. updateDisplay();
  321. singleteam = false;
  322. if(list.getSize(allteams) == 1) {
  323. singleteam = true;
  324. }
  325. @loop
  326. if(--seconds < 0) {
  327. minutes--;
  328. seconds = 59;
  329. }
  330. if(seconds < 10) {
  331. minigame.displayAll(1, concat("§aTime left: §r", text.number(minutes), ":0", text.number(seconds)));
  332. } else {
  333. minigame.displayAll(1, concat("§aTime left: §r", text.number(minutes), ":", text.number(seconds)));
  334. }
  335. if(minutes == 0 && seconds == 30) {
  336. minigame.speakAll(gamename, "The shops are closing in 30 seconds.");
  337. for(i = 0; i < list.getSize(player_list); i++) {
  338. p = player.get(list.getIndex(player_list, i));
  339. sound.spawnForPlayer(p, join_sound, sound_category_ambient);
  340. }
  341. } elseif(minutes == 0 && seconds == 10) {
  342. minigame.speakAll(gamename, "The shops are closing in 10 seconds.");
  343. for(i = 0; i < list.getSize(player_list); i++) {
  344. p = player.get(list.getIndex(player_list, i));
  345. sound.spawnForPlayer(p, join_sound, sound_category_ambient);
  346. }
  347. } elseif(minutes == 0 && seconds <= 3) {
  348. for(i = 0; i < list.getSize(player_list); i++) {
  349. p = player.get(list.getIndex(player_list, i));
  350. sound.spawnForPlayer(p, join_sound, sound_category_ambient);
  351. }
  352. }
  353. if(minutes == 0 && seconds == 0) {
  354. max = -1;
  355. minigame.msgAll(getSpacer());
  356. for(i = 0; i < list.getSize(allteams); i++) {
  357. team = list.getIndex(allteams, i);
  358. teampoints = map.get(points, team);
  359. if(teampoints > max) {
  360. max = teampoints;
  361. winning_team = team;
  362. winner_list = map.get(teamidtolist, winning_team);
  363. }
  364. teamlist = map.get(teamidtolist, team);
  365. team_string = "";
  366. for(h = 0; h < list.getSize(teamlist); h++) {
  367. p_uuid = list.getIndex(teamlist, h);
  368. if(team_string == "") {
  369. team_string = player.getName(p_uuid);
  370. } else {
  371. team_string = concat(team_string, " ", player.getName(p_uuid));
  372. }
  373. money.addBoost(player.getId(p_uuid), math.round(teampoints) * 2);
  374. }
  375. minigame.speakAll(gamename, concat(text.number(teampoints), map.get(colorcodes, team), " (", team_string, ")"));
  376. }
  377. goto("win");
  378. }
  379. iter = map.iterator(sales_map);
  380. while(hasNext(iter)) {
  381. iter_element = next(iter);
  382. key = map.getKey(iter_element);
  383. time = read.number(entity.getName(key)) - 1;
  384. if(time > 0) {
  385. entity.setName(key, text.number(time));
  386. } else {
  387. index = list.getIndexOf(humans_list, key);
  388. location = list.getIndex(sell_frame_locs, index);
  389. entity.removeAll("net.minecraft.entity.item.ItemFrameEntity", location, 1.5);
  390. step = list.getSize(sell_frame_locs) / numberofteams;
  391. team = math.roundDown(index / step);
  392. direction = map.get(sell_frame_directions, team);
  393. item = getItem(getRandomIndex());
  394. entity.spawnItemFrame(location, direction, item);
  395. map.add(sales_map, key, item);
  396. time = math.random(30, 60);
  397. entity.setName(key, text.number(time));
  398. }
  399. }
  400. sgoto(20, "loop");
  401. @checkgame
  402. wait();
  403. if(event == "living_pre_hurt") {
  404. if(!isPlayer(living_entity)) {
  405. goto("checkgame");
  406. }
  407. player = living_entity;
  408. } elseif(event == "human_hurt") {
  409. if(!isPlayer(entity)) {
  410. goto("checkgame");
  411. }
  412. player = entity;
  413. }
  414. if(player.hasMinigameId(player, script_id)) {
  415. ignoreGoto(event);
  416. }
  417. goto("checkgame");
  418. @block_click
  419. if(block.hasTag(wall_signs_tag, block)) {
  420. if(block.getSign(block_loc, 0) == "Click here") {
  421. if(player.getItemAmount(player, false, emerald) >= 10) {
  422. direction = block.property.getValue(block_loc, facing_prop);
  423. block.set(block_loc, air);
  424. item = getItem(getRandomIndex());
  425. entity.spawnItemFrame(block_loc, direction, item);
  426. entity = list.getIndex(humans_list, list.getIndexOf(sell_frame_locs, block_loc));
  427. map.add(sales_map, entity, item);
  428. time = math.random(30, 60);
  429. entity.setName(entity, text.number(time));
  430. player.removeItem(player, emerald10);
  431. } else {
  432. msg.prefix(player, gamename, "You need 10 emeralds.");
  433. }
  434. }
  435. }
  436. goto("checkgame");
  437. @living_pre_hurt
  438. if(isPlayer(living_entity)) {
  439. cancel = true;
  440. }
  441. goto("checkgame");
  442. @block_break
  443. @block_place
  444. cancel = true;
  445. goto("checkgame");
  446. @human_hurt
  447. if(isPlayer(entity)) {
  448. player = entity;
  449. if(map.contains(sales_map, human)) {
  450. hand_item = living.getEquip(player, "hand");
  451. aim_item = map.get(sales_map, human);
  452. if(item.getType(hand_item) == item.getType(aim_item)) {
  453. player_uuid = player.getUuid(player);
  454. team = map.get(players, player_uuid);
  455. direction = map.get(sell_frame_directions, team);
  456. item = getItem(getRandomIndex());
  457. location = list.getIndex(sell_frame_locs, list.getIndexOf(humans_list, human));
  458. entity.removeAll("net.minecraft.entity.item.ItemFrameEntity", location, 1.5);
  459. entity.spawnItemFrame(location, direction, item);
  460. map.add(sales_map, human, item);
  461. time = math.random(30, 60);
  462. entity.setName(human, text.number(time));
  463. player.giveItem(player, emerald);
  464. player.removeItem(player, aim_item);
  465. map.add(points, team, map.get(points, team) + 1);
  466. updateDisplay();
  467. msg.prefix(player, gamename, "Thank you §e+§r1 §aSmaragd");
  468. } else {
  469. msg.prefix(player, gamename, "Wrong item in your mainhand.");
  470. }
  471. }
  472. } else {
  473. if(entity.getName(human) != "Recipes") {
  474. msg.prefix(player, gamename, "Shop not unlocked.");
  475. }
  476. }
  477. goto("checkgame");
  478. @inv_click
  479. if(inv_name == "Recipes") {
  480. player_uuid = player.getUuid(player);
  481. team = map.get(players, player_uuid);
  482. item_type = item.getType(item);
  483. if(item_type == air) {
  484. goto("checkgame");
  485. }
  486. if(item_type == paper) {
  487. name = item.getName(item);
  488. if(text.contains(name, "<<") || text.contains(name, ">>")) {
  489. page = removeFormat(name);
  490. page = text.replace(page, "<<", "");
  491. page = text.replace(page, ">>", "");
  492. page = read.number(page);
  493. if(inv_slot == 45) {
  494. setRecipePage(player, inv, page);
  495. }
  496. if(inv_slot == 46) {
  497. setRecipePage(player, inv, page);
  498. }
  499. goto("checkgame");
  500. }
  501. }
  502. index = getIndexFromItemType(item_type);
  503. if(index == null) {
  504. goto("checkgame");
  505. }
  506. setItemFrames(team, index);
  507. }
  508. goto("checkgame");
  509. @entity_click
  510. if(entity.getType(entity) == "human") {
  511. if(entity.getName(entity) == "Recipes") {
  512. player_uuid = player.getUuid(player);
  513. menu = map.get(recipe_menus, player_uuid);
  514. setRecipePage(player, menu, 1);
  515. inv.open(menu, player, "Recipes");
  516. }
  517. goto("checkgame");
  518. }
  519. human = entity;
  520. entity = player;
  521. goto("human_hurt");
  522. @player_post_respawn
  523. player_uuid = player.getUuid(player);
  524. team = map.get(players, player_uuid);
  525. location = map.get(spawn_locs, team);
  526. entity.teleport(player, location);
  527. goto("checkgame");
  528. @item_air_click
  529. if(hand == "MAIN_HAND") {
  530. item = living.getEquip(player, "hand");
  531. } else {
  532. item = living.getEquip(player, "offhand");
  533. }
  534. if(item.getType(item) == "minecraft:ender_pearl") {
  535. cancel = true;
  536. }
  537. goto("checkgame");
  538. @player_logout
  539. @player_giveup
  540. minigame.speakAll(gamename, concat("§8", player.getName(player), " §rhas left the game."));
  541. showstats(player, false);
  542. player_uuid = player.getUuid(player);
  543. //Building-Perms wieder geben
  544. if(list.contains(removed_perms, player_uuid)) {
  545. list.remove(removed_perms, player_uuid);
  546. perm.registerPlayer(player_uuid, 1);
  547. perm.registerPlayer(player_uuid, 15);
  548. }
  549. if(singleteam) {
  550. script = script.getFromId(script_id);
  551. minigame.kickPlayer(script, player);
  552. minigame.term(script, gamesignloc);
  553. term();
  554. }
  555. team = map.get(players, player_uuid);
  556. map.remove(players, player_uuid);
  557. script = script.getFromId(script_id);
  558. minigame.kickPlayer(script, player);
  559. amount = map.get(playersinteam, team) - 1;
  560. map.add(playersinteam, team, amount);
  561. if(amount <= 0) {
  562. list.remove(allteams, team);
  563. if(list.getSize(allteams) == 1) {
  564. winning_team = list.getIndex(allteams, 0);
  565. winner_list = map.get(teamidtolist, winning_team);
  566. goto("win");
  567. }
  568. }
  569. minigame.displayRemoveAll(2 + team);
  570. goto("checkgame");
  571. @win
  572. team_string = "";
  573. for(h = 0; h < list.getSize(winner_list); h++) {
  574. if(team_string == "") {
  575. team_string = player.getName(list.getIndex(winner_list, h));
  576. } else {
  577. team_string = concat(team_string, " ", player.getName(list.getIndex(winner_list, h)));
  578. }
  579. }
  580. if(!singleteam) {
  581. minigame.speakAll( gamename, concat("Team ", map.get(colorcodes, winning_team), "(", team_string, ") §rhas won."));
  582. }
  583. for(i = 0; i < list.getSize(player_list); i++) {
  584. player_uuid = list.getIndex(player_list, i);
  585. p = player.get(player_uuid);
  586. team = map.get(players, player_uuid);
  587. if(team == winning_team) {
  588. showstats(p, true);
  589. } else {
  590. showstats(p, false);
  591. }
  592. }
  593. //Building-Perms wieder geben
  594. for(i = 0; i < list.getSize(removed_perms); i++) {
  595. player_uuid = list.getIndex(removed_perms, i);
  596. perm.registerPlayer(player_uuid, 1);
  597. perm.registerPlayer(player_uuid, 15);
  598. }
  599. script = script.getFromId(script_id);
  600. minigame.kickAllPlayers(script);
  601. minigame.term(script, gamesignloc);
  602. term();
  603. function showstats(player, won) { //Player player, Boolean won
  604. player_id = player.getId(player);
  605. last_record = ranking.getPoints($rankingtable, player_id);
  606. playedgames = minigame.getPlayed(player_id, $game_short) + 1;
  607. minigame.setPlayed(player_id, $game_short, playedgames);
  608. player_uuid = player.getUuid(player);
  609. team = map.get($players, player_uuid);
  610. record = map.get($points, team);
  611. if(record < last_record) {
  612. record = last_record;
  613. }
  614. ranking.setPoints($rankingtable, player_id, record);
  615. wongames = minigame.getWon(player, "sc");
  616. if(!$singleteam) {
  617. if(won) {
  618. wongames++;
  619. minigame.setWon(player, "sc", wongames);
  620. }
  621. }
  622. minigame.statsHeader(player, $gamename, "§e");
  623. minigame.statsLine(player, "§e", "Max Items", text.number(last_record));
  624. minigame.statsLine(player, "§e", "Played games", text.number(playedgames));
  625. minigame.statsLine(player, "§e", "Won games", text.number(wongames));
  626. if(playedgames != 0) {
  627. minigame.statsLine(player, "§e", "Win ratio", concat(text.number(math.roundComma((wongames / playedgames) * 100, 2)), "%"));
  628. }
  629. }
  630. function updateDisplay() {
  631. minigame.displayAll(0, $gamename);
  632. for(i = 0; i < list.getSize($allteams); i++) {
  633. team = list.getIndex($allteams, i);
  634. teamlist = map.get($teamidtolist, team);
  635. team_string = "";
  636. for(h = 0; h < list.getSize(teamlist); h++) {
  637. if(team_string == "") {
  638. team_string = player.getName(list.getIndex(teamlist, h));
  639. } else {
  640. team_string = concat(team_string, " ", player.getName(list.getIndex(teamlist, h)));
  641. }
  642. }
  643. minigame.displayAll(2 + team, concat("§r", text.number(map.get($points, team)), " ", map.get($colorcodes, team), team_string));
  644. }
  645. }
  646. function addItem(item, item1, item2, item3, item4, item5, item6, item7, item8, item9) {
  647. array = array.new(10);
  648. array[0] = item;
  649. array[1] = item1;
  650. array[2] = item2;
  651. array[3] = item3;
  652. array[4] = item4;
  653. array[5] = item5;
  654. array[6] = item6;
  655. array[7] = item7;
  656. array[8] = item8;
  657. array[9] = item9;
  658. list.add($items_list, array);
  659. }
  660. function getRandomIndex() {
  661. return math.random(0, list.getSize($items_list) - 1);
  662. }
  663. function getIndexFromItemType(item_type) {
  664. for(i = 0; i < list.getSize($items_list); i++) {
  665. array = list.getIndex($items_list, i);
  666. if(array[0] == item_type) {
  667. return i;
  668. }
  669. }
  670. return null;
  671. }
  672. function getItem(index) {
  673. array = list.getIndex($items_list, index);
  674. return read.item(array[0]);
  675. }
  676. function setItemFrames(team, index) {
  677. loc = list.getIndex($frame_locs, team);
  678. entity.removeAll("net.minecraft.entity.item.ItemFrameEntity", loc, 3.5);
  679. direction = map.get($frame_directions, team);
  680. array = list.getIndex($items_list, index);
  681. entity.spawnItemFrame(loc, direction, read.item(array[0]));
  682. if(direction == "north") {
  683. entity.spawnItemFrame(loc.mod(loc, 1, -1, 0), direction, read.item(array[1]));
  684. entity.spawnItemFrame(loc.mod(loc, 0, -1, 0), direction, read.item(array[2]));
  685. entity.spawnItemFrame(loc.mod(loc, -1, -1, 0), direction, read.item(array[3]));
  686. entity.spawnItemFrame(loc.mod(loc, 1, -2, 0), direction, read.item(array[4]));
  687. entity.spawnItemFrame(loc.mod(loc, 0, -2, 0), direction, read.item(array[5]));
  688. entity.spawnItemFrame(loc.mod(loc, -1, -2, 0), direction, read.item(array[6]));
  689. entity.spawnItemFrame(loc.mod(loc, 1, -3, 0), direction, read.item(array[7]));
  690. entity.spawnItemFrame(loc.mod(loc, 0, -3, 0), direction, read.item(array[8]));
  691. entity.spawnItemFrame(loc.mod(loc, -1, -3, 0), direction, read.item(array[9]));
  692. } elseif(direction == "east") {
  693. entity.spawnItemFrame(loc.mod(loc, 0, -1, -1), direction, read.item(array[1]));
  694. entity.spawnItemFrame(loc.mod(loc, 0, -1, 0), direction, read.item(array[2]));
  695. entity.spawnItemFrame(loc.mod(loc, 0, -1, 1), direction, read.item(array[3]));
  696. entity.spawnItemFrame(loc.mod(loc, 0, -2, -1), direction, read.item(array[4]));
  697. entity.spawnItemFrame(loc.mod(loc, 0, -2, 0), direction, read.item(array[5]));
  698. entity.spawnItemFrame(loc.mod(loc, 0, -2, 1), direction, read.item(array[6]));
  699. entity.spawnItemFrame(loc.mod(loc, 0, -3, -1), direction, read.item(array[7]));
  700. entity.spawnItemFrame(loc.mod(loc, 0, -3, 0), direction, read.item(array[8]));
  701. entity.spawnItemFrame(loc.mod(loc, 0, -3, 1), direction, read.item(array[9]));
  702. } elseif(direction == "south") {
  703. entity.spawnItemFrame(loc.mod(loc, -1, -1, 0), direction, read.item(array[1]));
  704. entity.spawnItemFrame(loc.mod(loc, 0, -1, 0), direction, read.item(array[2]));
  705. entity.spawnItemFrame(loc.mod(loc, 1, -1, 0), direction, read.item(array[3]));
  706. entity.spawnItemFrame(loc.mod(loc, -1, -2, 0), direction, read.item(array[4]));
  707. entity.spawnItemFrame(loc.mod(loc, 0, -2, 0), direction, read.item(array[5]));
  708. entity.spawnItemFrame(loc.mod(loc, 1, -2, 0), direction, read.item(array[6]));
  709. entity.spawnItemFrame(loc.mod(loc, -1, -3, 0), direction, read.item(array[7]));
  710. entity.spawnItemFrame(loc.mod(loc, 0, -3, 0), direction, read.item(array[8]));
  711. entity.spawnItemFrame(loc.mod(loc, 1, -3, 0), direction, read.item(array[9]));
  712. } elseif(direction == "west") {
  713. entity.spawnItemFrame(loc.mod(loc, 0, -1, 1), direction, read.item(array[1]));
  714. entity.spawnItemFrame(loc.mod(loc, 0, -1, 0), direction, read.item(array[2]));
  715. entity.spawnItemFrame(loc.mod(loc, 0, -1, -1), direction, read.item(array[3]));
  716. entity.spawnItemFrame(loc.mod(loc, 0, -2, 1), direction, read.item(array[4]));
  717. entity.spawnItemFrame(loc.mod(loc, 0, -2, 0), direction, read.item(array[5]));
  718. entity.spawnItemFrame(loc.mod(loc, 0, -2, -1), direction, read.item(array[6]));
  719. entity.spawnItemFrame(loc.mod(loc, 0, -3, 1), direction, read.item(array[7]));
  720. entity.spawnItemFrame(loc.mod(loc, 0, -3, 0), direction, read.item(array[8]));
  721. entity.spawnItemFrame(loc.mod(loc, 0, -3, -1), direction, read.item(array[9]));
  722. }
  723. }
  724. function resetSigns() {
  725. step = list.getSize($sell_frame_locs) / $numberofteams;
  726. team = 0;
  727. counter = 0;
  728. for(i = 0; i < list.getSize($sell_frame_locs); i++) {
  729. if(counter != 0) { //Erste Locs werden übersprungen. Kein Schild platzieren = Freigeschalteter Shop
  730. loc = list.getIndex($sell_frame_locs, i);
  731. entity.removeAll("net.minecraft.entity.item.ItemFrameEntity", loc, 1.5);
  732. direction = map.get($sell_frame_directions, team);
  733. block.set(loc, concat("minecraft:oak_wall_sign[facing=", direction, "]"));
  734. block.setSign(loc, 0, "Click here");
  735. block.setSign(loc, 1, "to unlock for");
  736. block.setSign(loc, 2, "§a10 §rEmerald");
  737. block.setSign(loc, 3, ">> >> >>");
  738. }
  739. if(++counter == step) {
  740. counter = 0;
  741. team++;
  742. }
  743. }
  744. }
  745. function resetFrames() {
  746. for(i = 0; i < list.getSize($frame_locs); i++) {
  747. loc = list.getIndex($frame_locs, i);
  748. entity.removeAll("net.minecraft.entity.item.ItemFrameEntity", loc, 3.5);
  749. direction = map.get($frame_directions, i);
  750. entity.spawnItemFrame(loc, direction, $air_item);
  751. entity.spawnItemFrame(loc.mod(loc, 0, -1, 0), direction, $air_item);
  752. entity.spawnItemFrame(loc.mod(loc, 0, -2, 0), direction, $air_item);
  753. entity.spawnItemFrame(loc.mod(loc, 0, -3, 0), direction, $air_item);
  754. if(direction == "north" || direction == "south") {
  755. entity.spawnItemFrame(loc.mod(loc, 1, -1, 0), direction, $air_item);
  756. entity.spawnItemFrame(loc.mod(loc, -1, -1, 0), direction, $air_item);
  757. entity.spawnItemFrame(loc.mod(loc, 1, -2, 0), direction, $air_item);
  758. entity.spawnItemFrame(loc.mod(loc, -1, -2, 0), direction, $air_item);
  759. entity.spawnItemFrame(loc.mod(loc, 1, -3, 0), direction, $air_item);
  760. entity.spawnItemFrame(loc.mod(loc, -1, -3, 0), direction, $air_item);
  761. }
  762. if(direction == "east" || direction == "west") {
  763. entity.spawnItemFrame(loc.mod(loc, 0, -1, 1), direction, $air_item);
  764. entity.spawnItemFrame(loc.mod(loc, 0, -1, -1), direction, $air_item);
  765. entity.spawnItemFrame(loc.mod(loc, 0, -2, 1), direction, $air_item);
  766. entity.spawnItemFrame(loc.mod(loc, 0, -2, -1), direction, $air_item);
  767. entity.spawnItemFrame(loc.mod(loc, 0, -3, 1), direction, $air_item);
  768. entity.spawnItemFrame(loc.mod(loc, 0, -3, -1), direction, $air_item);
  769. }
  770. }
  771. }
  772. function resetContainers() {
  773. //1.Kiste
  774. for(i = 0; i < list.getSize($chest_locs1); i++) {
  775. loc = list.getIndex($chest_locs1, i);
  776. block.clone(loc.mod(loc, 0, -3, 0), loc);
  777. }
  778. //2.Kiste
  779. for(i = 0; i < list.getSize($chest_locs2); i++) {
  780. loc = list.getIndex($chest_locs2, i);
  781. block.clone(loc.mod(loc, 0, -3, 0), loc);
  782. }
  783. //Ofen
  784. for(i = 0; i < list.getSize($furnace_locs); i++) {
  785. loc = list.getIndex($furnace_locs, i);
  786. block.clone(loc.mod(loc, 0, -3, 0), loc);
  787. }
  788. }
  789. function setRecipePage(player, menu, page) {
  790. size = list.getSize($items_list);
  791. max_page = math.roundUp(size / 45);
  792. if(page > max_page) {
  793. return;
  794. }
  795. if(page > 1) {
  796. inv.setItem(menu, 45, read.item("minecraft:paper", 1, concat("§e", text.number(page - 1), " <<")));
  797. } else {
  798. inv.setItem(menu, 45, $air_item);
  799. }
  800. if(page < max_page) {
  801. inv.setItem(menu, 46, read.item("minecraft:paper", 1, concat("§e>> ", text.number(page + 1))));
  802. } else {
  803. inv.setItem(menu, 46, $air_item);
  804. }
  805. max_index = size - 1;
  806. for(i = 0; i < 45; i++) {
  807. list_index = i + 45 * (page - 1);
  808. if(list_index > max_index) {
  809. inv.setItem(menu, i, $air_item);
  810. } else {
  811. array = list.getIndex($items_list, list_index);
  812. inv.setItem(menu, i, read.item(array[0]));
  813. }
  814. }
  815. inv.update(player);
  816. }
  817. function getAllEntites() {
  818. humans_list = list.new();
  819. for(i = 0; i < list.getSize($humans_locs); i++) {
  820. location = list.getIndex($humans_locs, i);
  821. entity = entity.get(location, 10, "me.km.entities.EntityHuman");
  822. list.add(humans_list, entity);
  823. entity.setName(entity, "Shop");
  824. }
  825. return humans_list;
  826. }