survival.txt 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052
  1. event.load("entity_click");
  2. event.load("container_click");
  3. event.load("inv_click");
  4. event.load("player_pre_respawn");
  5. event.load("player_post_respawn");
  6. event.load("player_login");
  7. event.load("player_move");
  8. event.load("block_break");
  9. event.load("block_click");
  10. event.load("living_death");
  11. event.load("living_pre_hurt");
  12. event.load("pre_explosion");
  13. event.load("mob_griefing");
  14. event.load("item_air_click");
  15. event.load("projectile_hit");
  16. setScriptVar("skills", list.new());
  17. skill.add("Keep Inventory", "skill.subcu_inv", "minecraft:chest", "Keeps the inventory on death", 100, false, false, true);
  18. skill.add("Comeback", "skill.comeback", "km:skill55", "Respawn at your death location", 100, false, false, true);
  19. skill.add("Head Hunter", "skill.head_human", "minecraft:player_head", "Drops a player's head with a 20% chance if you kill a player (5% if a staff member is killed)", 1000, true, false, false);
  20. skill.add("Mobheads", "skill.head_monster", "minecraft:zombie_head", "Drops a mobs's head with a 20% chance (zombie / skeleton / creeper)", 500, true, false, false);
  21. skill.add("Fly 10min", "skill.fly10min", "minecraft:elytra", "You can fly for 10 minutes", 500, false, true, false);
  22. skill.add("Grow", "skill.grow", "minecraft:farmland", "Grow seeds in radius 5", 25, false, true, false);
  23. skill.add("Haste", "skill.haste", "minecraft:iron_pickaxe", "Haste for 2 minutes", 25, false, true, false);
  24. skill.add("Speed", "skill.speed", "minecraft:iron_boots", "Speed for 2 minutes", 25, false, true, false);
  25. skill.add("Jump Boost", "skill.jump_boost", "minecraft:rabbit_foot", "JumpBoost Lvl.2 for 2 minutes", 25, false, true, false);
  26. skill.add("Dolphin", "skill.dolphin", "minecraft:fire_coral", "Swim like a dolphin for a minute", 25, false, true, false);
  27. skill.add("Block Up", "skill.block_up", "minecraft:diamond_pickaxe", "Break a block and the block above for a minute", 25, false, true, false);
  28. skill.add("Block Down", "skill.block_down", "minecraft:diamond_pickaxe", "Break a block and the block below for a minute", 25, false, true, false);
  29. skill.add("Timber", "skill.timber", "minecraft:iron_axe", "Break whole trees with an axe for a minute", 128, false, true, false);
  30. skill.add("Fire Arrow", "skill.fire_arrow", "minecraft:arrow", "For a minute with an flame enchanted bow your arrows ignite hit blocks", 50, false, true, false);
  31. skill.add("Better Shears", "skill.better_shears", "minecraft:shears", "Sharpness enchanted shears increase the radius for destruction of leaves", 500, true, false, true);
  32. skill.add("Cobweb Miner", "skill.cobweb_miner", "minecraft:cobweb", "Swords increase the radius for destruction of cobwebs", 250, true, false, true);
  33. clan.loadData();
  34. tp_list = list.new();
  35. tp_map = map.new();
  36. tp_set = set.new();
  37. afk_loop_map = map.new();
  38. death_loc_map = map.new();
  39. survival_respawn = set.new();
  40. overworld = world.getOverWorld();
  41. moveid_storyspawn = event.addMoveData(loc.new(overworld, 167, 70, 241), loc.new(overworld, 169, 72, 243), 5, -1);
  42. moveid_gamesspawn = event.addMoveData(loc.new(overworld, 219, 66, 253), loc.new(overworld, 223, 69, 258), 5, -1);
  43. move_id_afk_loop = event.addMoveData(loc.new(overworld, 208, 69, 226), loc.new(overworld, 209, 69.5, 227), 5, -1);
  44. move_id_afk_loop_2 = event.addMoveData(loc.new(overworld, 208, 62, 242), loc.new(overworld, 209, 62.5, 243), 5, -1);
  45. move_id_afk_loop_3 = event.addMoveData(loc.new(overworld, 210, 62, 242), loc.new(overworld, 211, 62.5, 243), 5, -1);
  46. move_id_afk_loop_4 = event.addMoveData(loc.new(overworld, 206, 62, 246), loc.new(overworld, 207, 62.5, 247), 5, -1);
  47. move_id_afk_loop_5 = event.addMoveData(loc.new(overworld, 212, 62, 246), loc.new(overworld, 213, 62.5, 247), 5, -1);
  48. afk_loop_ids = set.new();
  49. set.add(afk_loop_ids, move_id_afk_loop);
  50. set.add(afk_loop_ids, move_id_afk_loop_2);
  51. set.add(afk_loop_ids, move_id_afk_loop_3);
  52. set.add(afk_loop_ids, move_id_afk_loop_4);
  53. set.add(afk_loop_ids, move_id_afk_loop_5);
  54. config = getScriptVar("server_config");
  55. survival_spawn = read.location(config.getString(config, "surv_spawn", "games:0:0:0"));
  56. adventure_chest_loc = loc.new(overworld, 177, 74, 237);
  57. adventure_aim_loc = loc.new(overworld, 180, 70, 241);
  58. lottery_loc_1 = loc.new(overworld, 186, 69, 227);
  59. lottery_loc_2 = loc.new(overworld, 186, 69, 223);
  60. gambler_loc = loc.new(overworld, 185, 68, 225);
  61. prefix_money = "§2Money";
  62. prefix_skill = "§2Skill";
  63. sword_tag = item.getTag("km:sword");
  64. dye_tag = item.getTag("km:dye");
  65. leaves_tag = block.getTag("minecraft:leaves");
  66. sign_tag = block.getTag("minecraft:signs");
  67. prop_persistent = block.getProperty("persistent");
  68. ench_flame = enchantment.get("flame");
  69. ench_unbreaking = enchantment.get("unbreaking");
  70. ench_sharpness = enchantment.get("sharpness");
  71. piston_sound = sound.get("block.piston.extend");
  72. adv_tp_sound = sound.get("block.portal.travel");
  73. sound_category_ambient = sound.getCategory("ambient");
  74. gambler_inv = inv.new("020202020");
  75. gambler_inv_id = inv.getId(gambler_inv);
  76. inv.setItem(gambler_inv, 0, read.item("km:coin_copper", 1, "§f1 snuvi"));
  77. inv.setItem(gambler_inv, 1, read.item("km:coin_silver", 1, "§f64 snuvis"));
  78. inv.setItem(gambler_inv, 2, read.item("km:coin_gold", 1, "§f4096 snuvis"));
  79. inv.setItem(gambler_inv, 3, read.item("minecraft:netherite_block", 1, "§fAll in"));
  80. //bankmenu = inv.new("233302332233302332");
  81. bankmenu = inv.new("233330000233330000000000000233200000233200000");
  82. //bankmenu = inv.new("233330000 233330000 000000000 233200000 233200000");
  83. bankinvid = inv.getId(bankmenu);
  84. coin_gold = read.item("km:coin_gold");
  85. coin_silver = read.item("km:coin_silver");
  86. coin_copper = read.item("km:coin_copper");
  87. coin_silver64 = read.item("km:coin_silver", 64);
  88. coin_copper64 = read.item("km:coin_copper", 64);
  89. arrow_left = read.item("km:arrow_left", 1, "§fchange to");
  90. arrow_right = read.item("km:arrow_right", 1, "§fchange to");
  91. inv.setItem(bankmenu, 0, read.item("km:plus_green", 1, "§fDeposit..."));
  92. inv.setItem(bankmenu, 1, read.item("km:coin_copper", 1, "§f1 snuvi"));
  93. inv.setItem(bankmenu, 2, read.item("km:coin_silver", 1, "§f64 snuvis"));
  94. inv.setItem(bankmenu, 3, read.item("km:coin_gold", 1, "§f4096 snuvis"));
  95. inv.setItem(bankmenu, 4, read.item("minecraft:netherite_block", 1, "§fAll snuvis"));
  96. inv.setItem(bankmenu, 5, read.item("km:minus_red", 1, "§fWithdraw..."));
  97. inv.setItem(bankmenu, 6, read.item("km:coin_copper", 1, "§f1 snuvi"));
  98. inv.setItem(bankmenu, 7, read.item("km:coin_silver", 1, "§f64 snuvis"));
  99. inv.setItem(bankmenu, 8, read.item("km:coin_gold", 1, "§f4096 snuvis"));
  100. inv.setItem(bankmenu, 9, read.item("minecraft:netherite_block", 1, "§fAll snuvis"));
  101. inv.setItem(bankmenu, 10, read.item("km:coin_copper", 64, "§f64 snuvis"));
  102. inv.setItem(bankmenu, 11, arrow_left);
  103. inv.setItem(bankmenu, 12, arrow_right);
  104. inv.setItem(bankmenu, 13, read.item("km:coin_silver", 1, "§f64 snuvis"));
  105. inv.setItem(bankmenu, 14, read.item("km:coin_silver", 64, "§f4096 snuvis"));
  106. inv.setItem(bankmenu, 15, arrow_left);
  107. inv.setItem(bankmenu, 16, arrow_right);
  108. inv.setItem(bankmenu, 17, read.item("km:coin_gold", 1, "§f4096 snuvis"));
  109. msg("dev", "§bSurvival §rloaded.");
  110. @wait
  111. wait();
  112. if(event == "player_move") {
  113. if(id == moveid_storyspawn) {
  114. player.setBackPosLoc(player, world.getServerSpawn());
  115. player.teleport(player, world.getStorySpawn(), false);
  116. goto("wait");
  117. }
  118. if(id == moveid_gamesspawn) {
  119. player.setBackPosLoc(player, world.getServerSpawn());
  120. player.teleport(player, world.getGamesSpawn(), false);
  121. goto("wait");
  122. }
  123. if(set.contains(afk_loop_ids, id)) {
  124. player_uuid = player.getUuid(player);
  125. now_time = time.getMillis();
  126. time = map.getOrDefault(afk_loop_map, player_uuid, 0);
  127. if(now_time - time > 9000) { //9 Sekunden
  128. map.add(afk_loop_map, player_uuid, now_time);
  129. money.addBoost(player, 1);
  130. }
  131. goto("wait");
  132. }
  133. goto("wait");
  134. }
  135. //Wenn Event aus Survival-Welten, dann wird er verarbeitet
  136. if(event == "living_death" || event == "living_pre_hurt") {
  137. loc = entity.getLocation(living_entity);
  138. } elseif(event == "pre_explosion") {
  139. loc = location;
  140. } elseif(event == "mob_griefing") {
  141. if(entity == null) {
  142. goto("wait");
  143. }
  144. loc = entity.getLocation(entity);
  145. } else {
  146. loc = entity.getLocation(player);
  147. }
  148. world_name = world.getName(loc.getWorld(loc));
  149. if(world.isSurvName(world_name)) {
  150. ignoreGoto(event);
  151. }
  152. goto("wait");
  153. @item_air_click
  154. player_loc = entity.getLocation(player);
  155. world = loc.getWorld(player_loc);
  156. if(world.getName(world) != "overworld") {
  157. goto("wait");
  158. }
  159. item = living.getEquip(player, "hand");
  160. if(item.getType(item) != "minecraft:clock") {
  161. goto("wait");
  162. }
  163. time = world.getTime(world);
  164. time_h = math.roundDown(time/1000) + 6;
  165. while(time_h >= 24) {
  166. time_h -= 24;
  167. }
  168. //m min = t ticks * 60m / 1000 ticks
  169. time_m = time%1000;
  170. time_m = math.roundDown(time_m * 60 / 1000);
  171. if(time_m < 10) {
  172. time_m = concat("0", text.number(time_m));
  173. } else {
  174. time_m = text.number(time_m);
  175. }
  176. msg.prefix(player, "§eClock", concat(text.number(time_h), ":", time_m));
  177. goto("wait");
  178. @mob_griefing
  179. if(entity.getType(entity) == "enderman") {
  180. cancel = true;
  181. }
  182. goto("wait");
  183. @pre_explosion
  184. plot_list = plot.get(location);
  185. for(i = 0; i < list.getSize(plot_list); i++) {
  186. plot = list.getIndex(plot_list, i);
  187. if(plot.isExplosive(plot)) {
  188. cancel = false;
  189. }
  190. }
  191. //Kein Grundstück existiert
  192. if(i == 0) {
  193. cancel = false;
  194. }
  195. goto("wait");
  196. @living_pre_hurt
  197. if(!isPlayer(living_entity)) {
  198. damager = player.getFromDamageSource(damage_source);
  199. if(!isPlayer(damager)) {
  200. goto("wait");
  201. }
  202. pet_type = entity.getType(living_entity);
  203. if(pet_type == "wolf" || pet_type == "cat" || pet_type == "parrot" || pet_type == "horse") {
  204. if(pet.isTamed(living_entity)) {
  205. owner_uuid = pet.getOwner(living_entity);
  206. if(owner_uuid == player.getUuid(damager)) {
  207. if(player.getNoPetDamage(damager)) {
  208. cancel = true;
  209. }
  210. }
  211. }
  212. }
  213. goto("wait");
  214. }
  215. player = living_entity;
  216. damager = player.getFromDamageSource(damage_source);
  217. if(!isPlayer(damager)) {
  218. player_loc = entity.getLocation(player);
  219. if(loc.hasPlotId(player_loc, 128) && damage.getType(damage_source) == "fall") {
  220. cancel = true;
  221. }
  222. goto("wait");
  223. }
  224. if(player == damager) {
  225. goto("wait");
  226. }
  227. if(!hasPvpOn(damager)) {
  228. cancel = true;
  229. msg.prefix(damager, "§5PvP", "You have PvP disabled.");
  230. goto("wait");
  231. }
  232. if(!hasPvpOn(player)) {
  233. cancel = true;
  234. msg.prefix(damager, "§5PvP", concat(player.getName(player), " has PvP disabled."));
  235. goto("wait");
  236. }
  237. goto("wait");
  238. @entity_click
  239. if(hand == "OFF_HAND") {
  240. goto("wait");
  241. }
  242. if(entity.getType(entity) == "human") {
  243. entity_name = entity.getName(entity);
  244. if(entity_name == "Administrator\n§cmarvinius") {
  245. item = living.getHand(player);
  246. item_name = item.getName(item);
  247. if(removeFormat(item_name) == "Beer") {
  248. msg.prefix(player, "§cmarvinius", "Prost!");
  249. }
  250. goto("wait");
  251. }
  252. if(entity_name == "Administrator\n§cMentorMentos") {
  253. item = living.getHand(player);
  254. item_name = item.getName(item);
  255. if(removeFormat(item_name) == "Beer") {
  256. msg.prefix(player, "§cMentorMentos", "Folg mir auf Twitch! ");
  257. msg(player, text.link("Klick mich an :D","https://www.twitch.tv/Mentor_Mentos"));
  258. }
  259. goto("wait");
  260. }
  261. if(entity_name == "Info-Point") {
  262. msg(player, getSpacer());
  263. msg(player, text.click("§r [§cclick§r] [§eSurvival§r]", "/infopoint1"));
  264. msg(player, text.click("§r [§cclick§r] [§eAdventure§r]", "/infopoint2"));
  265. msg(player, text.click("§r [§cclick§r] [§ePlots§r]", "/infopoint3"));
  266. msg(player, text.click("§r [§cclick§r] [§eClans§r]", "/infopoint4"));
  267. msg(player, text.click("§r [§cclick§r] [§eCities§r]", "/infopoint5"));
  268. msg(player, text.click("§r [§cclick§r] [§eShops§r]", "/infopoint6"));
  269. msg(player, text.click("§r [§cclick§r] [§eMinigames§r]", "/infopoint7"), " ", text.click("§f[§bTeleport§f]", "/games"));
  270. msg(player, text.click("§r [§cclick§r] [§eQuests§r]", "/infopoint8"), " ", text.click("§f[§bTeleport§f]", "/story"));
  271. msg(player, text.click("§r [§cclick§r] [§eCreative§r]", "/infopoint12"), " ", text.click("§f[§bTeleport§f]", "/creative"));
  272. msg(player, text.click("§r [§cclick§r] [§eRanking§r]", "/infopoint9"), " ", text.link("§f[§bRanks§f]", "https://minecraft.hammerle.me/?site=ranks"));
  273. msg(player, text.click("§r [§cclick§r] [§eRules§r]", "/infopoint10"), " ", text.link("§f[§bFake Rules§f]", "https://minecraft.hammerle.me/?site=rules"));
  274. msg(player, text.click("§r [§cclick§r] [§eNote§r]", "/infopoint11"));
  275. goto("wait");
  276. }
  277. if(entity_name == "Banker") {
  278. inv.open(bankmenu, player, "Banker");
  279. goto("wait");
  280. }
  281. if(entity_name == "Adventure") {
  282. if(!player.isOnAdventure(player)) {
  283. msg.prefix(player, "§5Adventure", "You aren't on an adventure. Click the chest in the teleporter to start an adventure.");
  284. goto("wait");
  285. }
  286. player.setAdventure(player, false);
  287. adventures = player.getAdventureAmounts(player);
  288. if(adventures == null) {
  289. adventures = 0;
  290. }
  291. player.setAdventureAmounts(player, ++adventures);
  292. msg.prefix(player, "§5Adventure", "Congratulations, you finished your adventure, here ist your reward!");
  293. if(adventures == 10) {
  294. offerRank(player, "rank.pioneer");
  295. } elseif(adventures == 5) {
  296. offerRank(player, "rank.explorer");
  297. } elseif(adventures == 1) {
  298. offerRank(player, "rank.adventurer");
  299. }
  300. removeAdventureDisplay(player);
  301. money.addBoost(player, 8192);
  302. goto("wait");
  303. }
  304. }
  305. goto("wait");
  306. @player_login
  307. if(player.isOnAdventure(player)) {
  308. addAdventureDisplay(player, adventure_aim_loc);
  309. }
  310. goto("wait");
  311. @container_click
  312. //Verhindert während eines (Abenteuer-)Teleports, die Benutzung des Spielerinventars (inkl. Crafting-Bereich!)
  313. player_uuid = player.getUuid(player);
  314. if(set.contains(tp_set, player_uuid)) {
  315. cancel = true;
  316. }
  317. goto("wait");
  318. @inv_click
  319. if(inv_id == bankinvid) { //Bankmenü
  320. factor = 1;
  321. if(click_type == "QUICK_MOVE") {
  322. factor = 8;
  323. }
  324. gold_inv = player.getItemAmount(player, false, coin_gold);
  325. silver_inv = player.getItemAmount(player, false, coin_silver);
  326. copper_inv = player.getItemAmount(player, false, coin_copper);
  327. //Wechseln
  328. if(inv_slot == 11 || inv_slot == 12 || inv_slot == 15 || inv_slot == 16) {
  329. if(inv_slot == 11) {
  330. //1 Silbermünze --> 64 Kupfermünzen
  331. item1 = coin_silver;
  332. item2 = coin_copper64;
  333. message = "No silvercoin in inventory.";
  334. item_type = "km:coin_copper";
  335. coin_inv = silver_inv;
  336. }
  337. elseif(inv_slot == 12) {
  338. //64 Kupfermünzen --> 1 Silbermünze
  339. item1 = coin_copper64;
  340. item2 = coin_silver;
  341. message = "Not enough coppercoins in inventory.";
  342. item_type = "km:coin_silver";
  343. coin_inv = copper_inv;
  344. }
  345. elseif(inv_slot == 15) {
  346. //1 Goldmünze --> 64 Silbermünzen
  347. item1 = coin_gold;
  348. item2 = coin_silver64;
  349. message = "No goldcoin in inventory.";
  350. item_type = "km:coin_silver";
  351. coin_inv = gold_inv;
  352. }
  353. elseif(inv_slot == 16) {
  354. //64 Silbermünzen --> 1 Goldmünze
  355. item1 = coin_silver64;
  356. item2 = coin_gold;
  357. message = "Not enough silvercoins in inventory.";
  358. item_type = "km:coin_gold";
  359. coin_inv = silver_inv;
  360. }
  361. item_1 = item.clone(item1);
  362. item.setAmount(item_1, item.getAmount(item_1) * factor);
  363. item_2 = item.clone(item2);
  364. item.setAmount(item_2, item.getAmount(item_2) * factor);
  365. amount1 = item.getAmount(item_1);
  366. amount2 = item.getAmount(item_2);
  367. if(coin_inv * factor < amount1) {
  368. msg.prefix(player, prefix_money, message);
  369. goto("wait");
  370. }
  371. player.removeItemNbt(player, item_1);
  372. notgiven = player.giveItem(player, item_2);
  373. if(item.getType(notgiven) != "minecraft:air") {
  374. amount = item.getAmount(notgiven);
  375. player.removeItemNbt(player, read.item(item_type, amount2 - amount));
  376. player.giveItem(player, item_1);
  377. msg.prefix(player, prefix_money, "Not enough space in inventory.");
  378. goto("wait");
  379. }
  380. inv.update(player);
  381. msg.prefix(player, prefix_money, "Exchange succesfull.");
  382. goto("wait");
  383. }
  384. //Kontobewegungen
  385. if(inv_slot == 1 || inv_slot == 6) {
  386. betrag = 1 * factor;
  387. coin_inv = copper_inv;
  388. }
  389. elseif(inv_slot == 2 || inv_slot == 7) {
  390. betrag = 64 * factor;
  391. coin_inv = silver_inv;
  392. }
  393. elseif(inv_slot == 3 || inv_slot == 8) {
  394. betrag = 4096 * factor;
  395. coin_inv = gold_inv;
  396. }
  397. elseif(inv_slot == 4 || inv_slot == 9) {
  398. if(inv_slot == 4) {
  399. betrag = copper_inv + silver_inv * 64 + gold_inv * 4096;
  400. coin_inv = 8;
  401. } elseif(inv_slot == 9) {
  402. betrag = getMoney(player);
  403. coin_inv = 8;
  404. }
  405. }
  406. //Einzahlen
  407. if(inv_slot > 0 && inv_slot < 5) {
  408. if(coin_inv < 1 * factor) {
  409. msg.prefix(player, prefix_money, "Coins not in inventory.");
  410. goto("wait");
  411. }
  412. if(betrag == 0) {
  413. msg.prefix(player, prefix_money, "No coins in your inventory.");
  414. goto("wait");
  415. }
  416. addMoney(player, betrag);
  417. if(inv_slot == 4) {
  418. player.removeItemNbt(player, read.item("km:coin_gold", gold_inv));
  419. player.removeItemNbt(player, read.item("km:coin_silver", silver_inv));
  420. player.removeItemNbt(player, read.item("km:coin_copper", copper_inv));
  421. } else {
  422. remove_item = item.clone(inv.getItem(bankmenu, inv_slot));
  423. item.setAmount(remove_item, item.getAmount(remove_item) * factor);
  424. player.removeItemNbt(player, remove_item);
  425. }
  426. inv.update(player);
  427. goto("wait");
  428. }
  429. //Auszahlen
  430. if(inv_slot > 5 && inv_slot < 10) {
  431. if(!hasEnoughMoney(player, betrag)) {
  432. msg.prefix(player, prefix_money, "Not enough snuvis on your account.");
  433. } else {
  434. subMoney(player, betrag);
  435. if(inv_slot == 9) {
  436. gold_amount = math.roundDown(betrag / 4096);
  437. betrag %= 4096;
  438. silver_amount = math.roundDown(betrag / 64);
  439. copper_amount = math.roundDown(betrag % 64);
  440. coin_item = read.item("km:coin_gold", gold_amount);
  441. player.giveItem(player, coin_item);
  442. coin_item = read.item("km:coin_silver", silver_amount);
  443. player.giveItem(player, coin_item);
  444. coin_item = read.item("km:coin_copper", copper_amount);
  445. player.giveItem(player, coin_item);
  446. } else {
  447. item = inv.getItem(bankmenu, inv_slot);
  448. new_item = read.item(item.getType(item), item.getAmount(item) * factor);
  449. player.giveItem(player, new_item);
  450. }
  451. inv.update(player);
  452. }
  453. goto("wait");
  454. }
  455. goto("wait");
  456. }
  457. if(inv_id == gambler_inv_id) {
  458. if(inv_slot == 0) {
  459. amount = 1;
  460. } elseif(inv_slot == 1) {
  461. amount = 64;
  462. } elseif(inv_slot == 2) {
  463. amount = 4096;
  464. } elseif(inv_slot == 3) {
  465. amount = getMoney(player);
  466. if(amount == 0) {
  467. msg.prefix(player, prefix_money, "You need at least 1 snuvi on your account.");
  468. goto("wait");
  469. }
  470. }
  471. if(!hasEnoughMoney(player, amount)) {
  472. msg.prefix(player, prefix_money, "Not enough snuvis on your account.");
  473. goto("wait");
  474. }
  475. win = math.random(1, 2);
  476. if(win == 1) {
  477. addMoney(player, amount);
  478. temp = " won ";
  479. } else {
  480. subMoney(player, amount);
  481. temp = " lost ";
  482. }
  483. if(amount == 1) {
  484. message = concat(player.getName(player), temp, text.number(amount), " snuvi.");
  485. } else {
  486. message = concat(player.getName(player), temp, text.number(amount), " snuvis.");
  487. }
  488. if(amount < 64) {
  489. msg.prefix(player, "§2Gambler", message);
  490. } elseif(amount >= 131072) {
  491. msg.online("§2Gambler", message);
  492. } else {
  493. msg.radius("§2Gambler", message, entity.getLocation(player), 10);
  494. }
  495. goto("wait");
  496. }
  497. goto("wait");
  498. @projectile_hit
  499. if(!isPlayer(shooter)) {
  500. goto("wait");
  501. }
  502. player = shooter;
  503. duration = data.getTimer(player, "skill.fire_arrow");
  504. if(duration > 0) {
  505. if(loc_hit == null) {
  506. goto("wait");
  507. }
  508. flame = enchantment.getLevel(ench_flame, living.getHand(player));
  509. if(flame <= 0) {
  510. goto("wait");
  511. }
  512. if(!plot.check(loc_hit, player, 3, true) && !perm.has(player, "plot.bypass")) {
  513. msg.prefix(player, prefix_skill, "You have no permissions on this plot.");
  514. goto("wait");
  515. }
  516. ent_loc = entity.getLocation(projectile);
  517. if(block.isAir(ent_loc)){
  518. block.set(ent_loc, "minecraft:fire");
  519. }
  520. fire_ring(ent_loc, "minecraft:fire", 0);
  521. }
  522. goto("wait");
  523. function fire_ring(location, block_string, radius){
  524. loc_x = loc.getX(location);
  525. loc_y = loc.getY(location);
  526. loc_z = loc.getZ(location);
  527. for(a = -radius; a < radius + 1; a++){
  528. loc.setX(location, loc_x + a);
  529. for(b = -radius; b < radius + 1; b++){
  530. loc.setY(location, loc_y + b);
  531. for(c = -radius; c < radius + 1; c++){
  532. loc.setZ(location, loc_z + c);
  533. if(block.isAir(location)){
  534. block.set(location, block_string);
  535. }
  536. }
  537. }
  538. }
  539. }
  540. @block_break
  541. duration = data.getTimer(player, "block_down");
  542. if(duration > 0) {
  543. do = true;
  544. loc = loc.mod(block_loc, 0, -1, 0);
  545. b_type = block.getType(loc);
  546. if(b_type == "minecraft:bedrock" || b_type == "minecraft:end_portal_frame") {
  547. do = false;
  548. }
  549. if(!plot.check(loc, player, 2, true)) {
  550. do = false;
  551. }
  552. if(do) {
  553. block.break(loc, player);
  554. }
  555. }
  556. duration = data.getTimer(player, "block_up");
  557. if(duration > 0) {
  558. do = true;
  559. loc = loc.mod(block_loc, 0, 1, 0);
  560. b_type = block.getType(loc);
  561. if(b_type == "minecraft:bedrock" || b_type == "minecraft:end_portal_frame") {
  562. do = false;
  563. }
  564. if(!plot.check(loc, player, 2, true)) {
  565. do = false;
  566. }
  567. if(do) {
  568. block.break(loc, player);
  569. }
  570. }
  571. if(block_type == "minecraft:cobweb") {
  572. if(cancel) {
  573. goto("wait");
  574. }
  575. hand_item = living.getHand(player);
  576. if(!item.hasTag(sword_tag, hand_item)) {
  577. goto("wait");
  578. }
  579. amount = skill.getAmount(player, "skill.cobweb_miner");
  580. if(amount <= 0) {
  581. goto("wait");
  582. }
  583. if(!skill.isActivated(player, "skill.cobweb_miner")) {
  584. goto("wait");
  585. }
  586. location = loc.mod(block_loc, 0, 0, 0);
  587. cobweb_X = loc.getX(location);
  588. cobweb_Y = loc.getY(location);
  589. cobweb_Z = loc.getZ(location);
  590. cobweb_radius = 1;
  591. unbreaking_level = enchantment.getLevel(ench_unbreaking, hand_item);
  592. for(a = -cobweb_radius; a < cobweb_radius + 1; a++) {
  593. loc.setX(location, cobweb_X + a);
  594. for(b = -cobweb_radius; b < cobweb_radius + 1; b++) {
  595. loc.setY(location, cobweb_Y + b);
  596. for(c = -cobweb_radius; c < cobweb_radius + 1; c++) {
  597. loc.setZ(location, cobweb_Z + c);
  598. if(math.abs(a) + math.abs(b) + math.abs(c) + math.random(0, 2) < cobweb_radius + 2) {
  599. shear_cobweb(location, block_type, player, unbreaking_level);
  600. }
  601. }
  602. }
  603. }
  604. goto("wait");
  605. }
  606. if(block.hasTag(leaves_tag, block)) {
  607. if(cancel) {
  608. goto("wait");
  609. }
  610. hand_item = living.getHand(player);
  611. if(item.getType(hand_item) != "minecraft:shears") {
  612. goto("wait");
  613. }
  614. if(block.property.getValue(block_loc, prop_persistent)){
  615. goto("wait");
  616. }
  617. amount = skill.getAmount(player, "skill.better_shears");
  618. if(amount <= 0) {
  619. goto("wait");
  620. }
  621. if(!skill.isActivated(player, "skill.better_shears")) {
  622. goto("wait");
  623. }
  624. location = loc.mod(block_loc, 0, 0, 0);
  625. shears_X = loc.getX(location);
  626. shears_Y = loc.getY(location);
  627. shears_Z = loc.getZ(location);
  628. unbreaking_level = enchantment.getLevel(ench_unbreaking, hand_item);
  629. radius = enchantment.getLevel(ench_sharpness, hand_item);
  630. if(radius > 0) {
  631. cancel = true;
  632. }
  633. orig_item = block.toStack(location);
  634. for(a = -radius; a < radius + 1; a++){
  635. loc.setX(location, shears_X + a);
  636. for(b = -radius; b < radius + 1; b++){
  637. loc.setY(location, shears_Y + b);
  638. for(c = -radius; c < radius + 1; c++){
  639. loc.setZ(location, shears_Z + c);
  640. if(math.abs(a) + math.abs(b) + math.abs(c) + math.random(0, 2) < radius + 2) {
  641. shear_leave(location, block_type, orig_item, player, unbreaking_level);
  642. }
  643. }
  644. }
  645. }
  646. goto("wait");
  647. }
  648. goto("wait");
  649. function shear_leave(block_loc, original_block_type, original_item, player, unbreaking_level){
  650. if(block.getType(block_loc) != original_block_type) {
  651. return;
  652. }
  653. if(block.property.getValue(block_loc, $prop_persistent)) {
  654. return;
  655. }
  656. block.set(block_loc, "minecraft:air");
  657. item.drop(block_loc, original_item);
  658. if(player.isSurvival(player)) {
  659. player.damageItem(player, 1);
  660. }
  661. }
  662. function shear_cobweb(block_loc, original_block_type, player, unbreaking_level) {
  663. if(block.getType(block_loc) != original_block_type) {
  664. return;
  665. }
  666. block.break(block_loc, player);
  667. if(math.random(0, 99) < 100 / (unbreaking_level + 1)) {
  668. player.damageItem(player, 1);
  669. }
  670. }
  671. @block_click
  672. if(action == "right" && player.checkHandsForTag(player, dye_tag)) {
  673. if(block.hasTag(sign_tag, block)) {
  674. if(!perm.has(player, "plot.bypass")) {
  675. if(!plot.check(block_loc, player, 3, true)) {
  676. cancel = true;
  677. goto("wait");
  678. }
  679. }
  680. }
  681. }
  682. if(hand == "OFF_HAND") {
  683. goto("wait");
  684. }
  685. if(block_type == "minecraft:chest") {
  686. if(isATpReceiver(block_loc)) {
  687. tp_item = read.item("km:gear", 1, "§rTeleport");
  688. list = list.new();
  689. list.add(list, world.getName(loc.getWorld(block_loc)));
  690. list.add(list, text.number(loc.getX(block_loc)));
  691. list.add(list, text.number(loc.getY(block_loc)));
  692. list.add(list, text.number(loc.getZ(block_loc)));
  693. item.setLore(tp_item, list);
  694. player.giveItem(player, tp_item);
  695. goto("wait");
  696. }
  697. if(isATpTransmitter(block_loc)) {
  698. player_uuid = player.getUuid(player);
  699. clicked = map.getOrDefault(tp_map, player_uuid, 0);
  700. now_time = time.getMillis();
  701. if(now_time - clicked < 5000) {
  702. msg.prefix(player, "§5Adventure", "Wait 5 seconds!");
  703. goto("wait");
  704. }
  705. map.add(tp_map, player_uuid, now_time);
  706. //Abenteuer-Teleport
  707. if(block_loc == adventure_chest_loc) {
  708. if(!player.isOnAdventure(player)) {
  709. if(!player.hasClearInventory(player)) {
  710. msg.prefix(player, "§5Adventure", "Your inventory needs to be empty!");
  711. goto("wait");
  712. }
  713. alpha = math.random(0, 360);
  714. alpha *= math.pi() / 180;
  715. x = math.round(math.sin(alpha) * 10000) + 0.5;
  716. z = math.round(math.cos(alpha) * 10000) + 0.5;
  717. y = 255;
  718. tp_loc = loc.new(world.getOverWorld(), x, y, z);
  719. while(block.isAir(tp_loc)) {
  720. loc.setY(tp_loc, y);
  721. y--;
  722. }
  723. tp_loc = loc.mod(tp_loc, 0, 1, 0);
  724. setTpWallX(block_loc, "minecraft:lime_stained_glass");
  725. sound.spawn(block_loc, piston_sound, sound_category_ambient);
  726. player_uuid = player.getUuid(player);
  727. array = array.new(4);
  728. array[0] = player_uuid;
  729. array[1] = block_loc;
  730. array[2] = tp_loc;
  731. array[3] = true;
  732. list.add(tp_list, array);
  733. set.add(tp_set, player_uuid);
  734. sgoto(30, "tp_ticker");
  735. }
  736. goto("wait");
  737. }
  738. //Normaler Teleport
  739. temp = false;
  740. inv = block.getInv(block_loc);
  741. inv_size = inv.getSize(inv);
  742. for(i = 0; i < inv_size; i++) {
  743. item = inv.getItem(inv, i);
  744. if(item.getType(item) == "km:gear") {
  745. if(item.getName(item) == "§rTeleport") {
  746. temp = true;
  747. break;
  748. }
  749. }
  750. }
  751. if(!temp) {
  752. msg.prefix(player, "§5Adventure", "No receiver found!");
  753. goto("wait");
  754. }
  755. lore_list = item.getLore(item);
  756. if(list.getSize(lore_list) != 4) {
  757. msg.prefix(player, "§5Adventure", "No receiver found!");
  758. goto("wait");
  759. }
  760. world = world.get(list.getIndex(lore_list, 0));
  761. x = read.number(list.getIndex(lore_list, 1));
  762. y = read.number(list.getIndex(lore_list, 2));
  763. z = read.number(list.getIndex(lore_list, 3));
  764. tp_loc = loc.new(world, x, y, z);
  765. if(!isATpReceiver(tp_loc)) {
  766. msg.prefix(player, "§5Adventure", "No receiver found!");
  767. goto("wait");
  768. }
  769. loc.add(tp_loc, 0.5, -3, 0.5);
  770. setTpWallX(block_loc, "minecraft:lime_stained_glass");
  771. sound.spawn(block_loc, piston_sound, sound_category_ambient);
  772. array = array.new(4);
  773. array[0] = player.getUuid(player);
  774. array[1] = block_loc;
  775. array[2] = tp_loc;
  776. array[3] = false;
  777. list.add(tp_list, array);
  778. sgoto(30, "tp_ticker");
  779. }
  780. goto("wait");
  781. }
  782. if(block_loc == gambler_loc) {
  783. cancel = true;
  784. inv.open(gambler_inv, player, "Choose your amount to bet with");
  785. goto("wait");
  786. }
  787. if(block_loc == lottery_loc_1 || block_loc == lottery_loc_2) {
  788. if(!hasEnoughMoney(player, 1)) {
  789. msg.prefix(player, prefix_money, "Not enough snuvis on your account.");
  790. goto("wait");
  791. }
  792. subMoney(player, 1);
  793. amount = lottery.add(block_loc, 1);
  794. if(amount == null) {
  795. goto("wait");
  796. }
  797. if(block_loc == lottery_loc_1) {
  798. winrate = 1000;
  799. } else {
  800. winrate = 10000;
  801. }
  802. win = math.random(1, winrate);
  803. if(win == 1) {
  804. addMoney(player, amount);
  805. lottery.set(block_loc, 0);
  806. message = concat(player.getName(player), " has won ", text.number(amount), " snuvis.");
  807. msg.radius(prefix_money, message, block_loc, 50);
  808. }
  809. goto("wait");
  810. }
  811. goto("wait");
  812. @living_death
  813. if(isPlayer(living_entity)) {
  814. player = living_entity;
  815. setDeathLoc(player);
  816. loc = entity.getLocation(player);
  817. amount = skill.getAmount(player, "skill.subcu_inv");
  818. if(skill.isActivated(player, "skill.subcu_inv") && amount > 0) {
  819. new_amount = amount - 1;
  820. skill.setAmount(player, "skill.subcu_inv", new_amount);
  821. msg.prefix(player, prefix_skill, concat("Used Subcutaneous Inventory. New amount: ", text.number(new_amount)));
  822. } else {
  823. player.dropInventory(player, loc);
  824. }
  825. killer = player.getFromDamageSource(damage_source);
  826. if(isPlayer(killer)) {
  827. amount = skill.getAmount(player, "skill.head_human");
  828. if(amount >= 1) {
  829. if(perm.has(player, "isTeam")) {
  830. temp = math.random(1, 20);
  831. } else {
  832. temp = math.random(1, 5);
  833. }
  834. if(temp == 1) {
  835. item.drop(loc, player.getHead(player.getUuid(player), player.getName(player)));
  836. }
  837. }
  838. }
  839. goto("wait");
  840. }
  841. killer = player.getFromDamageSource(damage_source);
  842. if(isPlayer(killer)) {
  843. r = math.random(1, 20);
  844. if(r == 1) {
  845. amount = skill.getAmount(killer, "skill.head_monster");
  846. if(amount >= 1) {
  847. entity_type = entity.getType(living_entity);
  848. if(entity_type == "creeper") {
  849. item.drop(loc, read.item("minecraft:creeper_head"));
  850. goto("wait");
  851. }
  852. if(entity_type == "zombie") {
  853. item.drop(loc, read.item("minecraft:zombie_head"));
  854. goto("wait");
  855. }
  856. if(entity_type == "skeleton") {
  857. item.drop(loc, read.item("minecraft:skeleton_skull"));
  858. goto("wait");
  859. }
  860. }
  861. }
  862. }
  863. goto("wait");
  864. @player_pre_respawn
  865. if(loc.isInSurvWorld(entity.getLocation(player))) {
  866. set.add(survival_respawn, player.getUuid(player));
  867. }
  868. goto("wait");
  869. @player_post_respawn
  870. player_uuid = player.getUuid(player);
  871. if(set.contains(survival_respawn, player_uuid)) {
  872. set.remove(survival_respawn, player_uuid);
  873. if(player.isOnAdventure(player)) {
  874. tp_loc = player.getAdventureStart(player);
  875. entity.teleport(player, tp_loc);
  876. goto("wait");
  877. }
  878. amount = skill.getAmount(player, "skill.comeback");
  879. if(skill.isActivated(player, "skill.comeback") && amount > 0) {
  880. new_amount = amount - 1;
  881. skill.setAmount(player, "skill.comeback", new_amount);
  882. msg.prefix(player, prefix_skill, concat("Used Comeback. New amount: ", text.number(new_amount)));
  883. entity.teleport(player, getDeathLoc(player));
  884. goto("wait");
  885. }
  886. entity.teleport(player, world.getServerSpawn());
  887. }
  888. goto("wait");
  889. @tp_ticker
  890. array = list.getIndex(tp_list, 0);
  891. list.removeIndex(tp_list, 0);
  892. block_loc = array[1];
  893. list.add(tp_list, array);
  894. setTpWallFull(block_loc, "minecraft:lime_stained_glass");
  895. sound.spawn(block_loc, piston_sound, sound_category_ambient);
  896. sgoto(30, "tp_final");
  897. goto("wait");
  898. @tp_final
  899. array = list.getIndex(tp_list, 0);
  900. list.removeIndex(tp_list, 0);
  901. player_uuid = array[0];
  902. block_loc = array[1];
  903. tp_loc = array[2];
  904. adventure = array[3];
  905. set.remove(tp_set, player_uuid);
  906. sound.spawn(block_loc, piston_sound, sound_category_ambient);
  907. setTpWallFull(block_loc, "minecraft:air");
  908. player = player.get(player_uuid);
  909. if(player == null) {
  910. goto("wait");
  911. }
  912. sound.spawn(tp_loc, adv_tp_sound, sound_category_ambient);
  913. if(adventure) {
  914. //Party
  915. if(player.isInParty(player) && player.isPartyLeader(player)) {
  916. party_id = player.getPartyId(player);
  917. party_list = party.getList(party_id);
  918. iter = list.iterator(party_list);
  919. while(hasNext(iter)) {
  920. p = player.get(next(iter));
  921. p_name = player.getName(p);
  922. p_loc = entity.getLocation(p);
  923. if(!loc.isSameWorld(adventure_chest_loc, p_loc)) {
  924. msg.prefix(player, "§5Party", concat(p_name, "§c is in another world."));
  925. msg.prefix(p, "§5Party", "§cYou are in another world.");
  926. continue;
  927. }
  928. if(loc.distance(adventure_chest_loc, p_loc) > 5) {
  929. msg.prefix(player, "§5Party", concat(p_name, "§c is too far away."));
  930. msg.prefix(p, "§5Party", "§cYou are too far away.");
  931. continue;
  932. }
  933. if(player.hasMinigame(p)) {
  934. msg.prefix(player, "§5Party", concat(p_name, "§c is in a game."));
  935. msg.prefix(p, "§5Party", "§cYou are in a game.");
  936. continue;
  937. }
  938. if(player.hasQuest2(p)) {
  939. msg.prefix(player, "§5Party", concat(p_name, "§c is doing a quest."));
  940. msg.prefix(p, "§5Party", "§cYou are doing a quest.");
  941. continue;
  942. }
  943. if(player.isOnAdventure(p)) {
  944. msg.prefix(player, "§5Party", concat(p_name, "§c is already on an adventure."));
  945. msg.prefix(p, "§5Party", "§cYou are already on an adventure.");
  946. continue;
  947. }
  948. if(player.isAfk(p)) {
  949. msg.prefix(player, "§5Party", concat(p_name, "§c is afk."));
  950. msg.prefix(p, "§5Party", "§cYou are afk.");
  951. continue;
  952. }
  953. if(!player.hasClearInventory(p)) {
  954. msg.prefix(player, "§5Party", concat(p_name, "§c has no clear inventory."));
  955. msg.prefix(p, "§5Party", "§cYou have no clear inventory.");
  956. continue;
  957. }
  958. player.teleport(p, tp_loc, false);
  959. player.setAdventure(p, true);
  960. player.setAdventureStart(p, tp_loc);
  961. addAdventureDisplay(p, adventure_aim_loc);
  962. title.reset(p);
  963. title.setSub(p, "Have fun!");
  964. title.send(p, "§cAdventure");
  965. msg.prefix(p, "§5Adventure", "To complete your adventure, go to the survival spawn. You cannot teleport. If you die, you start again!");
  966. }
  967. goto("wait");
  968. }
  969. if(!player.hasClearInventory(player)) {
  970. msg.prefix(player, "§5Adventure", "Your inventory needs to be empty!");
  971. goto("wait");
  972. }
  973. player.teleport(player, tp_loc, false);
  974. player.setAdventure(player, true);
  975. player.setAdventureStart(player, tp_loc);
  976. addAdventureDisplay(player, adventure_aim_loc);
  977. title.reset(player);
  978. title.setSub(player, "Have fun!");
  979. title.send(player, "§cAdventure");
  980. msg.prefix(player, "§5Adventure", "To complete your adventure, go to the survival spawn. You cannot teleport. If you die, you start again!");
  981. goto("wait");
  982. }
  983. player.teleport(player, tp_loc, false);
  984. goto("wait");
  985. function lottery.set(location, amount) {
  986. location = loc.mod(location, 0.5, 0, 0.5);
  987. list = living.near(location, 0.1);
  988. text_entity = list.getIndex(list, 0);
  989. name = entity.getName(text_entity);
  990. if(!text.startsWith(name, "Snuvis to win: ", 0)) {
  991. snuvi.debug("Lottery error");
  992. return;
  993. }
  994. entity.setName(text_entity, concat("Snuvis to win: ", text.number(amount)), true);
  995. }
  996. function lottery.add(location, amount) {
  997. location = loc.mod(location, 0.5, 0, 0.5);
  998. list = living.near(location, 0.1);
  999. text_entity = list.getIndex(list, 0);
  1000. name = entity.getName(text_entity);
  1001. if(!text.startsWith(name, "Snuvis to win:", 0)) {
  1002. snuvi.debug("Lottery error");
  1003. return null;
  1004. }
  1005. amount = text.convert(text.subString(name, 15, text.length(name))) + 1;
  1006. entity.setName(text_entity, concat("Snuvis to win: ", text.number(amount)), true);
  1007. return amount;
  1008. }
  1009. function setDeathLoc(player) {
  1010. map.add($death_loc_map, player.getUuid(player), entity.getLocation(player));
  1011. }
  1012. function getDeathLoc(player) {
  1013. return map.getOrDefault($death_loc_map, player.getUuid(player), world.getServerSpawn());
  1014. }