shoppingchaos.txt 35 KB

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