gamecenter.txt 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. event.load("living_pre_hurt");
  2. event.load("player_login");
  3. event.load("player_pre_respawn");
  4. event.load("player_post_respawn");
  5. event.load("block_click");
  6. event.load("block_break");
  7. event.load("entity_click");
  8. event.load("custom_command");
  9. event.load("player_logout");
  10. event.load("term_script");
  11. event.load("player_move");
  12. event.load("item_air_click");
  13. event.load("inv_click");
  14. script_ids = map.new();
  15. script_players = list.new();
  16. script_paths = list.new();
  17. games_respawn = set.new();
  18. gamesign_ground_block = set.new();
  19. block_click_catcher = set.new();
  20. gamesignsmap = map.new();
  21. openedgames = map.new();
  22. gamepaths = map.new();
  23. gamemappaths = map.new();
  24. singleplayergames = set.new();
  25. compass_loc_list = list.new();
  26. prefix_party = "§5Party";
  27. gamesworld = world.getGames();
  28. sign_tag = block.getTag("minecraft:wall_signs");
  29. facing_property = block.getProperty("horizontal_facing");
  30. marv_loc = loc.new(gamesworld, -410, 161, -60);
  31. dice_loc = loc.new(gamesworld, -416, 156, -57);
  32. dice_loc_rm5 = loc.new(gamesworld, -3064, 156, 1061);
  33. dice_time = time.getMillis();
  34. move_id_to_spawn = event.addMoveData(loc.new(gamesworld, -415, 148, -62), loc.new(gamesworld, -411, 153, -58), 5, -1);
  35. minigame.addSign("bwmapsign1", true, loc.new(gamesworld, -423, 158, -42), "minigames/bedwars/bedwars", "minigames/bedwars/region_bwmap1", false);
  36. minigame.addSign("bwmapsign2", true, loc.new(gamesworld, -423, 158, -43), "minigames/bedwars/bedwars", "minigames/bedwars/region_bwmap2", false);
  37. minigame.addSign("bwmapsign3", true, loc.new(gamesworld, -423, 158, -44), "minigames/bedwars/bedwars", "minigames/bedwars/region_bwmap3", false);
  38. minigame.addSign("bwmapsign4", true, loc.new(gamesworld, -423, 157, -42), "minigames/bedwars/bedwars", "minigames/bedwars/region_bwmap4", false);
  39. minigame.addSign("bwmapsign5", true, loc.new(gamesworld, -423, 157, -43), "minigames/bedwars/bedwars", "minigames/bedwars/region_bwmap5", false);
  40. minigame.addSign("bwmapsign6", true, loc.new(gamesworld, -423, 157, -44), "minigames/bedwars/bedwars", "minigames/bedwars/region_bwmap6", false);
  41. minigame.addSign("bwmapsign7", true, loc.new(gamesworld, -423, 156, -42), "minigames/bedwars/bedwars", "minigames/bedwars/region_bwmap7", false);
  42. minigame.addSign("bwmapsign8", true, loc.new(gamesworld, -423, 156, -43), "minigames/bedwars/bedwars", "minigames/bedwars/region_bwmap8", false);
  43. minigame.addSign("bwmapsign9", true, loc.new(gamesworld, -423, 156, -44), "minigames/bedwars/bedwars", "minigames/bedwars/region_bwmap9", false);
  44. minigame.addSign("letterssign1", true, loc.new(gamesworld, -396, 158, -63), "minigames/letters/letters", "minigames/letters/region_lettersmap1", true);
  45. minigame.addSign("letterssign2", true, loc.new(gamesworld, -396, 158, -62), "minigames/letters/letters", "minigames/letters/region_lettersmap2", true);
  46. minigame.addSign("letterssign3", true, loc.new(gamesworld, -396, 158, -61), "minigames/letters/letters", "minigames/letters/region_lettersmap3", true);
  47. minigame.addSign("rmmaploc1", true, loc.new(gamesworld, -411, 158, -44), "minigames/ragemode/ragemode", "minigames/ragemode/rmmap1", false);
  48. minigame.addSign("rmmaploc2", true, loc.new(gamesworld, -411, 158, -43), "minigames/ragemode/ragemode", "minigames/ragemode/rmmap2", false);
  49. minigame.addSign("rmmaploc3", true, loc.new(gamesworld, -411, 158, -42), "minigames/ragemode/ragemode", "minigames/ragemode/rmmap3", false);
  50. minigame.addSign("rmmaploc4", true, loc.new(gamesworld, -411, 157, -44), "minigames/ragemode/ragemode", "minigames/ragemode/rmmap4", false);
  51. minigame.addSign("rmmaploc5", true, loc.new(gamesworld, -411, 157, -43), "minigames/ragemode/ragemode", "minigames/ragemode/rmmap5", false);
  52. minigame.addSign("sfsign1", true, loc.new(gamesworld, -398, 158, -47), "minigames/sammelfieber/sfranked", "minigames/sammelfieber/sfmap1", true);
  53. minigame.addSign("sfsign2", true, loc.new(gamesworld, -398, 157, -47), "minigames/sammelfieber/sfranked", "minigames/sammelfieber/sfmap2", true);
  54. minigame.addSign("sfsign3", true, loc.new(gamesworld, -399, 158, -47), "minigames/sammelfieber/sammelfieber", "minigames/sammelfieber/sfmap3", false);
  55. minigame.addSign("buttonssign1", true, loc.new(gamesworld, -399, 158, -65), "minigames/buttons/buttons", "minigames/buttons/buttonsmap1", true);
  56. minigame.addSign("buttonssign2", true, loc.new(gamesworld, -398, 158, -65), "minigames/buttons/buttons", "minigames/buttons/buttonsmap2", true);
  57. minigame.addSign("spleefsign1", true, loc.new(gamesworld, -419, 156, -40), "minigames/spleef/spleef", "minigames/spleef/spleefmap1", false);
  58. minigame.addSign("spleefsign2", true, loc.new(gamesworld, -420, 156, -40), "minigames/spleef/spleef", "minigames/spleef/spleefmap2", false);
  59. minigame.addSign("spleefsign3", true, loc.new(gamesworld, -421, 156, -40), "minigames/spleef/spleef", "minigames/spleef/spleefmap3", false);
  60. minigame.addSign("knockfightsign1", true, loc.new(gamesworld, -419, 157, -40), "minigames/knockfight/knockfight", "minigames/knockfight/knockmap1", false);
  61. minigame.addSign("knockfightsign2", true, loc.new(gamesworld, -420, 157, -40), "minigames/knockfight/knockfight", "minigames/knockfight/knockmap2", false);
  62. minigame.addSign("knockfightsign3", true, loc.new(gamesworld, -421, 157, -40), "minigames/knockfight/knockfight", "minigames/knockfight/knockmap3", false);
  63. minigame.addSign("invertingsign1", true, loc.new(gamesworld, -396, 158, -57), "minigames/inverting/inverting", "minigames/inverting/invertingmap1", true);
  64. minigame.addSign("invertingsign2", true, loc.new(gamesworld, -396, 158, -56), "minigames/inverting/inverting", "minigames/inverting/invertingmap2", true);
  65. minigame.addSign("invertingsign3", true, loc.new(gamesworld, -396, 158, -55), "minigames/inverting/inverting", "minigames/inverting/invertingmap3", true);
  66. minigame.addSign("invertingclsign1", true, loc.new(gamesworld, -396, 157, -57), "minigames/inverting/inverting", "minigames/inverting/invertingclmap1", true);
  67. minigame.addSign("invertingclsign2", true, loc.new(gamesworld, -396, 157, -56), "minigames/inverting/inverting", "minigames/inverting/invertingclmap2", true);
  68. minigame.addSign("invertingclsign3", true, loc.new(gamesworld, -396, 157, -55), "minigames/inverting/inverting", "minigames/inverting/invertingclmap3", true);
  69. //minigame.addSign("ctfsign1", false, loc.new(gamesworld, 13, 75, 64), "minigames/capturetheflag/capturetheflag", "minigames/capturetheflag/ctfmap1", false);
  70. minigame.addSign("jrmap", true, loc.new(gamesworld, -396, 158, -51), "minigames/jumpnrun/jumpnrun", "minigames/jumpnrun/jumpnrun", true);
  71. minigame.addSign("parcoursign1", true, loc.new(gamesworld, -396, 158, -50), "minigames/parcour/parcour", "minigames/parcour/parcour_map1", true);
  72. minigame.addSign("tjrsign", true, loc.new(gamesworld, -396, 157, -51), "minigames/jumpnrun/todesjumpnrun", "minigames/jumpnrun/todesjumpnrun", true);
  73. minigame.addSign("icejrsign", true, loc.new(gamesworld, -404, 157, -75), "minigames/jumpnrun/icejumpnrun", "minigames/jumpnrun/icejumpnrun", true);
  74. minigame.addSign("fastbridgesign1", true, loc.new(gamesworld, -413, 157, -40), "minigames/fastbridge/fastbridge", "minigames/fastbridge/region_fastbridgemap1", false);
  75. minigame.addSign("fastbridgesign2", true, loc.new(gamesworld, -414, 157, -40), "minigames/fastbridge/fastbridge", "minigames/fastbridge/region_fastbridgemap2", false);
  76. minigame.addSign("halmasign1", true, loc.new(gamesworld, -413, 156, -40), "minigames/halma/halma", "minigames/halma/halma_map1", false);
  77. minigame.addSign("halmasign2", true, loc.new(gamesworld, -414, 156, -40), "minigames/halma/halma", "minigames/halma/halma_map2", false);
  78. minigame.addSign("rebuildsign1", true, loc.new(gamesworld, -405, 158, -75), "minigames/rebuild/rebuild", "minigames/rebuild/rebuildmap1", false);
  79. minigame.addSign("rebuildsign2", true, loc.new(gamesworld, -404, 158, -75), "minigames/rebuild/rebuild", "minigames/rebuild/rebuildmap2", false);
  80. minigame.addSign("hideandseeksign1", true, loc.new(gamesworld, -413, 158, -40), "minigames/hideandseek/hideandseek", "minigames/hideandseek/hideandseekmap1", false);
  81. minigame.addSign("hideandseeksign2", true, loc.new(gamesworld, -414, 158, -40), "minigames/hideandseek/hideandseek", "minigames/hideandseek/hideandseekmap2", false);
  82. minigame.addSign("shoppingsign1", true, loc.new(gamesworld, -415, 158, -40), "minigames/shoppingchaos/shoppingchaos", "minigames/shoppingchaos/shopping_map1", false);
  83. minigame.addSign("mengersign1", true, loc.new(gamesworld, -405, 157, -75), "minigames/mengerrun/mengerrun", "minigames/mengerrun/menger_map1", false);
  84. minigame.addSign("leapfrogsign1", true, loc.new(gamesworld, -399, 157, -65), "minigames/leapfrog/leapfrog", "minigames/leapfrog/leapfrogmap1", true);
  85. minigame.addSign("snowsign1", true, loc.new(gamesworld, -419, 158, -40), "minigames/snowgame/snowgame", "minigames/snowgame/snowmap1", false);
  86. minigame.addSign("snowsign2", true, loc.new(gamesworld, -420, 158, -40), "minigames/snowgame/snowgame", "minigames/snowgame/snowmap2", false);
  87. //minigame.addSign("damesign1", false, loc.new(gamesworld, -411, 158, -44), "minigames/dame/dame", "minigames/dame/dame_map1", false);
  88. minigame.addSign("among_us_sign1", true, loc.new(gamesworld, -417, 157, -41), "minigames/among_us/among_us", "minigames/among_us/among_us_map1", false);
  89. setScriptVar("gamesigns", gamesignsmap);
  90. games_inv = inv.new("333333333333333333333333333");
  91. minigame.addCompass(0, read.item("minecraft:red_bed", 1, "§fBedWars"), loc.new(gamesworld, -420.5, 156, -41.5, 90, 0.0001));
  92. minigame.addCompass(1, read.item("minecraft:iron_axe", 1, "§fRageMode"), loc.new(gamesworld, -412.5, 156, -43.5, -90, 0.0001));
  93. minigame.addCompass(2, read.item("minecraft:snowball", 1, "§fSnowgame"), loc.new(gamesworld, -418.5, 156, -41.5, 0.0001, -20));
  94. minigame.addCompass(3, read.item("minecraft:diamond_block", 1, "§fHide and Seek"), loc.new(gamesworld, -412.5, 156, -41.5, 0.0001, -20));
  95. minigame.addCompass(4, read.item("minecraft:emerald", 1, "§fShoppingChaos"), loc.new(gamesworld, -414.5, 156, -41.5, 0.0001, -20));
  96. minigame.addCompass(5, read.item("minecraft:light_blue_terracotta", 1, "§fFastBridge"), loc.new(gamesworld, -412.5, 156, -41.5, 0.0001, 0.0001));
  97. minigame.addCompass(6, read.item("minecraft:blue_banner", 1, "§fHalma"), loc.new(gamesworld, -412.5, 156, -41.5, 0.0001, 25));
  98. minigame.addCompass(7, read.item("km:bronze_dagger", 1, "§fAmong Us"), loc.new(gamesworld, -416.5, 156, -42.5, 0.0001, 0.0001));
  99. minigame.addCompass(8, read.item("minecraft:grass_block", 1, "§fSammelfieber"), loc.new(gamesworld, -397.5, 156, -48.5, 0.0001, 0.0001));
  100. minigame.addCompass(9, read.item("minecraft:slime_block", 1, "§fJ&R / Parcour"), loc.new(gamesworld, -397.5, 156, -50.5, -90, 0.0001));
  101. minigame.addCompass(10, read.item("minecraft:lapis_block", 1, "§fInverting"), loc.new(gamesworld, -397.5, 156, -56.5, -90, 0.0001));
  102. minigame.addCompass(11, read.item("minecraft:oak_sign", 1, "§fLetters"), loc.new(gamesworld, -397.5, 156, -62.5, -90, -20));
  103. minigame.addCompass(12, read.item("minecraft:oak_button", 1, "§fButtons"), loc.new(gamesworld, -398.5, 156, -62.5, 180, -20));
  104. minigame.addCompass(13, read.item("minecraft:redstone_torch", 1, "§fLeapfrog"), loc.new(gamesworld, -398.5, 156, -62.5, 180, 0.0001));
  105. minigame.addCompass(14, read.item("minecraft:stick", 1, "§fKnockfight"), loc.new(gamesworld, -418.5, 156, -41.5, 0.0001, 0.0001));
  106. minigame.addCompass(15, read.item("minecraft:diamond_shovel", 1, "§fSpleef"), loc.new(gamesworld, -418.5, 156, -41.5, 0.0001, 25));
  107. iter = map.iterator(gamemappaths);
  108. while(hasNext(iter)) {
  109. entry = next(iter);
  110. gamesignloc = map.getKey(entry);
  111. facing = block.property.getValue(gamesignloc, facing_property);
  112. if(facing == "north") {
  113. ground_block = loc.mod(gamesignloc, 0, 0, 1);
  114. } elseif(facing == "east") {
  115. ground_block = loc.mod(gamesignloc, -1, 0, 0);
  116. } elseif(facing == "south") {
  117. ground_block = loc.mod(gamesignloc, 0, 0, -1);
  118. } elseif(facing == "west") {
  119. ground_block = loc.mod(gamesignloc, 1, 0, 0);
  120. }
  121. set.add(gamesign_ground_block, ground_block);
  122. if(map.get(openedgames, gamesignloc)) {
  123. if(!sign.ready(gamesignloc)) {
  124. snuvi.debug(concat("No Sign: ", text.location(gamesignloc)));
  125. }
  126. } else {
  127. if(!sign.closed(gamesignloc)) {
  128. snuvi.debug(concat("No Sign: ", text.location(gamesignloc)));
  129. }
  130. }
  131. }
  132. msg("dev", "§bGamecenter §rloaded.");
  133. @wait
  134. wait();
  135. ignoreGoto(event);
  136. goto("wait");
  137. @item_air_click
  138. item = living.getEquip(player, "hand");
  139. if(item.getType(item) == "km:cross_red") {
  140. cancel = true;
  141. goto("wait");
  142. }
  143. if(item.getType(item) == "minecraft:compass") {
  144. player_loc = entity.getLocation(player);
  145. if(loc.isInGamesWorld(player_loc)) {
  146. if(!player.hasMinigame(player)) {
  147. inv.open(games_inv, player, "Minigames");
  148. }
  149. }
  150. }
  151. goto("wait");
  152. @inv_click
  153. if(inv_name == "Minigames") {
  154. if(item.getType(item) == "minecraft:air") {
  155. goto("wait");
  156. }
  157. loc = list.getIndex(compass_loc_list, inv_slot);
  158. entity.teleport(player, loc);
  159. }
  160. goto("wait");
  161. @player_move
  162. if(id == move_id_to_spawn) {
  163. player.setBackPosLoc(player, world.getGamesSpawn());
  164. player.teleport(player, world.getServerSpawn(), false);
  165. }
  166. goto("wait");
  167. @term_script
  168. map.remove(script_ids, getScriptVar("sign_loc"));
  169. goto("wait");
  170. @custom_command
  171. if(player == null) {
  172. goto("wait");
  173. }
  174. if(!perm.has(player, command)) {
  175. goto("wait");
  176. }
  177. size = list.getSize(args);
  178. if(command == "game") {
  179. if(size != 1) {
  180. msg(player, "§6/game §r<open/close>");
  181. } else {
  182. arg0 = list.getIndex(args, 0);
  183. block_loc = player.getTarget(player, 5, false, false);
  184. if(!block.hasTag(sign_tag, block.get(block_loc))) {
  185. msg.prefix(player, "§6Games", "Look at a sign.");
  186. goto("wait");
  187. }
  188. if(arg0 == "open") {
  189. sign.ready(block_loc);
  190. map.add(openedgames, block_loc, true);
  191. } elseif(arg0 == "close") {
  192. sign.closed(block_loc);
  193. map.add(openedgames, block_loc, false);
  194. } else {
  195. msg(player, "§6/game §r<open/close>");
  196. }
  197. }
  198. }
  199. goto("wait");
  200. @entity_click
  201. if(hand == "OFF_HAND") {
  202. goto("wait");
  203. }
  204. if(loc.distance(marv_loc, entity.getLocation(player)) < 3) {
  205. msg.prefix(player, "§cGamerMarv", "Help! I'm being held here against my will!");
  206. }
  207. goto("wait");
  208. @block_break
  209. if(set.contains(gamesign_ground_block, block_loc) || map.contains(gamepaths, block_loc)) {
  210. cancel = true;
  211. msg.prefix(player, "§6Games", "You can´t break this block.");
  212. goto("wait");
  213. }
  214. goto("wait");
  215. @block_click
  216. item = living.getEquip(player, "hand");
  217. if(item.getType(item) == "km:cross_red") {
  218. cancel = true;
  219. }
  220. if(hand == "OFF_HAND") {
  221. goto("wait");
  222. }
  223. if(action == "left" && set.contains(block_click_catcher, player)) {
  224. set.remove(block_click_catcher, player);
  225. goto("wait");
  226. } else {
  227. set.add(block_click_catcher, player);
  228. }
  229. if(block_loc == dice_loc || block_loc == dice_loc_rm5) {
  230. now_time = time.getMillis();
  231. if(now_time - dice_time < 1000) {
  232. goto("wait");
  233. }
  234. dice_time = now_time;
  235. if(player.getName(player) == "ssiooo") {
  236. message = concat(player.getName(player), " has rolled a 6, cause he is the Oberf*****.");
  237. } else {
  238. message = concat(player.getName(player), " has rolled a ", text.number(math.random(1, 6)), ".");
  239. }
  240. msg.radius("§6Dice", message, block_loc, 20);
  241. goto("wait");
  242. }
  243. if(!block.hasTag(sign_tag, block.get(block_loc))) {
  244. goto("wait");
  245. }
  246. if(!map.contains(gamemappaths, block_loc)) {
  247. goto("wait");
  248. }
  249. cancel = true;
  250. if(!map.get(openedgames, block_loc)) {
  251. msg.prefix(player, "§6Games", "Closed game.");
  252. goto("wait");
  253. }
  254. if(minigame.isStarted(block_loc)) {
  255. script_id = map.get(script_ids, block_loc);
  256. if(script_id == null) {
  257. goto("error_on_gamejoin");
  258. }
  259. script = script.getFromId(script_id);
  260. if(script == null) {
  261. goto("error_on_gamejoin");
  262. }
  263. msg.prefix(player, "§6Games", "Could not enter.");
  264. goto("wait");
  265. }
  266. //Start/Get Script
  267. @startnewgame
  268. if(player.hasMinigame(player)) {
  269. //prevent double game join
  270. goto("wait");
  271. }
  272. pfad = map.get(gamemappaths, block_loc);
  273. pfad2 = map.get(gamepaths, block_loc);
  274. script_id = map.get(script_ids, block_loc);
  275. if(script_id == null) {
  276. if(pfad2 != null) {
  277. if(pfad2 == "minigames/sammelfieber/sammelfieber" || pfad2 == "minigames/sammelfieber/sfranked") {
  278. script = script.start(pfad, "minigames/sammelfieber/sammelfieberitems", pfad2, "utils/u_games", "utils/u_general");
  279. } else {
  280. script = script.start(pfad, pfad2, "utils/u_games", "utils/u_general");
  281. }
  282. } else {
  283. script = script.start(pfad, "utils/u_games", "utils/u_general");
  284. }
  285. if(script == null) {
  286. snuvi.debug("Minigame throws error on gamestart");
  287. goto("wait");
  288. }
  289. map.add(script_ids, block_loc, script.getId(script));
  290. } else {
  291. script = script.getFromId(script_id);
  292. }
  293. if(script == null) {
  294. goto("error_on_gamejoin");
  295. }
  296. //Add player to script
  297. script_id = script.getId(script);
  298. maxplayers = script.getVar(script, "maxplayers");
  299. script.setVar(script, "script_id", script_id);
  300. if(player.isInParty(player)) {
  301. if(player.isPartyLeader(player)) {
  302. if(set.contains(singleplayergames, block_loc)) {
  303. minigame.singleJoin(script, player);
  304. goto("wait");
  305. }
  306. party_list = party.getList(player.getPartyId(player));
  307. party_size = list.getSize(party_list);
  308. if(party_size > maxplayers) {
  309. msg.prefix(player, prefix_party, "Not enough space.");
  310. goto("wait");
  311. }
  312. minigame.partyJoin(script, player, party_list);
  313. goto("wait");
  314. }
  315. msg.prefix(player, prefix_party, "§cAttention! You are not the leader.");
  316. }
  317. minigame.singleJoin(script, player);
  318. goto("wait");
  319. @error_on_gamejoin
  320. snuvi.debug(concat("Started gamesign existing without game behind ", script_id, " ", block_loc));
  321. map.remove(script_ids, block_loc);
  322. goto("startnewgame");
  323. @player_login
  324. player_loc = entity.getLocation(player);
  325. if(loc.isInGamesWorld(player_loc)) {
  326. resetplayer(player);
  327. entity.teleport(player, world.getGamesSpawn());
  328. }
  329. goto("wait");
  330. @living_pre_hurt
  331. if(!isPlayer(living_entity)) {
  332. goto("wait");
  333. }
  334. player = living_entity;
  335. player_loc = entity.getLocation(player);
  336. if(!loc.isInGamesWorld(player_loc)) {
  337. goto("wait");
  338. }
  339. plot_id = plot.getIdFromLocation(player_loc);
  340. if(plot_id == 32 || plot_id == 106) {
  341. living.setHealth(player, 20);
  342. player.setHunger(player, 20);
  343. player.setSaturation(player, 5);
  344. cancel = true;
  345. }
  346. goto("wait");
  347. @player_pre_respawn
  348. if(loc.isInGamesWorld(entity.getLocation(player))) {
  349. if(!player.hasMinigame(player)) {
  350. set.add(games_respawn, player.getUuid(player));
  351. }
  352. }
  353. goto("wait");
  354. @player_post_respawn
  355. player_uuid = player.getUuid(player);
  356. if(set.contains(games_respawn, player_uuid)) {
  357. set.remove(games_respawn, player_uuid);
  358. entity.teleport(player, world.getGamesSpawn());
  359. }
  360. goto("wait");
  361. function minigame.addCompass(index, item, location) {
  362. list.add($compass_loc_list, location);
  363. item.hide(item, "attributes");
  364. inv.setItem($games_inv, index, item);
  365. }
  366. function minigame.addSign(map_string, opened, sign_loc, core_path, map_path, singleplayer) {
  367. map.add($gamesignsmap, map_string, sign_loc);
  368. map.add($openedgames, sign_loc, opened);
  369. map.add($gamepaths, sign_loc, core_path);
  370. map.add($gamemappaths, sign_loc, map_path);
  371. if(singleplayer) {
  372. set.add($singleplayergames, sign_loc);
  373. }
  374. }
  375. function minigame.joinPlayer(script, player) {
  376. id_set = player.getMinigameIds(player);
  377. player_uuid = player.getUuid(player);
  378. //Sicherheits-Handling 1
  379. if(player.hasMinigame(player)) {
  380. iter = set.iterator(id_set);
  381. while(hasNext(iter)) {
  382. s_id = next(iter);
  383. s = script.getFromId(s_id);
  384. if(s != null) {
  385. list.remove(minigame.getPlayers(s_id), player_uuid);
  386. }
  387. }
  388. set.clear(id_set);
  389. }
  390. minigame.setLastPos(player);
  391. script_id = script.getId(script);
  392. //Script-ID dem Set des Spielers hinzufügen
  393. set.add(id_set, script_id);
  394. //Spieler-UUID der Spielerliste des Scripts hinzufügen
  395. player_list = minigame.getPlayers(script_id);
  396. if(!list.contains(player_list, player_uuid)) { //Sicherheits-Handling 2
  397. list.add(player_list, player.getUuid(player));
  398. }
  399. stacks.setActive(player, false);
  400. //Event player_join
  401. script.setVar(script, "player", player);
  402. script.callEvent("player_join", script);
  403. sign.players($block_loc, list.getSize(player_list), $maxplayers);
  404. }
  405. function minigame.singleJoin(script, player) {
  406. player_list = minigame.getPlayers(script.getId(script));
  407. if(list.getSize(player_list) >= $maxplayers) {
  408. msg.prefix(player, "§6Games", "Not enough space.");
  409. return;
  410. }
  411. minigame.joinPlayer(script, player);
  412. }
  413. function minigame.partyJoin(script, party_leader, party_list) {
  414. minigame.joinPlayer(script, party_leader); //Party-Leader soll der 1.Spieler sein, der joint
  415. party_leader_uuid = player.getUuid(party_leader);
  416. iter = list.iterator(party_list);
  417. while(hasNext(iter)) {
  418. p_uuid = next(iter);
  419. if(p_uuid == party_leader_uuid) {
  420. continue;
  421. }
  422. p = player.get(p_uuid);
  423. p_name = player.getName(p);
  424. if(!loc.isInGamesWorld(entity.getLocation(p))) {
  425. msg.prefix(party_leader, $prefix_party, concat(p_name, "§c is not in the world 'games'."));
  426. continue;
  427. }
  428. if(player.hasMinigame(p)) {
  429. msg.prefix(party_leader, $prefix_party, concat(p_name, "§c is in another game."));
  430. continue;
  431. }
  432. if(player.isAfk(p)) {
  433. msg.prefix(party_leader, $prefix_party, concat(p_name, "§c is afk."));
  434. continue;
  435. }
  436. sign.ready($block_loc);
  437. minigame.joinPlayer(script, p);
  438. }
  439. }