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