u_general.txt 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352
  1. function checkIfEverOnline(player_name) {
  2. if(player.getUuid(player_name) == null) {
  3. return false;
  4. }
  5. return true;
  6. }
  7. function isOnline(player_name) {
  8. if(read.player(player_name) == null) {
  9. return false;
  10. }
  11. return true;
  12. }
  13. function setBackPos(player) {
  14. sgv(player, "backpos", text.location(entity.getLocation(player)));
  15. }
  16. function sendmessage(pname, topic, nachricht, boolean) { //Sendet eine Chat-Nachricht an einen Spieler. boolean = true heißt Mail geht raus, wenn Empfänger nicht online
  17. if(isOnline(pname)) {
  18. p = read.player(pname);
  19. player.speak(p, topic, nachricht);
  20. } elseif(boolean) {
  21. from_name = player.getName($player);
  22. mail.send(from_name, pname, nachricht);
  23. }
  24. }
  25. function getSpacer() {
  26. return("§0-------------------------------------------------");
  27. }
  28. function getDirection(yaw) {
  29. while(yaw < 0) {
  30. yaw += 360;
  31. }
  32. while(yaw >= 360) {
  33. yaw -= 360;
  34. }
  35. if(yaw > 60 && yaw < 120) {
  36. direction = "west";
  37. } elseif(yaw > 150 && yaw < 210) {
  38. direction = "north";
  39. } elseif(yaw > 240 && yaw < 300) {
  40. direction = "east";
  41. } elseif(yaw > 330 || yaw < 30) {
  42. direction = "south";
  43. } else {
  44. return null;
  45. }
  46. return direction;
  47. }
  48. function correctTimeFormat(textnumber) {
  49. if(text.length(textnumber) == 1) {
  50. textnumber = concat("0", textnumber);
  51. }
  52. return textnumber;
  53. }
  54. function checkInvChange(player, location) {
  55. if(event == "portal") {
  56. from_world = world.get($from);
  57. to_world = world.get($to);
  58. } else {
  59. from_world = loc.getWorld(entity.getLocation(player));
  60. to_world = loc.getWorld(location);
  61. }
  62. //Wenn ignore aktiviert --> kein Wechsel
  63. ignore = ggv(player, "invignore");
  64. if(ignore == null) {
  65. ignore = false;
  66. }
  67. if(!ignore) {
  68. //Wenn in selber Welt --> kein Wechsel
  69. if(from_world != to_world) {
  70. //Wenn beide Welten in derselben Liste sind --> kein Wechsel
  71. if(!(isSurvWorldName(world.getName(from_world)) && isSurvWorldName(world.getName(to_world)))) {
  72. savePlayerInventory(player, from_world);
  73. loadPlayerInventory(player, to_world);
  74. }
  75. }
  76. }
  77. }
  78. function savePlayerInventory(player, world) {
  79. world_name = world.getName(world);
  80. if(isSurvWorldName(world_name)) {
  81. pfad = "scripts/configs/default";
  82. } else {
  83. pfad = concat("scripts/configs/", world_name);
  84. }
  85. config = config.new(pfad, player.getId(player));
  86. //Allgemeine Daten
  87. config.set(config, "health", entity.getHealth(player));
  88. config.set(config, "hunger", player.getHunger(player));
  89. config.set(config, "saturation", player.getSaturation(player));
  90. //Inventare
  91. for(i = 0; i <= 35; i++) {
  92. config.set(config, concat("slot-", i), text.item(player.getInvSlot(player, i)));
  93. }
  94. for(i = 0; i <= 26; i++) {
  95. config.set(config, concat("eslot-", i), text.item(player.getEnderSlot(player, i)));
  96. }
  97. config.set(config, "offhand", text.item(entity.getEquip(player, "offhand")));
  98. config.set(config, "head", text.item(entity.getEquip(player, "head")));
  99. config.set(config, "chest", text.item(entity.getEquip(player, "chest")));
  100. config.set(config, "legs", text.item(entity.getEquip(player, "legs")));
  101. config.set(config, "feet", text.item(entity.getEquip(player, "feet")));
  102. config.set(config, "xp", player.getExp(player));
  103. config.set(config, "lvl", player.getLevel(player));
  104. entity.clearEffects(player);
  105. config.save(config);
  106. }
  107. function isGamesWorldName(world_name) {
  108. return world_name == "games";
  109. }
  110. function isSurvWorldName(world_name) {
  111. if(world_name == "overworld") {
  112. return true;
  113. } elseif(world_name == "the_end") {
  114. return true;
  115. } elseif(world_name == "the_nether") {
  116. return true;
  117. }
  118. return false;
  119. }
  120. function loadPlayerInventory(player, world) {
  121. world_name = world.getName(world);
  122. if(isSurvWorldName(world_name)) {
  123. pfad = "scripts/configs/default";
  124. } else {
  125. pfad = concat("scripts/configs/", world_name);
  126. }
  127. config = config.new(pfad, player.getId(player));
  128. if(!config.exists(config)) {
  129. return;
  130. }
  131. config.load(config);
  132. //Allgemeine Daten
  133. entity.setHealth(player, config.getDouble(config, "health", 1));
  134. player.setHunger(player, config.getDouble(config, "hunger", 1));
  135. player.setSaturation(player, config.getDouble(config, "saturation", 1));
  136. //Gamemode
  137. if(!perm.has(player, "isTeam")) {
  138. if(!player.isSpectator(player)) {
  139. if(world_name == "creative") {
  140. gm = "creative";
  141. } else {
  142. gm = "survival";
  143. }
  144. player.setGamemode(player, gm);
  145. }
  146. }
  147. //Inventare
  148. for(i = 0; i <= 35; i++) {
  149. player.setInvSlot(player, i, read.item(config.getString(config, concat("slot-", i), "minecraft:air")));
  150. }
  151. for(i = 0; i <= 26; i++) {
  152. player.setEnderSlot(player, i, read.item(config.getString(config, concat("eslot-", i), "minecraft:air")));
  153. }
  154. entity.setEquip(player, "offhand", read.item(config.getString(config, "offhand", "minecraft:air")));
  155. entity.setEquip(player, "head", read.item(config.getString(config, "head", "minecraft:air")));
  156. entity.setEquip(player, "chest", read.item(config.getString(config, "chest", "minecraft:air")));
  157. entity.setEquip(player, "legs", read.item(config.getString(config, "legs", "minecraft:air")));
  158. entity.setEquip(player, "feet", read.item(config.getString(config, "feet", "minecraft:air")));
  159. player.setExp(player, config.getDouble(config, "xp", 0));
  160. player.setLevel(player, config.getDouble(config, "lvl", 0));
  161. }
  162. function safeGiveItemPlayer(player, item) {
  163. rest_item = player.giveItem(player, item);
  164. item.drop(entity.getLocation(player), rest_item);
  165. }
  166. function setBlockIfNotAir(location, block) {
  167. if(block.getType(location) == "minecraft:air") {
  168. block.set(location, block, true);
  169. return true;
  170. }
  171. return false;
  172. }
  173. function teleportPlayer(player, location, backPos) {
  174. onadventure = ggv(player, "onadventure");
  175. if(onadventure != null) {
  176. if(onadventure) {
  177. msg(player, "[§5Adventure§r] Teleport blocked. ", text.click("[§5Cancel Adenture?§r]", concat("/stopadventure ", player)));
  178. return false;
  179. }
  180. }
  181. if(backPos) {
  182. setBackPos(player);
  183. }
  184. checkInvChange(player, location);
  185. entity.teleport(player, location);
  186. world = loc.getWorld(location);
  187. stacks.setActive(player, false);
  188. display.reset(player);
  189. entity.setName(player, player.getName(player));
  190. world_name = world.getName(world);
  191. if(world_name == "gpvp_spawn") {
  192. if(!registerGpvpPlayer(player)) {
  193. joinGpvpWorld(player);
  194. }
  195. }
  196. if(isSurvWorldName(world_name)) {
  197. joinSurvWorld(player);
  198. }
  199. //Tabliste
  200. nickname = map.getOrDefault(getScriptVar("nicknames"), player.getUuid(player), player.getName(player));
  201. if(isAfk(player)) {
  202. player.setDisplayName(player, concat("§7§m", nickname));
  203. } else {
  204. rank = getRank(player.getId(player));
  205. colorcode = text.subString(rank, 0, 2);
  206. player.setDisplayName(player, concat(colorcode, nickname));
  207. }
  208. return true;
  209. }
  210. function getBlockLocation(location) {
  211. world = world.get(loc.getCoord(location, "w"));
  212. bx = loc.getCoord(location, "bx");
  213. by = loc.getCoord(location, "by");
  214. bz = loc.getCoord(location, "bz");
  215. return loc.new(world, bx, by, bz);
  216. }
  217. function speakPrefix(player, prefix, message) {;
  218. msg(player, "§r[", prefix, "§r] ", message);
  219. }
  220. function sendRadiusMessage(prefix, message, location, radius) {
  221. list = players.near(location, radius);
  222. for(i = 0; i < list.getSize(list); i++) {
  223. player = list.getIndex(list, i);
  224. speakPrefix(player, prefix, message);
  225. }
  226. }
  227. function getPlayerFromDamageSource(damage_source) {
  228. entity = damage.getImmediateSource(damage_source);
  229. if(isPlayer(entity)) {
  230. return entity;
  231. }
  232. entity = damage.getTrueSource(damage_source);
  233. if(isPlayer(entity)) {
  234. return entity;
  235. }
  236. return null;
  237. }
  238. function loc.isAir(location) {
  239. type = block.getType(location);
  240. return type == "minecraft:air" || type == "minecraft:cave_air";
  241. }
  242. function getTimeString(millis) {
  243. calendar = time.new(millis);
  244. day = time.getDay(calendar);
  245. month = time.getMonth(calendar);
  246. year = time.getYear(calendar);
  247. hour = time.getHour(calendar);
  248. minute = time.getMinute(calendar);
  249. if(month < 10) {
  250. month = concat("0", text.number(month));
  251. } else {
  252. month = text.number(month);
  253. }
  254. if(day < 10) {
  255. day = concat("0", text.number(day));
  256. } else {
  257. day = text.number(day);
  258. }
  259. if(hour < 10) {
  260. hour = concat("0", text.number(hour));
  261. } else {
  262. hour = text.number(hour);
  263. }
  264. if(minute < 10) {
  265. minute = concat("0", text.number(minute));
  266. } else {
  267. minute = text.number(minute);
  268. }
  269. timestring = concat(day, ".", month, ".", text.number(year), " ", hour, ":", minute);
  270. return timestring;
  271. }
  272. function player.hasMinigame(player) {
  273. id_set = player.getMinigameIds(player);
  274. if(set.getSize(id_set) > 0) {
  275. return true;
  276. }
  277. return false;
  278. }
  279. function loc.isInGamesWorld(location) {
  280. return loc.getWorld(location) == getGamesWorld();
  281. }
  282. function getGamesWorld() {
  283. return world.get("games");
  284. }
  285. function getGamesSpawn() {
  286. return read.location(config.getString(getScriptVar("server_config"), "gamesspawn", "games:0:0:0"));
  287. }
  288. function getServerSpawn() {
  289. return read.location(config.getString(getScriptVar("server_config"), "serverspawn", "games:0:0:0"));
  290. }
  291. function getSurvivalSpawn() {
  292. return read.location(config.getString(getScriptVar("server_config"), "surv_spawn", "games:0:0:0"));
  293. }
  294. //--------------------------------------------------
  295. //Teleporter-Utils
  296. //--------------------------------------------------
  297. function isATpTransmitter(chest_loc) {
  298. loc = loc.mod(chest_loc, 0, 0 ,0);
  299. loc.add(loc, -1, 0, 0);
  300. if(block.getType(loc) != "minecraft:glowstone") {
  301. return false;
  302. }
  303. loc.add(loc, 2, 0, 0);
  304. if(block.getType(loc) != "minecraft:glowstone") {
  305. return false;
  306. }
  307. loc.add(loc, -1, 0, -1);
  308. if(block.getType(loc) != "minecraft:glowstone") {
  309. return false;
  310. }
  311. loc.add(loc, 0, 0, 2);
  312. if(block.getType(loc) != "minecraft:glowstone") {
  313. return false;
  314. }
  315. loc.add(loc, -1, 0, 0);
  316. if(block.getType(loc) != "km:bronze_block") {
  317. return false;
  318. }
  319. loc.add(loc, 2, 0, 0);
  320. if(block.getType(loc) != "km:bronze_block") {
  321. return false;
  322. }
  323. loc.add(loc, 0, 0, -2);
  324. if(block.getType(loc) != "km:bronze_block") {
  325. return false;
  326. }
  327. loc.add(loc, -2, 0, 0);
  328. if(block.getType(loc) != "km:bronze_block") {
  329. return false;
  330. }
  331. loc.add(loc, -1, 0, 0);
  332. if(block.getType(loc) != "km:bronze_block") {
  333. return false;
  334. }
  335. loc.add(loc, 0, 0, 1);
  336. if(block.getType(loc) != "km:bronze_block") {
  337. return false;
  338. }
  339. loc.add(loc, 0, 0, 1);
  340. if(block.getType(loc) != "km:bronze_block") {
  341. return false;
  342. }
  343. loc.add(loc, 0, 0, 1);
  344. if(block.getType(loc) != "minecraft:stone_brick_slab") {
  345. return false;
  346. }
  347. loc.add(loc, 1, 0, 0);
  348. if(block.getType(loc) != "km:bronze_block") {
  349. return false;
  350. }
  351. loc.add(loc, 1, 0, 0);
  352. if(block.getType(loc) != "km:bronze_block") {
  353. return false;
  354. }
  355. loc.add(loc, 1, 0, 0);
  356. if(block.getType(loc) != "km:bronze_block") {
  357. return false;
  358. }
  359. loc.add(loc, 1, 0, 0);
  360. if(block.getType(loc) != "minecraft:stone_brick_slab") {
  361. return false;
  362. }
  363. loc.add(loc, 0, 0, -1);
  364. if(block.getType(loc) != "km:bronze_block") {
  365. return false;
  366. }
  367. loc.add(loc, 0, 0, -1);
  368. if(block.getType(loc) != "km:bronze_block") {
  369. return false;
  370. }
  371. loc.add(loc, 0, 0, -1);
  372. if(block.getType(loc) != "km:bronze_block") {
  373. return false;
  374. }
  375. loc.add(loc, 0, 0, -1);
  376. if(block.getType(loc) != "minecraft:stone_brick_slab") {
  377. return false;
  378. }
  379. loc.add(loc, -1, 0, 0);
  380. if(block.getType(loc) != "km:bronze_block") {
  381. return false;
  382. }
  383. loc.add(loc, -1, 0, 0);
  384. if(block.getType(loc) != "km:bronze_block") {
  385. return false;
  386. }
  387. loc.add(loc, -1, 0, 0);
  388. if(block.getType(loc) != "km:bronze_block") {
  389. return false;
  390. }
  391. loc.add(loc, -1, 0, 0);
  392. if(block.getType(loc) != "minecraft:stone_brick_slab") {
  393. return false;
  394. }
  395. loc.add(loc, 1, 1, 2);
  396. if(block.getType(loc) != "km:bronze_block") {
  397. return false;
  398. }
  399. loc.add(loc, 1, 0, 0);
  400. if(block.getType(loc) != "km:bronze_block") {
  401. return false;
  402. }
  403. loc.add(loc, 1, 0, 0);
  404. if(block.getType(loc) != "km:bronze_block") {
  405. return false;
  406. }
  407. loc.add(loc, -1, 0, -1);
  408. if(block.getType(loc) != "km:bronze_block") {
  409. return false;
  410. }
  411. loc.add(loc, 0, 0, 2);
  412. if(block.getType(loc) != "km:bronze_block") {
  413. return false;
  414. }
  415. loc.add(loc, 0, 1, -1);
  416. if(block.getType(loc) != "km:copper_block") {
  417. return false;
  418. }
  419. loc.add(loc, 0, 1, 0);
  420. if(block.getType(loc) != "km:copper_block") {
  421. return false;
  422. }
  423. loc.add(loc, -2, -4, -2);
  424. if(block.getType(loc) != "km:bronze_block") {
  425. return false;
  426. }
  427. loc.add(loc, 0, -1, 0);
  428. if(block.getType(loc) != "km:bronze_block") {
  429. return false;
  430. }
  431. loc.add(loc, 0, -1, 0);
  432. if(block.getType(loc) != "km:bronze_block") {
  433. return false;
  434. }
  435. loc.add(loc, 0, 0, 4);
  436. if(block.getType(loc) != "km:bronze_block") {
  437. return false;
  438. }
  439. loc.add(loc, 0, 1, 0);
  440. if(block.getType(loc) != "km:bronze_block") {
  441. return false;
  442. }
  443. loc.add(loc, 0, 1, 0);
  444. if(block.getType(loc) != "km:bronze_block") {
  445. return false;
  446. }
  447. loc.add(loc, 4, 0, 0);
  448. if(block.getType(loc) != "km:bronze_block") {
  449. return false;
  450. }
  451. loc.add(loc, 0, -1, 0);
  452. if(block.getType(loc) != "km:bronze_block") {
  453. return false;
  454. }
  455. loc.add(loc, 0, -1, 0);
  456. if(block.getType(loc) != "km:bronze_block") {
  457. return false;
  458. }
  459. loc.add(loc, 0, 0, -4);
  460. if(block.getType(loc) != "km:bronze_block") {
  461. return false;
  462. }
  463. loc.add(loc, 0, 1, 0);
  464. if(block.getType(loc) != "km:bronze_block") {
  465. return false;
  466. }
  467. loc.add(loc, 0, 1, 0);
  468. if(block.getType(loc) != "km:bronze_block") {
  469. return false;
  470. }
  471. loc.add(loc, 0, -3, 0);
  472. if(block.getType(loc) != "km:bronze_block") {
  473. return false;
  474. }
  475. loc.add(loc, -1, 0, 0);
  476. if(block.getType(loc) != "km:bronze_block") {
  477. return false;
  478. }
  479. loc.add(loc, -1, 0, 0);
  480. if(block.getType(loc) != "km:bronze_block") {
  481. return false;
  482. }
  483. loc.add(loc, -1, 0, 0);
  484. if(block.getType(loc) != "km:bronze_block") {
  485. return false;
  486. }
  487. loc.add(loc, -1, 0, 0);
  488. if(block.getType(loc) != "km:bronze_block") {
  489. return false;
  490. }
  491. loc.add(loc, 0, 0, 1);
  492. if(block.getType(loc) != "km:bronze_block") {
  493. return false;
  494. }
  495. loc.add(loc, 0, 0, 1);
  496. if(block.getType(loc) != "km:bronze_block") {
  497. return false;
  498. }
  499. loc.add(loc, 0, 0, 1);
  500. if(block.getType(loc) != "km:bronze_block") {
  501. return false;
  502. }
  503. loc.add(loc, 0, 0, 1);
  504. if(block.getType(loc) != "km:bronze_block") {
  505. return false;
  506. }
  507. loc.add(loc, 1, 0, 0);
  508. if(block.getType(loc) != "km:bronze_block") {
  509. return false;
  510. }
  511. loc.add(loc, 1, 0, 0);
  512. if(block.getType(loc) != "km:bronze_block") {
  513. return false;
  514. }
  515. loc.add(loc, 1, 0, 0);
  516. if(block.getType(loc) != "km:bronze_block") {
  517. return false;
  518. }
  519. loc.add(loc, 1, 0, 0);
  520. if(block.getType(loc) != "km:bronze_block") {
  521. return false;
  522. }
  523. loc.add(loc, 0, 0, -1);
  524. if(block.getType(loc) != "km:bronze_block") {
  525. return false;
  526. }
  527. loc.add(loc, 0, 0, -1);
  528. if(block.getType(loc) != "km:bronze_block") {
  529. return false;
  530. }
  531. loc.add(loc, 0, 0, -1);
  532. if(block.getType(loc) != "km:bronze_block") {
  533. return false;
  534. }
  535. loc.add(loc, -1, 0, 0);
  536. if(block.getType(loc) != "minecraft:stone_bricks") {
  537. return false;
  538. }
  539. loc.add(loc, -2, 0, 0);
  540. if(block.getType(loc) != "minecraft:stone_bricks") {
  541. return false;
  542. }
  543. loc.add(loc, 0, 0, 2);
  544. if(block.getType(loc) != "minecraft:stone_bricks") {
  545. return false;
  546. }
  547. loc.add(loc, 2, 0, 0);
  548. if(block.getType(loc) != "minecraft:stone_bricks") {
  549. return false;
  550. }
  551. loc.add(loc, -1, 0, 0);
  552. if(block.getType(loc) != "km:bronze_block") {
  553. return false;
  554. }
  555. loc.add(loc, -1, 0, -1);
  556. if(block.getType(loc) != "km:bronze_block") {
  557. return false;
  558. }
  559. loc.add(loc, 1, 0, 0);
  560. if(block.getType(loc) != "km:bronze_block") {
  561. return false;
  562. }
  563. loc.add(loc, 1, 0, 0);
  564. if(block.getType(loc) != "km:bronze_block") {
  565. return false;
  566. }
  567. loc.add(loc, -1, 0, -1);
  568. if(block.getType(loc) != "km:bronze_block") {
  569. return false;
  570. }
  571. return true;
  572. }
  573. function isATpReceiver(chest_loc) {
  574. loc = loc.mod(chest_loc, 0, 0 ,0);
  575. loc.add(loc, -1, 0, 0);
  576. if(block.getType(loc) != "minecraft:glowstone") {
  577. return false;
  578. }
  579. loc.add(loc, 2, 0, 0);
  580. if(block.getType(loc) != "minecraft:glowstone") {
  581. return false;
  582. }
  583. loc.add(loc, -1, 0, -1);
  584. if(block.getType(loc) != "minecraft:glowstone") {
  585. return false;
  586. }
  587. loc.add(loc, 0, 0, 2);
  588. if(block.getType(loc) != "minecraft:glowstone") {
  589. return false;
  590. }
  591. loc.add(loc, -1, 0, 0);
  592. if(block.getType(loc) != "km:bronze_block") {
  593. return false;
  594. }
  595. loc.add(loc, 2, 0, 0);
  596. if(block.getType(loc) != "km:bronze_block") {
  597. return false;
  598. }
  599. loc.add(loc, 0, 0, -2);
  600. if(block.getType(loc) != "km:bronze_block") {
  601. return false;
  602. }
  603. loc.add(loc, -2, 0, 0);
  604. if(block.getType(loc) != "km:bronze_block") {
  605. return false;
  606. }
  607. loc.add(loc, -1, 0, 0);
  608. if(block.getType(loc) != "km:bronze_block") {
  609. return false;
  610. }
  611. loc.add(loc, 0, 0, 1);
  612. if(block.getType(loc) != "km:bronze_block") {
  613. return false;
  614. }
  615. loc.add(loc, 0, 0, 1);
  616. if(block.getType(loc) != "km:bronze_block") {
  617. return false;
  618. }
  619. loc.add(loc, 0, 0, 1);
  620. if(block.getType(loc) != "minecraft:dark_prismarine_slab") {
  621. return false;
  622. }
  623. loc.add(loc, 1, 0, 0);
  624. if(block.getType(loc) != "km:bronze_block") {
  625. return false;
  626. }
  627. loc.add(loc, 1, 0, 0);
  628. if(block.getType(loc) != "km:bronze_block") {
  629. return false;
  630. }
  631. loc.add(loc, 1, 0, 0);
  632. if(block.getType(loc) != "km:bronze_block") {
  633. return false;
  634. }
  635. loc.add(loc, 1, 0, 0);
  636. if(block.getType(loc) != "minecraft:dark_prismarine_slab") {
  637. return false;
  638. }
  639. loc.add(loc, 0, 0, -1);
  640. if(block.getType(loc) != "km:bronze_block") {
  641. return false;
  642. }
  643. loc.add(loc, 0, 0, -1);
  644. if(block.getType(loc) != "km:bronze_block") {
  645. return false;
  646. }
  647. loc.add(loc, 0, 0, -1);
  648. if(block.getType(loc) != "km:bronze_block") {
  649. return false;
  650. }
  651. loc.add(loc, 0, 0, -1);
  652. if(block.getType(loc) != "minecraft:dark_prismarine_slab") {
  653. return false;
  654. }
  655. loc.add(loc, -1, 0, 0);
  656. if(block.getType(loc) != "km:bronze_block") {
  657. return false;
  658. }
  659. loc.add(loc, -1, 0, 0);
  660. if(block.getType(loc) != "km:bronze_block") {
  661. return false;
  662. }
  663. loc.add(loc, -1, 0, 0);
  664. if(block.getType(loc) != "km:bronze_block") {
  665. return false;
  666. }
  667. loc.add(loc, -1, 0, 0);
  668. if(block.getType(loc) != "minecraft:dark_prismarine_slab") {
  669. return false;
  670. }
  671. loc.add(loc, 1, 1, 2);
  672. if(block.getType(loc) != "km:bronze_block") {
  673. return false;
  674. }
  675. loc.add(loc, 1, 0, 0);
  676. if(block.getType(loc) != "km:bronze_block") {
  677. return false;
  678. }
  679. loc.add(loc, 1, 0, 0);
  680. if(block.getType(loc) != "km:bronze_block") {
  681. return false;
  682. }
  683. loc.add(loc, -1, 0, -1);
  684. if(block.getType(loc) != "km:bronze_block") {
  685. return false;
  686. }
  687. loc.add(loc, 0, 0, 2);
  688. if(block.getType(loc) != "km:bronze_block") {
  689. return false;
  690. }
  691. loc.add(loc, -2, -2, -3);
  692. if(block.getType(loc) != "km:bronze_block") {
  693. return false;
  694. }
  695. loc.add(loc, 0, -1, 0);
  696. if(block.getType(loc) != "km:bronze_block") {
  697. return false;
  698. }
  699. loc.add(loc, 0, -1, 0);
  700. if(block.getType(loc) != "km:bronze_block") {
  701. return false;
  702. }
  703. loc.add(loc, 0, 0, 4);
  704. if(block.getType(loc) != "km:bronze_block") {
  705. return false;
  706. }
  707. loc.add(loc, 0, 1, 0);
  708. if(block.getType(loc) != "km:bronze_block") {
  709. return false;
  710. }
  711. loc.add(loc, 0, 1, 0);
  712. if(block.getType(loc) != "km:bronze_block") {
  713. return false;
  714. }
  715. loc.add(loc, 4, 0, 0);
  716. if(block.getType(loc) != "km:bronze_block") {
  717. return false;
  718. }
  719. loc.add(loc, 0, -1, 0);
  720. if(block.getType(loc) != "km:bronze_block") {
  721. return false;
  722. }
  723. loc.add(loc, 0, -1, 0);
  724. if(block.getType(loc) != "km:bronze_block") {
  725. return false;
  726. }
  727. loc.add(loc, 0, 0, -4);
  728. if(block.getType(loc) != "km:bronze_block") {
  729. return false;
  730. }
  731. loc.add(loc, 0, 1, 0);
  732. if(block.getType(loc) != "km:bronze_block") {
  733. return false;
  734. }
  735. loc.add(loc, 0, 1, 0);
  736. if(block.getType(loc) != "km:bronze_block") {
  737. return false;
  738. }
  739. loc.add(loc, 0, -3, 0);
  740. if(block.getType(loc) != "km:bronze_block") {
  741. return false;
  742. }
  743. loc.add(loc, -1, 0, 0);
  744. if(block.getType(loc) != "km:bronze_block") {
  745. return false;
  746. }
  747. loc.add(loc, -1, 0, 0);
  748. if(block.getType(loc) != "km:bronze_block") {
  749. return false;
  750. }
  751. loc.add(loc, -1, 0, 0);
  752. if(block.getType(loc) != "km:bronze_block") {
  753. return false;
  754. }
  755. loc.add(loc, -1, 0, 0);
  756. if(block.getType(loc) != "km:bronze_block") {
  757. return false;
  758. }
  759. loc.add(loc, 0, 0, 1);
  760. if(block.getType(loc) != "km:bronze_block") {
  761. return false;
  762. }
  763. loc.add(loc, 0, 0, 1);
  764. if(block.getType(loc) != "km:bronze_block") {
  765. return false;
  766. }
  767. loc.add(loc, 0, 0, 1);
  768. if(block.getType(loc) != "km:bronze_block") {
  769. return false;
  770. }
  771. loc.add(loc, 0, 0, 1);
  772. if(block.getType(loc) != "km:bronze_block") {
  773. return false;
  774. }
  775. loc.add(loc, 1, 0, 0);
  776. if(block.getType(loc) != "km:bronze_block") {
  777. return false;
  778. }
  779. loc.add(loc, 1, 0, 0);
  780. if(block.getType(loc) != "km:bronze_block") {
  781. return false;
  782. }
  783. loc.add(loc, 1, 0, 0);
  784. if(block.getType(loc) != "km:bronze_block") {
  785. return false;
  786. }
  787. loc.add(loc, 1, 0, 0);
  788. if(block.getType(loc) != "km:bronze_block") {
  789. return false;
  790. }
  791. loc.add(loc, 0, 0, -1);
  792. if(block.getType(loc) != "km:bronze_block") {
  793. return false;
  794. }
  795. loc.add(loc, 0, 0, -1);
  796. if(block.getType(loc) != "km:bronze_block") {
  797. return false;
  798. }
  799. loc.add(loc, 0, 0, -1);
  800. if(block.getType(loc) != "km:bronze_block") {
  801. return false;
  802. }
  803. loc.add(loc, -1, 0, 0);
  804. if(block.getType(loc) != "minecraft:dark_prismarine") {
  805. return false;
  806. }
  807. loc.add(loc, -2, 0, 0);
  808. if(block.getType(loc) != "minecraft:dark_prismarine") {
  809. return false;
  810. }
  811. loc.add(loc, 0, 0, 2);
  812. if(block.getType(loc) != "minecraft:dark_prismarine") {
  813. return false;
  814. }
  815. loc.add(loc, 2, 0, 0);
  816. if(block.getType(loc) != "minecraft:dark_prismarine") {
  817. return false;
  818. }
  819. loc.add(loc, -1, 0, 0);
  820. if(block.getType(loc) != "km:bronze_block") {
  821. return false;
  822. }
  823. loc.add(loc, -1, 0, -1);
  824. if(block.getType(loc) != "km:bronze_block") {
  825. return false;
  826. }
  827. loc.add(loc, 1, 0, 0);
  828. if(block.getType(loc) != "km:bronze_block") {
  829. return false;
  830. }
  831. loc.add(loc, 1, 0, 0);
  832. if(block.getType(loc) != "km:bronze_block") {
  833. return false;
  834. }
  835. loc.add(loc, -1, 0, -1);
  836. if(block.getType(loc) != "km:bronze_block") {
  837. return false;
  838. }
  839. return true;
  840. }
  841. function setWalls(chest_loc, item_type) {
  842. block.set(loc.mod(chest_loc, 2, -1, -1), item_type);
  843. block.set(loc.mod(chest_loc, 2, -1, 0), item_type);
  844. block.set(loc.mod(chest_loc, 2, -1, 1), item_type);
  845. block.set(loc.mod(chest_loc, -2, -1, -1), item_type);
  846. block.set(loc.mod(chest_loc, -2, -1, 0), item_type);
  847. block.set(loc.mod(chest_loc, -2, -1, 1), item_type);
  848. block.set(loc.mod(chest_loc, -1, -1, 2), item_type);
  849. block.set(loc.mod(chest_loc, 0, -1, 2), item_type);
  850. block.set(loc.mod(chest_loc, 1, -1, 2), item_type);
  851. block.set(loc.mod(chest_loc, -1, -1, -2), item_type);
  852. block.set(loc.mod(chest_loc, 0, -1, -2), item_type);
  853. block.set(loc.mod(chest_loc, 1, -1, -2), item_type);
  854. block.set(loc.mod(chest_loc, 2, -2, -1), item_type);
  855. block.set(loc.mod(chest_loc, 2, -2, 0), item_type);
  856. block.set(loc.mod(chest_loc, 2, -2, 1), item_type);
  857. block.set(loc.mod(chest_loc, -2, -2, -1), item_type);
  858. block.set(loc.mod(chest_loc, -2, -2, 0), item_type);
  859. block.set(loc.mod(chest_loc, -2, -2, 1), item_type);
  860. block.set(loc.mod(chest_loc, -1, -2, 2), item_type);
  861. block.set(loc.mod(chest_loc, 0, -2, 2), item_type);
  862. block.set(loc.mod(chest_loc, 1, -2, 2), item_type);
  863. block.set(loc.mod(chest_loc, -1, -2, -2), item_type);
  864. block.set(loc.mod(chest_loc, 0, -2, -2), item_type);
  865. block.set(loc.mod(chest_loc, 1, -2, -2), item_type);
  866. block.set(loc.mod(chest_loc, 2, -3, -1), item_type);
  867. block.set(loc.mod(chest_loc, 2, -3, 0), item_type);
  868. block.set(loc.mod(chest_loc, 2, -3, 1), item_type);
  869. block.set(loc.mod(chest_loc, -2, -3, -1), item_type);
  870. block.set(loc.mod(chest_loc, -2, -3, 0), item_type);
  871. block.set(loc.mod(chest_loc, -2, -3, 1), item_type);
  872. block.set(loc.mod(chest_loc, -1, -3, 2), item_type);
  873. block.set(loc.mod(chest_loc, 0, -3, 2), item_type);
  874. block.set(loc.mod(chest_loc, 1, -3, 2), item_type);
  875. block.set(loc.mod(chest_loc, -1, -3, -2), item_type);
  876. block.set(loc.mod(chest_loc, 0, -3, -2), item_type);
  877. block.set(loc.mod(chest_loc, 1, -3, -2), item_type);
  878. }
  879. function removeAdventureDisplay(player) {
  880. display.remove(player, 1);
  881. }
  882. function addAdventureDisplay(player, location) {
  883. x = text.number(loc.getX(location));
  884. y = text.number(loc.getY(location));
  885. z = text.number(loc.getZ(location));
  886. display.add(player, 1, concat("§2Adventure Ziel: §r", x, " ", y, " ", z));
  887. }
  888. //--------------------------------------------------
  889. //Money-Utils
  890. //--------------------------------------------------
  891. function getSameInvWorld(world) {
  892. world_name = world.getName(world);
  893. if(isSurvWorldName(world_name)) {
  894. world = world.get("overworld");
  895. }
  896. return world;
  897. }
  898. function hasEnoughMoney(player_id, moneyname, price) { //Zahl player_id, String moneyname, Zahl price
  899. playermoney = getMoney(player_id, moneyname);
  900. if(playermoney < price) {
  901. return false;
  902. }
  903. return true;
  904. }
  905. function isAdminshop(shopid) {
  906. if(gdmap.get("chestshops", shopid, "owner") == "AdminShop") {
  907. return true;
  908. }
  909. return false;
  910. }
  911. function getMoney(player_id, moneyname) {
  912. svar = getScriptVar("money_svar");
  913. player_map = map.get(svar, player_id);
  914. if(player_map == null) {
  915. //Aus Datenbank abrufen
  916. money = gdmap.getOrDefault("money", player_id, moneyname, 0);
  917. //Im Cache speichern
  918. player_map = map.new();
  919. map.add(player_map, moneyname, money);
  920. map.add(svar, player_id, player_map);
  921. setScriptVar("money_svar", svar);
  922. } else {
  923. //Aus Cache abrufen
  924. money = map.getOrDefault(player_map, moneyname, 0);
  925. }
  926. return money;
  927. }
  928. function setMoney(player_id, moneyname, money) {
  929. //In Datenbank speichern
  930. gdmap.add("money", player_id, moneyname, money);
  931. //Im Cache speichern
  932. svar = getScriptVar("money_svar");
  933. player_map = map.getOrDefault(svar, player_id, map.new());
  934. map.add(player_map, moneyname, money);
  935. map.add(svar, player_id, player_map);
  936. setScriptVar("money_svar", svar);
  937. if(moneyname == "survmoney") {
  938. player = read.player(player.getNameFromId(player_id));
  939. if(player != null) {
  940. displaySurvMoney(player, money);
  941. }
  942. }
  943. }
  944. function addMoney(player_id, moneyname, money) {
  945. setMoney(player_id, moneyname, getMoney(player_id, moneyname) + money);
  946. }
  947. function subMoney(player_id, moneyname, money) {
  948. setMoney(player_id, moneyname, getMoney(player_id, moneyname) - money);
  949. }
  950. //--------------------------------------------------
  951. //Afk-Utils
  952. //--------------------------------------------------
  953. function isAfk(player) {
  954. player_uuid = player.getUuid(player);
  955. afk_map = getScriptVar("afk_map");
  956. if(map.contains(afk_map, player_uuid)) {
  957. return true;
  958. }
  959. return false;
  960. }
  961. function setAfk(player, boolean) {
  962. player_uuid = player.getUuid(player);
  963. afk_map = getScriptVar("afk_map");
  964. if(boolean) {
  965. map.add(afk_map, player_uuid, loc.getYaw(entity.getLocation(player)));
  966. } else {
  967. map.remove(afk_map, player_uuid);
  968. }
  969. }
  970. //--------------------------------------------------
  971. //PvP-Utils
  972. //--------------------------------------------------
  973. function hasPvpOn(player) {
  974. player_uuid = player.getUuid(player);
  975. pvp_set = getScriptVar("pvp_set");
  976. if(set.contains(pvp_set, player_uuid)) {
  977. return true;
  978. }
  979. return false;
  980. }
  981. function setPvp(player, mode) {
  982. player_uuid = player.getUuid(player);
  983. pvp_set = getScriptVar("pvp_set");
  984. if(mode == "on") {
  985. set.add(pvp_set, player_uuid);
  986. } else {
  987. set.remove(pvp_set, player_uuid);
  988. }
  989. }
  990. //--------------------------------------------------
  991. //Rank-Utils
  992. //--------------------------------------------------
  993. function setRank(player_name, category, rank) {
  994. rank = text.replace(rank, "&", "§");
  995. stmt = databank.prepare("INSERT INTO chatranks (player_id, category, rank) VALUES (?,?,?) ON DUPLICATE KEY UPDATE chatranks.rank = ?;");
  996. player_uuid = player.getUuid(player_name);
  997. player_id = player.getId(player_uuid);
  998. databank.setInt(stmt, 1, player_id);
  999. databank.setString(stmt, 2, category);
  1000. databank.setString(stmt, 3, rank);
  1001. databank.setString(stmt, 4, rank);
  1002. databank.workerExecute(stmt);
  1003. }
  1004. function getRank(player_id) {
  1005. player_name = player.getNameFromId(player_id);
  1006. player = read.player(player_name);
  1007. world_name = world.getName(loc.getWorld(entity.getLocation(player)));
  1008. if(isSurvWorldName(world_name)) {
  1009. world_name = "survival";
  1010. }
  1011. stmt = databank.prepare("SELECT rank FROM chatranks WHERE player_id = ? AND category = ?;");
  1012. databank.setInt(stmt, 1, player_id);
  1013. databank.setString(stmt, 2, world_name);
  1014. result = databank.execute(stmt);
  1015. if(databank.next(result)) {
  1016. rank = databank.getString(result, 1);
  1017. } else {
  1018. rank = "§bUser";
  1019. }
  1020. databank.close(result);
  1021. databank.close(stmt);
  1022. return rank;
  1023. }
  1024. function offerRank(player, rank) {
  1025. rank2 = text.replace(rank, "§", "&");
  1026. world_name = world.getName(loc.getWorld(entity.getLocation(player)));
  1027. if(isSurvWorldName(world_name)) {
  1028. world_name = "survival";
  1029. }
  1030. player.speak(player, "§6Commands", "Neuer Rang verfügbar: ", text.hover(text.click(concat("[", rank, "§r]"), concat("/setrank ", player.getName(player), " ", world_name, " ", rank2)), "Zum Auswählen klicken"));
  1031. }
  1032. //--------------------------------------------------
  1033. //Perm-Utils
  1034. //--------------------------------------------------
  1035. function givePerm(player_id, perm_id) {
  1036. stmt = databank.prepare("INSERT INTO playerperms (player_id, perm_id) VALUES (?,?);");
  1037. databank.setInt(stmt, 1, player_id);
  1038. databank.setInt(stmt, 2, perm_id);
  1039. databank.workerExecute(stmt);
  1040. perm.registerPlayer(player.getUuidFromID(player_id), perm_id);
  1041. }
  1042. function removePerm(player_id, perm_id) {
  1043. stmt = databank.prepare("DELETE FROM playerperms WHERE player_id = ? AND perm_id = ?;");
  1044. databank.setInt(stmt, 1, player_id);
  1045. databank.setInt(stmt, 2, perm_id);
  1046. databank.workerExecute(stmt);
  1047. perm.unregisterPlayer(player.getUuidFromID(player_id), perm_id);
  1048. }
  1049. function removeAllPermsTemporarly(player_id) {
  1050. perm.registerPlayer(player.getUuidFromID(player_id), 8);
  1051. permslist = getPermsFromPlayer(player_id);
  1052. for(i = 0; i < list.getSize(permslist); i++) {
  1053. perm_id = list.getIndex(permslist, i);
  1054. perm.unregisterPlayer(player.getUuidFromID(player_id), perm_id);
  1055. }
  1056. }
  1057. function reloadAllPerms(player_id) {
  1058. perm.unregisterPlayer(player.getUuidFromID(player_id), 8);
  1059. permslist = getPermsFromPlayer(player_id);
  1060. for(i = 0; i < list.getSize(permslist); i++) {
  1061. perm_id = list.getIndex(permslist, i);
  1062. perm.registerPlayer(player.getUuidFromID(player_id), perm_id);
  1063. }
  1064. }
  1065. function removeAllPerms(player_id) {
  1066. permslist = getPermsFromPlayer(player_id);
  1067. for(i = 0; i < list.getSize(permslist); i++) {
  1068. removePerm(player_id, list.getIndex(permslist, i));
  1069. }
  1070. }
  1071. function isAPermGroup(permstring) {
  1072. if(list.contains($permgroups, text.toLowerCase(permstring))) {
  1073. return true;
  1074. }
  1075. return false;
  1076. }
  1077. function getPermsFromPlayer(player_id) {
  1078. list.new(permslist);
  1079. stmt = databank.prepare("SELECT perm_id FROM playerperms WHERE player_id = ?;");
  1080. databank.setInt(stmt, 1, player_id);
  1081. result = databank.execute(stmt);
  1082. while(databank.next(result)) {
  1083. list.add(permslist, databank.getInt(result, 1));
  1084. }
  1085. databank.close(result);
  1086. databank.close(stmt);
  1087. return permslist;
  1088. }
  1089. function hasPermAlready(player_id, perm_id) {
  1090. permslist = getPermsFromPlayer(player_id);
  1091. if(list.contains(permslist, perm_id)) {
  1092. return true;
  1093. } else {
  1094. return false;
  1095. }
  1096. }
  1097. function registerAllPerms() {
  1098. stmt = databank.prepare("SELECT * FROM playerperms;");
  1099. result = databank.execute(stmt);
  1100. while(databank.next(result)) {
  1101. player_id = databank.getInt(result, 1);
  1102. perm_id = databank.getInt(result, 2);
  1103. perm.registerPlayer(player.getUuidFromID(player_id), perm_id);
  1104. }
  1105. databank.close(result);
  1106. databank.close(stmt);
  1107. }
  1108. //--------------------------------------------------
  1109. //Nickname-Utils
  1110. //--------------------------------------------------
  1111. function setNickName(player, nickname) {
  1112. map.add(getScriptVar("nicknames"), player.getUuid(player), nickname);
  1113. }
  1114. function getNickName(player) {
  1115. return map.getOrDefault(getScriptVar("nicknames"), player.getUuid(player), player.getName(player));
  1116. }
  1117. function removeNickName(player) {
  1118. map.remove(getScriptVar("nicknames"), player.getUuid(player));
  1119. }
  1120. function sendMessageToWorld(world, message) {
  1121. world_name = world.getName(world);
  1122. if(isSurvWorldName(world_name)) {
  1123. worldlist = players.toWorldList(world.get("overworld"));
  1124. for(i = 0; i < list.getSize(worldlist); i++) {
  1125. msg(list.getIndex(worldlist, i), message);
  1126. }
  1127. worldlist = players.toWorldList(world.get("the_end"));
  1128. for(i = 0; i < list.getSize(worldlist); i++) {
  1129. msg(list.getIndex(worldlist, i), message);
  1130. }
  1131. worldlist = players.toWorldList(world.get("the_nether"));
  1132. for(i = 0; i < list.getSize(worldlist); i++) {
  1133. msg(list.getIndex(worldlist, i), message);
  1134. }
  1135. return;
  1136. }
  1137. worldlist = players.toWorldList(world);
  1138. for(i = 0; i < list.getSize(worldlist); i++) {
  1139. msg(list.getIndex(worldlist, i), message);
  1140. }
  1141. }
  1142. function sendMessageToWorld2(world, message1, message2) {
  1143. world_name = world.getName(world);
  1144. if(isSurvWorldName(world_name)) {
  1145. worldlist = players.toWorldList(world.get("overworld"));
  1146. for(i = 0; i < list.getSize(worldlist); i++) {
  1147. msg(list.getIndex(worldlist, i), message1, message2);
  1148. }
  1149. worldlist = players.toWorldList(world.get("the_end"));
  1150. for(i = 0; i < list.getSize(worldlist); i++) {
  1151. msg(list.getIndex(worldlist, i), message1, message2);
  1152. }
  1153. worldlist = players.toWorldList(world.get("the_nether"));
  1154. for(i = 0; i < list.getSize(worldlist); i++) {
  1155. msg(list.getIndex(worldlist, i), message1, message2);
  1156. }
  1157. return;
  1158. }
  1159. worldlist = players.toWorldList(world);
  1160. for(i = 0; i < list.getSize(worldlist); i++) {
  1161. msg(list.getIndex(worldlist, i), message1, message2);
  1162. }
  1163. }
  1164. //--------------------------------------------------
  1165. //Mail-Utils
  1166. //--------------------------------------------------
  1167. function mail.send(from_name, to_name, message) {
  1168. server_config = getScriptVar("server_config");
  1169. mail_id = config.getDouble(server_config, "mail_id", 0) + 1;
  1170. config.set(server_config, "mail_id", mail_id);
  1171. config.saveAsync(server_config);
  1172. from_id = player.getId(player.getUuid(from_name));
  1173. to_id = player.getId(player.getUuid(to_name));
  1174. stmt = databank.prepare("INSERT INTO mails (mail_id, from_id, to_id, readed, time, message) VALUES (?, ?, ?, ?, ?, ?);");
  1175. databank.setInt(stmt, 1, mail_id);
  1176. databank.setInt(stmt, 2, from_id);
  1177. databank.setInt(stmt, 3, to_id);
  1178. databank.setBool(stmt, 4, false);
  1179. databank.setLong(stmt, 5, time.getMillis());
  1180. databank.setString(stmt, 6, message);
  1181. databank.workerExecute(stmt);
  1182. //Wenn Spieler online, dann Pushmeldung veranlassen
  1183. p = read.player(to_name);
  1184. if(p != null) {
  1185. player.speak(p, "§bMail", concat("§rYou´ve got a new mail from §b", from_name, "."));
  1186. }
  1187. }
  1188. function mail.checkForNew(player) {
  1189. stmt = databank.prepare("SELECT mail_id, from_id, time, message FROM mails WHERE to_id = ? AND readed = false;");
  1190. to_id = player.getId(player);
  1191. databank.setInt(stmt, 1, to_id);
  1192. result = databank.execute(stmt);
  1193. nextrow = databank.next(result);
  1194. if(!nextrow) {
  1195. databank.close(result);
  1196. databank.close(stmt);
  1197. return;
  1198. }
  1199. newmails = 0;
  1200. while(nextrow) {
  1201. newmails++;
  1202. nextrow = databank.next(result);
  1203. }
  1204. databank.close(result);
  1205. databank.close(stmt);
  1206. if(newmails > 0) {
  1207. if(newmails > 1) {
  1208. speakPrefix(player, "§bMail", concat("§rYou´ve got §b", text.number(newmails), "§r new mails."));
  1209. } else {
  1210. speakPrefix(player, "§bMail", "§rYou´ve got §b1 §rnew mail.");
  1211. }
  1212. }
  1213. }
  1214. //--------------------------------------------------
  1215. //Friend-Utils
  1216. //--------------------------------------------------
  1217. function isAFriend(player_id, friend_id) {
  1218. temp = false;
  1219. stmt = databank.prepare("SELECT friend_id FROM friends WHERE player_id = ?;");
  1220. databank.setInt(stmt, 1, player_id);
  1221. result = databank.execute(stmt);
  1222. while(databank.next(result)) {
  1223. id = databank.getInt(result, 1);
  1224. if(friend_id == id) {
  1225. temp = true;
  1226. }
  1227. }
  1228. databank.close(result);
  1229. databank.close(stmt);
  1230. return temp;
  1231. }
  1232. function addFriend(player_id, friend_id) {
  1233. nowtime = time.getMillis();
  1234. stmt1 = databank.prepare("INSERT INTO friends (player_id, friend_id, time) VALUES (?, ?, ?);");
  1235. databank.setInt(stmt1, 1, player_id);
  1236. databank.setInt(stmt1, 2, friend_id);
  1237. databank.setLong(stmt1, 3, nowtime);
  1238. databank.workerExecute(stmt1);
  1239. stmt2 = databank.prepare("INSERT INTO friends (player_id, friend_id, time) VALUES (?, ?, ?);");
  1240. databank.setInt(stmt2, 1, friend_id);
  1241. databank.setInt(stmt2, 2, player_id);
  1242. databank.setLong(stmt2, 3, nowtime);
  1243. databank.workerExecute(stmt2);
  1244. }
  1245. function deleteFriend(player_id, friend_id) {
  1246. stmt = databank.prepare("DELETE FROM friends WHERE player_id = ? AND friend_id = ?;");
  1247. databank.setInt(stmt, 1, player_id);
  1248. databank.setInt(stmt, 2, friend_id);
  1249. databank.workerExecute(stmt);
  1250. }
  1251. function getFriendsList(player_id) {
  1252. list.new(list);
  1253. stmt = databank.prepare("SELECT friend_id FROM friends WHERE player_id = ?;");
  1254. databank.setInt(stmt, 1, player_id);
  1255. result = databank.execute(stmt);
  1256. while(databank.next(result)) {
  1257. friend_id = databank.getInt(result, 1);
  1258. list.add(list, player.getNameFromId(friend_id));
  1259. }
  1260. databank.close(result);
  1261. databank.close(stmt);
  1262. return list;
  1263. }