u_general.txt 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373
  1. function snuvi.debug(message) {
  2. msg("dev", concat("[§eDebug§r] ", message));
  3. }
  4. function perm.no(player, perm) {
  5. player.speak(player, "§6§zPerms", "You have no permission for §c", perm, "§r.");
  6. }
  7. function checkIfEverOnline(player_name) {
  8. if(player.getUuid(player_name) == null) {
  9. return false;
  10. }
  11. return true;
  12. }
  13. function isOnline(player_name) {
  14. if(read.player(player_name) == null) {
  15. return false;
  16. }
  17. return true;
  18. }
  19. function map.sort(map, ascending) {
  20. map_size = map.getSize(map);
  21. my_array = array.new(map_size, 2);
  22. //Map in 2 Arrays verwandeln
  23. i = 0;
  24. iter = map.iterator(map);
  25. while(hasNext(iter)) {
  26. element = next(iter);
  27. key = map.getKey(element);
  28. value = map.getValue(element);
  29. my_array[i, 0] = key;
  30. my_array[i, 1] = value;
  31. i++;
  32. }
  33. //Array sortieren
  34. if(ascending) {
  35. for(i = 0; i < map_size - 1; i++) {
  36. for(j = i + 1; j < map_size; j++) {
  37. if(my_array[j, 1] < my_array[i, 1]) {
  38. g = my_array[i, 0];
  39. h = my_array[i, 1];
  40. my_array[i, 0] = my_array[j, 0];
  41. my_array[i, 1] = my_array[j, 1];
  42. my_array[j, 0] = g;
  43. my_array[j, 1] = h;
  44. }
  45. }
  46. }
  47. } else {
  48. for(i = 0; i < map_size - 1; i++) {
  49. for(j = i + 1; j < map_size; j++) {
  50. if(my_array[j, 1] > my_array[i, 1]) {
  51. g = my_array[i, 0];
  52. h = my_array[i, 1];
  53. my_array[i, 0] = my_array[j, 0];
  54. my_array[i, 1] = my_array[j, 1];
  55. my_array[j, 0] = g;
  56. my_array[j, 1] = h;
  57. }
  58. }
  59. }
  60. }
  61. return my_array;
  62. }
  63. function getSpacer() {
  64. return("§0-------------------------------------------------");
  65. }
  66. function getDirection(yaw) {
  67. while(yaw < 0) {
  68. yaw += 360;
  69. }
  70. while(yaw >= 360) {
  71. yaw -= 360;
  72. }
  73. if(yaw > 60 && yaw < 120) {
  74. direction = "west";
  75. } elseif(yaw > 150 && yaw < 210) {
  76. direction = "north";
  77. } elseif(yaw > 240 && yaw < 300) {
  78. direction = "east";
  79. } elseif(yaw > 330 || yaw < 30) {
  80. direction = "south";
  81. } else {
  82. return null;
  83. }
  84. return direction;
  85. }
  86. function correctTimeFormat(textnumber) {
  87. if(text.length(textnumber) == 1) {
  88. textnumber = concat("0", textnumber);
  89. }
  90. return textnumber;
  91. }
  92. function isGamesWorldName(world_name) {
  93. return world_name == "games";
  94. }
  95. function isSurvWorldName(world_name) {
  96. if(world_name == "overworld") {
  97. return true;
  98. } elseif(world_name == "the_end") {
  99. return true;
  100. } elseif(world_name == "the_nether") {
  101. return true;
  102. }
  103. return false;
  104. }
  105. function safeGiveItemPlayer(player, item) {
  106. rest_item = player.giveItem(player, item);
  107. item.drop(entity.getLocation(player), rest_item);
  108. }
  109. function setBlockIfNotAir(location, block) {
  110. if(block.getType(location) == "minecraft:air") {
  111. block.set(location, block, true);
  112. return true;
  113. }
  114. return false;
  115. }
  116. function teleportPlayer(player, location, backPos) { //Deprecated
  117. return player.teleport(player, location, backPos);
  118. }
  119. function player.teleport(player, location, backPos) {
  120. if(player.isOnAdventure(player)) {
  121. msg(player, "[§5Adventure§r] Teleport blocked. ", text.click("[§5Cancel Adventure?§r]", concat("/stopadventure ", player)));
  122. return false;
  123. }
  124. if(backPos) {
  125. player.setBackPos(player);
  126. }
  127. inv.checkForChange(player, location);
  128. entity.teleport(player, location);
  129. world = loc.getWorld(location);
  130. display.reset(player);
  131. entity.setName(player, player.getName(player));
  132. world_name = world.getName(world);
  133. if(isGamesWorldName(world_name)) {
  134. joinGamesWorld(player);
  135. }
  136. if(isSurvWorldName(world_name)) {
  137. joinSurvWorld(player);
  138. }
  139. if(world.isCreativeWorldName(world_name)) {
  140. world.joinCreative(player);
  141. }
  142. //Tabliste
  143. nickname = player.getNickName(player);
  144. if(isAfk(player)) {
  145. player.setDisplayName(player, concat("§7§m", nickname));
  146. } else {
  147. rank = getRank(player.getId(player));
  148. colorcode = text.subString(rank, 0, 2);
  149. player.setDisplayName(player, concat(colorcode, nickname));
  150. }
  151. return true;
  152. }
  153. function getBlockLocation(location) {
  154. world = loc.getWorld(location, "w");
  155. bx = loc.getCoord(location, "bx");
  156. by = loc.getCoord(location, "by");
  157. bz = loc.getCoord(location, "bz");
  158. return loc.new(world, bx, by, bz);
  159. }
  160. function getDateString(time) {
  161. calendar = time.new(time);
  162. return concat(text.number(time.getDay(calendar)), ".", text.number(time.getMonth(calendar)), ".", text.number(time.getYear(calendar)));
  163. }
  164. function time.getClockString(time) {
  165. return concat(text.number(math.roundDown(time / 60)), " min ", text.number(math.round(time % 60)), " s");
  166. }
  167. function getTimeString(millis) {
  168. calendar = time.new(millis);
  169. day = time.getDay(calendar);
  170. month = time.getMonth(calendar);
  171. year = time.getYear(calendar);
  172. hour = time.getHour(calendar);
  173. minute = time.getMinute(calendar);
  174. if(month < 10) {
  175. month = concat("0", text.number(month));
  176. } else {
  177. month = text.number(month);
  178. }
  179. if(day < 10) {
  180. day = concat("0", text.number(day));
  181. } else {
  182. day = text.number(day);
  183. }
  184. if(hour < 10) {
  185. hour = concat("0", text.number(hour));
  186. } else {
  187. hour = text.number(hour);
  188. }
  189. if(minute < 10) {
  190. minute = concat("0", text.number(minute));
  191. } else {
  192. minute = text.number(minute);
  193. }
  194. timestring = concat(day, ".", month, ".", text.number(year), " ", hour, ":", minute);
  195. return timestring;
  196. }
  197. function player.hasMinigame(player) {
  198. id_set = player.getMinigameIds(player);
  199. if(set.getSize(id_set) > 0) {
  200. return true;
  201. }
  202. return false;
  203. }
  204. function player.getMinigameIds(player) {
  205. set = data.get(player, "minigames_set");
  206. if(set == null) {
  207. set = set.new();
  208. data.set(player, "minigames_set", set);
  209. }
  210. return set;
  211. }
  212. function tjr.getWholeModule(player_or_id) {
  213. if(isPlayer(player_or_id)) {
  214. player_or_id = player.getId(player_or_id);
  215. }
  216. return ranking.getPoints("tjrranks", player_or_id);
  217. }
  218. //Gibt die Rekord-Punkte eines Spielers zurück
  219. function ranking.getPoints(rankingtable, player_id) {
  220. stmt = databank.prepare(concat("SELECT points FROM ", rankingtable, " WHERE player_id = ?;"));
  221. databank.setInt(stmt, 1, player_id);
  222. result = databank.execute(stmt);
  223. if(databank.next(result)) {
  224. points = databank.getInt(result, 1);
  225. } else {
  226. points = 0;
  227. }
  228. databank.close(result);
  229. databank.close(stmt);
  230. return points;
  231. }
  232. //--------------------------------------------------
  233. //World-Utils
  234. //--------------------------------------------------
  235. function getGamesWorld() { //Deprecated
  236. return world.getGames();
  237. }
  238. function world.getServerSpawn() {
  239. return read.location(config.getString(getScriptVar("server_config"), "serverspawn", "games:0:0:0"));
  240. }
  241. function world.getGamesSpawn() {
  242. return read.location(config.getString(getScriptVar("server_config"), "gamesspawn", "games:0:0:0"));
  243. }
  244. function world.getCreativeSpawn() {
  245. return read.location(config.getString(getScriptVar("server_config"), "creativespawn", "games:0:0:0"));
  246. }
  247. function world.getOverWorld() {
  248. return world.get("overworld");
  249. }
  250. function world.getGames() {
  251. return world.get("games");
  252. }
  253. function world.getCreative() {
  254. return world.get("creative");
  255. }
  256. function world.joinCreative(player) {
  257. }
  258. function world.isCreativeWorldName(world_name) {
  259. return world_name == "creative";
  260. }
  261. //--------------------------------------------------
  262. //Inv-Utils
  263. //--------------------------------------------------
  264. function inv.checkForChange(player, location) {
  265. from_world = loc.getWorld(entity.getLocation(player));
  266. to_world = loc.getWorld(location);
  267. //Wenn ignore aktiviert --> kein Wechsel
  268. ignore = player.hasInvIgnore(player);
  269. if(ignore == null) {
  270. ignore = false;
  271. }
  272. if(ignore) {
  273. return;
  274. }
  275. from_world_name = world.getName(from_world);
  276. to_world_name = world.getName(to_world);
  277. //Wenn in selber Welt --> kein Wechsel
  278. if(from_world == to_world) {
  279. return;
  280. }
  281. //Wenn beide Welten in derselben Liste sind --> kein Wechsel
  282. if(isSurvWorldName(from_world_name) && isSurvWorldName(to_world_name)) {
  283. return;
  284. }
  285. //Weltwechsel
  286. entity.clearEffects(player);
  287. inv.saveForPlayer(player, player, from_world);
  288. inv.loadFromPlayer(player, player, to_world);
  289. if(!perm.has(player, "isTeam")) {
  290. if(!player.isSpectator(player)) {
  291. if(to_world_name == "creative") {
  292. gm = "creative";
  293. } else {
  294. gm = "survival";
  295. }
  296. player.setGamemode(player, gm);
  297. }
  298. }
  299. }
  300. function inv.saveForPlayer(sec_player, for_player_or_id, world) {
  301. if(isPlayer(for_player_or_id)) {
  302. for_player_or_id = player.getId(for_player_or_id);
  303. }
  304. world_name = world.getName(world);
  305. if(isSurvWorldName(world_name)) {
  306. pfad = "scripts/configs/default";
  307. } else {
  308. pfad = concat("scripts/configs/", world_name);
  309. }
  310. config = config.new(pfad, for_player_or_id);
  311. //Allgemeine Daten
  312. if(for_player_or_id == player.getId(sec_player)) {
  313. config.set(config, "health", entity.getHealth(sec_player));
  314. config.set(config, "hunger", player.getHunger(sec_player));
  315. config.set(config, "saturation", player.getSaturation(sec_player));
  316. config.set(config, "xp", player.getExp(sec_player));
  317. config.set(config, "lvl", player.getLevel(sec_player));
  318. }
  319. //Inventare
  320. for(i = 0; i <= 35; i++) {
  321. config.set(config, concat("slot-", i), text.item(player.getInvSlot(sec_player, i)));
  322. }
  323. for(i = 0; i <= 26; i++) {
  324. config.set(config, concat("eslot-", i), text.item(player.getEnderSlot(sec_player, i)));
  325. }
  326. config.set(config, "offhand", text.item(entity.getEquip(sec_player, "offhand")));
  327. config.set(config, "head", text.item(entity.getEquip(sec_player, "head")));
  328. config.set(config, "chest", text.item(entity.getEquip(sec_player, "chest")));
  329. config.set(config, "legs", text.item(entity.getEquip(sec_player, "legs")));
  330. config.set(config, "feet", text.item(entity.getEquip(sec_player, "feet")));
  331. config.save(config);
  332. }
  333. function inv.loadFromPlayer(sec_player, from_player_or_id, world) {
  334. if(isPlayer(from_player_or_id)) {
  335. from_player_or_id = player.getId(from_player_or_id);
  336. }
  337. world_name = world.getName(world);
  338. if(isSurvWorldName(world_name)) {
  339. pfad = "scripts/configs/default";
  340. } else {
  341. pfad = concat("scripts/configs/", world_name);
  342. }
  343. config = config.new(pfad, from_player_or_id);
  344. if(!config.exists(config)) {
  345. return;
  346. }
  347. config.load(config);
  348. //Allgemeine Daten
  349. if(from_player_or_id == player.getId(sec_player)) {
  350. entity.setHealth(sec_player, config.getDouble(config, "health", 20));
  351. player.setHunger(sec_player, config.getDouble(config, "hunger", 20));
  352. player.setSaturation(sec_player, config.getDouble(config, "saturation", 5));
  353. player.setExp(sec_player, config.getDouble(config, "xp", 0));
  354. player.setLevel(sec_player, config.getDouble(config, "lvl", 0));
  355. }
  356. //Inventare
  357. for(i = 0; i <= 35; i++) {
  358. player.setInvSlot(sec_player, i, read.item(config.getString(config, concat("slot-", i), "minecraft:air")));
  359. }
  360. for(i = 0; i <= 26; i++) {
  361. player.setEnderSlot(sec_player, i, read.item(config.getString(config, concat("eslot-", i), "minecraft:air")));
  362. }
  363. entity.setEquip(sec_player, "offhand", read.item(config.getString(config, "offhand", "minecraft:air")));
  364. entity.setEquip(sec_player, "head", read.item(config.getString(config, "head", "minecraft:air")));
  365. entity.setEquip(sec_player, "chest", read.item(config.getString(config, "chest", "minecraft:air")));
  366. entity.setEquip(sec_player, "legs", read.item(config.getString(config, "legs", "minecraft:air")));
  367. entity.setEquip(sec_player, "feet", read.item(config.getString(config, "feet", "minecraft:air")));
  368. }
  369. //--------------------------------------------------
  370. //Text-Utils
  371. //--------------------------------------------------
  372. function text.upperFirstLetter(string) {
  373. length = text.length(string);
  374. first_letter = text.subString(string, 0, 1);
  375. rest = text.substring(string, 1, length);
  376. return concat(text.toUpperCase(first_letter), rest);
  377. }
  378. //--------------------------------------------------
  379. //Showcoords-Utils
  380. //--------------------------------------------------
  381. function showCoords.get(player_or_id) {
  382. config = playerdata.getSurvival(player_or_id);
  383. return config.getBool(config, "showcoords", false);
  384. }
  385. function showCoords.set(player_or_id, bool) {
  386. config = playerdata.getSurvival(player_or_id);
  387. config.set(config, "showcoords", bool);
  388. config.saveAsync(config);
  389. }
  390. //--------------------------------------------------
  391. //Quest-Utils
  392. //--------------------------------------------------
  393. function quest.display(player, quest_name, stage, all_stages) {
  394. sb.add(player, 1, concat("§dQuest: ", quest_name, " [", text.number(stage), "/", text.number(all_stages), "]"));
  395. }
  396. function quest.removeDisplay(player) {
  397. sb.remove(player, 1);
  398. }
  399. function quest.addPlayer(script, player) {
  400. quest_ids = getScriptVar("quest_ids");
  401. map.add(quest_ids, player.getUuid(player), script.getId(script));
  402. }
  403. function quest.removePlayer(player) {
  404. quest_ids = getScriptVar("quest_ids");
  405. map.remove(quest_ids, player.getUuid(player));
  406. }
  407. function player.hasQuest2(player) {
  408. quest_ids = getScriptVar("quest_ids");
  409. return map.contains(quest_ids, player.getUuid(player));
  410. }
  411. function quest.getFromPlayer(player) {
  412. quest_ids = getScriptVar("quest_ids");
  413. return map.get(quest_ids, player.getUuid(player));
  414. }
  415. function quest.getCounter(player_or_id) {
  416. config = playerdata.getSurvival(player_or_id);
  417. return config.getDouble(config, "quests_solved", 0);
  418. }
  419. function quest.setCounter(player_or_id, amount) {
  420. config = playerdata.getSurvival(player_or_id);
  421. config.set(config, "quests_solved", amount);
  422. config.saveAsync(config);
  423. }
  424. function quest.addCounter(player_or_id, amount) {
  425. config = playerdata.getSurvival(player_or_id);
  426. config.set(config, "quests_solved", config.getDouble(config, "quests_solved", 0) + amount);
  427. config.saveAsync(config);
  428. }
  429. function quest.finish(script, player) {
  430. quest.addCounter(player, 1);
  431. quest.term(script, player);
  432. }
  433. function quest.term(script, player) {
  434. quest.removeDisplay(player);
  435. quest.removePlayer(player);
  436. script.term(script);
  437. }
  438. //--------------------------------------------------
  439. //Teleporter-Utils
  440. //--------------------------------------------------
  441. function isATpTransmitter(chest_loc) {
  442. loc = loc.mod(chest_loc, 0, 0 ,0);
  443. loc.add(loc, -1, 0, 0);
  444. if(block.getType(loc) != "minecraft:glowstone") {
  445. return false;
  446. }
  447. loc.add(loc, 2, 0, 0);
  448. if(block.getType(loc) != "minecraft:glowstone") {
  449. return false;
  450. }
  451. loc.add(loc, -1, 0, -1);
  452. if(block.getType(loc) != "minecraft:glowstone") {
  453. return false;
  454. }
  455. loc.add(loc, 0, 0, 2);
  456. if(block.getType(loc) != "minecraft:glowstone") {
  457. return false;
  458. }
  459. loc.add(loc, -1, 0, 0);
  460. if(block.getType(loc) != "km:bronze_block") {
  461. return false;
  462. }
  463. loc.add(loc, 2, 0, 0);
  464. if(block.getType(loc) != "km:bronze_block") {
  465. return false;
  466. }
  467. loc.add(loc, 0, 0, -2);
  468. if(block.getType(loc) != "km:bronze_block") {
  469. return false;
  470. }
  471. loc.add(loc, -2, 0, 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, 0, 0, 1);
  480. if(block.getType(loc) != "km:bronze_block") {
  481. return false;
  482. }
  483. loc.add(loc, 0, 0, 1);
  484. if(block.getType(loc) != "km:bronze_block") {
  485. return false;
  486. }
  487. loc.add(loc, 0, 0, 1);
  488. if(block.getType(loc) != "minecraft:stone_brick_slab") {
  489. return false;
  490. }
  491. loc.add(loc, 1, 0, 0);
  492. if(block.getType(loc) != "km:bronze_block") {
  493. return false;
  494. }
  495. loc.add(loc, 1, 0, 0);
  496. if(block.getType(loc) != "km:bronze_block") {
  497. return false;
  498. }
  499. loc.add(loc, 1, 0, 0);
  500. if(block.getType(loc) != "km:bronze_block") {
  501. return false;
  502. }
  503. loc.add(loc, 1, 0, 0);
  504. if(block.getType(loc) != "minecraft:stone_brick_slab") {
  505. return false;
  506. }
  507. loc.add(loc, 0, 0, -1);
  508. if(block.getType(loc) != "km:bronze_block") {
  509. return false;
  510. }
  511. loc.add(loc, 0, 0, -1);
  512. if(block.getType(loc) != "km:bronze_block") {
  513. return false;
  514. }
  515. loc.add(loc, 0, 0, -1);
  516. if(block.getType(loc) != "km:bronze_block") {
  517. return false;
  518. }
  519. loc.add(loc, 0, 0, -1);
  520. if(block.getType(loc) != "minecraft:stone_brick_slab") {
  521. return false;
  522. }
  523. loc.add(loc, -1, 0, 0);
  524. if(block.getType(loc) != "km:bronze_block") {
  525. return false;
  526. }
  527. loc.add(loc, -1, 0, 0);
  528. if(block.getType(loc) != "km:bronze_block") {
  529. return false;
  530. }
  531. loc.add(loc, -1, 0, 0);
  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_brick_slab") {
  537. return false;
  538. }
  539. loc.add(loc, 1, 1, 2);
  540. if(block.getType(loc) != "km:bronze_block") {
  541. return false;
  542. }
  543. loc.add(loc, 1, 0, 0);
  544. if(block.getType(loc) != "km:bronze_block") {
  545. return false;
  546. }
  547. loc.add(loc, 1, 0, 0);
  548. if(block.getType(loc) != "km:bronze_block") {
  549. return false;
  550. }
  551. loc.add(loc, -1, 0, -1);
  552. if(block.getType(loc) != "km:bronze_block") {
  553. return false;
  554. }
  555. loc.add(loc, 0, 0, 2);
  556. if(block.getType(loc) != "km:bronze_block") {
  557. return false;
  558. }
  559. loc.add(loc, 0, 1, -1);
  560. if(block.getType(loc) != "km:copper_block") {
  561. return false;
  562. }
  563. loc.add(loc, 0, 1, 0);
  564. if(block.getType(loc) != "km:copper_block") {
  565. return false;
  566. }
  567. loc.add(loc, -2, -4, -2);
  568. if(block.getType(loc) != "km:bronze_block") {
  569. return false;
  570. }
  571. loc.add(loc, 0, -1, 0);
  572. if(block.getType(loc) != "km:bronze_block") {
  573. return false;
  574. }
  575. loc.add(loc, 0, -1, 0);
  576. if(block.getType(loc) != "km:bronze_block") {
  577. return false;
  578. }
  579. loc.add(loc, 0, 0, 4);
  580. if(block.getType(loc) != "km:bronze_block") {
  581. return false;
  582. }
  583. loc.add(loc, 0, 1, 0);
  584. if(block.getType(loc) != "km:bronze_block") {
  585. return false;
  586. }
  587. loc.add(loc, 0, 1, 0);
  588. if(block.getType(loc) != "km:bronze_block") {
  589. return false;
  590. }
  591. loc.add(loc, 4, 0, 0);
  592. if(block.getType(loc) != "km:bronze_block") {
  593. return false;
  594. }
  595. loc.add(loc, 0, -1, 0);
  596. if(block.getType(loc) != "km:bronze_block") {
  597. return false;
  598. }
  599. loc.add(loc, 0, -1, 0);
  600. if(block.getType(loc) != "km:bronze_block") {
  601. return false;
  602. }
  603. loc.add(loc, 0, 0, -4);
  604. if(block.getType(loc) != "km:bronze_block") {
  605. return false;
  606. }
  607. loc.add(loc, 0, 1, 0);
  608. if(block.getType(loc) != "km:bronze_block") {
  609. return false;
  610. }
  611. loc.add(loc, 0, 1, 0);
  612. if(block.getType(loc) != "km:bronze_block") {
  613. return false;
  614. }
  615. loc.add(loc, 0, -3, 0);
  616. if(block.getType(loc) != "km:bronze_block") {
  617. return false;
  618. }
  619. loc.add(loc, -1, 0, 0);
  620. if(block.getType(loc) != "km:bronze_block") {
  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, 0, 0, 1);
  636. if(block.getType(loc) != "km:bronze_block") {
  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, 1, 0, 0);
  652. if(block.getType(loc) != "km:bronze_block") {
  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, 0, 0, -1);
  668. if(block.getType(loc) != "km:bronze_block") {
  669. return false;
  670. }
  671. loc.add(loc, 0, 0, -1);
  672. if(block.getType(loc) != "km:bronze_block") {
  673. return false;
  674. }
  675. loc.add(loc, 0, 0, -1);
  676. if(block.getType(loc) != "km:bronze_block") {
  677. return false;
  678. }
  679. loc.add(loc, -1, 0, 0);
  680. if(block.getType(loc) != "minecraft:stone_bricks") {
  681. return false;
  682. }
  683. loc.add(loc, -2, 0, 0);
  684. if(block.getType(loc) != "minecraft:stone_bricks") {
  685. return false;
  686. }
  687. loc.add(loc, 0, 0, 2);
  688. if(block.getType(loc) != "minecraft:stone_bricks") {
  689. return false;
  690. }
  691. loc.add(loc, 2, 0, 0);
  692. if(block.getType(loc) != "minecraft:stone_bricks") {
  693. return false;
  694. }
  695. loc.add(loc, -1, 0, 0);
  696. if(block.getType(loc) != "km:bronze_block") {
  697. return false;
  698. }
  699. loc.add(loc, -1, 0, -1);
  700. if(block.getType(loc) != "km:bronze_block") {
  701. return false;
  702. }
  703. loc.add(loc, 1, 0, 0);
  704. if(block.getType(loc) != "km:bronze_block") {
  705. return false;
  706. }
  707. loc.add(loc, 1, 0, 0);
  708. if(block.getType(loc) != "km:bronze_block") {
  709. return false;
  710. }
  711. loc.add(loc, -1, 0, -1);
  712. if(block.getType(loc) != "km:bronze_block") {
  713. return false;
  714. }
  715. return true;
  716. }
  717. function isATpReceiver(chest_loc) {
  718. loc = loc.mod(chest_loc, 0, 0 ,0);
  719. loc.add(loc, -1, 0, 0);
  720. if(block.getType(loc) != "minecraft:glowstone") {
  721. return false;
  722. }
  723. loc.add(loc, 2, 0, 0);
  724. if(block.getType(loc) != "minecraft:glowstone") {
  725. return false;
  726. }
  727. loc.add(loc, -1, 0, -1);
  728. if(block.getType(loc) != "minecraft:glowstone") {
  729. return false;
  730. }
  731. loc.add(loc, 0, 0, 2);
  732. if(block.getType(loc) != "minecraft:glowstone") {
  733. return false;
  734. }
  735. loc.add(loc, -1, 0, 0);
  736. if(block.getType(loc) != "km:bronze_block") {
  737. return false;
  738. }
  739. loc.add(loc, 2, 0, 0);
  740. if(block.getType(loc) != "km:bronze_block") {
  741. return false;
  742. }
  743. loc.add(loc, 0, 0, -2);
  744. if(block.getType(loc) != "km:bronze_block") {
  745. return false;
  746. }
  747. loc.add(loc, -2, 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, 0, 0, 1);
  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) != "minecraft:dark_prismarine_slab") {
  765. return false;
  766. }
  767. loc.add(loc, 1, 0, 0);
  768. if(block.getType(loc) != "km:bronze_block") {
  769. return false;
  770. }
  771. loc.add(loc, 1, 0, 0);
  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) != "minecraft:dark_prismarine_slab") {
  781. return false;
  782. }
  783. loc.add(loc, 0, 0, -1);
  784. if(block.getType(loc) != "km:bronze_block") {
  785. return false;
  786. }
  787. loc.add(loc, 0, 0, -1);
  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) != "minecraft:dark_prismarine_slab") {
  797. return false;
  798. }
  799. loc.add(loc, -1, 0, 0);
  800. if(block.getType(loc) != "km:bronze_block") {
  801. return false;
  802. }
  803. loc.add(loc, -1, 0, 0);
  804. if(block.getType(loc) != "km:bronze_block") {
  805. return false;
  806. }
  807. loc.add(loc, -1, 0, 0);
  808. if(block.getType(loc) != "km:bronze_block") {
  809. return false;
  810. }
  811. loc.add(loc, -1, 0, 0);
  812. if(block.getType(loc) != "minecraft:dark_prismarine_slab") {
  813. return false;
  814. }
  815. loc.add(loc, 1, 1, 2);
  816. if(block.getType(loc) != "km:bronze_block") {
  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, 0);
  824. if(block.getType(loc) != "km:bronze_block") {
  825. return false;
  826. }
  827. loc.add(loc, -1, 0, -1);
  828. if(block.getType(loc) != "km:bronze_block") {
  829. return false;
  830. }
  831. loc.add(loc, 0, 0, 2);
  832. if(block.getType(loc) != "km:bronze_block") {
  833. return false;
  834. }
  835. loc.add(loc, -2, -2, -3);
  836. if(block.getType(loc) != "km:bronze_block") {
  837. return false;
  838. }
  839. loc.add(loc, 0, -1, 0);
  840. if(block.getType(loc) != "km:bronze_block") {
  841. return false;
  842. }
  843. loc.add(loc, 0, -1, 0);
  844. if(block.getType(loc) != "km:bronze_block") {
  845. return false;
  846. }
  847. loc.add(loc, 0, 0, 4);
  848. if(block.getType(loc) != "km:bronze_block") {
  849. return false;
  850. }
  851. loc.add(loc, 0, 1, 0);
  852. if(block.getType(loc) != "km:bronze_block") {
  853. return false;
  854. }
  855. loc.add(loc, 0, 1, 0);
  856. if(block.getType(loc) != "km:bronze_block") {
  857. return false;
  858. }
  859. loc.add(loc, 4, 0, 0);
  860. if(block.getType(loc) != "km:bronze_block") {
  861. return false;
  862. }
  863. loc.add(loc, 0, -1, 0);
  864. if(block.getType(loc) != "km:bronze_block") {
  865. return false;
  866. }
  867. loc.add(loc, 0, -1, 0);
  868. if(block.getType(loc) != "km:bronze_block") {
  869. return false;
  870. }
  871. loc.add(loc, 0, 0, -4);
  872. if(block.getType(loc) != "km:bronze_block") {
  873. return false;
  874. }
  875. loc.add(loc, 0, 1, 0);
  876. if(block.getType(loc) != "km:bronze_block") {
  877. return false;
  878. }
  879. loc.add(loc, 0, 1, 0);
  880. if(block.getType(loc) != "km:bronze_block") {
  881. return false;
  882. }
  883. loc.add(loc, 0, -3, 0);
  884. if(block.getType(loc) != "km:bronze_block") {
  885. return false;
  886. }
  887. loc.add(loc, -1, 0, 0);
  888. if(block.getType(loc) != "km:bronze_block") {
  889. return false;
  890. }
  891. loc.add(loc, -1, 0, 0);
  892. if(block.getType(loc) != "km:bronze_block") {
  893. return false;
  894. }
  895. loc.add(loc, -1, 0, 0);
  896. if(block.getType(loc) != "km:bronze_block") {
  897. return false;
  898. }
  899. loc.add(loc, -1, 0, 0);
  900. if(block.getType(loc) != "km:bronze_block") {
  901. return false;
  902. }
  903. loc.add(loc, 0, 0, 1);
  904. if(block.getType(loc) != "km:bronze_block") {
  905. return false;
  906. }
  907. loc.add(loc, 0, 0, 1);
  908. if(block.getType(loc) != "km:bronze_block") {
  909. return false;
  910. }
  911. loc.add(loc, 0, 0, 1);
  912. if(block.getType(loc) != "km:bronze_block") {
  913. return false;
  914. }
  915. loc.add(loc, 0, 0, 1);
  916. if(block.getType(loc) != "km:bronze_block") {
  917. return false;
  918. }
  919. loc.add(loc, 1, 0, 0);
  920. if(block.getType(loc) != "km:bronze_block") {
  921. return false;
  922. }
  923. loc.add(loc, 1, 0, 0);
  924. if(block.getType(loc) != "km:bronze_block") {
  925. return false;
  926. }
  927. loc.add(loc, 1, 0, 0);
  928. if(block.getType(loc) != "km:bronze_block") {
  929. return false;
  930. }
  931. loc.add(loc, 1, 0, 0);
  932. if(block.getType(loc) != "km:bronze_block") {
  933. return false;
  934. }
  935. loc.add(loc, 0, 0, -1);
  936. if(block.getType(loc) != "km:bronze_block") {
  937. return false;
  938. }
  939. loc.add(loc, 0, 0, -1);
  940. if(block.getType(loc) != "km:bronze_block") {
  941. return false;
  942. }
  943. loc.add(loc, 0, 0, -1);
  944. if(block.getType(loc) != "km:bronze_block") {
  945. return false;
  946. }
  947. loc.add(loc, -1, 0, 0);
  948. if(block.getType(loc) != "minecraft:dark_prismarine") {
  949. return false;
  950. }
  951. loc.add(loc, -2, 0, 0);
  952. if(block.getType(loc) != "minecraft:dark_prismarine") {
  953. return false;
  954. }
  955. loc.add(loc, 0, 0, 2);
  956. if(block.getType(loc) != "minecraft:dark_prismarine") {
  957. return false;
  958. }
  959. loc.add(loc, 2, 0, 0);
  960. if(block.getType(loc) != "minecraft:dark_prismarine") {
  961. return false;
  962. }
  963. loc.add(loc, -1, 0, 0);
  964. if(block.getType(loc) != "km:bronze_block") {
  965. return false;
  966. }
  967. loc.add(loc, -1, 0, -1);
  968. if(block.getType(loc) != "km:bronze_block") {
  969. return false;
  970. }
  971. loc.add(loc, 1, 0, 0);
  972. if(block.getType(loc) != "km:bronze_block") {
  973. return false;
  974. }
  975. loc.add(loc, 1, 0, 0);
  976. if(block.getType(loc) != "km:bronze_block") {
  977. return false;
  978. }
  979. loc.add(loc, -1, 0, -1);
  980. if(block.getType(loc) != "km:bronze_block") {
  981. return false;
  982. }
  983. return true;
  984. }
  985. function setWalls(chest_loc, item_type) {
  986. block.set(loc.mod(chest_loc, 2, -1, -1), item_type);
  987. block.set(loc.mod(chest_loc, 2, -1, 0), item_type);
  988. block.set(loc.mod(chest_loc, 2, -1, 1), item_type);
  989. block.set(loc.mod(chest_loc, -2, -1, -1), item_type);
  990. block.set(loc.mod(chest_loc, -2, -1, 0), item_type);
  991. block.set(loc.mod(chest_loc, -2, -1, 1), item_type);
  992. block.set(loc.mod(chest_loc, -1, -1, 2), item_type);
  993. block.set(loc.mod(chest_loc, 0, -1, 2), item_type);
  994. block.set(loc.mod(chest_loc, 1, -1, 2), item_type);
  995. block.set(loc.mod(chest_loc, -1, -1, -2), item_type);
  996. block.set(loc.mod(chest_loc, 0, -1, -2), item_type);
  997. block.set(loc.mod(chest_loc, 1, -1, -2), item_type);
  998. block.set(loc.mod(chest_loc, 2, -2, -1), item_type);
  999. block.set(loc.mod(chest_loc, 2, -2, 0), item_type);
  1000. block.set(loc.mod(chest_loc, 2, -2, 1), item_type);
  1001. block.set(loc.mod(chest_loc, -2, -2, -1), item_type);
  1002. block.set(loc.mod(chest_loc, -2, -2, 0), item_type);
  1003. block.set(loc.mod(chest_loc, -2, -2, 1), item_type);
  1004. block.set(loc.mod(chest_loc, -1, -2, 2), item_type);
  1005. block.set(loc.mod(chest_loc, 0, -2, 2), item_type);
  1006. block.set(loc.mod(chest_loc, 1, -2, 2), item_type);
  1007. block.set(loc.mod(chest_loc, -1, -2, -2), item_type);
  1008. block.set(loc.mod(chest_loc, 0, -2, -2), item_type);
  1009. block.set(loc.mod(chest_loc, 1, -2, -2), item_type);
  1010. block.set(loc.mod(chest_loc, 2, -3, -1), item_type);
  1011. block.set(loc.mod(chest_loc, 2, -3, 0), item_type);
  1012. block.set(loc.mod(chest_loc, 2, -3, 1), item_type);
  1013. block.set(loc.mod(chest_loc, -2, -3, -1), item_type);
  1014. block.set(loc.mod(chest_loc, -2, -3, 0), item_type);
  1015. block.set(loc.mod(chest_loc, -2, -3, 1), item_type);
  1016. block.set(loc.mod(chest_loc, -1, -3, 2), item_type);
  1017. block.set(loc.mod(chest_loc, 0, -3, 2), item_type);
  1018. block.set(loc.mod(chest_loc, 1, -3, 2), item_type);
  1019. block.set(loc.mod(chest_loc, -1, -3, -2), item_type);
  1020. block.set(loc.mod(chest_loc, 0, -3, -2), item_type);
  1021. block.set(loc.mod(chest_loc, 1, -3, -2), item_type);
  1022. }
  1023. function removeAdventureDisplay(player) {
  1024. display.remove(player, 10);
  1025. }
  1026. function addAdventureDisplay(player, location) {
  1027. x = text.number(loc.getX(location));
  1028. y = text.number(loc.getY(location));
  1029. z = text.number(loc.getZ(location));
  1030. display.add(player, 10, concat("§2Adventure Target: §r", x, " ", y, " ", z));
  1031. }
  1032. //--------------------------------------------------
  1033. //Player-Data-Utils
  1034. //--------------------------------------------------
  1035. function playerdata.getSurvival(player_or_id) {
  1036. if(isPlayer(player_or_id)) {
  1037. player_id = player.getId(player_or_id);
  1038. } else {
  1039. player_id = player_or_id;
  1040. loadData(player_id, getScriptVar("survival_data"), "survival_data");
  1041. }
  1042. //On player_login data is needed, but the data isn't loaded yet, so the config can be null at this point
  1043. config = map.get(getScriptVar("survival_data"), player_id);
  1044. if(config == null) {
  1045. loadData(player_id, getScriptVar("survival_data"), "survival_data");
  1046. config = map.get(getScriptVar("survival_data"), player_id);
  1047. }
  1048. return config;
  1049. }
  1050. function playerdata.getGames(player_or_id) {
  1051. if(isPlayer(player_or_id)) {
  1052. player_id = player.getId(player_or_id);
  1053. } else {
  1054. player_id = player_or_id;
  1055. loadData(player_id, getScriptVar("games_data"), "games_data");
  1056. }
  1057. //On player_login data is needed, but the data isn't loaded yet, so the config can be null at this point
  1058. config = map.get(getScriptVar("games_data"), player_id);
  1059. if(config == null) {
  1060. loadData(player_id, getScriptVar("games_data"), "games_data");
  1061. config = map.get(getScriptVar("games_data"), player_id);
  1062. }
  1063. return config;
  1064. }
  1065. function loadData(player_or_id, map, name) {
  1066. if(isPlayer(player_or_id)) {
  1067. player_id = player.getId(player_or_id);
  1068. } else {
  1069. player_id = player_or_id;
  1070. }
  1071. config = map.get(map, player_id);
  1072. if(config == null) {
  1073. config = config.new(concat("scripts/configs/player_data/", name), player_id);
  1074. if(config.exists(config)) {
  1075. config.load(config);
  1076. }
  1077. map.add(map, player_id, config);
  1078. }
  1079. }
  1080. //--------------------------------------------------
  1081. //Msg-Utils
  1082. //--------------------------------------------------
  1083. function msg.quest(player, speaker, line_now, line_max, message) {
  1084. msg(player, concat("[§b", text.number(line_now), "§r/§b", text.number(line_max), "§r] §a", speaker, " §r| ", concat("§e", message)));
  1085. }
  1086. function sendMessageToWorld(world, message) {
  1087. world_name = world.getName(world);
  1088. if(isSurvWorldName(world_name)) {
  1089. worldlist = players.toWorldList(world.getOverWorld());
  1090. for(i = 0; i < list.getSize(worldlist); i++) {
  1091. msg(list.getIndex(worldlist, i), message);
  1092. }
  1093. worldlist = players.toWorldList(world.get("the_end"));
  1094. for(i = 0; i < list.getSize(worldlist); i++) {
  1095. msg(list.getIndex(worldlist, i), message);
  1096. }
  1097. worldlist = players.toWorldList(world.get("the_nether"));
  1098. for(i = 0; i < list.getSize(worldlist); i++) {
  1099. msg(list.getIndex(worldlist, i), message);
  1100. }
  1101. return;
  1102. }
  1103. worldlist = players.toWorldList(world);
  1104. for(i = 0; i < list.getSize(worldlist); i++) {
  1105. msg(list.getIndex(worldlist, i), message);
  1106. }
  1107. }
  1108. function sendMessageToWorld2(world, message1, message2) {
  1109. world_name = world.getName(world);
  1110. if(isSurvWorldName(world_name)) {
  1111. worldlist = players.toWorldList(world.getOverWorld());
  1112. for(i = 0; i < list.getSize(worldlist); i++) {
  1113. msg(list.getIndex(worldlist, i), message1, message2);
  1114. }
  1115. worldlist = players.toWorldList(world.get("the_end"));
  1116. for(i = 0; i < list.getSize(worldlist); i++) {
  1117. msg(list.getIndex(worldlist, i), message1, message2);
  1118. }
  1119. worldlist = players.toWorldList(world.get("the_nether"));
  1120. for(i = 0; i < list.getSize(worldlist); i++) {
  1121. msg(list.getIndex(worldlist, i), message1, message2);
  1122. }
  1123. return;
  1124. }
  1125. worldlist = players.toWorldList(world);
  1126. for(i = 0; i < list.getSize(worldlist); i++) {
  1127. msg(list.getIndex(worldlist, i), message1, message2);
  1128. }
  1129. }
  1130. function sendOnlineMessage(player, message) {
  1131. nickname = player.getNickName(player);
  1132. rank = getRank(player);
  1133. colorcode = text.subString(rank, 0, 2);
  1134. if(player.getId(player) == 35) {
  1135. nickname = concat(nickname, "§r][§e§l★");
  1136. rank = concat(rank, "\n§eSpecial VIP for Special Services");
  1137. }
  1138. online_list = players.toList();
  1139. iter = list.iterator(online_list);
  1140. while(hasNext(iter)) {
  1141. p = next(iter);
  1142. if(player.hasMinigame(p) && player.isMuted(p)) {
  1143. continue;
  1144. }
  1145. msg(p, "[", text.hover(concat(colorcode, nickname), rank), "§r] §r", message);
  1146. }
  1147. }
  1148. function sendmessage(pname, prefix, nachricht, boolean) { //Deprecated
  1149. player.sendMessage($player, pname, prefix, nachricht, boolean);
  1150. }
  1151. function player.sendMessage(from_player, to_name, prefix, message, send_mail) {
  1152. p = read.player(to_name);
  1153. if(p == null) {
  1154. mail.send(player.getName(from_player), to_name, message);
  1155. } elseif(send_mail) {
  1156. player.speakPrefix(p, prefix, message);
  1157. }
  1158. }
  1159. function speakPrefix(player, prefix, message) { //Deprecated
  1160. msg.prefix(player, prefix, message);
  1161. }
  1162. function player.speakPrefix(player, prefix, message) { //Deprecated
  1163. msg.prefix(player, prefix, message);
  1164. }
  1165. function msg.prefix(player, prefix, message) {
  1166. msg(player, concat("§r[", prefix, "§r] ", message));
  1167. }
  1168. function msg.radius(prefix, message, location, radius) {
  1169. list = players.near(location, radius);
  1170. iter = list.iterator(list);
  1171. while(hasNext(iter)) {
  1172. player.speakPrefix(next(iter), prefix, message);
  1173. }
  1174. }
  1175. //--------------------------------------------------
  1176. //Player-Utils
  1177. //--------------------------------------------------
  1178. function player.showDebug(player, boolean) {
  1179. player_uuid = player.getUuid(player);
  1180. if(boolean) {
  1181. perm.registerPlayer(player_uuid, 16);
  1182. } else {
  1183. perm.unregisterPlayer(player_uuid, 16);
  1184. }
  1185. }
  1186. function player.showDefaultStacks(player) {
  1187. stacks.clear(player);
  1188. stacks.set(player, 0, "km:gear");
  1189. }
  1190. function player.setSpeed(player, speed) {
  1191. living.setMovementSpeed(player, speed / 10);
  1192. living.setFlyingSpeed(player, speed / 10 * 4);
  1193. }
  1194. function player.hasEnoughFreeArea(player, area) {
  1195. free_area = player.getFreePlotArea(player);
  1196. if(free_area == -1) {
  1197. return true;
  1198. }
  1199. used_area = player.getUsedPlotArea(player);
  1200. new_area = used_area + area;
  1201. return new_area < free_area;
  1202. }
  1203. function player.getFreePlotArea(player) {
  1204. if(perm.has(player, "plot.other")) {
  1205. return -1;
  1206. }
  1207. if(perm.has(player, "isVIP") || perm.has(player, "isTeam")) {
  1208. return 16000;
  1209. }
  1210. return 4000;
  1211. }
  1212. function player.getUsedPlotArea(player_or_id) {
  1213. config = playerdata.getSurvival(player_or_id);
  1214. return config.getDouble(config, "plot.usedsize", 0);
  1215. }
  1216. function player.setUsedPlotArea(player_or_id, amount) {
  1217. config = playerdata.getSurvival(player_or_id);
  1218. config.set(config, "plot.usedsize", amount);
  1219. config.saveAsync(config);
  1220. }
  1221. function player.activateSitting(player_or_id, boolean) {
  1222. config = playerdata.getSurvival(player_or_id);
  1223. config.set(config, "sitting", boolean);
  1224. config.saveAsync(config);
  1225. }
  1226. function player.hasSittingActivated(player_or_id) {
  1227. config = playerdata.getSurvival(player_or_id);
  1228. return config.getBool(config, "sitting", true);
  1229. }
  1230. function player.acceptTpaRequests(player_or_id, boolean) {
  1231. config = playerdata.getSurvival(player_or_id);
  1232. config.set(config, "tptoggle", boolean);
  1233. config.saveAsync(config);
  1234. }
  1235. function player.doesAcceptTpaRequests(player_or_id) {
  1236. config = playerdata.getSurvival(player_or_id);
  1237. return config.getBool(config, "tptoggle", true);
  1238. }
  1239. function player.getBackPos(player) {
  1240. config = playerdata.getSurvival(player);
  1241. location = config.getString(config, "backpos", "null");
  1242. if(location == "null") {
  1243. location = null;
  1244. } else {
  1245. location = read.location(location);
  1246. }
  1247. return location;
  1248. }
  1249. function player.setBackPos(player) {
  1250. config = playerdata.getSurvival(player);
  1251. config.set(config, "backpos", text.location(entity.getLocation(player)));
  1252. config.saveAsync(config);
  1253. }
  1254. function player.clearBackPos(player) {
  1255. config = playerdata.getSurvival(player);
  1256. config.set(config, "backpos", "null");
  1257. config.saveAsync(config);
  1258. }
  1259. function player.getFromDamageSource(damage_source) {
  1260. entity = damage.getImmediateSource(damage_source);
  1261. if(isPlayer(entity)) {
  1262. return entity;
  1263. }
  1264. entity = damage.getTrueSource(damage_source);
  1265. if(isPlayer(entity)) {
  1266. return entity;
  1267. }
  1268. return null;
  1269. }
  1270. function player.getJoins(player_or_id) {
  1271. if(isPlayer(player_or_id)) {
  1272. player_id = player.getId(player_or_id);
  1273. } else {
  1274. player_id = player_or_id;
  1275. }
  1276. stmt = databank.prepare("SELECT COUNT(join_time) FROM playtime WHERE player_id = ?;");
  1277. databank.setInt(stmt, 1, player_id);
  1278. result = databank.execute(stmt);
  1279. if(databank.next(result)) {
  1280. amount = databank.getLong(result, 1);
  1281. }
  1282. databank.close(result);
  1283. databank.close(stmt);
  1284. return amount;
  1285. }
  1286. function player.getTotalPlaytime(player_or_id) {
  1287. if(isPlayer(player_or_id)) {
  1288. player_id = player.getId(player_or_id);
  1289. } else {
  1290. player_id = player_or_id;
  1291. }
  1292. //Online seit
  1293. since_minutes = 0;
  1294. if(isOnline(player.getNameFromId(player_id))) {
  1295. stmt = databank.prepare("SELECT join_time FROM playtime WHERE player_id = ? AND leave_time IS NULL;");
  1296. databank.setInt(stmt, 1, player_id);
  1297. result = databank.execute(stmt);
  1298. while(databank.next(result)) {
  1299. since_minutes = (time.getMillis() - databank.getLong(result, 1)) / 1000 / 60;
  1300. }
  1301. databank.close(result);
  1302. databank.close(stmt);
  1303. }
  1304. //Spielzeit gesamt
  1305. stmt2 = databank.prepare("SELECT SUM(leave_time - join_time) FROM playtime WHERE player_id = ?;");
  1306. databank.setInt(stmt2, 1, player_id);
  1307. result = databank.execute(stmt2);
  1308. while(databank.next(result)) {
  1309. minutes = databank.getLong(result, 1) / 1000 / 60 + since_minutes;
  1310. }
  1311. databank.close(result);
  1312. databank.close(stmt2);
  1313. return minutes;
  1314. }
  1315. function player.hasInvIgnore(player_or_id) {
  1316. config = playerdata.getSurvival(player_or_id);
  1317. return config.getBool(config, "invignore", false);
  1318. }
  1319. function player.invIgnore(player_or_id, boolean) {
  1320. config = playerdata.getSurvival(player_or_id);
  1321. config.set(config, "invignore", boolean);
  1322. config.saveAsync(config);
  1323. }
  1324. function player.setAdventureAmounts(player_or_id, amount) {
  1325. config = playerdata.getSurvival(player_or_id);
  1326. config.set(config, "adventures", amount);
  1327. config.saveAsync(config);
  1328. }
  1329. function player.getAdventureAmounts(player_or_id) {
  1330. config = playerdata.getSurvival(player_or_id);
  1331. return config.getDouble(config, "adventures", 0);
  1332. }
  1333. function player.isOnAdventure(player_or_id) {
  1334. config = playerdata.getSurvival(player_or_id);
  1335. return config.getBool(config, "onadventure", false);
  1336. }
  1337. function player.setAdventure(player_or_id, boolean) {
  1338. config = playerdata.getSurvival(player_or_id);
  1339. config.set(config, "onadventure", boolean);
  1340. config.saveAsync(config);
  1341. }
  1342. function player.getAdventureStart(player_or_id) {
  1343. config = playerdata.getSurvival(player_or_id);
  1344. location = config.getString(config, "adventureloc", "null");
  1345. if(location == "null") {
  1346. location = world.getServerSpawn();
  1347. } else {
  1348. location = read.location(location);
  1349. }
  1350. return location;
  1351. }
  1352. function player.setAdventureStart(player_or_id, location) {
  1353. config = playerdata.getSurvival(player_or_id);
  1354. config.set(config, "adventureloc", text.location(location));
  1355. config.saveAsync(config);
  1356. }
  1357. function player.isMuted(player_or_id) {
  1358. config = playerdata.getSurvival(player_or_id);
  1359. return config.getBool(config, "muted", false);
  1360. }
  1361. function player.mute(player_or_id, boolean) {
  1362. config = playerdata.getSurvival(player_or_id);
  1363. config.set(config, "muted", boolean);
  1364. config.saveAsync(config);
  1365. }
  1366. function player.getSilentJoin(player_or_id) {
  1367. config = playerdata.getSurvival(player_or_id);
  1368. return config.getBool(config, "silentjoin", false);
  1369. }
  1370. function player.setSilentJoin(player_or_id, boolean) {
  1371. config = playerdata.getSurvival(player_or_id);
  1372. config.set(config, "silentjoin", boolean);
  1373. config.saveAsync(config);
  1374. }
  1375. function player.getAutoCloseDoor(player_or_id) {
  1376. config = playerdata.getSurvival(player_or_id);
  1377. return config.getBool(config, "door_auto_close", true);
  1378. }
  1379. function player.setAutoCloseDoor(player_or_id, boolean) {
  1380. config = playerdata.getSurvival(player_or_id);
  1381. config.set(config, "door_auto_close", boolean);
  1382. config.saveAsync(config);
  1383. }
  1384. function player.hasFirstJoin(player_or_id) {
  1385. config = playerdata.getSurvival(player_or_id);
  1386. return config.getBool(config, "firstjoin", true);
  1387. }
  1388. function player.setFirstJoin(player_or_id, boolean) {
  1389. config = playerdata.getSurvival(player_or_id);
  1390. config.set(config, "firstjoin", !boolean);
  1391. config.saveAsync(config);
  1392. }
  1393. function player.getFirstJoin(player_or_id) {
  1394. if(isPlayer(player_or_id)) {
  1395. player_id = player.getId(player_or_id);
  1396. } else {
  1397. player_id = player_or_id;
  1398. }
  1399. stmt = databank.prepare("SELECT MIN(join_time) FROM playtime WHERE player_id = ?;");
  1400. databank.setInt(stmt, 1, player_id);
  1401. result = databank.execute(stmt);
  1402. if(databank.next(result)) {
  1403. time = databank.getLong(result, 1);
  1404. }
  1405. databank.close(result);
  1406. databank.close(stmt);
  1407. return time;
  1408. }
  1409. function player.getLastJoin(player_or_id) {
  1410. if(isPlayer(player_or_id)) {
  1411. player_id = player.getId(player_or_id);
  1412. } else {
  1413. player_id = player_or_id;
  1414. }
  1415. stmt = databank.prepare("SELECT MAX(join_time) FROM playtime WHERE player_id = ?;");
  1416. databank.setInt(stmt, 1, player_id);
  1417. result = databank.execute(stmt);
  1418. if(databank.next(result)) {
  1419. time = databank.getLong(result, 1);
  1420. }
  1421. databank.close(result);
  1422. databank.close(stmt);
  1423. return time;
  1424. }
  1425. function player.blockCommands(player) {
  1426. list = getScriptVar("block_commands_list");
  1427. list.add(list, player.getUuid(player));
  1428. }
  1429. function player.unblockCommands(player) {
  1430. list = getScriptVar("block_commands_list");
  1431. player_uuid = player.getUuid(player);
  1432. while(list.contains(list, player_uuid)) {
  1433. list.remove(list, player_uuid);
  1434. }
  1435. }
  1436. function player.isCommandBlocked(player) {
  1437. list = getScriptVar("block_commands_list");
  1438. return list.contains(list, player.getUuid(player));
  1439. }
  1440. //--------------------------------------------------
  1441. //Block-Utils
  1442. //--------------------------------------------------
  1443. function block.getSecondDoor(door_loc_1) {
  1444. prop_h_facing = block.getProperty("horizontal_facing");
  1445. state_facing = block.getState(door_loc_1, prop_h_facing);
  1446. prop_hinge = block.getProperty("hinge");
  1447. state_hinge = block.getState(door_loc_1, prop_hinge);
  1448. if(state_facing == "north") {
  1449. if(state_hinge == "right") {
  1450. door_loc_2 = loc.mod(door_loc_1, -1, 0, 0);
  1451. } else {
  1452. door_loc_2 = loc.mod(door_loc_1, 1, 0, 0);
  1453. }
  1454. } elseif(state_facing == "east") {
  1455. if(state_hinge == "right") {
  1456. door_loc_2 = loc.mod(door_loc_1, 0, 0, -1);
  1457. } else {
  1458. door_loc_2 = loc.mod(door_loc_1, 0, 0, 1);
  1459. }
  1460. } elseif(state_facing == "south") {
  1461. if(state_hinge == "right") {
  1462. door_loc_2 = loc.mod(door_loc_1, 1, 0, 0);
  1463. } else {
  1464. door_loc_2 = loc.mod(door_loc_1, -1, 0, 0);
  1465. }
  1466. } else {
  1467. if(state_hinge == "right") {
  1468. door_loc_2 = loc.mod(door_loc_1, 0, 0, 1);
  1469. } else {
  1470. door_loc_2 = loc.mod(door_loc_1, 0, 0, -1);
  1471. }
  1472. }
  1473. if(block.isDoor(door_loc_2)) {
  1474. if(block.isSameDoorHalf(door_loc_1, door_loc_2)) {
  1475. state_hinge_2 = block.getState(door_loc_2, prop_hinge);
  1476. if(state_hinge == "left" && state_hinge_2 == "right" || state_hinge == "right" && state_hinge_2 == "left") {
  1477. return door_loc_2;
  1478. }
  1479. }
  1480. }
  1481. return null;
  1482. }
  1483. function block.isSameDoorHalf(door_loc_1, door_loc_2) {
  1484. prop_d_half = block.getProperty("double_block_half");
  1485. state_half = block.getState(door_loc_1, prop_d_half);
  1486. state_half_2 = block.getState(door_loc_2, prop_d_half);
  1487. return state_half == state_half_2;
  1488. }
  1489. //--------------------------------------------------
  1490. //Money-Utils
  1491. //--------------------------------------------------
  1492. function hasEnoughMoney(player_or_id, price) {
  1493. return getMoney(player_or_id) >= price;
  1494. }
  1495. function getMoney(player_or_id) {
  1496. config = playerdata.getSurvival(player_or_id);
  1497. return config.getDouble(config, "money", 0);
  1498. }
  1499. function setMoney(player_or_id, money) {
  1500. config = playerdata.getSurvival(player_or_id);
  1501. config.set(config, "money", money);
  1502. config.saveAsync(config);
  1503. if(isPlayer(player_or_id)) {
  1504. displayMoney(player_or_id, money);
  1505. return;
  1506. }
  1507. if(player.get(player.getUuidFromId(player_or_id)) != null) {
  1508. displayMoney(player_or_id, money);
  1509. }
  1510. }
  1511. function addMoney(player_or_id, money) {
  1512. config = playerdata.getSurvival(player_or_id);
  1513. new_money = config.getDouble(config, "money", 0) + money;
  1514. config.set(config, "money", new_money);
  1515. config.saveAsync(config);
  1516. if(isPlayer(player_or_id)) {
  1517. displayMoney(player_or_id, new_money);
  1518. return;
  1519. }
  1520. player = player.get(player.getUuidFromId(player_or_id));
  1521. if(player != null) {
  1522. displayMoney(player, new_money);
  1523. }
  1524. }
  1525. function subMoney(player_or_id, money) {
  1526. config = playerdata.getSurvival(player_or_id);
  1527. new_money = config.getDouble(config, "money", 0) - money;
  1528. config.set(config, "money", new_money);
  1529. config.saveAsync(config);
  1530. if(isPlayer(player_or_id)) {
  1531. displayMoney(player_or_id, new_money);
  1532. return;
  1533. }
  1534. player = player.get(player.getUuidFromId(player_or_id));
  1535. if(player != null) {
  1536. displayMoney(player, new_money);
  1537. }
  1538. }
  1539. function displayMoney(player, money) {
  1540. a = money.split(money);
  1541. display.add(player, 0, concat("#23-1- ", text.number(a[0])));
  1542. display.add(player, 1, concat("#24-1- ", text.number(a[1])));
  1543. display.add(player, 2, concat("#25-1- ", text.number(a[2])));
  1544. }
  1545. function money.split(money) {
  1546. array = array.new(3);
  1547. gold = math.roundDown(money / 4096);
  1548. pre_silver = money % 4096;;
  1549. silver = math.roundDown(pre_silver / 64);
  1550. bronze = pre_silver % 64;
  1551. array[0] = gold;
  1552. array[1] = silver;
  1553. array[2] = bronze;
  1554. return array;
  1555. }
  1556. //--------------------------------------------------
  1557. //Plot-Utils
  1558. //--------------------------------------------------
  1559. function plot.getIdFromLocation(location) {
  1560. list = plot.get(location);
  1561. if(list.getSize(list) == 0) {
  1562. plot_id = null;
  1563. } else {
  1564. plot = list.getIndex(list, 0);
  1565. plot_id = plot.getId(plot);
  1566. }
  1567. return plot_id;
  1568. }
  1569. function plot.addPlayer(plot, player_name) {
  1570. list = plot.getOwners(plot);
  1571. uuid = player.getUuid(player_name);
  1572. if(!list.contains(list, uuid)) {
  1573. list.add(list, uuid);
  1574. }
  1575. }
  1576. function plot.removePlayer(plot, player_name) {
  1577. list = plot.getOwners(plot);
  1578. uuid = player.getUuid(player_name);
  1579. list.remove(list, uuid);
  1580. player_id = player.getId(player.getUuid(player_name));
  1581. plot.removeRank(plot, player_id);
  1582. }
  1583. function plot.getOwnersString(plot) {
  1584. list = plot.getOwners(plot);
  1585. if(list.getSize(list) == 0) {
  1586. return "";
  1587. }
  1588. owners_list = list.new();
  1589. for(i = 0; i < list.getSize(list); i++) {
  1590. list.add(owners_list, player.getName(list.getIndex(list, i)));
  1591. }
  1592. return text.concatList(owners_list, " / ", 0, list.getSize(owners_list) - 1);
  1593. }
  1594. function plot.isLeader(plot, player_id) {
  1595. return plot.getRank(plot, player_id) == "leader";
  1596. }
  1597. function getPlotLeader(plot) {
  1598. plot_id = plot.getId(plot);
  1599. stmt = databank.prepare("SELECT player_id FROM plotranks WHERE plot_id = ? AND rank = ?;");
  1600. databank.setInt(stmt, 1, plot_id);
  1601. databank.setString(stmt, 2, "leader");
  1602. result = databank.execute(stmt);
  1603. while(databank.next(result)) {
  1604. player_id = databank.getInt(result, 1);
  1605. }
  1606. databank.close(result);
  1607. databank.close(stmt);
  1608. return player_id;
  1609. }
  1610. function plot.getRank(plot, player_id) {
  1611. plot_id = plot.getId(plot);
  1612. stmt = databank.prepare("SELECT rank FROM plotranks WHERE player_id = ? AND plot_id = ?;");
  1613. databank.setInt(stmt, 1, player_id);
  1614. databank.setInt(stmt, 2, plot_id);
  1615. result = databank.execute(stmt);
  1616. while(databank.next(result)) {
  1617. rank = databank.getString(result, 1);
  1618. }
  1619. databank.close(result);
  1620. databank.close(stmt);
  1621. return rank;
  1622. }
  1623. function plot.setRank(plot, player_id, rank) {
  1624. plot_id = plot.getId(plot);
  1625. stmt = databank.prepare("INSERT INTO plotranks (plot_id, player_id, rank) VALUES (?,?,?)");
  1626. databank.setInt(stmt, 1, plot_id);
  1627. databank.setInt(stmt, 2, player_id);
  1628. databank.setString(stmt, 3, rank);
  1629. databank.workerExecute(stmt);
  1630. }
  1631. function plot.removeRank(plot, player_id) {
  1632. plot_id = plot.getId(plot);
  1633. stmt = databank.prepare("DELETE FROM plotranks WHERE player_id = ? AND plot_id = ?;");
  1634. databank.setInt(stmt, 1, player_id);
  1635. databank.setInt(stmt, 2, plot_id);
  1636. databank.workerExecute(stmt);
  1637. }
  1638. function plot.removeAllPlayers(plot) {
  1639. list = plot.getOwners(plot);
  1640. iter = list.iterator(list);
  1641. while(hasNext(iter)) {
  1642. plot.removeRank(plot, player.getId(next(iter)));
  1643. }
  1644. }
  1645. function plot.setEdges(plot, location1, location2) {
  1646. //Alte Daten abrufen
  1647. plot_name = plot.getName(plot);
  1648. list = plot.getOwners(plot);
  1649. flags = plot.getFlags(plot);
  1650. //Neues Plot erstellen und altes Plot löschen
  1651. new_plot = plot.add(location1, location2);
  1652. world = loc.getWorld(location1);
  1653. plot.remove(plot, world);
  1654. //Alte Daten auf neuem Plot setzen
  1655. plot.setName(new_plot, plot_name);
  1656. new_list = plot.getOwners(new_plot);
  1657. for(i = 0; i < list.getSize(list); i++) {
  1658. list.add(new_list, list.getIndex(list, i));
  1659. }
  1660. plot.setFlags(new_plot, flags, true);
  1661. }
  1662. function getFlags(plot, getActive) { //getActive = true means getActiveFlags
  1663. flags = plot.getFlags(plot);
  1664. flags_true = list.new();
  1665. flags_false = list.new();
  1666. array = array.new(2);
  1667. array[0] = 128;
  1668. array[1] = "FARM_FLAG";
  1669. if(flags >= 128) {
  1670. list.add(flags_true, array);
  1671. flags -= 128;
  1672. } else {
  1673. list.add(flags_false, array);
  1674. }
  1675. array = array.new(2);
  1676. array[0] = 64;
  1677. array[1] = "EXPLOSION_FLAG";
  1678. if(flags >= 64) {
  1679. list.add(flags_true, array);
  1680. flags -= 64;
  1681. } else {
  1682. list.add(flags_false, array);
  1683. }
  1684. array = array.new(2);
  1685. array[0] = 32;
  1686. array[1] = "ENTITY_INTERACT_FLAG";
  1687. if(flags >= 32) {
  1688. list.add(flags_true, array);
  1689. flags -= 32;
  1690. } else {
  1691. list.add(flags_false, array);
  1692. }
  1693. array = array.new(2);
  1694. array[0] = 16;
  1695. array[1] = "BLOCK_INTERACT_FLAG";
  1696. if(flags >= 16) {
  1697. list.add(flags_true, array);
  1698. flags -= 16;
  1699. } else {
  1700. list.add(flags_false, array);
  1701. }
  1702. array = array.new(2);
  1703. array[0] = 8;
  1704. array[1] = "HIT_AMBIENT_FLAG";
  1705. if(flags >= 8) {
  1706. list.add(flags_true, array);
  1707. flags -= 8;
  1708. } else {
  1709. list.add(flags_false, array);
  1710. }
  1711. array = array.new(2);
  1712. array[0] = 4;
  1713. array[1] = "BUCKET_FLAG";
  1714. if(flags >= 4) {
  1715. list.add(flags_true, array);
  1716. flags -= 4;
  1717. } else {
  1718. list.add(flags_false, array);
  1719. }
  1720. array = array.new(2);
  1721. array[0] = 2;
  1722. array[1] = "BREAK_FLAG";
  1723. if(flags >= 2) {
  1724. list.add(flags_true, array);
  1725. flags -= 2;
  1726. } else {
  1727. list.add(flags_false, array);
  1728. }
  1729. array = array.new(2);
  1730. array[0] = 1;
  1731. array[1] = "PLACE_FLAG";
  1732. if(flags >= 1) {
  1733. list.add(flags_true, array);
  1734. } else {
  1735. list.add(flags_false, array);
  1736. }
  1737. if(getActive) {
  1738. return flags_true;
  1739. } else {
  1740. return flags_false;
  1741. }
  1742. }
  1743. //--------------------------------------------------
  1744. //Skill-Utils
  1745. //--------------------------------------------------
  1746. function skill.getAmount(player_or_id, tech_name) {
  1747. config = playerdata.getSurvival(player_or_id);
  1748. return config.getDouble(config, tech_name, 0);
  1749. }
  1750. function skill.setAmount(player_or_id, tech_name, amount) {
  1751. config = playerdata.getSurvival(player_or_id);
  1752. config.set(config, tech_name, amount);
  1753. config.saveAsync(config);
  1754. }
  1755. function skill.addAmount(player_or_id, tech_name, amount) {
  1756. config = playerdata.getSurvival(player_or_id);
  1757. config.set(config, tech_name, config.getDouble(config, tech_name, 0) + amount);
  1758. config.saveAsync(config);
  1759. }
  1760. function skill.add(skill_name, tech_name, item, description, cost, permanent) {
  1761. skill = array.new(6);
  1762. skill[0] = skill_name;
  1763. skill[1] = tech_name;
  1764. skill[2] = item;
  1765. skill[3] = description;
  1766. skill[4] = cost;
  1767. skill[5] = permanent;
  1768. list.add(getScriptVar("skills"), skill);
  1769. }
  1770. function skill.get(skill_name) {
  1771. skill_list = getScriptVar("skills");
  1772. for(i = 0; i < list.getSize(skill_list); i++) {
  1773. array = list.getIndex(skill_list, i);
  1774. temp_skill_name = array[0];
  1775. if(temp_skill_name == skill_name) {
  1776. return array;
  1777. }
  1778. }
  1779. }
  1780. function skill.getShopItem(player, skill_name) {
  1781. if(skill_name == null) {
  1782. return read.item("minecraft:air");
  1783. }
  1784. skill = skill.get(skill_name);
  1785. config = playerdata.getSurvival(player);
  1786. amount = config.getDouble(config, skill[1], 0);
  1787. if(skill[5]) {
  1788. prop = "Permanent";
  1789. if(amount == 0) {
  1790. text = concat("Bought: No");
  1791. } else {
  1792. text = concat("Bought: Yes");
  1793. }
  1794. } else {
  1795. prop = "Levelable";
  1796. text = concat("Amount you have: ", text.number(amount));
  1797. }
  1798. item = read.item(skill[2], 1, skill_name, concat("Cost: ", text.number(skill[4])), skill[3], prop, text);
  1799. return item;
  1800. }
  1801. function skill.getTechName(skill_name) {
  1802. skill_list = getScriptVar("skills");
  1803. for(i = 0; i < list.getSize(skill_list); i++) {
  1804. array = list.getIndex(skill_list, i);
  1805. temp_skill_name = array[0];
  1806. if(temp_skill_name == skill_name) {
  1807. return array[1];
  1808. }
  1809. }
  1810. }
  1811. function skill.getItem(skill_name) {
  1812. skill_list = getScriptVar("skills");
  1813. for(i = 0; i < list.getSize(skill_list); i++) {
  1814. array = list.getIndex(skill_list, i);
  1815. temp_skill_name = array[0];
  1816. if(temp_skill_name == skill_name) {
  1817. return array[2];
  1818. }
  1819. }
  1820. }
  1821. function skill.getDescription(skill_name) {
  1822. skill_list = getScriptVar("skills");
  1823. for(i = 0; i < list.getSize(skill_list); i++) {
  1824. array = list.getIndex(skill_list, i);
  1825. temp_skill_name = array[0];
  1826. if(temp_skill_name == skill_name) {
  1827. return array[3];
  1828. }
  1829. }
  1830. }
  1831. function skill.getCost(skill_name) {
  1832. skill_list = getScriptVar("skills");
  1833. for(i = 0; i < list.getSize(skill_list); i++) {
  1834. array = list.getIndex(skill_list, i);
  1835. temp_skill_name = array[0];
  1836. if(temp_skill_name == skill_name) {
  1837. return array[4];
  1838. }
  1839. }
  1840. }
  1841. function skill.isPermanent(skill_name) {
  1842. skill_list = getScriptVar("skills");
  1843. for(i = 0; i < list.getSize(skill_list); i++) {
  1844. array = list.getIndex(skill_list, i);
  1845. temp_skill_name = array[0];
  1846. if(temp_skill_name == skill_name) {
  1847. return array[5];
  1848. }
  1849. }
  1850. }
  1851. function skill.showShop(player, skill_name1, skill_name2, skill_name3, skill_name4, skill_name5, skill_name6, skill_name7, skill_name8, skill_name9) {
  1852. inv = inv.new(333333333);
  1853. inv.setItem(inv, 0, skill.getShopItem(player, skill_name1));
  1854. inv.setItem(inv, 1, skill.getShopItem(player, skill_name2));
  1855. inv.setItem(inv, 2, skill.getShopItem(player, skill_name3));
  1856. inv.setItem(inv, 3, skill.getShopItem(player, skill_name4));
  1857. inv.setItem(inv, 4, skill.getShopItem(player, skill_name5));
  1858. inv.setItem(inv, 5, skill.getShopItem(player, skill_name6));
  1859. inv.setItem(inv, 6, skill.getShopItem(player, skill_name7));
  1860. inv.setItem(inv, 7, skill.getShopItem(player, skill_name8));
  1861. inv.setItem(inv, 8, skill.getShopItem(player, skill_name9));
  1862. inv.open(inv, player, "Skillshop");
  1863. }
  1864. //--------------------------------------------------
  1865. //Loc-Utils
  1866. //--------------------------------------------------
  1867. function loc.isAir(location) {
  1868. type = block.getType(location);
  1869. return type == "minecraft:air" || type == "minecraft:cave_air";
  1870. }
  1871. function loc.isInGamesWorld(location) {
  1872. return loc.getWorld(location) == world.getGames();
  1873. }
  1874. function loc.isInCreativeWorld(location) {
  1875. return loc.getWorld(location) == world.getCreative();
  1876. }
  1877. //--------------------------------------------------
  1878. //Survival-Utils
  1879. //--------------------------------------------------
  1880. function joinSurvWorld(player) {
  1881. displayMoney(player, getMoney(player));
  1882. }
  1883. function living.setAi(bool) {
  1884. config = getScriptVar("server_config");
  1885. config.set(config, "spawnWithAi", bool);
  1886. config.saveAsync(config);
  1887. }
  1888. function living.getAi() {
  1889. config = getScriptVar("server_config");
  1890. return config.getBool(config, "spawnWithAi", true);
  1891. }
  1892. //--------------------------------------------------
  1893. //Games-Utils
  1894. //--------------------------------------------------
  1895. function joinGamesWorld(player) {
  1896. minigame.displayElo(player, minigame.getElo(player));
  1897. }
  1898. function minigame.displayElo(player, elo) {
  1899. display.add(player, 101, concat("§b§tElo: §r", text.number(elo)));
  1900. }
  1901. function minigame.setElo(player_or_id, elo) {
  1902. config = playerdata.getGames(player_or_id);
  1903. config.set(config, "game_elo", elo);
  1904. config.saveAsync(config);
  1905. if(isPlayer(player_or_id)) {
  1906. minigame.displayElo(player_or_id, elo);
  1907. }
  1908. }
  1909. function minigame.getElo(player_or_id) {
  1910. config = playerdata.getGames(player_or_id);
  1911. return config.getDouble(config, "game_elo", 0);
  1912. }
  1913. function minigame.addElo(player_or_id, elo) {
  1914. config = playerdata.getGames(player_or_id);
  1915. new_elo = config.getDouble(config, "game_elo", 0) + elo;
  1916. config.set(config, "game_elo", new_elo);
  1917. config.saveAsync(config);
  1918. if(isPlayer(player_or_id)) {
  1919. minigame.displayElo(player_or_id, new_elo);
  1920. player.speakPrefix(player_or_id, "§b§tElo", concat("§r+§e", text.number(elo)));
  1921. }
  1922. }
  1923. //--------------------------------------------------
  1924. //Afk-Utils
  1925. //--------------------------------------------------
  1926. function isAfk(player) {
  1927. player_uuid = player.getUuid(player);
  1928. afk_map = getScriptVar("afk_map");
  1929. if(map.contains(afk_map, player_uuid)) {
  1930. return true;
  1931. }
  1932. return false;
  1933. }
  1934. function setAfk(player, boolean) {
  1935. player_uuid = player.getUuid(player);
  1936. afk_map = getScriptVar("afk_map");
  1937. if(boolean) {
  1938. map.add(afk_map, player_uuid, loc.getYaw(entity.getLocation(player)));
  1939. } else {
  1940. map.remove(afk_map, player_uuid);
  1941. }
  1942. }
  1943. //--------------------------------------------------
  1944. //PvP-Utils
  1945. //--------------------------------------------------
  1946. function hasPvpOn(player_or_id) {
  1947. config = playerdata.getSurvival(player_or_id);
  1948. return config.getBool(config, "pvp", false);
  1949. }
  1950. function setPvp(player_or_id, bool) {
  1951. config = playerdata.getSurvival(player_or_id);
  1952. config.set(config, "pvp", bool);
  1953. config.save(config);
  1954. }
  1955. //--------------------------------------------------
  1956. //Rank-Utils
  1957. //--------------------------------------------------
  1958. function getRank(player_or_id) {
  1959. config = playerdata.getSurvival(player_or_id);
  1960. return config.getString(config, "rank", "§bUser");
  1961. }
  1962. function setRank(player_or_id, rank) {
  1963. rank = text.replace(rank, "&", "§");
  1964. config = playerdata.getSurvival(player_or_id);
  1965. config.set(config, "rank", rank);
  1966. config.save(config);
  1967. }
  1968. function offerRank(player, rank) {
  1969. rank2 = text.replace(rank, "§", "&");
  1970. player.speak(player, "§6Commands", "New rank available: ", text.hover(text.click(concat("[", rank, "§r]"), concat("/setrank ", player.getName(player), " ", rank2)), "Click to set"));
  1971. }
  1972. //--------------------------------------------------
  1973. //Perm-Utils
  1974. //--------------------------------------------------
  1975. function givePerm(player_id, perm_id) {
  1976. stmt = databank.prepare("INSERT INTO playerperms (player_id, perm_id) VALUES (?,?);");
  1977. databank.setInt(stmt, 1, player_id);
  1978. databank.setInt(stmt, 2, perm_id);
  1979. databank.workerExecute(stmt);
  1980. perm.registerPlayer(player.getUuidFromID(player_id), perm_id);
  1981. }
  1982. function removePerm(player_id, perm_id) {
  1983. stmt = databank.prepare("DELETE FROM playerperms WHERE player_id = ? AND perm_id = ?;");
  1984. databank.setInt(stmt, 1, player_id);
  1985. databank.setInt(stmt, 2, perm_id);
  1986. databank.workerExecute(stmt);
  1987. perm.unregisterPlayer(player.getUuidFromID(player_id), perm_id);
  1988. }
  1989. function removeAllPermsTemporarly(player_id) {
  1990. perm.registerPlayer(player.getUuidFromID(player_id), 8);
  1991. permslist = getPermsFromPlayer(player_id);
  1992. for(i = 0; i < list.getSize(permslist); i++) {
  1993. perm_id = list.getIndex(permslist, i);
  1994. perm.unregisterPlayer(player.getUuidFromID(player_id), perm_id);
  1995. }
  1996. }
  1997. function reloadAllPerms(player_id) {
  1998. perm.unregisterPlayer(player.getUuidFromID(player_id), 8);
  1999. permslist = getPermsFromPlayer(player_id);
  2000. for(i = 0; i < list.getSize(permslist); i++) {
  2001. perm_id = list.getIndex(permslist, i);
  2002. perm.registerPlayer(player.getUuidFromID(player_id), perm_id);
  2003. }
  2004. }
  2005. function removeAllPerms(player_id) {
  2006. permslist = getPermsFromPlayer(player_id);
  2007. for(i = 0; i < list.getSize(permslist); i++) {
  2008. removePerm(player_id, list.getIndex(permslist, i));
  2009. }
  2010. }
  2011. function isAPermGroup(permstring) {
  2012. if(map.contains($permgroupsmap, text.toLowerCase(permstring))) {
  2013. return true;
  2014. }
  2015. return false;
  2016. }
  2017. function getPermsFromPlayer(player_id) {
  2018. list.new(permslist);
  2019. stmt = databank.prepare("SELECT perm_id FROM playerperms WHERE player_id = ?;");
  2020. databank.setInt(stmt, 1, player_id);
  2021. result = databank.execute(stmt);
  2022. while(databank.next(result)) {
  2023. list.add(permslist, databank.getInt(result, 1));
  2024. }
  2025. databank.close(result);
  2026. databank.close(stmt);
  2027. return permslist;
  2028. }
  2029. function hasPermAlready(player_id, perm_id) {
  2030. permslist = getPermsFromPlayer(player_id);
  2031. if(list.contains(permslist, perm_id)) {
  2032. return true;
  2033. } else {
  2034. return false;
  2035. }
  2036. }
  2037. function registerAllPerms() {
  2038. stmt = databank.prepare("SELECT * FROM playerperms;");
  2039. result = databank.execute(stmt);
  2040. while(databank.next(result)) {
  2041. player_id = databank.getInt(result, 1);
  2042. perm_id = databank.getInt(result, 2);
  2043. perm.registerPlayer(player.getUuidFromID(player_id), perm_id);
  2044. }
  2045. databank.close(result);
  2046. databank.close(stmt);
  2047. }
  2048. //--------------------------------------------------
  2049. //Nickname-Utils
  2050. //--------------------------------------------------
  2051. function player.setNickName(player, nickname) {
  2052. map.add(getScriptVar("nicknames"), player.getUuid(player), nickname);
  2053. }
  2054. function player.getNickName(player) {
  2055. return map.getOrDefault(getScriptVar("nicknames"), player.getUuid(player), player.getName(player));
  2056. }
  2057. function player.removeNickName(player) {
  2058. map.remove(getScriptVar("nicknames"), player.getUuid(player));
  2059. }
  2060. //--------------------------------------------------
  2061. //Mail-Utils
  2062. //--------------------------------------------------
  2063. function mail.send(from_name, to_name, message) {
  2064. server_config = getScriptVar("server_config");
  2065. mail_id = config.getDouble(server_config, "mail_id", 0) + 1;
  2066. config.set(server_config, "mail_id", mail_id);
  2067. config.saveAsync(server_config);
  2068. from_id = player.getId(player.getUuid(from_name));
  2069. to_id = player.getId(player.getUuid(to_name));
  2070. stmt = databank.prepare("INSERT INTO mails (mail_id, from_id, to_id, readed, time, message) VALUES (?, ?, ?, ?, ?, ?);");
  2071. databank.setInt(stmt, 1, mail_id);
  2072. databank.setInt(stmt, 2, from_id);
  2073. databank.setInt(stmt, 3, to_id);
  2074. databank.setBool(stmt, 4, false);
  2075. databank.setLong(stmt, 5, time.getMillis());
  2076. databank.setString(stmt, 6, message);
  2077. databank.workerExecute(stmt);
  2078. //Wenn Spieler online, dann Pushmeldung veranlassen
  2079. p = read.player(to_name);
  2080. if(p != null) {
  2081. player.speak(p, "§bMail", concat("§rYou´ve got a new mail from §b", from_name, "."));
  2082. }
  2083. }
  2084. function mail.checkForNew(player) {
  2085. stmt = databank.prepare("SELECT mail_id, from_id, time, message FROM mails WHERE to_id = ? AND readed = false;");
  2086. to_id = player.getId(player);
  2087. databank.setInt(stmt, 1, to_id);
  2088. result = databank.execute(stmt);
  2089. nextrow = databank.next(result);
  2090. if(!nextrow) {
  2091. databank.close(result);
  2092. databank.close(stmt);
  2093. return;
  2094. }
  2095. newmails = 0;
  2096. while(nextrow) {
  2097. newmails++;
  2098. nextrow = databank.next(result);
  2099. }
  2100. databank.close(result);
  2101. databank.close(stmt);
  2102. if(newmails > 0) {
  2103. if(newmails > 1) {
  2104. player.speakPrefix(player, "§bMail", concat("§rYou´ve got §b", text.number(newmails), "§r new mails."));
  2105. } else {
  2106. player.speakPrefix(player, "§bMail", "§rYou´ve got §b1 §rnew mail.");
  2107. }
  2108. }
  2109. }
  2110. //--------------------------------------------------
  2111. //Friend-Utils
  2112. //--------------------------------------------------
  2113. function friend.check(player_id, friend_id) {
  2114. stmt = databank.prepare("SELECT friend_id FROM friends WHERE player_id = ? AND friend_id = ?;");
  2115. databank.setInt(stmt, 1, player_id);
  2116. databank.setInt(stmt, 2, friend_id);
  2117. result = databank.execute(stmt);
  2118. temp = false;
  2119. while(databank.next(result)) {
  2120. temp = true;
  2121. }
  2122. databank.close(result);
  2123. databank.close(stmt);
  2124. return temp;
  2125. }
  2126. function friend.add(player_id, friend_id) {
  2127. nowtime = time.getMillis();
  2128. stmt1 = databank.prepare("INSERT INTO friends (player_id, friend_id, time) VALUES (?, ?, ?);");
  2129. databank.setInt(stmt1, 1, player_id);
  2130. databank.setInt(stmt1, 2, friend_id);
  2131. databank.setLong(stmt1, 3, nowtime);
  2132. databank.workerExecute(stmt1);
  2133. stmt2 = databank.prepare("INSERT INTO friends (player_id, friend_id, time) VALUES (?, ?, ?);");
  2134. databank.setInt(stmt2, 1, friend_id);
  2135. databank.setInt(stmt2, 2, player_id);
  2136. databank.setLong(stmt2, 3, nowtime);
  2137. databank.workerExecute(stmt2);
  2138. }
  2139. function friend.delete(player_id, friend_id) {
  2140. stmt1 = databank.prepare("DELETE FROM friends WHERE player_id = ? AND friend_id = ?;");
  2141. databank.setInt(stmt1, 1, player_id);
  2142. databank.setInt(stmt1, 2, friend_id);
  2143. databank.workerExecute(stmt1);
  2144. stmt2 = databank.prepare("DELETE FROM friends WHERE player_id = ? AND friend_id = ?;");
  2145. databank.setInt(stmt2, 1, friend_id);
  2146. databank.setInt(stmt2, 2, player_id);
  2147. databank.workerExecute(stmt2);
  2148. }
  2149. function friend.getList(player_id) {
  2150. list.new(list);
  2151. stmt = databank.prepare("SELECT friend_id FROM friends WHERE player_id = ?;");
  2152. databank.setInt(stmt, 1, player_id);
  2153. result = databank.execute(stmt);
  2154. while(databank.next(result)) {
  2155. friend_id = databank.getInt(result, 1);
  2156. list.add(list, player.getNameFromId(friend_id));
  2157. }
  2158. databank.close(result);
  2159. databank.close(stmt);
  2160. return list;
  2161. }