u_general.txt 115 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440
  1. function snuvi.debug(message) {
  2. msg("dev", concat("[§eDebug§r] ", message));
  3. }
  4. function perm.no(player, perm) {
  5. msg.prefix(player, "§6§zPerms", concat("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 list.copy(list) {
  20. list_new = list.new();
  21. iter = list.iterator(list);
  22. while(hasNext(iter)) {
  23. list.add(list_new, next(iter));
  24. }
  25. return list_new;
  26. }
  27. function array.sort(my_array, ascending) {
  28. size = array.getSize(my_array);
  29. if(ascending) {
  30. for(i = 0; i < size - 1; i++) {
  31. for(j = i + 1; j < size; j++) {
  32. if(my_array[j] < my_array[i]) {
  33. temp = my_array[i];
  34. my_array[i] = my_array[j];
  35. my_array[j] = temp;
  36. }
  37. }
  38. }
  39. } else {
  40. for(i = 0; i < size - 1; i++) {
  41. for(j = i + 1; j < size; j++) {
  42. if(my_array[j] > my_array[i]) {
  43. temp = my_array[i];
  44. my_array[i] = my_array[j];
  45. my_array[j] = temp;
  46. }
  47. }
  48. }
  49. }
  50. return my_array;
  51. }
  52. function map.sort(map, ascending) {
  53. size = map.getSize(map);
  54. my_array = array.new(size, 2);
  55. //Map in Array umwandeln
  56. i = 0;
  57. iter = map.iterator(map);
  58. while(hasNext(iter)) {
  59. element = next(iter);
  60. key = map.getKey(element);
  61. value = map.getValue(element);
  62. my_array[i, 0] = key;
  63. my_array[i, 1] = value;
  64. i++;
  65. }
  66. //Array sortieren
  67. if(ascending) {
  68. for(i = 0; i < size - 1; i++) {
  69. for(j = i + 1; j < size; j++) {
  70. if(my_array[j, 1] < my_array[i, 1]) {
  71. g = my_array[i, 0];
  72. h = my_array[i, 1];
  73. my_array[i, 0] = my_array[j, 0];
  74. my_array[i, 1] = my_array[j, 1];
  75. my_array[j, 0] = g;
  76. my_array[j, 1] = h;
  77. }
  78. }
  79. }
  80. } else {
  81. for(i = 0; i < size - 1; i++) {
  82. for(j = i + 1; j < size; j++) {
  83. if(my_array[j, 1] > my_array[i, 1]) {
  84. g = my_array[i, 0];
  85. h = my_array[i, 1];
  86. my_array[i, 0] = my_array[j, 0];
  87. my_array[i, 1] = my_array[j, 1];
  88. my_array[j, 0] = g;
  89. my_array[j, 1] = h;
  90. }
  91. }
  92. }
  93. }
  94. return my_array;
  95. }
  96. function getSpacer() {
  97. return("§0-------------------------------------------------");
  98. }
  99. function getDirection(yaw) {
  100. while(yaw < 0) {
  101. yaw += 360;
  102. }
  103. while(yaw >= 360) {
  104. yaw -= 360;
  105. }
  106. if(yaw > 60 && yaw < 120) {
  107. direction = "west";
  108. } elseif(yaw > 150 && yaw < 210) {
  109. direction = "north";
  110. } elseif(yaw > 240 && yaw < 300) {
  111. direction = "east";
  112. } elseif(yaw > 330 || yaw < 30) {
  113. direction = "south";
  114. } else {
  115. return null;
  116. }
  117. return direction;
  118. }
  119. function correctTimeFormat(textnumber) {
  120. if(text.length(textnumber) == 1) {
  121. textnumber = concat("0", textnumber);
  122. }
  123. return textnumber;
  124. }
  125. function player.giveSingleItem(player, item, boolean) {
  126. amount = player.getItemAmount(player, boolean, item);
  127. if(amount == 0) {
  128. player.safeGiveItem(player, item);
  129. }
  130. }
  131. function player.safeGiveItem(player, item) {
  132. rest_item = player.giveItem(player, item);
  133. item.drop(entity.getLocation(player), rest_item);
  134. }
  135. function setBlockIfNotAir(location, block) {
  136. if(block.getType(location) == "minecraft:air") {
  137. block.set(location, block, true);
  138. return true;
  139. }
  140. return false;
  141. }
  142. //Gesamte Spielzeit eines Spielers inkl. der Online-Spielzeit
  143. function playtime.getPlayerTotal(player_or_id) {
  144. player_id = player.getValidId(player_or_id);
  145. minutes = playtime.getPlayerOnlineMinutes(player_id);
  146. stmt = databank.prepare("SELECT SUM(leave_time - join_time) FROM playtime WHERE player_id = ?;");
  147. databank.setInt(stmt, 1, player_id);
  148. result = databank.execute(stmt);
  149. if(databank.next(result)) {
  150. minutes += databank.getLong(result, 1) / 1000 / 60;
  151. }
  152. databank.close(result);
  153. databank.close(stmt);
  154. return minutes;
  155. }
  156. //Spielzeit eines Online-Spielers
  157. function playtime.getPlayerOnlineMinutes(player_id) {
  158. stmt = databank.prepare("SELECT join_time FROM playtime WHERE player_id = ? AND leave_time IS NULL;");
  159. databank.setInt(stmt, 1, player_id);
  160. result = databank.execute(stmt);
  161. if(databank.next(result)) {
  162. minutes = (time.getMillis() - databank.getLong(result, 1)) / 1000 / 60;
  163. } else {
  164. minutes = 0;
  165. }
  166. databank.close(result);
  167. databank.close(stmt);
  168. return minutes;
  169. }
  170. function grow(center_loc, radius) {
  171. crops_tag = block.getTag("minecraft:crops");
  172. for(x = radius * -1; x <= radius; x++) {
  173. for(z = radius * -1; z <= radius; z++) {
  174. for(y = radius * -1; y <= radius; y++) {
  175. length = math.hypot(x, math.hypot(y, z));
  176. if(length <= radius) {
  177. mod_loc = loc.mod(center_loc, x, y, z);
  178. block = block.get(mod_loc);
  179. if(block.hasTag(crops_tag, block)) {
  180. if(block.getType(mod_loc) == "minecraft:beetroots") {
  181. block.set(mod_loc, concat(block.getType(mod_loc), "[age=3]"));
  182. } else {
  183. block.set(mod_loc, concat(block.getType(mod_loc), "[age=7]"));
  184. }
  185. }
  186. }
  187. }
  188. }
  189. }
  190. }
  191. function getBlockLocation(location) {
  192. world = loc.getWorld(location, "w");
  193. bx = loc.getCoord(location, "bx");
  194. by = loc.getCoord(location, "by");
  195. bz = loc.getCoord(location, "bz");
  196. return loc.new(world, bx, by, bz);
  197. }
  198. function getDateString(time) {
  199. calendar = time.new(time);
  200. return concat(text.number(time.getDay(calendar)), ".", text.number(time.getMonth(calendar)), ".", text.number(time.getYear(calendar)));
  201. }
  202. function time.getClockString(time) { //s
  203. return concat(text.number(math.roundDown(time / 60)), " min ", text.number(math.round(time % 60)), " s");
  204. }
  205. function getTimeString(millis) {
  206. calendar = time.new(millis);
  207. day = time.getDay(calendar);
  208. month = time.getMonth(calendar);
  209. year = time.getYear(calendar);
  210. hour = time.getHour(calendar);
  211. minute = time.getMinute(calendar);
  212. if(month < 10) {
  213. month = concat("0", text.number(month));
  214. } else {
  215. month = text.number(month);
  216. }
  217. if(day < 10) {
  218. day = concat("0", text.number(day));
  219. } else {
  220. day = text.number(day);
  221. }
  222. if(hour < 10) {
  223. hour = concat("0", text.number(hour));
  224. } else {
  225. hour = text.number(hour);
  226. }
  227. if(minute < 10) {
  228. minute = concat("0", text.number(minute));
  229. } else {
  230. minute = text.number(minute);
  231. }
  232. timestring = concat(day, ".", month, ".", text.number(year), " ", hour, ":", minute);
  233. return timestring;
  234. }
  235. function isFollowingDay(timestamp_1, timestamp_2) {
  236. cal_1 = time.new(timestamp_1);
  237. time.nextDay(cal_1);
  238. mid_1 = time.from(cal_1);
  239. diff = timestamp_2 - mid_1;
  240. return diff > 0 && diff < 86400000;
  241. }
  242. function isSameDay(timestamp_1, timestamp_2) {
  243. cal_1 = time.new(timestamp_1);
  244. cal_2 = time.new(timestamp_2);
  245. time.nextDay(cal_1);
  246. time.nextDay(cal_2);
  247. mid_1 = time.from(cal_1);
  248. mid_2 = time.from(cal_2);
  249. return mid_1 == mid_2;
  250. }
  251. function player.hasMinigame(player) {
  252. id_set = player.getMinigameIds(player);
  253. if(set.getSize(id_set) > 0) {
  254. return true;
  255. }
  256. return false;
  257. }
  258. function player.getMinigameIds(player) {
  259. set = data.get(player, "minigames_set");
  260. if(set == null) {
  261. set = set.new();
  262. data.set(player, "minigames_set", set);
  263. }
  264. return set;
  265. }
  266. function tjr.getWholeModule(player_or_id) {
  267. return ranking.getPoints("tjrranks", player_or_id);
  268. }
  269. function tjr.getWholeTime(player_or_id) {
  270. return ranking.getSecPoints("tjrranks", player_or_id);
  271. }
  272. function ranking.getPoints(rankingtable, player_or_id) {
  273. player_id = player.getValidId(player_or_id);
  274. stmt = databank.prepare(concat("SELECT points FROM ", rankingtable, " WHERE player_id = ?;"));
  275. databank.setInt(stmt, 1, player_id);
  276. result = databank.execute(stmt);
  277. if(databank.next(result)) {
  278. points = databank.getInt(result, 1);
  279. } else {
  280. points = 0;
  281. }
  282. databank.close(result);
  283. databank.close(stmt);
  284. return points;
  285. }
  286. function ranking.getSecPoints(rankingtable, player_or_id) {
  287. player_id = player.getValidId(player_or_id);
  288. stmt = databank.prepare(concat("SELECT sec_points FROM ", rankingtable, " WHERE player_id = ?;"));
  289. databank.setInt(stmt, 1, player_id);
  290. result = databank.execute(stmt);
  291. if(databank.next(result)) {
  292. sec_points = databank.getInt(result, 1);
  293. } else {
  294. sec_points = 0;
  295. }
  296. databank.close(result);
  297. databank.close(stmt);
  298. return sec_points;
  299. }
  300. function isAdminShop(sign_loc) {
  301. return block.getSign(sign_loc, 0) == "[Admin Shop]";
  302. }
  303. //--------------------------------------------------
  304. //ModTimer-Utils
  305. //--------------------------------------------------
  306. function modTimer.scriptCallEvent(event, script) {
  307. modTimer(-20);
  308. if(script == null) {
  309. script.callEvent(event);
  310. return;
  311. }
  312. script.callEvent(event, script);
  313. }
  314. function modTimer.entityTeleport(entity, location) {
  315. modTimer(-15);
  316. entity.teleport(entity, location);
  317. }
  318. //--------------------------------------------------
  319. //World-Utils
  320. //--------------------------------------------------
  321. function world.getServerSpawn() {
  322. return read.location(config.getString(getScriptVar("server_config"), "serverspawn", "overworld:0:100:0"));
  323. }
  324. function world.getGamesSpawn() {
  325. return read.location(config.getString(getScriptVar("server_config"), "gamesspawn", "games:0:100:0"));
  326. }
  327. function world.getCreativeSpawn() {
  328. return read.location(config.getString(getScriptVar("server_config"), "creativespawn", "creative:0:100:0"));
  329. }
  330. function world.getStorySpawn() {
  331. return read.location(config.getString(getScriptVar("server_config"), "storyspawn", "story:0:100:0"));
  332. }
  333. function world.getOverWorld() {
  334. return world.get("overworld");
  335. }
  336. function world.getTheEnd() {
  337. return world.get("the_end");
  338. }
  339. function world.getTheNether() {
  340. return world.get("the_nether");
  341. }
  342. function world.getGames() {
  343. return world.get("games");
  344. }
  345. function world.getCreative() {
  346. return world.get("creative");
  347. }
  348. function world.getStory() {
  349. return world.get("story");
  350. }
  351. function world.isCreativeName(world_name) {
  352. return world_name == "creative";
  353. }
  354. function world.isGamesName(world_name) {
  355. return world_name == "games";
  356. }
  357. function world.isStoryName(world_name) {
  358. return world_name == "story";
  359. }
  360. function world.isSurvName(world_name) {
  361. if(world_name == "overworld") {
  362. return true;
  363. } elseif(world_name == "the_end") {
  364. return true;
  365. } elseif(world_name == "the_nether") {
  366. return true;
  367. }
  368. return false;
  369. }
  370. function world.canUsePlots(world) {
  371. world_name = world.getName(world);
  372. if(world.isSurvName(world_name)) {
  373. return true;
  374. }
  375. if(world.isCreativeName(world_name)) {
  376. return true;
  377. }
  378. return false;
  379. }
  380. function world.addTimedStatus(world, index, time, message) {
  381. world_name = world.getName(world);
  382. if(world.isSurvName(world_name)) {
  383. worldlist = players.toWorldList(world.getOverWorld());
  384. for(i = 0; i < list.getSize(worldlist); i++) {
  385. status.addTimed(list.getIndex(worldlist, i), index, time, message);
  386. }
  387. worldlist = players.toWorldList(world.getTheEnd());
  388. for(i = 0; i < list.getSize(worldlist); i++) {
  389. status.addTimed(list.getIndex(worldlist, i), index, time, message);
  390. }
  391. worldlist = players.toWorldList(world.getTheNether());
  392. for(i = 0; i < list.getSize(worldlist); i++) {
  393. status.addTimed(list.getIndex(worldlist, i), index, time, message);
  394. }
  395. return;
  396. }
  397. worldlist = players.toWorldList(world);
  398. for(i = 0; i < list.getSize(worldlist); i++) {
  399. status.addTimed(list.getIndex(worldlist, i), index, time, message);
  400. }
  401. }
  402. function world.giveItem(world, item) {
  403. world_list = players.toWorldList(world);
  404. iter = iterator(world_list);
  405. while(hasNext(iter)) {
  406. player.safeGiveItem(next(iter), item);
  407. }
  408. }
  409. //--------------------------------------------------
  410. //Inv-Utils
  411. //--------------------------------------------------
  412. function player.checkForWorldChange(player, location) {
  413. from_world = loc.getWorld(entity.getLocation(player));
  414. to_world = loc.getWorld(location);
  415. //Wenn ignore aktiviert --> kein Wechsel
  416. if(player.hasInvIgnore(player)) {
  417. return false;
  418. }
  419. from_world_name = world.getName(from_world);
  420. to_world_name = world.getName(to_world);
  421. //Wenn in selber Welt --> kein Wechsel
  422. if(from_world == to_world) {
  423. return false;
  424. }
  425. //Wenn beide Welten in derselben Liste sind --> kein Wechsel
  426. if(world.isSurvName(from_world_name) && world.isSurvName(to_world_name)) {
  427. return false;
  428. }
  429. return true;
  430. }
  431. function player.changeInv(player, from_world, to_world) {
  432. from_world_name = world.getName(from_world);
  433. to_world_name = world.getName(to_world);
  434. //Inventory
  435. inv.saveForPlayer(player, player, from_world);
  436. inv.loadFromPlayer(player, player, to_world);
  437. if(perm.has(player, "isTeam")) {
  438. if(perm.has(player, "isSupporter") && !perm.has(player, "isAdmin") && !perm.has(player, "isMod")) {
  439. player.changeGamemode(player, to_world_name);
  440. }
  441. } else {
  442. player.changeGamemode(player, to_world_name);
  443. }
  444. if(world.isSurvName(to_world_name)) {
  445. if(player.hasFly(player)) {
  446. scheduler.addFly(5, player, true);
  447. }
  448. }
  449. }
  450. function player.changeGamemode(player, to_world_name) {
  451. if(!player.isSpectator(player)) {
  452. if(to_world_name == "creative") {
  453. if(perm.has(player, "creative")) {
  454. gm = "creative";
  455. } else {
  456. gm = "adventure";
  457. scheduler.addFly(5, player, true);
  458. }
  459. } else {
  460. gm = "survival";
  461. }
  462. player.setGamemode(player, gm);
  463. duration = data.getTimer(player, "fly");
  464. if(world.isSurvName(to_world_name) && duration > 0) {
  465. scheduler.addFly(5, player, true);
  466. }
  467. }
  468. }
  469. function inv.saveForPlayer(sec_player, for_player_or_id, world) {
  470. if(isPlayer(for_player_or_id)) {
  471. for_player_or_id = player.getId(for_player_or_id);
  472. }
  473. world_name = world.getName(world);
  474. if(world.isSurvName(world_name)) {
  475. pfad = "scripts/configs/inv_data/survival";
  476. } else {
  477. pfad = concat("scripts/configs/inv_data/", world_name);
  478. }
  479. config = config.new(pfad, for_player_or_id);
  480. //Allgemeine Daten
  481. if(for_player_or_id == player.getId(sec_player)) {
  482. config.set(config, "health", living.getHealth(sec_player));
  483. config.set(config, "hunger", player.getHunger(sec_player));
  484. config.set(config, "saturation", player.getSaturation(sec_player));
  485. config.set(config, "xp", player.getExp(sec_player));
  486. config.set(config, "lvl", player.getLevel(sec_player));
  487. }
  488. //Inventare
  489. inv = player.getInv(sec_player);
  490. for(i = 0; i < 36; i++) {
  491. item_string = text.item(inv.getItem(inv, i));
  492. config.set(config, concat("slot-", i), item_string);
  493. }
  494. ender_inv = player.getEnderInv(sec_player);
  495. for(i = 0; i < 27; i++) {
  496. item_string = text.item(inv.getItem(ender_inv, i));
  497. config.set(config, concat("eslot-", i), item_string);
  498. }
  499. config.set(config, "offhand", text.item(living.getEquip(sec_player, "offhand")));
  500. config.set(config, "head", text.item(living.getEquip(sec_player, "head")));
  501. config.set(config, "chest", text.item(living.getEquip(sec_player, "chest")));
  502. config.set(config, "legs", text.item(living.getEquip(sec_player, "legs")));
  503. config.set(config, "feet", text.item(living.getEquip(sec_player, "feet")));
  504. config.saveAsync(config);
  505. }
  506. function inv.loadFromPlayer(sec_player, from_player_or_id, world) {
  507. if(isPlayer(from_player_or_id)) {
  508. from_player_or_id = player.getId(from_player_or_id);
  509. }
  510. world_name = world.getName(world);
  511. if(world.isSurvName(world_name)) {
  512. pfad = "scripts/configs/inv_data/survival";
  513. } else {
  514. pfad = concat("scripts/configs/inv_data/", world_name);
  515. }
  516. config = config.new(pfad, from_player_or_id);
  517. if(config.exists(config)) {
  518. config.load(config);
  519. }
  520. //Allgemeine Daten
  521. if(from_player_or_id == player.getId(sec_player)) {
  522. living.setHealth(sec_player, config.getDouble(config, "health", 20));
  523. player.setHunger(sec_player, config.getDouble(config, "hunger", 20));
  524. player.setSaturation(sec_player, config.getDouble(config, "saturation", 5));
  525. player.setExp(sec_player, config.getDouble(config, "xp", 0));
  526. player.setLevel(sec_player, config.getDouble(config, "lvl", 0));
  527. }
  528. //Inventare
  529. for(i = 0; i <= 35; i++) {
  530. item_string = config.getString(config, concat("slot-", i), "minecraft:air");
  531. item = read.item(item_string);
  532. if(item != null) {
  533. inv = player.getInv(sec_player);
  534. inv.setItem(inv, i, item);
  535. }
  536. }
  537. for(i = 0; i < 27; i++) {
  538. item_string = config.getString(config, concat("eslot-", i), "minecraft:air");
  539. item = read.item(item_string);
  540. if(item != null) {
  541. ender_inv = player.getEnderInv(sec_player);
  542. inv.setItem(ender_inv, i, item);
  543. }
  544. }
  545. living.setEquip(sec_player, "offhand", read.item(config.getString(config, "offhand", "minecraft:air")));
  546. living.setEquip(sec_player, "head", read.item(config.getString(config, "head", "minecraft:air")));
  547. living.setEquip(sec_player, "chest", read.item(config.getString(config, "chest", "minecraft:air")));
  548. living.setEquip(sec_player, "legs", read.item(config.getString(config, "legs", "minecraft:air")));
  549. living.setEquip(sec_player, "feet", read.item(config.getString(config, "feet", "minecraft:air")));
  550. }
  551. //--------------------------------------------------
  552. //Text-Utils
  553. //--------------------------------------------------
  554. function text.upperFirstLetter(string) {
  555. length = text.length(string);
  556. first_letter = text.subString(string, 0, 1);
  557. rest = text.substring(string, 1, length);
  558. return concat(text.toUpperCase(first_letter), rest);
  559. }
  560. //connects all list elements as objects
  561. function text.concatList2(list, connector, fromIndex, toIndex) {
  562. string = "";
  563. iter = list.iterator(list);
  564. for(i = fromIndex; i <= toIndex; i++) {
  565. element = list.getIndex(list, i);
  566. if(string == "") {
  567. string = element;
  568. } else {
  569. string = text.concat2(string, connector, element);
  570. }
  571. }
  572. return string;
  573. }
  574. function text.getLinkMessage(string) {
  575. if(text.contains(string, "https://")) {
  576. https_index = text.indexOf(string, "https://", 0);
  577. space_index = text.indexOf(string, " ", https_index);
  578. length = text.length(string);
  579. if(https_index == 0) {
  580. msg_before = "";
  581. } else {
  582. msg_before = text.subString(string, 0, https_index);
  583. }
  584. if(space_index == -1) {
  585. msg_link = text.subString(string, https_index, length);
  586. msg_after = "";
  587. } else {
  588. msg_link = text.subString(string, https_index, space_index);
  589. msg_after = text.subString(string, space_index, length);
  590. }
  591. msg_link = text.link(msg_link, msg_link);
  592. a = array.new(3);
  593. a[0] = msg_before;
  594. a[1] = msg_link;
  595. a[2] = msg_after;
  596. return a;
  597. }
  598. }
  599. //--------------------------------------------------
  600. //Quest-Utils
  601. //--------------------------------------------------
  602. function quest.display(player, quest_name, stage, all_stages) {
  603. sb.add(player, 1, concat("§dQuest: ", quest_name, " [", text.number(stage), "/", text.number(all_stages), "]"));
  604. }
  605. function quest.removeDisplay(player) {
  606. sb.remove(player, 1);
  607. }
  608. function quest.getIds() {
  609. return getScriptVar("quest_ids");
  610. }
  611. function quest.addPlayer(script, player) {
  612. quest_ids = quest.getIds();
  613. map.add(quest_ids, player.getUuid(player), script.getId(script));
  614. }
  615. function quest.removePlayer(player) {
  616. quest_ids = quest.getIds();
  617. map.remove(quest_ids, player.getUuid(player));
  618. }
  619. function player.hasQuest2(player) {
  620. quest_ids = quest.getIds();
  621. return map.contains(quest_ids, player.getUuid(player));
  622. }
  623. function quest.getFromPlayer(player) {
  624. quest_ids = quest.getIds();
  625. return map.get(quest_ids, player.getUuid(player));
  626. }
  627. function player.isQuester(player, script) {
  628. if(player == null) {
  629. return false;
  630. }
  631. if(script == null) {
  632. return false;
  633. }
  634. script_id = script.getId(script);
  635. quest_ids = quest.getIds();
  636. return map.get(quest_ids, player.getUuid(player)) == script_id;
  637. }
  638. function quest.getCounter(player_or_id) {
  639. config = playerdata.getSurvival(player_or_id);
  640. return config.getDouble(config, "quests_solved", 0);
  641. }
  642. function quest.setCounter(player_or_id, amount) {
  643. config = playerdata.getSurvival(player_or_id);
  644. config.set(config, "quests_solved", amount);
  645. config.saveAsync(config);
  646. }
  647. function quest.addCounter(player, amount) {
  648. config = playerdata.getSurvival(player);
  649. new_amount = config.getDouble(config, "quests_solved", 0) + amount;
  650. config.set(config, "quests_solved", new_amount);
  651. config.saveAsync(config);
  652. if(new_amount == 500) {
  653. offerRank(player, "rank.altruist");
  654. } elseif(new_amount == 50) {
  655. offerRank(player, "rank.friend");
  656. } elseif(new_amount == 15) {
  657. offerRank(player, "rank.volunteer");
  658. }
  659. }
  660. function quest.getBlockList() {
  661. list = getScriptVar("quest_block_list");
  662. if(list == null) {
  663. list = list.new();
  664. quest.setBlockList(list);
  665. }
  666. return list;
  667. }
  668. function quest.setBlockList(list) {
  669. setScriptVar("quest_block_list", list);
  670. }
  671. function quest.setCooldown(player) {
  672. list = quest.getBlockList();
  673. list.add(list, player.getUuid(player));
  674. quest.setBlockList(list);
  675. }
  676. function quest.removeCooldown(player) {
  677. list = quest.getBlockList();
  678. list.remove(list, player.getUuid(player));
  679. quest.setBlockList(list);
  680. }
  681. function quest.isPlayerBlocked(player) {
  682. list = quest.getBlockList();
  683. return list.contains(list, player.getUuid(player));
  684. }
  685. function quest.finish(script, player) {
  686. sound = sound.get("entity.experience_orb.pickup");
  687. category = sound.getCategory("master");
  688. sound.spawnForPlayer(player, sound, category);
  689. quest.addCounter(player, 1);
  690. quest.setCooldown(player);
  691. quest.term(script, player);
  692. }
  693. function quest.term(script, player) {
  694. quest.removeDisplay(player);
  695. quest.removePlayer(player);
  696. script.term(script);
  697. }
  698. function script.isActiveName(script_name) {
  699. script = script.get(script_name);
  700. if(script == null) {
  701. return false;
  702. }
  703. return true;
  704. }
  705. //--------------------------------------------------
  706. //Teleporter-Utils
  707. //--------------------------------------------------
  708. function isATpTransmitter(chest_loc) {
  709. loc = loc.mod(chest_loc, 0, 0 ,0);
  710. loc.add(loc, -1, 0, 0);
  711. if(block.getType(loc) != "minecraft:glowstone") {
  712. return false;
  713. }
  714. loc.add(loc, 2, 0, 0);
  715. if(block.getType(loc) != "minecraft:glowstone") {
  716. return false;
  717. }
  718. loc.add(loc, -1, 0, -1);
  719. if(block.getType(loc) != "minecraft:glowstone") {
  720. return false;
  721. }
  722. loc.add(loc, 0, 0, 2);
  723. if(block.getType(loc) != "minecraft:glowstone") {
  724. return false;
  725. }
  726. loc.add(loc, -1, 0, 0);
  727. if(block.getType(loc) != "km:bronze_block") {
  728. return false;
  729. }
  730. loc.add(loc, 2, 0, 0);
  731. if(block.getType(loc) != "km:bronze_block") {
  732. return false;
  733. }
  734. loc.add(loc, 0, 0, -2);
  735. if(block.getType(loc) != "km:bronze_block") {
  736. return false;
  737. }
  738. loc.add(loc, -2, 0, 0);
  739. if(block.getType(loc) != "km:bronze_block") {
  740. return false;
  741. }
  742. loc.add(loc, -1, 0, 0);
  743. if(block.getType(loc) != "km:bronze_block") {
  744. return false;
  745. }
  746. loc.add(loc, 0, 0, 1);
  747. if(block.getType(loc) != "km:bronze_block") {
  748. return false;
  749. }
  750. loc.add(loc, 0, 0, 1);
  751. if(block.getType(loc) != "km:bronze_block") {
  752. return false;
  753. }
  754. loc.add(loc, 0, 0, 1);
  755. if(block.getType(loc) != "minecraft:stone_brick_slab") {
  756. return false;
  757. }
  758. loc.add(loc, 1, 0, 0);
  759. if(block.getType(loc) != "km:bronze_block") {
  760. return false;
  761. }
  762. loc.add(loc, 1, 0, 0);
  763. if(block.getType(loc) != "km:bronze_block") {
  764. return false;
  765. }
  766. loc.add(loc, 1, 0, 0);
  767. if(block.getType(loc) != "km:bronze_block") {
  768. return false;
  769. }
  770. loc.add(loc, 1, 0, 0);
  771. if(block.getType(loc) != "minecraft:stone_brick_slab") {
  772. return false;
  773. }
  774. loc.add(loc, 0, 0, -1);
  775. if(block.getType(loc) != "km:bronze_block") {
  776. return false;
  777. }
  778. loc.add(loc, 0, 0, -1);
  779. if(block.getType(loc) != "km:bronze_block") {
  780. return false;
  781. }
  782. loc.add(loc, 0, 0, -1);
  783. if(block.getType(loc) != "km:bronze_block") {
  784. return false;
  785. }
  786. loc.add(loc, 0, 0, -1);
  787. if(block.getType(loc) != "minecraft:stone_brick_slab") {
  788. return false;
  789. }
  790. loc.add(loc, -1, 0, 0);
  791. if(block.getType(loc) != "km:bronze_block") {
  792. return false;
  793. }
  794. loc.add(loc, -1, 0, 0);
  795. if(block.getType(loc) != "km:bronze_block") {
  796. return false;
  797. }
  798. loc.add(loc, -1, 0, 0);
  799. if(block.getType(loc) != "km:bronze_block") {
  800. return false;
  801. }
  802. loc.add(loc, -1, 0, 0);
  803. if(block.getType(loc) != "minecraft:stone_brick_slab") {
  804. return false;
  805. }
  806. loc.add(loc, 1, 1, 2);
  807. if(block.getType(loc) != "km:bronze_block") {
  808. return false;
  809. }
  810. loc.add(loc, 1, 0, 0);
  811. if(block.getType(loc) != "km:bronze_block") {
  812. return false;
  813. }
  814. loc.add(loc, 1, 0, 0);
  815. if(block.getType(loc) != "km:bronze_block") {
  816. return false;
  817. }
  818. loc.add(loc, -1, 0, -1);
  819. if(block.getType(loc) != "km:bronze_block") {
  820. return false;
  821. }
  822. loc.add(loc, 0, 0, 2);
  823. if(block.getType(loc) != "km:bronze_block") {
  824. return false;
  825. }
  826. loc.add(loc, 0, 1, -1);
  827. if(block.getType(loc) != "km:copper_block") {
  828. return false;
  829. }
  830. loc.add(loc, 0, 1, 0);
  831. if(block.getType(loc) != "km:copper_block") {
  832. return false;
  833. }
  834. loc.add(loc, -2, -4, -2);
  835. if(block.getType(loc) != "km:bronze_block") {
  836. return false;
  837. }
  838. loc.add(loc, 0, -1, 0);
  839. if(block.getType(loc) != "km:bronze_block") {
  840. return false;
  841. }
  842. loc.add(loc, 0, -1, 0);
  843. if(block.getType(loc) != "km:bronze_block") {
  844. return false;
  845. }
  846. loc.add(loc, 0, 0, 4);
  847. if(block.getType(loc) != "km:bronze_block") {
  848. return false;
  849. }
  850. loc.add(loc, 0, 1, 0);
  851. if(block.getType(loc) != "km:bronze_block") {
  852. return false;
  853. }
  854. loc.add(loc, 0, 1, 0);
  855. if(block.getType(loc) != "km:bronze_block") {
  856. return false;
  857. }
  858. loc.add(loc, 4, 0, 0);
  859. if(block.getType(loc) != "km:bronze_block") {
  860. return false;
  861. }
  862. loc.add(loc, 0, -1, 0);
  863. if(block.getType(loc) != "km:bronze_block") {
  864. return false;
  865. }
  866. loc.add(loc, 0, -1, 0);
  867. if(block.getType(loc) != "km:bronze_block") {
  868. return false;
  869. }
  870. loc.add(loc, 0, 0, -4);
  871. if(block.getType(loc) != "km:bronze_block") {
  872. return false;
  873. }
  874. loc.add(loc, 0, 1, 0);
  875. if(block.getType(loc) != "km:bronze_block") {
  876. return false;
  877. }
  878. loc.add(loc, 0, 1, 0);
  879. if(block.getType(loc) != "km:bronze_block") {
  880. return false;
  881. }
  882. loc.add(loc, 0, -3, 0);
  883. if(block.getType(loc) != "km:bronze_block") {
  884. return false;
  885. }
  886. loc.add(loc, -1, 0, 0);
  887. if(block.getType(loc) != "km:bronze_block") {
  888. return false;
  889. }
  890. loc.add(loc, -1, 0, 0);
  891. if(block.getType(loc) != "km:bronze_block") {
  892. return false;
  893. }
  894. loc.add(loc, -1, 0, 0);
  895. if(block.getType(loc) != "km:bronze_block") {
  896. return false;
  897. }
  898. loc.add(loc, -1, 0, 0);
  899. if(block.getType(loc) != "km:bronze_block") {
  900. return false;
  901. }
  902. loc.add(loc, 0, 0, 1);
  903. if(block.getType(loc) != "km:bronze_block") {
  904. return false;
  905. }
  906. loc.add(loc, 0, 0, 1);
  907. if(block.getType(loc) != "km:bronze_block") {
  908. return false;
  909. }
  910. loc.add(loc, 0, 0, 1);
  911. if(block.getType(loc) != "km:bronze_block") {
  912. return false;
  913. }
  914. loc.add(loc, 0, 0, 1);
  915. if(block.getType(loc) != "km:bronze_block") {
  916. return false;
  917. }
  918. loc.add(loc, 1, 0, 0);
  919. if(block.getType(loc) != "km:bronze_block") {
  920. return false;
  921. }
  922. loc.add(loc, 1, 0, 0);
  923. if(block.getType(loc) != "km:bronze_block") {
  924. return false;
  925. }
  926. loc.add(loc, 1, 0, 0);
  927. if(block.getType(loc) != "km:bronze_block") {
  928. return false;
  929. }
  930. loc.add(loc, 1, 0, 0);
  931. if(block.getType(loc) != "km:bronze_block") {
  932. return false;
  933. }
  934. loc.add(loc, 0, 0, -1);
  935. if(block.getType(loc) != "km:bronze_block") {
  936. return false;
  937. }
  938. loc.add(loc, 0, 0, -1);
  939. if(block.getType(loc) != "km:bronze_block") {
  940. return false;
  941. }
  942. loc.add(loc, 0, 0, -1);
  943. if(block.getType(loc) != "km:bronze_block") {
  944. return false;
  945. }
  946. loc.add(loc, -1, 0, 0);
  947. if(block.getType(loc) != "minecraft:stone_bricks") {
  948. return false;
  949. }
  950. loc.add(loc, -2, 0, 0);
  951. if(block.getType(loc) != "minecraft:stone_bricks") {
  952. return false;
  953. }
  954. loc.add(loc, 0, 0, 2);
  955. if(block.getType(loc) != "minecraft:stone_bricks") {
  956. return false;
  957. }
  958. loc.add(loc, 2, 0, 0);
  959. if(block.getType(loc) != "minecraft:stone_bricks") {
  960. return false;
  961. }
  962. loc.add(loc, -1, 0, 0);
  963. if(block.getType(loc) != "km:bronze_block") {
  964. return false;
  965. }
  966. loc.add(loc, -1, 0, -1);
  967. if(block.getType(loc) != "km:bronze_block") {
  968. return false;
  969. }
  970. loc.add(loc, 1, 0, 0);
  971. if(block.getType(loc) != "km:bronze_block") {
  972. return false;
  973. }
  974. loc.add(loc, 1, 0, 0);
  975. if(block.getType(loc) != "km:bronze_block") {
  976. return false;
  977. }
  978. loc.add(loc, -1, 0, -1);
  979. if(block.getType(loc) != "km:bronze_block") {
  980. return false;
  981. }
  982. return true;
  983. }
  984. function isATpReceiver(chest_loc) {
  985. loc = loc.mod(chest_loc, 0, 0 ,0);
  986. loc.add(loc, -1, 0, 0);
  987. if(block.getType(loc) != "minecraft:glowstone") {
  988. return false;
  989. }
  990. loc.add(loc, 2, 0, 0);
  991. if(block.getType(loc) != "minecraft:glowstone") {
  992. return false;
  993. }
  994. loc.add(loc, -1, 0, -1);
  995. if(block.getType(loc) != "minecraft:glowstone") {
  996. return false;
  997. }
  998. loc.add(loc, 0, 0, 2);
  999. if(block.getType(loc) != "minecraft:glowstone") {
  1000. return false;
  1001. }
  1002. loc.add(loc, -1, 0, 0);
  1003. if(block.getType(loc) != "km:tin_block") {
  1004. return false;
  1005. }
  1006. loc.add(loc, 2, 0, 0);
  1007. if(block.getType(loc) != "km:tin_block") {
  1008. return false;
  1009. }
  1010. loc.add(loc, 0, 0, -2);
  1011. if(block.getType(loc) != "km:tin_block") {
  1012. return false;
  1013. }
  1014. loc.add(loc, -2, 0, 0);
  1015. if(block.getType(loc) != "km:tin_block") {
  1016. return false;
  1017. }
  1018. loc.add(loc, -1, 0, 0);
  1019. if(block.getType(loc) != "km:tin_block") {
  1020. return false;
  1021. }
  1022. loc.add(loc, 0, 0, 1);
  1023. if(block.getType(loc) != "km:tin_block") {
  1024. return false;
  1025. }
  1026. loc.add(loc, 0, 0, 1);
  1027. if(block.getType(loc) != "km:tin_block") {
  1028. return false;
  1029. }
  1030. loc.add(loc, 0, 0, 1);
  1031. if(block.getType(loc) != "minecraft:stone_brick_slab") {
  1032. return false;
  1033. }
  1034. loc.add(loc, 1, 0, 0);
  1035. if(block.getType(loc) != "km:tin_block") {
  1036. return false;
  1037. }
  1038. loc.add(loc, 1, 0, 0);
  1039. if(block.getType(loc) != "km:tin_block") {
  1040. return false;
  1041. }
  1042. loc.add(loc, 1, 0, 0);
  1043. if(block.getType(loc) != "km:tin_block") {
  1044. return false;
  1045. }
  1046. loc.add(loc, 1, 0, 0);
  1047. if(block.getType(loc) != "minecraft:stone_brick_slab") {
  1048. return false;
  1049. }
  1050. loc.add(loc, 0, 0, -1);
  1051. if(block.getType(loc) != "km:tin_block") {
  1052. return false;
  1053. }
  1054. loc.add(loc, 0, 0, -1);
  1055. if(block.getType(loc) != "km:tin_block") {
  1056. return false;
  1057. }
  1058. loc.add(loc, 0, 0, -1);
  1059. if(block.getType(loc) != "km:tin_block") {
  1060. return false;
  1061. }
  1062. loc.add(loc, 0, 0, -1);
  1063. if(block.getType(loc) != "minecraft:stone_brick_slab") {
  1064. return false;
  1065. }
  1066. loc.add(loc, -1, 0, 0);
  1067. if(block.getType(loc) != "km:tin_block") {
  1068. return false;
  1069. }
  1070. loc.add(loc, -1, 0, 0);
  1071. if(block.getType(loc) != "km:tin_block") {
  1072. return false;
  1073. }
  1074. loc.add(loc, -1, 0, 0);
  1075. if(block.getType(loc) != "km:tin_block") {
  1076. return false;
  1077. }
  1078. loc.add(loc, -1, 0, 0);
  1079. if(block.getType(loc) != "minecraft:stone_brick_slab") {
  1080. return false;
  1081. }
  1082. loc.add(loc, 1, 1, 2);
  1083. if(block.getType(loc) != "km:tin_block") {
  1084. return false;
  1085. }
  1086. loc.add(loc, 1, 0, 0);
  1087. if(block.getType(loc) != "km:tin_block") {
  1088. return false;
  1089. }
  1090. loc.add(loc, 1, 0, 0);
  1091. if(block.getType(loc) != "km:tin_block") {
  1092. return false;
  1093. }
  1094. loc.add(loc, -1, 0, -1);
  1095. if(block.getType(loc) != "km:tin_block") {
  1096. return false;
  1097. }
  1098. loc.add(loc, 0, 0, 2);
  1099. if(block.getType(loc) != "km:tin_block") {
  1100. return false;
  1101. }
  1102. loc.add(loc, -2, -2, -3);
  1103. if(block.getType(loc) != "km:tin_block") {
  1104. return false;
  1105. }
  1106. loc.add(loc, 0, -1, 0);
  1107. if(block.getType(loc) != "km:tin_block") {
  1108. return false;
  1109. }
  1110. loc.add(loc, 0, -1, 0);
  1111. if(block.getType(loc) != "km:tin_block") {
  1112. return false;
  1113. }
  1114. loc.add(loc, 0, 0, 4);
  1115. if(block.getType(loc) != "km:tin_block") {
  1116. return false;
  1117. }
  1118. loc.add(loc, 0, 1, 0);
  1119. if(block.getType(loc) != "km:tin_block") {
  1120. return false;
  1121. }
  1122. loc.add(loc, 0, 1, 0);
  1123. if(block.getType(loc) != "km:tin_block") {
  1124. return false;
  1125. }
  1126. loc.add(loc, 4, 0, 0);
  1127. if(block.getType(loc) != "km:tin_block") {
  1128. return false;
  1129. }
  1130. loc.add(loc, 0, -1, 0);
  1131. if(block.getType(loc) != "km:tin_block") {
  1132. return false;
  1133. }
  1134. loc.add(loc, 0, -1, 0);
  1135. if(block.getType(loc) != "km:tin_block") {
  1136. return false;
  1137. }
  1138. loc.add(loc, 0, 0, -4);
  1139. if(block.getType(loc) != "km:tin_block") {
  1140. return false;
  1141. }
  1142. loc.add(loc, 0, 1, 0);
  1143. if(block.getType(loc) != "km:tin_block") {
  1144. return false;
  1145. }
  1146. loc.add(loc, 0, 1, 0);
  1147. if(block.getType(loc) != "km:tin_block") {
  1148. return false;
  1149. }
  1150. loc.add(loc, 0, -3, 0);
  1151. if(block.getType(loc) != "km:tin_block") {
  1152. return false;
  1153. }
  1154. loc.add(loc, -1, 0, 0);
  1155. if(block.getType(loc) != "km:tin_block") {
  1156. return false;
  1157. }
  1158. loc.add(loc, -1, 0, 0);
  1159. if(block.getType(loc) != "km:tin_block") {
  1160. return false;
  1161. }
  1162. loc.add(loc, -1, 0, 0);
  1163. if(block.getType(loc) != "km:tin_block") {
  1164. return false;
  1165. }
  1166. loc.add(loc, -1, 0, 0);
  1167. if(block.getType(loc) != "km:tin_block") {
  1168. return false;
  1169. }
  1170. loc.add(loc, 0, 0, 1);
  1171. if(block.getType(loc) != "km:tin_block") {
  1172. return false;
  1173. }
  1174. loc.add(loc, 0, 0, 1);
  1175. if(block.getType(loc) != "km:tin_block") {
  1176. return false;
  1177. }
  1178. loc.add(loc, 0, 0, 1);
  1179. if(block.getType(loc) != "km:tin_block") {
  1180. return false;
  1181. }
  1182. loc.add(loc, 0, 0, 1);
  1183. if(block.getType(loc) != "km:tin_block") {
  1184. return false;
  1185. }
  1186. loc.add(loc, 1, 0, 0);
  1187. if(block.getType(loc) != "km:tin_block") {
  1188. return false;
  1189. }
  1190. loc.add(loc, 1, 0, 0);
  1191. if(block.getType(loc) != "km:tin_block") {
  1192. return false;
  1193. }
  1194. loc.add(loc, 1, 0, 0);
  1195. if(block.getType(loc) != "km:tin_block") {
  1196. return false;
  1197. }
  1198. loc.add(loc, 1, 0, 0);
  1199. if(block.getType(loc) != "km:tin_block") {
  1200. return false;
  1201. }
  1202. loc.add(loc, 0, 0, -1);
  1203. if(block.getType(loc) != "km:tin_block") {
  1204. return false;
  1205. }
  1206. loc.add(loc, 0, 0, -1);
  1207. if(block.getType(loc) != "km:tin_block") {
  1208. return false;
  1209. }
  1210. loc.add(loc, 0, 0, -1);
  1211. if(block.getType(loc) != "km:tin_block") {
  1212. return false;
  1213. }
  1214. loc.add(loc, -1, 0, 0);
  1215. if(block.getType(loc) != "minecraft:stone_bricks") {
  1216. return false;
  1217. }
  1218. loc.add(loc, -2, 0, 0);
  1219. if(block.getType(loc) != "minecraft:stone_bricks") {
  1220. return false;
  1221. }
  1222. loc.add(loc, 0, 0, 2);
  1223. if(block.getType(loc) != "minecraft:stone_bricks") {
  1224. return false;
  1225. }
  1226. loc.add(loc, 2, 0, 0);
  1227. if(block.getType(loc) != "minecraft:stone_bricks") {
  1228. return false;
  1229. }
  1230. loc.add(loc, -1, 0, 0);
  1231. if(block.getType(loc) != "km:tin_block") {
  1232. return false;
  1233. }
  1234. loc.add(loc, -1, 0, -1);
  1235. if(block.getType(loc) != "km:tin_block") {
  1236. return false;
  1237. }
  1238. loc.add(loc, 1, 0, 0);
  1239. if(block.getType(loc) != "km:tin_block") {
  1240. return false;
  1241. }
  1242. loc.add(loc, 1, 0, 0);
  1243. if(block.getType(loc) != "km:tin_block") {
  1244. return false;
  1245. }
  1246. loc.add(loc, -1, 0, -1);
  1247. if(block.getType(loc) != "km:tin_block") {
  1248. return false;
  1249. }
  1250. return true;
  1251. }
  1252. function setTpWallX(chest_loc, item_type) {
  1253. block.set(loc.mod(chest_loc, 2, -1, -1), item_type);
  1254. //block.set(loc.mod(chest_loc, 2, -1, 0), item_type);
  1255. block.set(loc.mod(chest_loc, 2, -1, 1), item_type);
  1256. block.set(loc.mod(chest_loc, -2, -1, -1), item_type);
  1257. //block.set(loc.mod(chest_loc, -2, -1, 0), item_type);
  1258. block.set(loc.mod(chest_loc, -2, -1, 1), item_type);
  1259. block.set(loc.mod(chest_loc, -1, -1, 2), item_type);
  1260. //block.set(loc.mod(chest_loc, 0, -1, 2), item_type);
  1261. block.set(loc.mod(chest_loc, 1, -1, 2), item_type);
  1262. block.set(loc.mod(chest_loc, -1, -1, -2), item_type);
  1263. //block.set(loc.mod(chest_loc, 0, -1, -2), item_type);
  1264. block.set(loc.mod(chest_loc, 1, -1, -2), item_type);
  1265. //block.set(loc.mod(chest_loc, 2, -2, -1), item_type);
  1266. block.set(loc.mod(chest_loc, 2, -2, 0), item_type);
  1267. //block.set(loc.mod(chest_loc, 2, -2, 1), item_type);
  1268. //block.set(loc.mod(chest_loc, -2, -2, -1), item_type);
  1269. block.set(loc.mod(chest_loc, -2, -2, 0), item_type);
  1270. //block.set(loc.mod(chest_loc, -2, -2, 1), item_type);
  1271. //block.set(loc.mod(chest_loc, -1, -2, 2), item_type);
  1272. block.set(loc.mod(chest_loc, 0, -2, 2), item_type);
  1273. //block.set(loc.mod(chest_loc, 1, -2, 2), item_type);
  1274. //block.set(loc.mod(chest_loc, -1, -2, -2), item_type);
  1275. block.set(loc.mod(chest_loc, 0, -2, -2), item_type);
  1276. //block.set(loc.mod(chest_loc, 1, -2, -2), item_type);
  1277. block.set(loc.mod(chest_loc, 2, -3, -1), item_type);
  1278. //block.set(loc.mod(chest_loc, 2, -3, 0), item_type);
  1279. block.set(loc.mod(chest_loc, 2, -3, 1), item_type);
  1280. block.set(loc.mod(chest_loc, -2, -3, -1), item_type);
  1281. //block.set(loc.mod(chest_loc, -2, -3, 0), item_type);
  1282. block.set(loc.mod(chest_loc, -2, -3, 1), item_type);
  1283. block.set(loc.mod(chest_loc, -1, -3, 2), item_type);
  1284. //block.set(loc.mod(chest_loc, 0, -3, 2), item_type);
  1285. block.set(loc.mod(chest_loc, 1, -3, 2), item_type);
  1286. block.set(loc.mod(chest_loc, -1, -3, -2), item_type);
  1287. //block.set(loc.mod(chest_loc, 0, -3, -2), item_type);
  1288. block.set(loc.mod(chest_loc, 1, -3, -2), item_type);
  1289. }
  1290. function setTpWallFull(chest_loc, item_type) {
  1291. block.set(loc.mod(chest_loc, 2, -1, -1), item_type);
  1292. block.set(loc.mod(chest_loc, 2, -1, 0), item_type);
  1293. block.set(loc.mod(chest_loc, 2, -1, 1), item_type);
  1294. block.set(loc.mod(chest_loc, -2, -1, -1), item_type);
  1295. block.set(loc.mod(chest_loc, -2, -1, 0), item_type);
  1296. block.set(loc.mod(chest_loc, -2, -1, 1), item_type);
  1297. block.set(loc.mod(chest_loc, -1, -1, 2), item_type);
  1298. block.set(loc.mod(chest_loc, 0, -1, 2), item_type);
  1299. block.set(loc.mod(chest_loc, 1, -1, 2), item_type);
  1300. block.set(loc.mod(chest_loc, -1, -1, -2), item_type);
  1301. block.set(loc.mod(chest_loc, 0, -1, -2), item_type);
  1302. block.set(loc.mod(chest_loc, 1, -1, -2), item_type);
  1303. block.set(loc.mod(chest_loc, 2, -2, -1), item_type);
  1304. block.set(loc.mod(chest_loc, 2, -2, 0), item_type);
  1305. block.set(loc.mod(chest_loc, 2, -2, 1), item_type);
  1306. block.set(loc.mod(chest_loc, -2, -2, -1), item_type);
  1307. block.set(loc.mod(chest_loc, -2, -2, 0), item_type);
  1308. block.set(loc.mod(chest_loc, -2, -2, 1), item_type);
  1309. block.set(loc.mod(chest_loc, -1, -2, 2), item_type);
  1310. block.set(loc.mod(chest_loc, 0, -2, 2), item_type);
  1311. block.set(loc.mod(chest_loc, 1, -2, 2), item_type);
  1312. block.set(loc.mod(chest_loc, -1, -2, -2), item_type);
  1313. block.set(loc.mod(chest_loc, 0, -2, -2), item_type);
  1314. block.set(loc.mod(chest_loc, 1, -2, -2), item_type);
  1315. block.set(loc.mod(chest_loc, 2, -3, -1), item_type);
  1316. block.set(loc.mod(chest_loc, 2, -3, 0), item_type);
  1317. block.set(loc.mod(chest_loc, 2, -3, 1), item_type);
  1318. block.set(loc.mod(chest_loc, -2, -3, -1), item_type);
  1319. block.set(loc.mod(chest_loc, -2, -3, 0), item_type);
  1320. block.set(loc.mod(chest_loc, -2, -3, 1), item_type);
  1321. block.set(loc.mod(chest_loc, -1, -3, 2), item_type);
  1322. block.set(loc.mod(chest_loc, 0, -3, 2), item_type);
  1323. block.set(loc.mod(chest_loc, 1, -3, 2), item_type);
  1324. block.set(loc.mod(chest_loc, -1, -3, -2), item_type);
  1325. block.set(loc.mod(chest_loc, 0, -3, -2), item_type);
  1326. block.set(loc.mod(chest_loc, 1, -3, -2), item_type);
  1327. }
  1328. function removeAdventureDisplay(player) {
  1329. display.remove(player, 10);
  1330. }
  1331. function addAdventureDisplay(player, location) {
  1332. x = text.number(loc.getX(location));
  1333. y = text.number(loc.getY(location));
  1334. z = text.number(loc.getZ(location));
  1335. display.add(player, 10, concat("§2Adventure Target: §r", x, " ", y, " ", z));
  1336. }
  1337. //--------------------------------------------------
  1338. //Player-Data-Utils
  1339. //--------------------------------------------------
  1340. function player.teleport(player, location, setBackPos) {
  1341. player_uuid = player.getUuid(player);
  1342. if(player.isOnAdventure(player)) {
  1343. msg(player, "[§5Adventure§r] Teleport blocked. ", text.click("[§5Cancel Adventure?§r]", concat("/stopadventure ", player)));
  1344. return false;
  1345. }
  1346. if(player.hasMinigame(player)) {
  1347. return false;
  1348. }
  1349. if(setBackPos) {
  1350. player.setBackPos(player);
  1351. }
  1352. player_loc = entity.getLocation(player);
  1353. from_world = loc.getWorld(player_loc);
  1354. from_world_name = world.getName(from_world);
  1355. to_world = loc.getWorld(location);
  1356. to_world_name = world.getName(to_world);
  1357. world_change = player.checkForWorldChange(player, location);
  1358. if(world_change) {
  1359. //Inventory
  1360. player.changeInv(player, from_world, to_world);
  1361. entity.clearEffects(player);
  1362. //Party
  1363. if(player.isInParty(player) && player.isPartyLeader(player)) {
  1364. party_id = player.getPartyId(player);
  1365. party_list = party.getList(party_id);
  1366. iter = list.iterator(party_list);
  1367. while(hasNext(iter)) {
  1368. p = player.get(next(iter));
  1369. if(player_uuid == player.getUuid(p)) {
  1370. continue;
  1371. }
  1372. p_name = player.getName(p);
  1373. if(!loc.isSameWorld(player_loc, entity.getLocation(p))) {
  1374. msg.prefix(player, "§5Party", concat(p_name, "§c is in another world."));
  1375. continue;
  1376. }
  1377. if(player.hasMinigame(p)) {
  1378. msg.prefix(player, "§5Party", concat(p_name, "§c is in a game."));
  1379. continue;
  1380. }
  1381. if(player.hasQuest2(p)) {
  1382. msg.prefix(player, "§5Party", concat(p_name, "§c is doing a quest."));
  1383. continue;
  1384. }
  1385. if(player.isOnAdventure(p)) {
  1386. msg.prefix(player, "§5Party", concat(p_name, "§c is on an adventure."));
  1387. continue;
  1388. }
  1389. if(player.isAfk(p)) {
  1390. msg.prefix(player, "§5Party", concat(p_name, "§c is afk."));
  1391. continue;
  1392. }
  1393. player.teleport(p, location, setBackPos);
  1394. }
  1395. }
  1396. //Quests
  1397. script_id = quest.getFromPlayer(player);
  1398. if(script_id != null) {
  1399. script = script.getFromId(script_id);
  1400. if(script != null) {
  1401. setScriptVar("player", player);
  1402. script.callEvent("quest_term", script);
  1403. quest.term(script, player);
  1404. msg.prefix(player, "§dQuest", "Quest termed.");
  1405. }
  1406. }
  1407. }
  1408. modTimer(-50);
  1409. entity.teleport(player, location);
  1410. player.setHeadName(player);
  1411. player.showDefaultStacks(player);
  1412. if(world.isGamesName(to_world_name)) {
  1413. player.clearInventory(player);
  1414. inv = player.getInv(player);
  1415. inv.setItem(inv, 0, read.item("minecraft:compass"));
  1416. }
  1417. player.setTabName(player);
  1418. return true;
  1419. }
  1420. function playerdata.getSurvival(player_or_id) {
  1421. player_id = player.getValidId(player_or_id);
  1422. if(player_id == null) {
  1423. snuvi.debug(concat("invalid player_id ", player_id, " on playerdata.getSurvival"));
  1424. return;
  1425. }
  1426. map = getScriptVar("survival_data");
  1427. config = map.get(map, player_id);
  1428. if(config == null) {
  1429. playerdata.load(player_id, map, "survival_data");
  1430. config = map.get(map, player_id);
  1431. }
  1432. return config;
  1433. }
  1434. function playerdata.getGames(player_or_id) {
  1435. player_id = player.getValidId(player_or_id);
  1436. if(player_id == null) {
  1437. snuvi.debug(concat("invalid player_id ", player_id, " on playerdata.getGames"));
  1438. return;
  1439. }
  1440. map = getScriptVar("games_data");
  1441. config = map.get(map, player_id);
  1442. if(config == null) {
  1443. playerdata.load(player_id, map, "games_data");
  1444. config = map.get(map, player_id);
  1445. }
  1446. return config;
  1447. }
  1448. function playerdata.getStory(player_or_id) {
  1449. player_id = player.getValidId(player_or_id);
  1450. if(player_id == null) {
  1451. snuvi.debug(concat("invalid player_id ", player_id, " on playerdata.getStory"));
  1452. return;
  1453. }
  1454. map = getScriptVar("story_data");
  1455. config = map.get(map, player_id);
  1456. if(config == null) {
  1457. playerdata.load(player_id, map, "story_data");
  1458. config = map.get(map, player_id);
  1459. }
  1460. return config;
  1461. }
  1462. function playerdata.load(player_or_id, map, name) {
  1463. player_id = player.getValidId(player_or_id);
  1464. if(player_id == null) {
  1465. snuvi.debug(concat("invalid player_id ", player_id, " on playerdata.load"));
  1466. return;
  1467. }
  1468. config = map.get(map, player_id);
  1469. if(config == null) {
  1470. config = config.new(concat("scripts/configs/player_data/", name), player_id);
  1471. if(config.exists(config)) {
  1472. config.load(config);
  1473. }
  1474. map.add(map, player_id, config);
  1475. }
  1476. }
  1477. function player.getValidId(player_or_id) {
  1478. if(isPlayer(player_or_id)) {
  1479. return player.getId(player_or_id);
  1480. }
  1481. if(isDouble(player_or_id)) {
  1482. if(player.getNameFromId(player_or_id) != null) {
  1483. return player_or_id;
  1484. }
  1485. }
  1486. return null;
  1487. }
  1488. function player.getValid(player_or_id) {
  1489. if(isPlayer(player_or_id)) {
  1490. return player_or_id;
  1491. }
  1492. player = player.get(player.getUuidFromId(player_or_id));
  1493. if(player == null) {
  1494. return null;
  1495. }
  1496. return player;
  1497. }
  1498. //--------------------------------------------------
  1499. //Msg-Utils
  1500. //--------------------------------------------------
  1501. function msg.quest(player, speaker, line_now, line_max, message) {
  1502. msg(player, concat("[§b", text.number(line_now), "§r/§b", text.number(line_max), "§r] §a", speaker, " §r| ", concat("§e", message)));
  1503. }
  1504. function msg.chat(player, message) {
  1505. nickname = player.getNickName(player);
  1506. rank = getRank(player);
  1507. colorcode = text.subString(rank, 0, 2);
  1508. player_id = player.getId(player);
  1509. if(player_id == 35 || player_id == 62) {
  1510. nickname = concat(nickname, "§r][§e§l★");
  1511. rank = concat(rank, "\n§eSpecial VIP for Special Services");
  1512. }
  1513. live_tag = "";
  1514. if(player.isLive(player)) {
  1515. live_tag = "§f[§dLive§f]";
  1516. }
  1517. online_list = players.toList();
  1518. iter = list.iterator(online_list);
  1519. while(hasNext(iter)) {
  1520. p = next(iter);
  1521. if(player.hasMinigame(p) && player.isMuted(p)) {
  1522. continue;
  1523. }
  1524. msg(p, live_tag, "[", text.hover(concat(colorcode, nickname), rank), "§r] §r", message);
  1525. }
  1526. }
  1527. function msg.send(from_player, to_name, prefix, message, send_mail) {
  1528. p = read.player(to_name);
  1529. if(p == null) {
  1530. if(send_mail) {
  1531. mail.send(player.getName(from_player), to_name, message);
  1532. }
  1533. } else {
  1534. msg.prefix(p, prefix, message);
  1535. }
  1536. }
  1537. function msg.prefix(player, prefix, message) {
  1538. msg(player, concat("§r[", prefix, "§r] ", message));
  1539. }
  1540. function msg.online(prefix, message) {
  1541. msg("online", concat("§r[", prefix, "§r] "), message);
  1542. }
  1543. function msg.radius(prefix, message, location, radius) {
  1544. list = players.near(location, radius);
  1545. iter = list.iterator(list);
  1546. while(hasNext(iter)) {
  1547. msg.prefix(next(iter), prefix, message);
  1548. }
  1549. }
  1550. function msg.server(message) {
  1551. msg("online", text.hover("[§cServer§r]", "The center of Wusiness"), " ", text.replace(message, "&", "§"));
  1552. msg("SERVER", "[§cServer§r] ", text.replace(message, "&", "§"));
  1553. }
  1554. function msg.world(world, message) {
  1555. world_list = players.toWorldList(world);
  1556. iter = iterator(world_list);
  1557. while(hasNext(iter)) {
  1558. msg(next(iter), message);
  1559. }
  1560. }
  1561. function msg.survival(message) {
  1562. msg.world(world.getOverWorld(), message);
  1563. msg.world(world.getTheEnd(), message);
  1564. msg.world(world.getTheNether(), message);
  1565. }
  1566. function msg.story(message) {
  1567. msg.world(world.getStory(), message);
  1568. }
  1569. function msg.creative(message) {
  1570. msg.world(world.getCreative(), message);
  1571. }
  1572. function msg.games(message) {
  1573. msg.world(world.getGames(), message);
  1574. }
  1575. //--------------------------------------------------
  1576. //Item-Utils
  1577. //--------------------------------------------------
  1578. function item.getAir() {
  1579. return read.item("minecraft:air");
  1580. }
  1581. function item.isAmber(item) {
  1582. return text.item(item) == "{id:\"km:flawless_gem_stone\",Count:1b,tag:{color:13664802,display:{Name:'{\"text\":\"§fAmber\"}'}}}";
  1583. }
  1584. function item.isSapphire(item) {
  1585. return text.item(item) == "{id:\"km:flawless_gem_stone\",Count:1b,tag:{color:3289855,display:{Name:'{\"text\":\"§fSapphire\"}'}}}";
  1586. }
  1587. function item.isRuby(item) {
  1588. return text.item(item) == "{id:\"km:flawless_gem_stone\",Count:1b,tag:{color:16724530,display:{Name:'{\"text\":\"§fRuby\"}'}}}";
  1589. }
  1590. function item.getAmber() {
  1591. return read.item("{id:\"km:flawless_gem_stone\",Count:1b,tag:{color:13664802,display:{Name:'{\"text\":\"§fAmber\"}'}}}");
  1592. }
  1593. function item.getSapphire() {
  1594. return read.item("{id:\"km:flawless_gem_stone\",Count:1b,tag:{color:3289855,display:{Name:'{\"text\":\"§fSapphire\"}'}}}");
  1595. }
  1596. function item.getRuby() {
  1597. return read.item("{id:\"km:flawless_gem_stone\",Count:1b,tag:{color:16724530,display:{Name:'{\"text\":\"§fRuby\"}'}}}");
  1598. }
  1599. //--------------------------------------------------
  1600. //Player-Utils
  1601. //--------------------------------------------------
  1602. function player.canTeleport(player) {
  1603. if(player.hasMinigame(player)) {
  1604. return false;
  1605. }
  1606. if(player.isOnAdventure(player)) {
  1607. return false;
  1608. }
  1609. return true;
  1610. }
  1611. function player.hasClearInventory(player) {
  1612. inv = player.getInv(player);
  1613. for(slot = 0; slot < 36; slot++) {
  1614. if(item.getType(inv.getItem(inv, slot)) != "minecraft:air") {
  1615. return false;
  1616. }
  1617. }
  1618. if(item.getType(living.getEquip(player, "head")) != "minecraft:air") {
  1619. return false;
  1620. }
  1621. if(item.getType(living.getEquip(player, "chest")) != "minecraft:air") {
  1622. return false;
  1623. }
  1624. if(item.getType(living.getEquip(player, "legs")) != "minecraft:air") {
  1625. return false;
  1626. }
  1627. if(item.getType(living.getEquip(player, "feet")) != "minecraft:air") {
  1628. return false;
  1629. }
  1630. if(item.getType(living.getEquip(player, "offhand")) != "minecraft:air") {
  1631. return false;
  1632. }
  1633. return true;
  1634. }
  1635. function player.getJoinMessage(player_or_id) {
  1636. config = playerdata.getSurvival(player_or_id);
  1637. temp = config.getString(config, "message.join", "null");
  1638. if(temp == "null") {
  1639. return null;
  1640. }
  1641. return temp;
  1642. }
  1643. function player.setJoinMessage(player_or_id, message) {
  1644. config = playerdata.getSurvival(player_or_id);
  1645. config.set(config, "message.join", message);
  1646. config.saveAsync(config);
  1647. }
  1648. function player.getLeaveMessage(player_or_id) {
  1649. config = playerdata.getSurvival(player_or_id);
  1650. temp = config.getString(config, "message.leave", "null");
  1651. if(temp == "null") {
  1652. return null;
  1653. }
  1654. return temp;
  1655. }
  1656. function player.setLeaveMessage(player_or_id, message) {
  1657. config = playerdata.getSurvival(player_or_id);
  1658. config.set(config, "message.leave", message);
  1659. config.saveAsync(config);
  1660. }
  1661. function player.isLive(player) {
  1662. player_uuid = player.getUuid(player);
  1663. live_set = getScriptVar("live_set");
  1664. return set.contains(live_set, player_uuid);
  1665. }
  1666. function player.setLive(player, boolean) {
  1667. player_uuid = player.getUuid(player);
  1668. live_set = getScriptVar("live_set");
  1669. if(boolean) {
  1670. set.add(live_set, player_uuid);
  1671. } else {
  1672. set.remove(live_set, player_uuid);
  1673. }
  1674. }
  1675. function player.getFullName(player) {
  1676. player_name = player.getName(player);
  1677. nickname = removeFormat(player.getNickname(player));
  1678. if(nickname == player_name) {
  1679. personally_messages = true;
  1680. } else {
  1681. personally_messages = false;
  1682. }
  1683. if(personally_messages) {
  1684. full_name = concat("[", getRank(player), "§r] ", nickname);
  1685. } else {
  1686. full_name = concat("[§3User§r] ", nickname);
  1687. }
  1688. return full_name;
  1689. }
  1690. function player.setTabName(player) {
  1691. nickname = player.getNickname(player);
  1692. rank = getRank(player);
  1693. if(text.startswith(rank, "§", 0)) {
  1694. colorcode = text.subString(rank, 0, 2);
  1695. tab_name = concat(colorcode, nickname);
  1696. } else {
  1697. tab_name = nickname;
  1698. }
  1699. if(player.isAfk(player)) {
  1700. tab_name = concat(tab_name, " §5§o[Afk]");
  1701. }
  1702. if(player.isLive(player)) {
  1703. tab_name = concat(tab_name, " §f[§dLive§f]");
  1704. }
  1705. player.setDisplayName(player, tab_name);
  1706. }
  1707. function player.removeItemNbt(player, itemstack) {
  1708. //Make a copy
  1709. item_type = item.getType(itemstack);
  1710. amount = item.getAmount(itemstack);
  1711. my_item = read.item(item_type, amount);
  1712. //Loop the inventory
  1713. inv = player.getInv(player);
  1714. for(slot = 0; slot < inv.getSize(inv); slot++) {
  1715. item = inv.getItem(inv, slot);
  1716. if(item.getType(item) == item_type) {
  1717. diff = amount - item.getAmount(item);
  1718. if(diff > 0) {
  1719. amount = diff;
  1720. item.setAmount(item, 0);
  1721. } else {
  1722. item.setAmount(item, math.abs(diff));
  1723. air = item.getAir();
  1724. item.setAmount(air, 0);
  1725. return air;
  1726. }
  1727. }
  1728. }
  1729. item.setAmount(my_item, amount);
  1730. return my_item;
  1731. }
  1732. function player.removeItemTag(player, tag, amount) {
  1733. air = item.getAir();
  1734. inv = player.getInv(player);
  1735. for(slot = 0; slot < inv.getSize(inv); slot++) {
  1736. item = inv.getItem(inv, slot);
  1737. if(item.hasTag(tag, item)) {
  1738. diff = amount - item.getAmount(item);
  1739. if(diff > 0) {
  1740. item.setAmount(item, 0);
  1741. amount = diff;
  1742. } else {
  1743. item.setAmount(item, math.abs(diff));
  1744. amount = 0;
  1745. break;
  1746. }
  1747. }
  1748. }
  1749. item.setAmount(air, amount);
  1750. return air;
  1751. }
  1752. function player.showDebug(player, boolean) {
  1753. player_uuid = player.getUuid(player);
  1754. if(boolean) {
  1755. perm.registerPlayer(player_uuid, 16);
  1756. } else {
  1757. perm.unregisterPlayer(player_uuid, 16);
  1758. }
  1759. }
  1760. function player.showDefaultStacks(player) {
  1761. player_loc = entity.getLocation(player);
  1762. world_name = world.getName(loc.getWorld(player_loc));
  1763. stacks.clear(player);
  1764. if(world.isSurvName(world_name)) {
  1765. stacks.set(player, 0, "km:gear");
  1766. stacks.set(player, 1, "km:golden_scepter");
  1767. stacks.set(player, 2, "minecraft:red_bed");
  1768. } elseif(world_name == "games") {
  1769. stacks.set(player, 0, "km:gear");
  1770. } elseif(world_name == "story") {
  1771. stacks.set(player, 0, "km:gear");
  1772. stacks.set(player, 1, "km:golden_scepter");
  1773. } elseif(world_name == "creative") {
  1774. stacks.set(player, 0, "km:gear");
  1775. }
  1776. stacks.setActive(player, true);
  1777. }
  1778. function player.setSpeed(player, speed) {
  1779. living.setPersistentMovementSpeed(player, speed / 10);
  1780. living.setPersistentFlyingSpeed(player, speed / 10 * 4);
  1781. }
  1782. function player.hasBigPlotCreated(player_or_id) {
  1783. config = playerdata.getSurvival(player_or_id);
  1784. return config.getBool(config, "plot.big", false);
  1785. }
  1786. function player.setBigPlotCreated(player_or_id, boolean) {
  1787. config = playerdata.getSurvival(player_or_id);
  1788. config.set(config, "plot.big", boolean);
  1789. config.saveAsync(config);
  1790. }
  1791. function player.hasPlotRaised(player_or_id) {
  1792. config = playerdata.getSurvival(player_or_id);
  1793. return config.getBool(config, "plot.raised", false);
  1794. }
  1795. function player.setPlotRaised(player_or_id, boolean) {
  1796. config = playerdata.getSurvival(player_or_id);
  1797. config.set(config, "plot.raised", boolean);
  1798. config.saveAsync(config);
  1799. }
  1800. function player.usedHisFreePlot(player_or_id) {
  1801. config = playerdata.getSurvival(player_or_id);
  1802. return config.getBool(config, "plot.usedFree", false);
  1803. }
  1804. function player.setUsedFreePlot(player_or_id, boolean) {
  1805. config = playerdata.getSurvival(player_or_id);
  1806. config.set(config, "plot.usedFree", boolean);
  1807. config.saveAsync(config);
  1808. }
  1809. function player.activateSitting(player_or_id, boolean) {
  1810. config = playerdata.getSurvival(player_or_id);
  1811. config.set(config, "sitting", boolean);
  1812. config.saveAsync(config);
  1813. }
  1814. function player.hasSittingActivated(player_or_id) {
  1815. config = playerdata.getSurvival(player_or_id);
  1816. return config.getBool(config, "sitting", true);
  1817. }
  1818. function player.acceptTpaRequests(player_or_id, boolean) {
  1819. config = playerdata.getSurvival(player_or_id);
  1820. config.set(config, "tptoggle", boolean);
  1821. config.saveAsync(config);
  1822. }
  1823. function player.doesAcceptTpaRequests(player_or_id) {
  1824. config = playerdata.getSurvival(player_or_id);
  1825. return config.getBool(config, "tptoggle", true);
  1826. }
  1827. function player.getBackPos(player) {
  1828. config = playerdata.getSurvival(player);
  1829. location = config.getString(config, "backpos", "null");
  1830. if(location == "null") {
  1831. return null;
  1832. }
  1833. return read.location(location);
  1834. }
  1835. function player.setBackPos(player) {
  1836. config = playerdata.getSurvival(player);
  1837. config.set(config, "backpos", text.location(entity.getLocation(player)));
  1838. config.saveAsync(config);
  1839. }
  1840. function player.setBackPosLoc(player, location) {
  1841. config = playerdata.getSurvival(player);
  1842. config.set(config, "backpos", text.location(location));
  1843. config.saveAsync(config);
  1844. }
  1845. function player.clearBackPos(player) {
  1846. config = playerdata.getSurvival(player);
  1847. config.set(config, "backpos", "null");
  1848. config.saveAsync(config);
  1849. }
  1850. function entity.getFromDamageSource(damage_source) {
  1851. entity = damage.getImmediateSource(damage_source);
  1852. if(entity == null) {
  1853. return damage.getTrueSource(damage_source);
  1854. }
  1855. return entity;
  1856. }
  1857. function player.getFromDamageSource(damage_source) {
  1858. entity = damage.getImmediateSource(damage_source);
  1859. if(isPlayer(entity)) {
  1860. return entity;
  1861. }
  1862. entity = damage.getTrueSource(damage_source);
  1863. if(isPlayer(entity)) {
  1864. return entity;
  1865. }
  1866. return null;
  1867. }
  1868. function player.getJoins(player_or_id) {
  1869. if(isPlayer(player_or_id)) {
  1870. player_id = player.getId(player_or_id);
  1871. } else {
  1872. player_id = player_or_id;
  1873. }
  1874. stmt = databank.prepare("SELECT COUNT(join_time) FROM playtime WHERE player_id = ?;");
  1875. databank.setInt(stmt, 1, player_id);
  1876. result = databank.execute(stmt);
  1877. if(databank.next(result)) {
  1878. amount = databank.getLong(result, 1);
  1879. }
  1880. databank.close(result);
  1881. databank.close(stmt);
  1882. return amount;
  1883. }
  1884. function player.getTotalPlaytime(player_or_id) {
  1885. if(isPlayer(player_or_id)) {
  1886. player_id = player.getId(player_or_id);
  1887. } else {
  1888. player_id = player_or_id;
  1889. }
  1890. //Online seit
  1891. since_minutes = 0;
  1892. if(isOnline(player.getNameFromId(player_id))) {
  1893. stmt = databank.prepare("SELECT join_time FROM playtime WHERE player_id = ? AND leave_time IS NULL;");
  1894. databank.setInt(stmt, 1, player_id);
  1895. result = databank.execute(stmt);
  1896. while(databank.next(result)) {
  1897. since_minutes = (time.getMillis() - databank.getLong(result, 1)) / 1000 / 60;
  1898. }
  1899. databank.close(result);
  1900. databank.close(stmt);
  1901. }
  1902. //Spielzeit gesamt
  1903. stmt2 = databank.prepare("SELECT SUM(leave_time - join_time) FROM playtime WHERE player_id = ?;");
  1904. databank.setInt(stmt2, 1, player_id);
  1905. result = databank.execute(stmt2);
  1906. while(databank.next(result)) {
  1907. minutes = databank.getLong(result, 1) / 1000 / 60 + since_minutes;
  1908. }
  1909. databank.close(result);
  1910. databank.close(stmt2);
  1911. return minutes;
  1912. }
  1913. function player.hasInvIgnore(player_or_id) {
  1914. config = playerdata.getSurvival(player_or_id);
  1915. return config.getBool(config, "invignore", false);
  1916. }
  1917. function player.invIgnore(player_or_id, boolean) {
  1918. config = playerdata.getSurvival(player_or_id);
  1919. config.set(config, "invignore", boolean);
  1920. config.saveAsync(config);
  1921. }
  1922. function player.getClanId(player_or_id) {
  1923. config = playerdata.getSurvival(player_or_id);
  1924. return config.getDouble(config, "clan_id", -1);
  1925. }
  1926. function player.setClanId(player_or_id, clan_id) {
  1927. config = playerdata.getSurvival(player_or_id);
  1928. config.set(config, "clan_id", clan_id);
  1929. config.saveAsync(config);
  1930. }
  1931. function player.getClanRole(player_or_id) {
  1932. config = playerdata.getSurvival(player_or_id);
  1933. temp = config.getString(config, "clan_role", "null");
  1934. if(temp == "null") {
  1935. return null;
  1936. }
  1937. return temp;
  1938. }
  1939. function player.setClanRole(player_or_id, clan_id) {
  1940. config = playerdata.getSurvival(player_or_id);
  1941. config.set(config, "clan_role", clan_id);
  1942. config.saveAsync(config);
  1943. }
  1944. function player.isInClan(player_or_id) {
  1945. return player.getClanId(player_or_id) >= 0;
  1946. }
  1947. function player.isClanLeader(player_or_id) {
  1948. return player.getClanRole(player_or_id) == "leader";
  1949. }
  1950. function player.isClanMod(player_or_id) {
  1951. return player.getClanRole(player_or_id) == "mod";
  1952. }
  1953. function player.isClanMember(player_or_id) {
  1954. return player.getClanRole(player_or_id) == "member";
  1955. }
  1956. function player.isSameClan(player_or_id_1, player_or_id_2) {
  1957. id_1 = player.getClanId(player_or_id_1);
  1958. id_2 = player.getClanId(player_or_id_2);
  1959. if(id_1 < 0 || id_2 < 0) {
  1960. return false;
  1961. }
  1962. return id_1 == id_2;
  1963. }
  1964. function player.setHeadName(player) {
  1965. nickname = player.getNickname(player);
  1966. clan_string = "";
  1967. if(player.isInClan(player)) {
  1968. clan_id = player.getClanId(player);
  1969. clan_string = text.concat(" [§6", clan.getTag(clan_id), "§r]");
  1970. }
  1971. live_string = "";
  1972. if(player.isLive(player)) {
  1973. live_string = "§f[§dLive§f] ";
  1974. }
  1975. entity.setName(player, text.concat(live_string, nickname, clan_string));
  1976. }
  1977. function player.setAdventureAmounts(player_or_id, amount) {
  1978. config = playerdata.getSurvival(player_or_id);
  1979. config.set(config, "adventures", amount);
  1980. config.saveAsync(config);
  1981. }
  1982. function player.getAdventureAmounts(player_or_id) {
  1983. config = playerdata.getSurvival(player_or_id);
  1984. return config.getDouble(config, "adventures", 0);
  1985. }
  1986. function player.isOnAdventure(player_or_id) {
  1987. config = playerdata.getSurvival(player_or_id);
  1988. return config.getBool(config, "onadventure", false);
  1989. }
  1990. function player.setAdventure(player_or_id, boolean) {
  1991. config = playerdata.getSurvival(player_or_id);
  1992. config.set(config, "onadventure", boolean);
  1993. config.saveAsync(config);
  1994. }
  1995. function player.getAdventureStart(player_or_id) {
  1996. config = playerdata.getSurvival(player_or_id);
  1997. location = config.getString(config, "adventureloc", "null");
  1998. if(location == "null") {
  1999. return world.getServerSpawn();
  2000. }
  2001. return read.location(location);
  2002. }
  2003. function player.setAdventureStart(player_or_id, location) {
  2004. config = playerdata.getSurvival(player_or_id);
  2005. config.set(config, "adventureloc", text.location(location));
  2006. config.saveAsync(config);
  2007. }
  2008. function player.isMuted(player_or_id) {
  2009. config = playerdata.getSurvival(player_or_id);
  2010. return config.getBool(config, "muted", false);
  2011. }
  2012. function player.mute(player_or_id, boolean) {
  2013. config = playerdata.getSurvival(player_or_id);
  2014. config.set(config, "muted", boolean);
  2015. config.saveAsync(config);
  2016. }
  2017. function player.getSilentJoin(player_or_id) {
  2018. config = playerdata.getSurvival(player_or_id);
  2019. return config.getBool(config, "silentjoin", false);
  2020. }
  2021. function player.setSilentJoin(player_or_id, boolean) {
  2022. config = playerdata.getSurvival(player_or_id);
  2023. config.set(config, "silentjoin", boolean);
  2024. config.saveAsync(config);
  2025. }
  2026. function player.getAutoCloseDoor(player_or_id) {
  2027. config = playerdata.getSurvival(player_or_id);
  2028. return config.getBool(config, "door_auto_close", true);
  2029. }
  2030. function player.setAutoCloseDoor(player_or_id, boolean) {
  2031. config = playerdata.getSurvival(player_or_id);
  2032. config.set(config, "door_auto_close", boolean);
  2033. config.saveAsync(config);
  2034. }
  2035. function player.getNoPetDamage(player_or_id) {
  2036. config = playerdata.getSurvival(player_or_id);
  2037. return config.getBool(config, "pet_damage", true);
  2038. }
  2039. function player.setNoPetDamage(player_or_id, boolean) {
  2040. config = playerdata.getSurvival(player_or_id);
  2041. config.set(config, "pet_damage", boolean);
  2042. config.saveAsync(config);
  2043. }
  2044. function player.getTipLoop(player_or_id) {
  2045. config = playerdata.getSurvival(player_or_id);
  2046. return config.getBool(config, "tip_loop", true);
  2047. }
  2048. function player.setTipLoop(player_or_id, boolean) {
  2049. config = playerdata.getSurvival(player_or_id);
  2050. config.set(config, "tip_loop", boolean);
  2051. config.saveAsync(config);
  2052. }
  2053. function player.setVoteStreak(player_or_id, millis) {
  2054. config = playerdata.getSurvival(player_or_id);
  2055. config.set(config, "votestreak", millis);
  2056. config.saveAsync(config);
  2057. }
  2058. function player.getVoteStreak(player_or_id) {
  2059. config = playerdata.getSurvival(player_or_id);
  2060. return config.getDouble(config, "votestreak", 0);
  2061. }
  2062. function player.setLastVoteTime(player_or_id, millis) {
  2063. config = playerdata.getSurvival(player_or_id);
  2064. config.set(config, "lastvotetime", millis);
  2065. config.saveAsync(config);
  2066. }
  2067. function player.getLastVoteTime(player_or_id) {
  2068. config = playerdata.getSurvival(player_or_id);
  2069. return config.getDouble(config, "lastvotetime", 0);
  2070. }
  2071. function player.setVotePoints(player_or_id, amount) {
  2072. config = playerdata.getSurvival(player_or_id);
  2073. config.set(config, "votepoints", amount);
  2074. config.saveAsync(config);
  2075. }
  2076. function player.getVotePoints(player_or_id) {
  2077. config = playerdata.getSurvival(player_or_id);
  2078. return config.getDouble(config, "votepoints", 0);
  2079. }
  2080. function player.addVotePoints(player_or_id, amount) {
  2081. config = playerdata.getSurvival(player_or_id);
  2082. points = config.getDouble(config, "votepoints", 0) + amount;
  2083. config.set(config, "votepoints", points);
  2084. config.saveAsync(config);
  2085. }
  2086. function player.hasFirstJoin(player_or_id) {
  2087. config = playerdata.getSurvival(player_or_id);
  2088. return config.getBool(config, "firstjoin", true);
  2089. }
  2090. function player.setFirstJoin(player_or_id, boolean) {
  2091. config = playerdata.getSurvival(player_or_id);
  2092. config.set(config, "firstjoin", !boolean);
  2093. config.saveAsync(config);
  2094. }
  2095. function player.getShowcoords(player_or_id) {
  2096. config = playerdata.getSurvival(player_or_id);
  2097. return config.getBool(config, "showcoords", true);
  2098. }
  2099. function player.setShowcoords(player_or_id, bool) {
  2100. config = playerdata.getSurvival(player_or_id);
  2101. config.set(config, "showcoords", bool);
  2102. config.saveAsync(config);
  2103. }
  2104. function player.getFirstJoin(player_or_id) {
  2105. if(isPlayer(player_or_id)) {
  2106. player_id = player.getId(player_or_id);
  2107. } else {
  2108. player_id = player_or_id;
  2109. }
  2110. stmt = databank.prepare("SELECT MIN(join_time) FROM playtime WHERE player_id = ?;");
  2111. databank.setInt(stmt, 1, player_id);
  2112. result = databank.execute(stmt);
  2113. if(databank.next(result)) {
  2114. time = databank.getLong(result, 1);
  2115. }
  2116. databank.close(result);
  2117. databank.close(stmt);
  2118. return time;
  2119. }
  2120. function player.getLastJoin(player_or_id) {
  2121. if(isPlayer(player_or_id)) {
  2122. player_id = player.getId(player_or_id);
  2123. } else {
  2124. player_id = player_or_id;
  2125. }
  2126. stmt = databank.prepare("SELECT MAX(join_time) FROM playtime WHERE player_id = ?;");
  2127. databank.setInt(stmt, 1, player_id);
  2128. result = databank.execute(stmt);
  2129. if(databank.next(result)) {
  2130. time = databank.getLong(result, 1);
  2131. }
  2132. databank.close(result);
  2133. databank.close(stmt);
  2134. return time;
  2135. }
  2136. function player.blockCommands(player) {
  2137. list = getScriptVar("block_commands_list");
  2138. list.add(list, player.getUuid(player));
  2139. }
  2140. function player.unblockCommands(player) {
  2141. list = getScriptVar("block_commands_list");
  2142. player_uuid = player.getUuid(player);
  2143. while(list.contains(list, player_uuid)) {
  2144. list.remove(list, player_uuid);
  2145. }
  2146. }
  2147. function player.isCommandBlocked(player) {
  2148. list = getScriptVar("block_commands_list");
  2149. return list.contains(list, player.getUuid(player));
  2150. }
  2151. function player.checkHandsForItem(player, item_or_type) {
  2152. if(text.class(item_or_type) != "String") {
  2153. item_or_type = item.getType(item_or_type);
  2154. }
  2155. hand = living.getEquip(player, "hand");
  2156. if(item.getType(hand) == item_or_type) {
  2157. return true;
  2158. }
  2159. offhand = living.getEquip(player, "offhand");
  2160. return item.getType(offhand) == item_or_type;
  2161. }
  2162. function player.checkHandsForTag(player, tag) {
  2163. hand = living.getEquip(player, "hand");
  2164. if(item.hasTag(tag, hand)) {
  2165. return true;
  2166. }
  2167. offhand = living.getEquip(player, "offhand");
  2168. return item.hasTag(tag, offhand);
  2169. }
  2170. //--------------------------------------------------
  2171. //Block-Utils
  2172. //--------------------------------------------------
  2173. function block.gotWater(block, block_type, block_loc) {
  2174. if(block_type == "minecraft:water") {
  2175. return true;
  2176. }
  2177. value = block.property.getValue(block_loc, block.getProperty("waterlogged"));
  2178. if(value == null) {
  2179. return false;
  2180. }
  2181. return value;
  2182. }
  2183. function block.getSecondDoor(door_loc_1) {
  2184. prop_h_facing = block.getProperty("horizontal_facing");
  2185. state_facing = block.property.getValue(door_loc_1, prop_h_facing);
  2186. prop_hinge = block.getProperty("hinge");
  2187. state_hinge = block.property.getValue(door_loc_1, prop_hinge);
  2188. if(state_facing == "north") {
  2189. if(state_hinge == "right") {
  2190. door_loc_2 = loc.mod(door_loc_1, -1, 0, 0);
  2191. } else {
  2192. door_loc_2 = loc.mod(door_loc_1, 1, 0, 0);
  2193. }
  2194. } elseif(state_facing == "east") {
  2195. if(state_hinge == "right") {
  2196. door_loc_2 = loc.mod(door_loc_1, 0, 0, -1);
  2197. } else {
  2198. door_loc_2 = loc.mod(door_loc_1, 0, 0, 1);
  2199. }
  2200. } elseif(state_facing == "south") {
  2201. if(state_hinge == "right") {
  2202. door_loc_2 = loc.mod(door_loc_1, 1, 0, 0);
  2203. } else {
  2204. door_loc_2 = loc.mod(door_loc_1, -1, 0, 0);
  2205. }
  2206. } else {
  2207. if(state_hinge == "right") {
  2208. door_loc_2 = loc.mod(door_loc_1, 0, 0, 1);
  2209. } else {
  2210. door_loc_2 = loc.mod(door_loc_1, 0, 0, -1);
  2211. }
  2212. }
  2213. if(block.hasTag(block.getTag("minecraft:wooden_doors"), block.get(door_loc_2))) {
  2214. if(block.isSameDoorHalf(door_loc_1, door_loc_2)) {
  2215. state_hinge_2 = block.property.getValue(door_loc_2, prop_hinge);
  2216. if(state_hinge == "left" && state_hinge_2 == "right" || state_hinge == "right" && state_hinge_2 == "left") {
  2217. return door_loc_2;
  2218. }
  2219. }
  2220. }
  2221. return null;
  2222. }
  2223. function block.isSameDoorHalf(door_loc_1, door_loc_2) {
  2224. prop_d_half = block.getProperty("double_block_half");
  2225. state_half = block.property.getValue(door_loc_1, prop_d_half);
  2226. state_half_2 = block.property.getValue(door_loc_2, prop_d_half);
  2227. return state_half == state_half_2;
  2228. }
  2229. //--------------------------------------------------
  2230. //Money-Utils
  2231. //--------------------------------------------------
  2232. function hasEnoughMoney(player_or_id, price) {
  2233. return getMoney(player_or_id) >= price;
  2234. }
  2235. function getMoney(player_or_id) {
  2236. config = playerdata.getSurvival(player_or_id);
  2237. return config.getDouble(config, "money", 0);
  2238. }
  2239. function setMoney(player_or_id, money) {
  2240. config = playerdata.getSurvival(player_or_id);
  2241. config.set(config, "money", money);
  2242. config.saveAsync(config);
  2243. player = player.getValid(player_or_id);
  2244. if(player == null) {
  2245. return;
  2246. }
  2247. displayMoney(player, money);
  2248. }
  2249. function money.getBoostFactor() {
  2250. return getScriptVar("money_factor");
  2251. }
  2252. function money.setBoostFactor(factor) {
  2253. setScriptVar("money_factor", factor);
  2254. }
  2255. function money.addBoost(player_or_id, money) {
  2256. money *= money.getBoostFactor();
  2257. player = player.getValid(player_or_id);
  2258. if(player == null) {
  2259. return;
  2260. }
  2261. if(money.getBoostFactor() > 1) {
  2262. money.popUp(player, money, true);
  2263. }
  2264. addMoney(player, money);
  2265. }
  2266. function addMoney(player_or_id, money) {
  2267. if(money == 0) {
  2268. return;
  2269. }
  2270. config = playerdata.getSurvival(player_or_id);
  2271. new_money = config.getDouble(config, "money", 0) + money;
  2272. config.set(config, "money", new_money);
  2273. config.saveAsync(config);
  2274. player = player.getValid(player_or_id);
  2275. if(player == null) {
  2276. return;
  2277. }
  2278. displayMoney(player, new_money);
  2279. money.popUp(player, money, false);
  2280. }
  2281. function subMoney(player_or_id, money) {
  2282. if(money == 0) {
  2283. return;
  2284. }
  2285. config = playerdata.getSurvival(player_or_id);
  2286. new_money = config.getDouble(config, "money", 0) - money;
  2287. config.set(config, "money", new_money);
  2288. config.saveAsync(config);
  2289. player = player.getValid(player_or_id);
  2290. if(player == null) {
  2291. return;
  2292. }
  2293. displayMoney(player, new_money);
  2294. money.popUp(player, money * -1, false);
  2295. }
  2296. function money.popUp(player, money, boosted) {
  2297. if($boost_blocker == null) {
  2298. $boost_blocker = false;
  2299. }
  2300. if($boost_blocker) {
  2301. $boost_blocker = false;
  2302. return;
  2303. }
  2304. if(money == 0) {
  2305. return;
  2306. }
  2307. if(money > 0) {
  2308. pre = "+";
  2309. }
  2310. if(money < 0) {
  2311. pre = "-";
  2312. money *= -1;
  2313. }
  2314. if(boosted) {
  2315. $boost_blocker = true;
  2316. post = " §6§k#§rBoosted§6§k#";
  2317. } else {
  2318. post = "";
  2319. }
  2320. player.action(player, concat(pre, "§6", text.number(money), " §rsnuvi", post));
  2321. }
  2322. function displayMoney(player, money) {
  2323. a = money.split(money);
  2324. display.add(player, 0, concat("#23-1- ", text.number(a[0])));
  2325. display.add(player, 1, concat("#24-1- ", text.number(a[1])));
  2326. display.add(player, 2, concat("#25-1- ", text.number(a[2])));
  2327. }
  2328. function money.split(money) {
  2329. array = array.new(3);
  2330. gold = math.roundDown(money / 4096);
  2331. pre_silver = money % 4096;;
  2332. silver = math.roundDown(pre_silver / 64);
  2333. bronze = pre_silver % 64;
  2334. array[0] = gold;
  2335. array[1] = silver;
  2336. array[2] = bronze;
  2337. return array;
  2338. }
  2339. //--------------------------------------------------
  2340. //Plot-Utils
  2341. //--------------------------------------------------
  2342. function plot.getFromId(plot_id, world) {
  2343. iter = plot.iterator(world);
  2344. while(hasNext(iter)) {
  2345. plot = next(iter);
  2346. if(plot.getId(plot) == plot_id) {
  2347. return plot;
  2348. }
  2349. }
  2350. return null;
  2351. }
  2352. function plot.calcCost(world, arg1, arg2) {
  2353. //function plot.calcCost(world, length, width) {
  2354. //function plot.calcCost(world, loc1, loc2) {
  2355. if(isDouble(arg1)) {
  2356. length = arg1;
  2357. width = arg2;
  2358. } else {
  2359. x1 = loc.getX(arg1);
  2360. z1 = loc.getZ(arg1);
  2361. x2 = loc.getX(arg2);
  2362. z2 = loc.getZ(arg2);
  2363. length = math.abs(x1 - x2) + 1;
  2364. width = math.abs(z1 - z2) + 1;
  2365. }
  2366. if(world.getName(world) == "creative") {
  2367. factor = 1;
  2368. } else {
  2369. factor = 3;
  2370. }
  2371. return length * width * factor;
  2372. }
  2373. function plot.getIdFromLocation(location) {
  2374. list = plot.get(location);
  2375. if(list.getSize(list) == 0) {
  2376. plot_id = null;
  2377. } else {
  2378. plot = list.getIndex(list, 0);
  2379. plot_id = plot.getId(plot);
  2380. }
  2381. return plot_id;
  2382. }
  2383. function plot.getIdListFromLocation(location) {
  2384. list = plot.get(location);
  2385. for(i = 0; i < list.getSize(list); i++) {
  2386. plot = list.getIndex(list, i);
  2387. list.setIndex(list, i, plot.getId(plot));
  2388. }
  2389. return list;
  2390. }
  2391. function plot.addPlayer(plot, player_name) {
  2392. list = plot.getOwners(plot);
  2393. uuid = player.getUuid(player_name);
  2394. if(!list.contains(list, uuid)) {
  2395. list.add(list, uuid);
  2396. }
  2397. }
  2398. function plot.removePlayer(plot, player_name) {
  2399. list = plot.getOwners(plot);
  2400. uuid = player.getUuid(player_name);
  2401. list.remove(list, uuid);
  2402. player_id = player.getId(player.getUuid(player_name));
  2403. plot.removeRank(plot, player_id);
  2404. }
  2405. function plot.getOwnersString(plot) {
  2406. list = plot.getOwners(plot);
  2407. if(list.getSize(list) == 0) {
  2408. return "";
  2409. }
  2410. owners_list = list.new();
  2411. for(i = 0; i < list.getSize(list); i++) {
  2412. list.add(owners_list, player.getName(list.getIndex(list, i)));
  2413. }
  2414. return text.concatList(owners_list, " / ", 0, list.getSize(owners_list) - 1);
  2415. }
  2416. function plot.isLeader(plot, player_or_id) {
  2417. return plot.getRank(plot, player_or_id) == "leader";
  2418. }
  2419. function plot.getLeaderName(plot) {
  2420. plot_leader_id = plot.getLeaderId(plot);
  2421. if(plot_leader_id == null) {
  2422. return "";
  2423. }
  2424. return player.getNameFromId(plot_leader_id);
  2425. }
  2426. function plot.getLeaderId(plot) {
  2427. plot_id = plot.getId(plot);
  2428. stmt = databank.prepare("SELECT player_id FROM plotranks WHERE plot_id = ? AND rank = ?;");
  2429. databank.setInt(stmt, 1, plot_id);
  2430. databank.setString(stmt, 2, "leader");
  2431. result = databank.execute(stmt);
  2432. while(databank.next(result)) {
  2433. player_id = databank.getInt(result, 1);
  2434. }
  2435. databank.close(result);
  2436. databank.close(stmt);
  2437. return player_id;
  2438. }
  2439. function plot.setLeader(plot, player_or_id) {
  2440. plot.setRank(plot, player_or_id, "leader");
  2441. }
  2442. function plot.isMod(plot, player_or_id) {
  2443. return plot.getRank(plot, player_or_id) == "mod";
  2444. }
  2445. function plot.getMods(plot) {
  2446. list = list.new();
  2447. plot_id = plot.getId(plot);
  2448. stmt = databank.prepare("SELECT player_id FROM plotranks WHERE plot_id = ? AND rank = ?;");
  2449. databank.setInt(stmt, 1, plot_id);
  2450. databank.setString(stmt, 2, "mod");
  2451. result = databank.execute(stmt);
  2452. while(databank.next(result)) {
  2453. list.add(list, databank.getInt(result, 1));
  2454. }
  2455. databank.close(result);
  2456. databank.close(stmt);
  2457. return list;
  2458. }
  2459. function plot.setMod(plot, player_or_id) {
  2460. plot.setRank(plot, player_or_id, "mod");
  2461. }
  2462. function plot.canOpenChests(plot, player_or_id) {
  2463. return plot.getRank(plot, player_or_id) == "chest";
  2464. }
  2465. function plot.setChest(plot, player_or_id) {
  2466. plot.setRank(plot, player_or_id, "chest");
  2467. }
  2468. function plot.getChestRanks(plot) {
  2469. list = list.new();
  2470. plot_id = plot.getId(plot);
  2471. stmt = databank.prepare("SELECT player_id FROM plotranks WHERE plot_id = ? AND rank = ?;");
  2472. databank.setInt(stmt, 1, plot_id);
  2473. databank.setString(stmt, 2, "chest");
  2474. result = databank.execute(stmt);
  2475. while(databank.next(result)) {
  2476. list.add(list, databank.getInt(result, 1));
  2477. }
  2478. databank.close(result);
  2479. databank.close(stmt);
  2480. return list;
  2481. }
  2482. function plot.getRank(plot, player_or_id) {
  2483. if(isPlayer(player_or_id)) {
  2484. player_id = player.getId(player_or_id);
  2485. } else {
  2486. player_id = player_or_id;
  2487. }
  2488. plot_id = plot.getId(plot);
  2489. stmt = databank.prepare("SELECT rank FROM plotranks WHERE player_id = ? AND plot_id = ?;");
  2490. databank.setInt(stmt, 1, player_id);
  2491. databank.setInt(stmt, 2, plot_id);
  2492. result = databank.execute(stmt);
  2493. while(databank.next(result)) {
  2494. rank = databank.getString(result, 1);
  2495. }
  2496. databank.close(result);
  2497. databank.close(stmt);
  2498. return rank;
  2499. }
  2500. function plot.setRank(plot, player_or_id, rank) {
  2501. if(isPlayer(player_or_id)) {
  2502. player_id = player.getId(player_or_id);
  2503. } else {
  2504. player_id = player_or_id;
  2505. }
  2506. plot_id = plot.getId(plot);
  2507. stmt = databank.prepare("INSERT INTO plotranks (plot_id, player_id, rank) VALUES (?,?,?) ON DUPLICATE KEY UPDATE rank = ?");
  2508. databank.setInt(stmt, 1, plot_id);
  2509. databank.setInt(stmt, 2, player_id);
  2510. databank.setString(stmt, 3, rank);
  2511. databank.setString(stmt, 4, rank);
  2512. databank.workerExecute(stmt);
  2513. }
  2514. function plot.removeRank(plot, player_or_id) {
  2515. if(isPlayer(player_or_id)) {
  2516. player_id = player.getId(player_or_id);
  2517. } else {
  2518. player_id = player_or_id;
  2519. }
  2520. plot_id = plot.getId(plot);
  2521. stmt = databank.prepare("DELETE FROM plotranks WHERE player_id = ? AND plot_id = ?;");
  2522. databank.setInt(stmt, 1, player_id);
  2523. databank.setInt(stmt, 2, plot_id);
  2524. databank.workerExecute(stmt);
  2525. }
  2526. function plot.transferRanks(old_plot_id, new_plot_id) {
  2527. stmt = databank.prepare("UPDATE plotranks SET plot_id = ? WHERE plot_id = ?;");
  2528. databank.setInt(stmt, 1, new_plot_id);
  2529. databank.setInt(stmt, 2, old_plot_id);
  2530. databank.workerExecute(stmt);
  2531. }
  2532. function plot.removeAllPlayers(plot) {
  2533. list = plot.getOwners(plot);
  2534. iter = list.iterator(list);
  2535. while(hasNext(iter)) {
  2536. plot.removeRank(plot, player.getId(next(iter)));
  2537. }
  2538. }
  2539. function plot.setEdges(plot, location1, location2) {
  2540. //Alte Daten abrufen
  2541. plot_name = plot.getName(plot);
  2542. plot_id = plot.getId(plot);
  2543. list = plot.getOwners(plot);
  2544. flags = plot.getFlags(plot);
  2545. //Neues Plot erstellen und altes Plot löschen
  2546. plot.remove(plot, loc.getWorld(location1));
  2547. new_plot = plot.add(location1, location2, plot_id);
  2548. //Alte Daten auf neuem Plot setzen
  2549. plot.transferRanks(plot.getId(plot), plot.getId(new_plot));
  2550. plot.setName(new_plot, plot_name);
  2551. new_list = plot.getOwners(new_plot);
  2552. for(i = 0; i < list.getSize(list); i++) {
  2553. list.add(new_list, list.getIndex(list, i));
  2554. }
  2555. plot.setFlags(new_plot, flags, true);
  2556. return new_plot;
  2557. }
  2558. function getFlags(plot, getActive) { //getActive = true means getActiveFlags
  2559. flags = plot.getFlags(plot);
  2560. flags_true = list.new();
  2561. flags_false = list.new();
  2562. array = array.new(2);
  2563. array[0] = 512;
  2564. array[1] = "SUB_PLOT_FLAG";
  2565. if(flags >= 512) {
  2566. list.add(flags_true, array);
  2567. flags -= 512;
  2568. } else {
  2569. list.add(flags_false, array);
  2570. }
  2571. array = array.new(2);
  2572. array[0] = 256;
  2573. array[1] = "FREE_FLAG";
  2574. if(flags >= 256) {
  2575. list.add(flags_true, array);
  2576. flags -= 256;
  2577. } else {
  2578. list.add(flags_false, array);
  2579. }
  2580. array = array.new(2);
  2581. array[0] = 128;
  2582. array[1] = "CITY_FLAG";
  2583. if(flags >= 128) {
  2584. list.add(flags_true, array);
  2585. flags -= 128;
  2586. } else {
  2587. list.add(flags_false, array);
  2588. }
  2589. array = array.new(2);
  2590. array[0] = 64;
  2591. array[1] = "EXPLOSION_FLAG";
  2592. if(flags >= 64) {
  2593. list.add(flags_true, array);
  2594. flags -= 64;
  2595. } else {
  2596. list.add(flags_false, array);
  2597. }
  2598. array = array.new(2);
  2599. array[0] = 32;
  2600. array[1] = "ENTITY_INTERACT_FLAG";
  2601. if(flags >= 32) {
  2602. list.add(flags_true, array);
  2603. flags -= 32;
  2604. } else {
  2605. list.add(flags_false, array);
  2606. }
  2607. array = array.new(2);
  2608. array[0] = 16;
  2609. array[1] = "BLOCK_INTERACT_FLAG";
  2610. if(flags >= 16) {
  2611. list.add(flags_true, array);
  2612. flags -= 16;
  2613. } else {
  2614. list.add(flags_false, array);
  2615. }
  2616. array = array.new(2);
  2617. array[0] = 8;
  2618. array[1] = "HIT_AMBIENT_FLAG";
  2619. if(flags >= 8) {
  2620. list.add(flags_true, array);
  2621. flags -= 8;
  2622. } else {
  2623. list.add(flags_false, array);
  2624. }
  2625. array = array.new(2);
  2626. array[0] = 4;
  2627. array[1] = "BUCKET_FLAG";
  2628. if(flags >= 4) {
  2629. list.add(flags_true, array);
  2630. flags -= 4;
  2631. } else {
  2632. list.add(flags_false, array);
  2633. }
  2634. array = array.new(2);
  2635. array[0] = 2;
  2636. array[1] = "BREAK_FLAG";
  2637. if(flags >= 2) {
  2638. list.add(flags_true, array);
  2639. flags -= 2;
  2640. } else {
  2641. list.add(flags_false, array);
  2642. }
  2643. array = array.new(2);
  2644. array[0] = 1;
  2645. array[1] = "PLACE_FLAG";
  2646. if(flags >= 1) {
  2647. list.add(flags_true, array);
  2648. } else {
  2649. list.add(flags_false, array);
  2650. }
  2651. if(getActive) {
  2652. return flags_true;
  2653. } else {
  2654. return flags_false;
  2655. }
  2656. }
  2657. function plot.getType(plot) {
  2658. if(plot.isCity(plot)) {
  2659. type = "§4[§cCity§4]";
  2660. } elseif(plot.isFree(plot)) {
  2661. type = "§3[§bFree§3]";
  2662. } elseif(plot.isSub(plot)) {
  2663. type = "§6[§eSubPlot§6]";
  2664. } else {
  2665. type = "§6[§ePlot§6]";
  2666. }
  2667. return type;
  2668. }
  2669. function plot.isPlot(plot) {
  2670. return !plot.isCity(plot) && !plot.isFree(plot) && !plot.isSub(plot);
  2671. }
  2672. function plot.isExplosive(plot) {
  2673. return plot.hasFlags(plot, 64);
  2674. }
  2675. function plot.isCity(plot) {
  2676. return plot.hasFlags(plot, 128);
  2677. }
  2678. function plot.isFree(plot) {
  2679. return plot.hasFlags(plot, 256);
  2680. }
  2681. function plot.isSub(plot) {
  2682. return plot.hasFlags(plot, 512);
  2683. }
  2684. function plot.setCity(plot, boolean) {
  2685. plot.setFlags(plot, 128, boolean);
  2686. }
  2687. function plot.setFree(plot, boolean) {
  2688. plot.setFlags(plot, 256, boolean);
  2689. plot.setFlags(plot, 512, !boolean); //Sub-Plot entfernen
  2690. }
  2691. function plot.setSub(plot, boolean) {
  2692. plot.setFlags(plot, 512, boolean);
  2693. plot.setFlags(plot, 256, !boolean); //Free-Plot entfernen
  2694. }
  2695. //--------------------------------------------------
  2696. //Skill-Utils
  2697. //--------------------------------------------------
  2698. function skill.getAmount(player_or_id, tech_name) {
  2699. config = playerdata.getSurvival(player_or_id);
  2700. return config.getDouble(config, tech_name, 0);
  2701. }
  2702. function skill.setAmount(player_or_id, tech_name, amount) {
  2703. config = playerdata.getSurvival(player_or_id);
  2704. config.set(config, tech_name, amount);
  2705. config.saveAsync(config);
  2706. }
  2707. function skill.addAmount(player_or_id, tech_name, amount) {
  2708. config = playerdata.getSurvival(player_or_id);
  2709. config.set(config, tech_name, config.getDouble(config, tech_name, 0) + amount);
  2710. config.saveAsync(config);
  2711. }
  2712. function skill.isActivated(player_or_id, tech_name) {
  2713. config = playerdata.getSurvival(player_or_id);
  2714. return config.getBool(config, concat(tech_name, ".active"), true);
  2715. }
  2716. function skill.setActivated(player_or_id, tech_name, bool) {
  2717. config = playerdata.getSurvival(player_or_id);
  2718. config.set(config, concat(tech_name, ".active"), bool);
  2719. }
  2720. function skill.add(skill_name, tech_name, item, description, cost, permanent, active, toggleable) {
  2721. skill = array.new(8);
  2722. skill[0] = skill_name;
  2723. skill[1] = tech_name;
  2724. skill[2] = item;
  2725. skill[3] = description;
  2726. skill[4] = cost;
  2727. skill[5] = permanent;
  2728. skill[6] = active;
  2729. skill[7] = toggleable;
  2730. list.add(getScriptVar("skills"), skill);
  2731. }
  2732. function skill.get(tech_name) {
  2733. skill_list = getScriptVar("skills");
  2734. for(i = 0; i < list.getSize(skill_list); i++) {
  2735. array = list.getIndex(skill_list, i);
  2736. temp_tech_name = array[1];
  2737. if(temp_tech_name == tech_name) {
  2738. return array;
  2739. }
  2740. }
  2741. }
  2742. function skill.getShopItem(player_or_id, tech_name) {
  2743. if(tech_name == null) {
  2744. return item.getAir();
  2745. }
  2746. skill = skill.get(tech_name);
  2747. amount = skill.getAmount(player_or_id, tech_name);
  2748. permanent = skill[5];
  2749. if(permanent) {
  2750. if(amount == 0) {
  2751. text_property = concat("§fBought: §cNo §f(Permanent)");
  2752. } else {
  2753. text_property = concat("§fBought: §aYes §f(Permanent)");
  2754. }
  2755. } else {
  2756. text_property = concat("§fAmount you have: §e", text.number(amount));
  2757. }
  2758. active = skill[6];
  2759. if(active) {
  2760. type = "§fActive skill";
  2761. } else {
  2762. type = "§fPassive skill";
  2763. }
  2764. toggleable = skill[7];
  2765. if(toggleable) {
  2766. if(skill.isActivated(player_or_id, tech_name)) {
  2767. tog = "§fToggleable: §aActive";
  2768. } else {
  2769. tog = "§fToggleable: §cInactive";
  2770. }
  2771. } else {
  2772. tog = "§fNot toggleable";
  2773. }
  2774. skill_name = skill.getName(tech_name);
  2775. item = read.item(skill[2], 1, concat("§e§o", skill_name), concat("§fCost: §e", text.number(skill[4])), skill[3], type, tog, text_property);
  2776. return item;
  2777. }
  2778. function skill.getName(tech_name) {
  2779. skill_list = getScriptVar("skills");
  2780. for(i = 0; i < list.getSize(skill_list); i++) {
  2781. array = list.getIndex(skill_list, i);
  2782. temp_tech_name = array[1];
  2783. if(temp_tech_name == tech_name) {
  2784. return array[0];
  2785. }
  2786. }
  2787. }
  2788. function skill.getTechName(skill_name) {
  2789. skill_list = getScriptVar("skills");
  2790. for(i = 0; i < list.getSize(skill_list); i++) {
  2791. array = list.getIndex(skill_list, i);
  2792. temp_skill_name = array[0];
  2793. if(temp_skill_name == skill_name) {
  2794. return array[1];
  2795. }
  2796. }
  2797. }
  2798. function skill.getItem(skill_name) {
  2799. skill_list = getScriptVar("skills");
  2800. for(i = 0; i < list.getSize(skill_list); i++) {
  2801. array = list.getIndex(skill_list, i);
  2802. temp_skill_name = array[0];
  2803. if(temp_skill_name == skill_name) {
  2804. return array[2];
  2805. }
  2806. }
  2807. }
  2808. function skill.getDescription(skill_name) {
  2809. skill_list = getScriptVar("skills");
  2810. for(i = 0; i < list.getSize(skill_list); i++) {
  2811. array = list.getIndex(skill_list, i);
  2812. temp_skill_name = array[0];
  2813. if(temp_skill_name == skill_name) {
  2814. return array[3];
  2815. }
  2816. }
  2817. }
  2818. function skill.getCost(skill_name) {
  2819. skill_list = getScriptVar("skills");
  2820. for(i = 0; i < list.getSize(skill_list); i++) {
  2821. array = list.getIndex(skill_list, i);
  2822. temp_skill_name = array[0];
  2823. if(temp_skill_name == skill_name) {
  2824. return array[4];
  2825. }
  2826. }
  2827. }
  2828. function skill.isPermanent(skill_name) {
  2829. skill_list = getScriptVar("skills");
  2830. for(i = 0; i < list.getSize(skill_list); i++) {
  2831. array = list.getIndex(skill_list, i);
  2832. temp_skill_name = array[0];
  2833. if(temp_skill_name == skill_name) {
  2834. return array[5];
  2835. }
  2836. }
  2837. }
  2838. function skill.isActive(skill_name) {
  2839. skill_list = getScriptVar("skills");
  2840. for(i = 0; i < list.getSize(skill_list); i++) {
  2841. array = list.getIndex(skill_list, i);
  2842. temp_skill_name = array[0];
  2843. if(temp_skill_name == skill_name) {
  2844. return array[6];
  2845. }
  2846. }
  2847. }
  2848. function skill.isToggleable(skill_name) {
  2849. skill_list = getScriptVar("skills");
  2850. for(i = 0; i < list.getSize(skill_list); i++) {
  2851. array = list.getIndex(skill_list, i);
  2852. temp_skill_name = array[0];
  2853. if(temp_skill_name == skill_name) {
  2854. return array[7];
  2855. }
  2856. }
  2857. }
  2858. function skill.showShop(player, tech_name1, tech_name2, tech_name3, tech_name4, tech_name5, tech_name6, tech_name7, tech_name8, tech_name9, tech_name10, tech_name11, tech_name12, tech_name13, tech_name14, tech_name15, tech_name16, tech_name17, tech_name18) {
  2859. inv = inv.new("333333333333333333");
  2860. inv.setItem(inv, 0, skill.getShopItem(player, tech_name1));
  2861. inv.setItem(inv, 1, skill.getShopItem(player, tech_name2));
  2862. inv.setItem(inv, 2, skill.getShopItem(player, tech_name3));
  2863. inv.setItem(inv, 3, skill.getShopItem(player, tech_name4));
  2864. inv.setItem(inv, 4, skill.getShopItem(player, tech_name5));
  2865. inv.setItem(inv, 5, skill.getShopItem(player, tech_name6));
  2866. inv.setItem(inv, 6, skill.getShopItem(player, tech_name7));
  2867. inv.setItem(inv, 7, skill.getShopItem(player, tech_name8));
  2868. inv.setItem(inv, 8, skill.getShopItem(player, tech_name9));
  2869. inv.setItem(inv, 9, skill.getShopItem(player, tech_name10));
  2870. inv.setItem(inv, 10, skill.getShopItem(player, tech_name11));
  2871. inv.setItem(inv, 11, skill.getShopItem(player, tech_name12));
  2872. inv.setItem(inv, 12, skill.getShopItem(player, tech_name13));
  2873. inv.setItem(inv, 13, skill.getShopItem(player, tech_name14));
  2874. inv.setItem(inv, 14, skill.getShopItem(player, tech_name15));
  2875. inv.setItem(inv, 15, skill.getShopItem(player, tech_name16));
  2876. inv.setItem(inv, 16, skill.getShopItem(player, tech_name17));
  2877. inv.setItem(inv, 17, skill.getShopItem(player, tech_name18));
  2878. inv.open(inv, player, "Skillshop");
  2879. }
  2880. function skill.showAll(from_player_or_id, to_player) {
  2881. inv = inv.new("333333333333333333333333333");
  2882. skill_list = getScriptVar("skills");
  2883. for(i = 0; i < list.getSize(skill_list); i++) {
  2884. a = list.getIndex(skill_list, i);
  2885. tech_name = a[1];
  2886. inv.setItem(inv, i, skill.getShopItem(from_player_or_id, tech_name));
  2887. }
  2888. from_player_id = player.getValidId(from_player_or_id);
  2889. if(from_player_id == player.getValidId(to_player)) {
  2890. inv_name = "Skills";
  2891. } else {
  2892. inv_name = concat("Skills von ", player.getNameFromId(from_player_id));
  2893. }
  2894. inv.open(inv, to_player, inv_name);
  2895. }
  2896. //--------------------------------------------------
  2897. //Loc-Utils
  2898. //--------------------------------------------------
  2899. function loc.getStringColon(loc) {
  2900. world_name = world.getName(loc.getWorld(loc));
  2901. x = text.number(loc.getX(loc));
  2902. y = text.number(loc.getY(loc));
  2903. z = text.number(loc.getZ(loc));
  2904. return concat(world_name, ":", x, ":", y, ":", z);
  2905. }
  2906. function loc.getStringSpace(loc) {
  2907. world_name = world.getName(loc.getWorld(loc));
  2908. x = text.number(loc.getX(loc));
  2909. y = text.number(loc.getY(loc));
  2910. z = text.number(loc.getZ(loc));
  2911. return concat(world_name, " ", x, " ", y, " ", z);
  2912. }
  2913. function loc.isSameWorld(loc1, loc2) {
  2914. return world.getName(loc.getWorld(loc1)) == world.getName(loc.getWorld(loc2));
  2915. }
  2916. function loc.getSubPlot(location) {
  2917. list = plot.get(location);
  2918. iter = list.iterator(list);
  2919. while(hasNext(iter)) {
  2920. plot = next(iter);
  2921. if(plot.isSub(plot)) {
  2922. return plot;
  2923. }
  2924. }
  2925. return null;
  2926. }
  2927. function loc.isCity(location) {
  2928. list = plot.get(location);
  2929. iter = list.iterator(list);
  2930. while(hasNext(iter)) {
  2931. plot = next(iter);
  2932. if(plot.isCity(plot)) {
  2933. return true;
  2934. }
  2935. }
  2936. return false;
  2937. }
  2938. function loc.hasPlotId(location, plot_id) {
  2939. return list.contains(plot.getIdListFromLocation(location), plot_id);
  2940. }
  2941. function loc.hasPlotName(location, plot_name) {
  2942. list = plot.get(location);
  2943. iter = list.iterator(list);
  2944. while(hasNext(iter)) {
  2945. plot = next(iter);
  2946. if(plot.getName(plot) == plot_name) {
  2947. return true;
  2948. }
  2949. }
  2950. return false;
  2951. }
  2952. function loc.isAir(location) {
  2953. type = block.getType(location);
  2954. return type == "minecraft:air" || type == "minecraft:cave_air";
  2955. }
  2956. function loc.isInSurvWorld(location) {
  2957. world_name = world.getName(loc.getWorld(location));
  2958. if(world_name == "overworld") {
  2959. return true;
  2960. } elseif(world_name == "the_end") {
  2961. return true;
  2962. } elseif(world_name == "the_nether") {
  2963. return true;
  2964. }
  2965. return false;
  2966. }
  2967. function loc.isInGamesWorld(location) {
  2968. return loc.getWorld(location) == world.getGames();
  2969. }
  2970. function loc.isInCreativeWorld(location) {
  2971. return loc.getWorld(location) == world.getCreative();
  2972. }
  2973. function loc.isInStoryWorld(location) {
  2974. return loc.getWorld(location) == world.getStory();
  2975. }
  2976. function loc.round(location) {
  2977. world = loc.getWorld(location);
  2978. x = math.round(loc.getX(location));
  2979. y = math.round(loc.getY(location));
  2980. z = math.round(loc.getZ(location));
  2981. return loc.new(world, x, y, z);
  2982. }
  2983. //--------------------------------------------------
  2984. //Survival-Utils
  2985. //--------------------------------------------------
  2986. function living.setAi(bool) {
  2987. config = getScriptVar("server_config");
  2988. config.set(config, "spawnWithAi", bool);
  2989. config.saveAsync(config);
  2990. }
  2991. function living.getAi() {
  2992. config = getScriptVar("server_config");
  2993. return config.getBool(config, "spawnWithAi", true);
  2994. }
  2995. function living.getHand(living) {
  2996. return living.getEquip(living, "hand");
  2997. }
  2998. //--------------------------------------------------
  2999. //Afk-Utils
  3000. //--------------------------------------------------
  3001. function player.isAfk(player) {
  3002. player_uuid = player.getUuid(player);
  3003. afk_map = getScriptVar("afk_map");
  3004. return map.contains(afk_map, player_uuid);
  3005. }
  3006. function player.setAfk(player, boolean) {
  3007. player_uuid = player.getUuid(player);
  3008. afk_map = getScriptVar("afk_map");
  3009. if(boolean) {
  3010. map.add(afk_map, player_uuid, loc.getYaw(entity.getLocation(player)));
  3011. } else {
  3012. map.remove(afk_map, player_uuid);
  3013. }
  3014. }
  3015. //--------------------------------------------------
  3016. //PvP-Utils
  3017. //--------------------------------------------------
  3018. function hasPvpOn(player_or_id) {
  3019. config = playerdata.getSurvival(player_or_id);
  3020. return config.getBool(config, "pvp", false);
  3021. }
  3022. function setPvp(player_or_id, bool) {
  3023. config = playerdata.getSurvival(player_or_id);
  3024. config.set(config, "pvp", bool);
  3025. config.saveAsync(config);
  3026. }
  3027. //--------------------------------------------------
  3028. //Rank-Utils
  3029. //--------------------------------------------------
  3030. function getRank(player_or_id) {
  3031. config = playerdata.getSurvival(player_or_id);
  3032. return config.getString(config, "rank", "§3User");
  3033. }
  3034. function setRank(player_or_id, rank) {
  3035. rank = text.replace(rank, "&", "§");
  3036. config = playerdata.getSurvival(player_or_id);
  3037. config.set(config, "rank", rank);
  3038. config.saveAsync(config);
  3039. }
  3040. function offerRank(player, tech_name) {
  3041. rank = rank.getFromTechName(tech_name);
  3042. msg(player, "§r[§6Commands§r] New rank available: ", text.hover(text.click(concat("[§", rank, "§r]"), concat("/setrank ", player.getName(player), " &", rank)), "Click to set"));
  3043. }
  3044. function rank.offerClan(clan_id, tech_name) {
  3045. leader_uuid = clan.getLeader(clan_id);
  3046. leader = player.get(leader_uuid);
  3047. if(leader == null) {
  3048. mail.send("marvinius", player.getName(leader_uuid), concat("New rank available: ", tech_name));
  3049. } else {
  3050. offerRank(leader, tech_name);
  3051. }
  3052. }
  3053. function rank.checkCriteria(player, tech_name) {
  3054. //Playtime
  3055. if(tech_name == "rank.newcomer") {
  3056. return player.getTotalPlaytime(player) >= 1200; //20 Stunden
  3057. }
  3058. if(tech_name == "rank.frequenter") {
  3059. return player.getTotalPlaytime(player) >= 6000; //100 Stunden
  3060. }
  3061. if(tech_name == "rank.legend") {
  3062. return player.getTotalPlaytime(player) >= 42000; //700 Stunden
  3063. }
  3064. //Adventure
  3065. if(tech_name == "rank.adventurer") {
  3066. return player.getAdventureAmounts(player) >= 1;
  3067. }
  3068. if(tech_name == "rank.explorer") {
  3069. return player.getAdventureAmounts(player) >= 5;
  3070. }
  3071. if(tech_name == "rank.pioneer") {
  3072. return player.getAdventureAmounts(player) >= 10;
  3073. }
  3074. //Clans
  3075. if(tech_name == "rank.commander") {
  3076. if(player.isClanLeader(player)) {
  3077. clan_id = player.getClanId(player);
  3078. return clan.getMembersAmount(clan_id) >= 5;
  3079. }
  3080. }
  3081. if(tech_name == "rank.chief") {
  3082. if(player.isClanLeader(player)) {
  3083. clan_id = player.getClanId(player);
  3084. return clan.getMembersAmount(clan_id) >= 10;
  3085. }
  3086. }
  3087. if(tech_name == "rank.lord") {
  3088. if(player.isClanLeader(player)) {
  3089. clan_id = player.getClanId(player);
  3090. return clan.getMembersAmount(clan_id) >= 15;
  3091. }
  3092. }
  3093. //Quests
  3094. if(tech_name == "rank.volunteer") {
  3095. return quest.getCounter(player) >= 15;
  3096. }
  3097. if(tech_name == "rank.friend") {
  3098. return quest.getCounter(player) >= 50;
  3099. }
  3100. if(tech_name == "rank.altruist") {
  3101. return quest.getCounter(player) >= 500;
  3102. }
  3103. //Plots
  3104. if(tech_name == "rank.settler") {
  3105. return player.usedHisFreePlot(player);
  3106. }
  3107. if(tech_name == "rank.colonizer") {
  3108. return player.hasBigPlotCreated(player);
  3109. }
  3110. if(tech_name == "rank.major") {
  3111. return player.hasPlotRaised(player);
  3112. }
  3113. //Team
  3114. if(tech_name == "rank.owner") {
  3115. return perm.has(player, "isOwner");
  3116. }
  3117. if(tech_name == "rank.admin") {
  3118. return perm.has(player, "isAdmin");
  3119. }
  3120. if(tech_name == "rank.builder") {
  3121. return perm.has(player, "isBuilder");
  3122. }
  3123. if(tech_name == "rank.dev") {
  3124. return perm.has(player, "isDev");
  3125. }
  3126. if(tech_name == "rank.moderator") {
  3127. return perm.has(player, "isMod");
  3128. }
  3129. if(tech_name == "rank.supporter") {
  3130. return perm.has(player, "isSupporter");
  3131. }
  3132. //Other
  3133. if(tech_name == "rank.vip") {
  3134. return perm.has(player, "isVIP");
  3135. }
  3136. if(tech_name == "rank.influencer") {
  3137. return perm.has(player, "isYT") || perm.has(player, "isStreamer");
  3138. }
  3139. if(tech_name == "rank.sponsor") {
  3140. return perm.has(player, "isSponsor");
  3141. }
  3142. if(tech_name == "rank.user") {
  3143. return true;
  3144. }
  3145. return perm.has(player, "setrank.other");
  3146. }
  3147. function rank.getRankArray() {
  3148. return getScriptVar("ranks");
  3149. }
  3150. function rank.getFromTechName(tech_name) {
  3151. a = rank.getRankArray();
  3152. a_size = array.getSize(a);
  3153. for(i = 0; i < a_size; i++) {
  3154. if(a[i, 0] == tech_name) {
  3155. return a[i, 1];
  3156. }
  3157. }
  3158. return null;
  3159. }
  3160. function rank.getTechName(rank) {
  3161. a = rank.getRankArray();
  3162. a_size = array.getSize(a);
  3163. for(i = 0; i < a_size; i++) {
  3164. if(a[i, 1] == rank) {
  3165. return a[i, 0];
  3166. }
  3167. }
  3168. return null;
  3169. }
  3170. function rank.choose(player, tech_name) {
  3171. rank = rank.getFromTechName(tech_name);
  3172. msg(player, text.click(concat(" [§", rank, "§r]"), concat("/setrank ", player.getName(player), " &", rank)));
  3173. }
  3174. function rank.showAll(player) {
  3175. a = rank.getRankArray();
  3176. a_size = array.getSize(a);
  3177. for(i = 0; i < a_size; i++) {
  3178. tech_name = a[i, 0];
  3179. if(rank.checkCriteria(player, tech_name)) {
  3180. rank.choose(player, tech_name);
  3181. }
  3182. }
  3183. }
  3184. //--------------------------------------------------
  3185. //Perm-Utils
  3186. //--------------------------------------------------
  3187. function givePerm(player_id, perm_id) {
  3188. stmt = databank.prepare("INSERT INTO playerperms (player_id, perm_id) VALUES (?,?);");
  3189. databank.setInt(stmt, 1, player_id);
  3190. databank.setInt(stmt, 2, perm_id);
  3191. databank.workerExecute(stmt);
  3192. perm.registerPlayer(player.getUuidFromID(player_id), perm_id);
  3193. }
  3194. function removePerm(player_id, perm_id) {
  3195. stmt = databank.prepare("DELETE FROM playerperms WHERE player_id = ? AND perm_id = ?;");
  3196. databank.setInt(stmt, 1, player_id);
  3197. databank.setInt(stmt, 2, perm_id);
  3198. databank.workerExecute(stmt);
  3199. perm.unregisterPlayer(player.getUuidFromID(player_id), perm_id);
  3200. }
  3201. function removeAllPermsTemporarly(player_id) {
  3202. perm.registerPlayer(player.getUuidFromID(player_id), 8);
  3203. permslist = getPermsFromPlayer(player_id);
  3204. for(i = 0; i < list.getSize(permslist); i++) {
  3205. perm_id = list.getIndex(permslist, i);
  3206. perm.unregisterPlayer(player.getUuidFromID(player_id), perm_id);
  3207. }
  3208. }
  3209. function reloadAllPerms(player_id) {
  3210. perm.unregisterPlayer(player.getUuidFromID(player_id), 8);
  3211. permslist = getPermsFromPlayer(player_id);
  3212. for(i = 0; i < list.getSize(permslist); i++) {
  3213. perm_id = list.getIndex(permslist, i);
  3214. perm.registerPlayer(player.getUuidFromID(player_id), perm_id);
  3215. }
  3216. }
  3217. function removeAllPerms(player_id) {
  3218. permslist = getPermsFromPlayer(player_id);
  3219. for(i = 0; i < list.getSize(permslist); i++) {
  3220. removePerm(player_id, list.getIndex(permslist, i));
  3221. }
  3222. }
  3223. function getPermsFromPlayer(player_id) {
  3224. permslist = list.new();
  3225. stmt = databank.prepare("SELECT perm_id FROM playerperms WHERE player_id = ?;");
  3226. databank.setInt(stmt, 1, player_id);
  3227. result = databank.execute(stmt);
  3228. while(databank.next(result)) {
  3229. list.add(permslist, databank.getInt(result, 1));
  3230. }
  3231. databank.close(result);
  3232. databank.close(stmt);
  3233. return permslist;
  3234. }
  3235. function registerAllPerms() {
  3236. stmt = databank.prepare("SELECT * FROM playerperms;");
  3237. result = databank.execute(stmt);
  3238. while(databank.next(result)) {
  3239. player_id = databank.getInt(result, 1);
  3240. perm_id = databank.getInt(result, 2);
  3241. perm.registerPlayer(player.getUuidFromID(player_id), perm_id);
  3242. }
  3243. databank.close(result);
  3244. databank.close(stmt);
  3245. }
  3246. function perm.setGroups(permgroups) {
  3247. setScriptVar("permgroups", permgroups);
  3248. }
  3249. function perm.getGroups() {
  3250. return getScriptVar("permgroups");
  3251. }
  3252. function perm.getNameFromId(permgroup_id) {
  3253. a = perm.getGroups();
  3254. for(i = 0; i < array.getSize(a); i++) {
  3255. if(a[i, 0] == permgroup_id) {
  3256. return a[i, 1];
  3257. }
  3258. }
  3259. return null;
  3260. }
  3261. function perm.getRankFromId(permgroup_id) {
  3262. a = perm.getGroups();
  3263. for(i = 0; i < array.getSize(a); i++) {
  3264. if(a[i, 0] == permgroup_id) {
  3265. return a[i, 2];
  3266. }
  3267. }
  3268. return null;
  3269. }
  3270. function perm.getIdFromGroupname(permgroup_name) {
  3271. a = perm.getGroups();
  3272. for(i = 0; i < array.getSize(a); i++) {
  3273. if(a[i, 1] == permgroup_name) {
  3274. return a[i, 0];
  3275. }
  3276. }
  3277. return null;
  3278. }
  3279. function perm.getRankFromGroupname(permgroup_name) {
  3280. a = perm.getGroups();
  3281. for(i = 0; i < array.getSize(a); i++) {
  3282. if(a[i, 1] == permgroup_name) {
  3283. return a[i, 2];
  3284. }
  3285. }
  3286. return null;
  3287. }
  3288. function perm.isGroupName(permgroup_name) {
  3289. a = perm.getGroups();
  3290. for(i = 0; i < array.getSize(a); i++) {
  3291. if(a[i, 1] == permgroup_name) {
  3292. return true;
  3293. }
  3294. }
  3295. return false;
  3296. }
  3297. function player.hasPermGroup(player_id, perm_id) {
  3298. permslist = getPermsFromPlayer(player_id);
  3299. return list.contains(permslist, perm_id);
  3300. }
  3301. //--------------------------------------------------
  3302. //Nickname-Utils
  3303. //--------------------------------------------------
  3304. function player.setNickName(player, nickname) {
  3305. map.add(getScriptVar("nicknames"), player.getUuid(player), nickname);
  3306. }
  3307. function player.getNickName(player) {
  3308. return map.getOrDefault(getScriptVar("nicknames"), player.getUuid(player), player.getName(player));
  3309. }
  3310. function player.removeNickName(player) {
  3311. map.remove(getScriptVar("nicknames"), player.getUuid(player));
  3312. }
  3313. //--------------------------------------------------
  3314. //Mail-Utils
  3315. //--------------------------------------------------
  3316. function mail.send(from_name, to_name, message) {
  3317. server_config = getScriptVar("server_config");
  3318. mail_id = config.getDouble(server_config, "mail_id", 0) + 1;
  3319. config.set(server_config, "mail_id", mail_id);
  3320. config.saveAsync(server_config);
  3321. from_id = player.getId(player.getUuid(from_name));
  3322. to_id = player.getId(player.getUuid(to_name));
  3323. stmt = databank.prepare("INSERT INTO mails (mail_id, from_id, to_id, readed, time, message) VALUES (?, ?, ?, ?, ?, ?);");
  3324. databank.setInt(stmt, 1, mail_id);
  3325. databank.setInt(stmt, 2, from_id);
  3326. databank.setInt(stmt, 3, to_id);
  3327. databank.setBool(stmt, 4, false);
  3328. databank.setLong(stmt, 5, time.getMillis());
  3329. databank.setString(stmt, 6, message);
  3330. databank.workerExecute(stmt);
  3331. //Wenn Spieler online, dann Pushmeldung veranlassen
  3332. p = read.player(to_name);
  3333. if(p != null) {
  3334. msg.prefix(p, "§bMail", concat("§rYou´ve got a new mail from §b", from_name, "."));
  3335. }
  3336. }
  3337. function mail.checkForNew(player) {
  3338. stmt = databank.prepare("SELECT mail_id, from_id, time, message FROM mails WHERE to_id = ? AND readed = false;");
  3339. to_id = player.getId(player);
  3340. databank.setInt(stmt, 1, to_id);
  3341. result = databank.execute(stmt);
  3342. nextrow = databank.next(result);
  3343. if(!nextrow) {
  3344. databank.close(result);
  3345. databank.close(stmt);
  3346. return;
  3347. }
  3348. newmails = 0;
  3349. while(nextrow) {
  3350. newmails++;
  3351. nextrow = databank.next(result);
  3352. }
  3353. databank.close(result);
  3354. databank.close(stmt);
  3355. if(newmails > 0) {
  3356. if(newmails > 1) {
  3357. msg.prefix(player, "§bMail", concat("§rYou´ve got §b", text.number(newmails), "§r new mails."));
  3358. } else {
  3359. msg.prefix(player, "§bMail", "§rYou´ve got §b1 §rnew mail.");
  3360. }
  3361. }
  3362. }
  3363. //--------------------------------------------------
  3364. //Friend-Utils
  3365. //--------------------------------------------------
  3366. function friend.check(player_id, friend_id) {
  3367. stmt = databank.prepare("SELECT friend_id FROM friends WHERE player_id = ? AND friend_id = ?;");
  3368. databank.setInt(stmt, 1, player_id);
  3369. databank.setInt(stmt, 2, friend_id);
  3370. result = databank.execute(stmt);
  3371. temp = false;
  3372. while(databank.next(result)) {
  3373. temp = true;
  3374. }
  3375. databank.close(result);
  3376. databank.close(stmt);
  3377. return temp;
  3378. }
  3379. function friend.add(player_id, friend_id) {
  3380. nowtime = time.getMillis();
  3381. stmt1 = databank.prepare("INSERT INTO friends (player_id, friend_id, time) VALUES (?, ?, ?);");
  3382. databank.setInt(stmt1, 1, player_id);
  3383. databank.setInt(stmt1, 2, friend_id);
  3384. databank.setLong(stmt1, 3, nowtime);
  3385. databank.workerExecute(stmt1);
  3386. stmt2 = databank.prepare("INSERT INTO friends (player_id, friend_id, time) VALUES (?, ?, ?);");
  3387. databank.setInt(stmt2, 1, friend_id);
  3388. databank.setInt(stmt2, 2, player_id);
  3389. databank.setLong(stmt2, 3, nowtime);
  3390. databank.workerExecute(stmt2);
  3391. }
  3392. function friend.delete(player_id, friend_id) {
  3393. stmt1 = databank.prepare("DELETE FROM friends WHERE player_id = ? AND friend_id = ?;");
  3394. databank.setInt(stmt1, 1, player_id);
  3395. databank.setInt(stmt1, 2, friend_id);
  3396. databank.workerExecute(stmt1);
  3397. stmt2 = databank.prepare("DELETE FROM friends WHERE player_id = ? AND friend_id = ?;");
  3398. databank.setInt(stmt2, 1, friend_id);
  3399. databank.setInt(stmt2, 2, player_id);
  3400. databank.workerExecute(stmt2);
  3401. }
  3402. function friend.getList(player_id) {
  3403. list = list.new();
  3404. stmt = databank.prepare("SELECT friend_id FROM friends WHERE player_id = ?;");
  3405. databank.setInt(stmt, 1, player_id);
  3406. result = databank.execute(stmt);
  3407. while(databank.next(result)) {
  3408. friend_id = databank.getInt(result, 1);
  3409. list.add(list, player.getNameFromId(friend_id));
  3410. }
  3411. databank.close(result);
  3412. databank.close(stmt);
  3413. return list;
  3414. }
  3415. //--------------------------------------------------
  3416. //Clan-Utils
  3417. //--------------------------------------------------
  3418. function clan.getIdList() {
  3419. file = file.new("scripts/configs/clan_data");
  3420. if(file.exists(file) && file.isDirectory(file)) {
  3421. list = file.getList(file);
  3422. }
  3423. id_list = list.new();
  3424. iter = list.iterator(list);
  3425. while(hasNext(iter)) {
  3426. element = next(iter);
  3427. file_name = file.getName(element);
  3428. file_name = text.replace(file_name, ".0.snuvic", "");
  3429. list.add(id_list, read.number(file_name));
  3430. }
  3431. return id_list;
  3432. }
  3433. function clan.loadData() {
  3434. list = clan.getIdList();
  3435. iter = list.iterator(list);
  3436. map = map.new();
  3437. while(hasNext(iter)) {
  3438. clan_id = next(iter);
  3439. config = config.new("scripts/configs/clan_data", clan_id);
  3440. if(config.exists(config)) {
  3441. config.load(config);
  3442. }
  3443. map.add(map, clan_id, config);
  3444. }
  3445. setScriptVar("clan_data", map);
  3446. }
  3447. function clan.getData(clan_id) {
  3448. if(clan_id == null) {
  3449. snuvi.debug("script termed. clan_id was null");
  3450. term();
  3451. }
  3452. map = getScriptVar("clan_data");
  3453. config = map.get(map, clan_id);
  3454. if(config == null) {
  3455. config = config.new("scripts/configs/clan_data", clan_id);
  3456. if(config.exists(config)) {
  3457. config.load(config);
  3458. }
  3459. map.add(map, clan_id, config);
  3460. }
  3461. return config;
  3462. }
  3463. function clan.setName(clan_id, name) {
  3464. config = clan.getData(clan_id);
  3465. config.set(config, "name", name);
  3466. config.saveAsync(config);
  3467. }
  3468. function clan.getName(clan_id) {
  3469. config = clan.getData(clan_id);
  3470. temp = config.getString(config, "name", "null");
  3471. if(temp == "null") {
  3472. return null;
  3473. }
  3474. return temp;
  3475. }
  3476. function clan.setTag(clan_id, tag) {
  3477. config = clan.getData(clan_id);
  3478. config.set(config, "tag", tag);
  3479. config.saveAsync(config);
  3480. }
  3481. function clan.getTag(clan_id) {
  3482. config = clan.getData(clan_id);
  3483. temp = config.getString(config, "tag", "null");
  3484. if(temp == "null") {
  3485. return null;
  3486. }
  3487. return temp;
  3488. }
  3489. function clan.setMoney(clan_id, money) {
  3490. config = clan.getData(clan_id);
  3491. config.set(config, "money", money);
  3492. config.saveAsync(config);
  3493. }
  3494. function clan.getMoney(clan_id) {
  3495. config = clan.getData(clan_id);
  3496. return config.getDouble(config, "money", 0);
  3497. }
  3498. function clan.addMoney(clan_id, money) {
  3499. config = clan.getData(clan_id);
  3500. new_money = config.getDouble(config, "money", 0) + money;
  3501. config.set(config, "money", new_money);
  3502. config.saveAsync(config);
  3503. }
  3504. function clan.subMoney(clan_id, money) {
  3505. config = clan.getData(clan_id);
  3506. new_money = config.getDouble(config, "money", 0) - money;
  3507. config.set(config, "money", new_money);
  3508. config.saveAsync(config);
  3509. }
  3510. function clan.setSpawn(clan_id, location) {
  3511. config = clan.getData(clan_id);
  3512. config.set(config, "spawn", text.location(location));
  3513. config.saveAsync(config);
  3514. }
  3515. function clan.getSpawn(clan_id) {
  3516. config = clan.getData(clan_id);
  3517. location = config.getString(config, "spawn", "null");
  3518. if(location == "null") {
  3519. return null;
  3520. }
  3521. return read.location(location);
  3522. }
  3523. function clan.getIdFromName(name) {
  3524. list = clan.getIdList();
  3525. iter = list.iterator(list);
  3526. while(hasNext(iter)) {
  3527. clan_id = next(iter);
  3528. if(clan.getName(clan_id) == name) {
  3529. return clan_id;
  3530. }
  3531. }
  3532. return null;
  3533. }
  3534. function clan.getIdFromTag(clan_tag) {
  3535. list = clan.getIdList();
  3536. iter = list.iterator(list);
  3537. while(hasNext(iter)) {
  3538. clan_id = next(iter);
  3539. if(clan.getTag(clan_id) == clan_tag) {
  3540. return clan_id;
  3541. }
  3542. }
  3543. return null;
  3544. }
  3545. function clan.isExistingTag(clan_tag) {
  3546. return !(clan.getIdFromTag(clan_tag) == null);
  3547. }
  3548. function clan.isExistingName(name) {
  3549. return !(clan.getIdFromName(name) == null);
  3550. }
  3551. function clan.getNextFreeId() {
  3552. server_config = getScriptVar("server_config");
  3553. id = config.getDouble(server_config, "clan.id.next", 0) + 1;
  3554. config.set(server_config, "clan.id.next", id);
  3555. config.saveAsync(server_config);
  3556. return id;
  3557. }
  3558. function clan.create(name, tag) {
  3559. clan_id = clan.getNextFreeId();
  3560. config = clan.getData(clan_id);
  3561. config.set(config, "name", name);
  3562. config.set(config, "tag", tag);
  3563. config.set(config, "members", 0);
  3564. config.save(config);
  3565. return clan_id;
  3566. }
  3567. function clan.getLeader(clan_id) {
  3568. list = clan.getMembersList(clan_id);
  3569. iter = list.iterator(list);
  3570. while(hasNext(iter)) {
  3571. player_uuid = next(iter);
  3572. player_id = player.getId(player_uuid);
  3573. if(player.isClanLeader(player_id)) {
  3574. return player_uuid;
  3575. }
  3576. }
  3577. return null;
  3578. }
  3579. function clan.getMembersAmount(clan_id) {
  3580. config = clan.getData(clan_id);
  3581. return config.getDouble(config, "members", 0);
  3582. }
  3583. function clan.setMembersAmount(clan_id, amount) {
  3584. config = clan.getData(clan_id);
  3585. config.set(config, "members", amount);
  3586. config.saveAsync(config);
  3587. }
  3588. function clan.addMember(clan_id, player_or_id, role) {
  3589. //Player
  3590. player.setClanId(player_or_id, clan_id);
  3591. player.setClanRole(player_or_id, role);
  3592. //Clan
  3593. new_amount = clan.getMembersAmount(clan_id) + 1;
  3594. if(isPlayer(player_or_id)) {
  3595. player_uuid = player.getUuid(player_or_id);
  3596. } else {
  3597. player_uuid = player.getUuidFromId(player_or_id);
  3598. }
  3599. config = clan.getData(clan_id);
  3600. config.set(config, text.concat("player_", new_amount), text(player_uuid));
  3601. config.set(config, "members", new_amount);
  3602. config.saveAsync(config);
  3603. }
  3604. function clan.removeMember(clan_id, player_or_id) {
  3605. //Player
  3606. player.setClanId(player_or_id, -1);
  3607. player.setClanRole(player_or_id, "null");
  3608. if(isPlayer(player_or_id)) {
  3609. player_uuid = player.getUuid(player_or_id);
  3610. } else {
  3611. player_uuid = player.getUuidFromId(player_or_id);
  3612. }
  3613. //Clan
  3614. config = clan.getData(clan_id);
  3615. amount = config.getDouble(config, "members", 0);
  3616. for(i = 1; i <= amount; i++) {
  3617. if(config.getString(config, text.concat("player_", i), "null") == text(player_uuid)) {
  3618. break;
  3619. }
  3620. }
  3621. if(i != amount) {
  3622. config.set(config, text.concat("player_", i), config.getString(config, text.concat("player_", amount), "null"));
  3623. }
  3624. config.set(config, text.concat("player_", amount), "null");
  3625. config.set(config, "members", amount - 1);
  3626. config.saveAsync(config);
  3627. }
  3628. function clan.delete(clan_id) {
  3629. //Members
  3630. list = clan.getMembersList(clan_id);
  3631. iter = list.iterator(list);
  3632. while(hasNext(iter)) {
  3633. player_uuid = next(iter);
  3634. player_id = player.getId(player_uuid);
  3635. player.setClanId(player_id, -1);
  3636. player.setClanRole(player_id, "null");
  3637. }
  3638. //Clan
  3639. config.delete(clan.getData(clan_id));
  3640. map.remove(getScriptVar("clan_data"), clan_id);
  3641. }
  3642. function clan.getMembersList(clan_id) {
  3643. list = list.new();
  3644. config = clan.getData(clan_id);
  3645. amount = config.getDouble(config, "members", 0);
  3646. for(i = 1; i <= amount; i++) {
  3647. player_uuid = read.uuid(config.getString(config, text.concat("player_", i), "null"));
  3648. list.add(list, player_uuid);
  3649. }
  3650. return list;
  3651. }
  3652. function clan.updateHeadNames(clan_id) {
  3653. list = clan.getMembersList(clan_id);
  3654. iter = list.iterator(list);
  3655. while(hasNext(iter)) {
  3656. p = player.get(next(iter));
  3657. if(p != null) {
  3658. player.setHeadName(p);
  3659. }
  3660. }
  3661. }
  3662. function clan.msg(clan_id, message) {
  3663. list = clan.getMembersList(clan_id);
  3664. iter = list.iterator(list);
  3665. while(hasNext(iter)) {
  3666. p = player.get(next(iter));
  3667. if(p != null) {
  3668. msg.prefix(p, "§2Clan", message);
  3669. }
  3670. }
  3671. }
  3672. function clan.mail(clan_id, from_name, message) {
  3673. list = clan.getMembersList(clan_id);
  3674. iter = list.iterator(list);
  3675. while(hasNext(iter)) {
  3676. to_name = player.getName(next(iter));
  3677. mail.send(from_name, to_name, message);
  3678. }
  3679. }
  3680. //--------------------------------------------------
  3681. //Party-Utils
  3682. //--------------------------------------------------
  3683. function player.isInParty(player) {
  3684. return player.getPartyId(player) != null;
  3685. }
  3686. function party.same(player1, player2) {
  3687. return player.getPartyId(player1) == player.getPartyId(player2);
  3688. }
  3689. function player.isPartyLeader(player) {
  3690. return player.getPartyRank(player) == "Leader";
  3691. }
  3692. function player.isPartyLeaderOrMod(player) {
  3693. return player.getPartyRank(player) != "Player";
  3694. }
  3695. function player.getPartyId(player) {
  3696. return map.get(getScriptVar("party_ids"), player.getUuid(player));
  3697. }
  3698. function player.setPartyId(player, party_id) {
  3699. map.add(getScriptVar("party_ids"), player.getUuid(player), party_id);
  3700. }
  3701. function player.delPartyId(player) {
  3702. map.remove(getScriptVar("party_ids"), player.getUuid(player));
  3703. }
  3704. function player.getPartyRank(player) {
  3705. return map.get(getScriptVar("party_ranks"), player.getUuid(player));
  3706. }
  3707. function player.setPartyRank(player, rank) {
  3708. map.add(getScriptVar("party_ranks"), player.getUuid(player), rank);
  3709. }
  3710. function player.delPartyRank(player) {
  3711. map.remove(getScriptVar("party_ranks"), player.getUuid(player));
  3712. }
  3713. function party.getList(party_id) {
  3714. return map.get(getScriptVar("party_lists"), party_id);
  3715. }
  3716. function party.setList(party_id, list) {
  3717. map = getScriptVar("party_lists");
  3718. map.add(map, party_id, list);
  3719. setScriptVar("party_lists", map);
  3720. }
  3721. function party.addPlayer(party_id, player) {
  3722. list.add(party.getList(party_id), player.getUuid(player));
  3723. player.setPartyId(player, party_id);
  3724. }
  3725. //--------------------------------------------------
  3726. //Scheduler-Utils
  3727. //--------------------------------------------------
  3728. function scheduler.add(data_array) {
  3729. list.add(getScriptVar("scheduler_list"), data_array);
  3730. }
  3731. function scheduler.addFly(ticks, player, bool) {
  3732. a = array.new(4);
  3733. a[0] = 0;
  3734. a[1] = ticks;
  3735. a[2] = player;
  3736. a[3] = bool;
  3737. scheduler.add(a);
  3738. }
  3739. function scheduler.msgPrefix(ticks, player, prefix, message) {
  3740. a = array.new(5);
  3741. a[0] = 1;
  3742. a[1] = ticks;
  3743. a[2] = player;
  3744. a[3] = prefix;
  3745. a[4] = message;
  3746. scheduler.add(a);
  3747. }
  3748. function scheduler.msg(ticks, player, message) {
  3749. a = array.new(4);
  3750. a[0] = 2;
  3751. a[1] = ticks;
  3752. a[2] = player;
  3753. a[3] = message;
  3754. scheduler.add(a);
  3755. }
  3756. function scheduler.setBlock(ticks, location, item_string, block_update) {
  3757. a = array.new(5);
  3758. a[0] = 3;
  3759. a[1] = ticks;
  3760. a[2] = location;
  3761. a[3] = item_string;
  3762. a[4] = block_update;
  3763. scheduler.add(a);
  3764. }
  3765. function scheduler.questFinish(ticks, script, player) {
  3766. a = array.new(4);
  3767. a[0] = 4;
  3768. a[1] = ticks;
  3769. a[2] = script;
  3770. a[3] = player;
  3771. scheduler.add(a);
  3772. }
  3773. function scheduler.setBurning(ticks, entity, seconds) {
  3774. a = array.new(4);
  3775. a[0] = 5;
  3776. a[1] = ticks;
  3777. a[2] = entity;
  3778. a[3] = seconds;
  3779. scheduler.add(a);
  3780. }
  3781. function scheduler.spawnEntity(ticks, type, location) {
  3782. a = array.new(4);
  3783. a[0] = 6;
  3784. a[1] = ticks;
  3785. a[2] = type;
  3786. a[3] = location;
  3787. scheduler.add(a);
  3788. }
  3789. function scheduler.removeEntity(ticks, entity) {
  3790. a = array.new(3);
  3791. a[0] = 7;
  3792. a[1] = ticks;
  3793. a[2] = entity;
  3794. scheduler.add(a);
  3795. }
  3796. function scheduler.giveItem(ticks, player, item) {
  3797. a = array.new(4);
  3798. a[0] = 8;
  3799. a[1] = ticks;
  3800. a[2] = player;
  3801. a[3] = item;
  3802. scheduler.add(a);
  3803. }
  3804. function scheduler.giveSingleItem(ticks, player, item, boolean) {
  3805. a = array.new(5);
  3806. a[0] = 9;
  3807. a[1] = ticks;
  3808. a[2] = player;
  3809. a[3] = item;
  3810. a[4] = boolean;
  3811. scheduler.add(a);
  3812. }
  3813. //--------------------------------------------------
  3814. //Hawkeye-Utils
  3815. //--------------------------------------------------
  3816. function hawkeye.getData(timeFrom, timeTo, location, radius, events, players, order) {
  3817. base_query = "SELECT * FROM hawkeye WHERE ";
  3818. and_query = " AND ";
  3819. //Events
  3820. where_query = hawkeye.getEventQuery(events);
  3821. if(where_query == -1) {
  3822. return "False input at e:";
  3823. }
  3824. //Players
  3825. player_query = hawkeye.getPlayerQuery(players);
  3826. if(player_query == -1) {
  3827. return "False input at p:";
  3828. }
  3829. if(text.length(where_query) == 0) {
  3830. where_query = player_query;
  3831. } elseif(text.length(player_query) != 0) {
  3832. where_query = concat(where_query, and_query, player_query);
  3833. }
  3834. //Location
  3835. location_query = hawkeye.getLocationQuery(location, radius);
  3836. if(text.length(where_query) == 0) {
  3837. where_query = location_query;
  3838. } elseif(text.length(location_query) != 0) {
  3839. where_query = concat(where_query, and_query, location_query);
  3840. }
  3841. //Time
  3842. time_query = hawkeye.getTimeQuery(timeFrom, timeTo);
  3843. if(text.length(where_query) == 0) {
  3844. where_query = time_query;
  3845. } elseif(text.length(time_query) != 0) {
  3846. where_query = concat(where_query, and_query, time_query);
  3847. }
  3848. //Safety check
  3849. if(text.length(where_query) == 0) {
  3850. return "No parameters found";
  3851. }
  3852. //Final Statement
  3853. stmt = databank.prepare(concat(base_query, where_query, " ORDER BY time ", order, ";"));
  3854. index = 1;
  3855. if(events != null) {
  3856. iter = list.iterator(events);
  3857. while(hasNext(iter)) {
  3858. databank.setString(stmt, index, next(iter));
  3859. index++;
  3860. }
  3861. }
  3862. if(players != null) {
  3863. iter = list.iterator(players);
  3864. while(hasNext(iter)) {
  3865. databank.setInt(stmt, index, player.getId(player.getUuid(next(iter))));
  3866. index++;
  3867. }
  3868. }
  3869. if(location != null && radius != null) {
  3870. databank.setInt(stmt, index++, loc.getX(location));
  3871. databank.setInt(stmt, index++, loc.getY(location));
  3872. databank.setInt(stmt, index++, loc.getZ(location));
  3873. databank.setInt(stmt, index++, radius);
  3874. }
  3875. if(timeFrom != null && timeTo != null) {
  3876. databank.setLong(stmt, index++, timeFrom);
  3877. databank.setLong(stmt, index++, timeTo);
  3878. }
  3879. l = list.new();
  3880. result = databank.execute(stmt);
  3881. while(databank.next(result)) {
  3882. a = array.new(6);
  3883. id = databank.getInt(result, 1);
  3884. a[0] = id; //id
  3885. a[1] = databank.getInt(result, 2); //player_id
  3886. a[2] = databank.getString(result, 3); //event
  3887. a[3] = loc.new(world.get(databank.getString(result, 4)), databank.getInt(result, 5), databank.getInt(result, 6), databank.getInt(result, 7)); //location
  3888. a[4] = databank.getLong(result, 8); //time
  3889. a[5] = databank.getString(result, 9); //text
  3890. list.add(l, a);
  3891. }
  3892. databank.close(result);
  3893. databank.close(stmt);
  3894. return l;
  3895. }
  3896. function hawkeye.getEventQuery(events) {
  3897. if(events == null) {
  3898. return "";
  3899. }
  3900. query = "event IN(";
  3901. c = 0;
  3902. iter = list.iterator(events);
  3903. while(hasNext(iter)) {
  3904. event = next(iter);
  3905. if(event != "block_break" && event != "block_place") {
  3906. return -1;
  3907. }
  3908. if(c == 0) {
  3909. query = concat(query, "?");
  3910. } else {
  3911. query = concat(query, ",?");
  3912. }
  3913. c++;
  3914. }
  3915. return concat(query, ")");
  3916. }
  3917. function hawkeye.getPlayerQuery(players) {
  3918. if(players == null) {
  3919. return "";
  3920. }
  3921. query = "player_id IN(";
  3922. c = 0;
  3923. iter = list.iterator(players);
  3924. while(hasNext(iter)) {
  3925. player_name = next(iter);
  3926. player_uuid = player.getUuid(player_name);
  3927. if(player_uuid == null) {
  3928. return -1;
  3929. }
  3930. if(c == 0) {
  3931. query = concat(query, "?");
  3932. } else {
  3933. query = concat(query, ",?");
  3934. }
  3935. c++;
  3936. }
  3937. return concat(query, ")");
  3938. }
  3939. function hawkeye.getLocationQuery(player_loc, radius) {
  3940. if(player_loc == null || radius == null) {
  3941. return "";
  3942. }
  3943. return "POWER(x - ?, 2) + POWER(y - ?, 2) + POWER(z - ?, 2) < POWER(?, 2)";
  3944. }
  3945. function hawkeye.getTimeQuery(timeFrom, timeTo) {
  3946. if(timeFrom == null || timeTo == null) {
  3947. return "";
  3948. }
  3949. return "time > ? AND time < ?";
  3950. }
  3951. function hawkeye.print(player, list, side) {
  3952. amount = list.getSize(list);
  3953. a = list.getIndex(list, side - 1);
  3954. msg.prefix(player, "§cHawkeye", concat("§7----- Page (§c", text.number(side), "§7/§c", text.number(amount), "§7) -----"));
  3955. msg(player, concat("§7| ID:", text.number(a[0]), " ", getTimeString(a[4])));
  3956. msg(player, concat("§7| §c", hawkeye.getEventName(read.number(a[2])), " ", player.getNameFromId(a[1])));
  3957. msg(player, concat("§7| ", loc.getStringSpace(a[3])));
  3958. msg(player, concat("§7| ", a[5]));
  3959. if(side == 1) {
  3960. backward = "§7<<<<";
  3961. if(amount == 1) {
  3962. forward = "§7>>>>";
  3963. } else {
  3964. forward = text.click("§c>>>>", concat("/hawkeye print ", side + 1));
  3965. }
  3966. } elseif(side >= amount) {
  3967. backward = text.click("§c<<<<", concat("/hawkeye print ", side - 1));
  3968. forward = "§7>>>>";
  3969. } else {
  3970. backward = text.click("§c<<<<", concat("/hawkeye print ", side - 1));
  3971. forward = text.click("§c>>>>", concat("/hawkeye print ", side + 1));
  3972. }
  3973. msg(player, backward, " ", forward);
  3974. msg(player, "§7-----------------------------");
  3975. }
  3976. function hawkeye.setDataList(player, list) {
  3977. map.add(getScriptVar("ha_data_lists"), player.getUuid(player), list);
  3978. }
  3979. function hawkeye.getDataList(player) {
  3980. return map.get(getScriptVar("ha_data_lists"), player.getUuid(player));
  3981. }
  3982. function hawkeye.setUndoList(player, list) {
  3983. map.add(getScriptVar("ha_undo_lists"), player.getUuid(player), list);
  3984. }
  3985. function hawkeye.getUndoList(player) {
  3986. return map.get(getScriptVar("ha_undo_lists"), player.getUuid(player));
  3987. }
  3988. function hawkeye.rollback(list) {
  3989. counter = 0;
  3990. for(i = 0; i < list.getSize(list); i++) {
  3991. a = list.getIndex(list, i);
  3992. event = a[2];
  3993. loc = a[3];
  3994. if(event == "1") {
  3995. block.set(loc, a[5], true);
  3996. counter++;
  3997. } elseif(event == "2") {
  3998. block.set(loc, "minecraft:air", true);
  3999. counter++;
  4000. }
  4001. }
  4002. return counter;
  4003. }
  4004. function hawkeye.undo(list) {
  4005. for(i = list.getSize(list) - 1; i >= 0; i--) {
  4006. a = list.getIndex(list, i);
  4007. event = a[2];
  4008. loc = a[3];
  4009. if(event == "1") {
  4010. block.set(loc, "minecraft:air", true);
  4011. } elseif(event == "2") {
  4012. block.set(loc, a[5], true);
  4013. }
  4014. }
  4015. }
  4016. //--------------------------------------------------
  4017. //
  4018. //--------------------------------------------------
  4019. function yeet (player, strength){
  4020. array = entity.getLook(player);
  4021. x = array[0] * (math.log(strength)+1);
  4022. y = math.abs(array[1]) * (math.log(strength)+1);
  4023. z = array[2] * (math.log(strength)+1);
  4024. entity.throw(player, x, y, z);
  4025. }