u_general.txt 114 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392
  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. entity.clearEffects(player);
  1339. //Party
  1340. if(player.isInParty(player) && player.isPartyLeader(player)) {
  1341. party_id = player.getPartyId(player);
  1342. party_list = party.getList(party_id);
  1343. iter = list.iterator(party_list);
  1344. while(hasNext(iter)) {
  1345. p = player.get(next(iter));
  1346. if(player_uuid == player.getUuid(p)) {
  1347. continue;
  1348. }
  1349. p_name = player.getName(p);
  1350. if(!loc.isSameWorld(player_loc, entity.getLocation(p))) {
  1351. msg.prefix(player, "§5Party", concat(p_name, "§c is in another world."));
  1352. continue;
  1353. }
  1354. if(player.hasMinigame(p)) {
  1355. msg.prefix(player, "§5Party", concat(p_name, "§c is in a game."));
  1356. continue;
  1357. }
  1358. if(player.hasQuest2(p)) {
  1359. msg.prefix(player, "§5Party", concat(p_name, "§c is doing a quest."));
  1360. continue;
  1361. }
  1362. if(player.isOnAdventure(p)) {
  1363. msg.prefix(player, "§5Party", concat(p_name, "§c is on an adventure."));
  1364. continue;
  1365. }
  1366. if(player.isAfk(p)) {
  1367. msg.prefix(player, "§5Party", concat(p_name, "§c is afk."));
  1368. continue;
  1369. }
  1370. player.teleport(p, location, setBackPos);
  1371. }
  1372. }
  1373. //Quests
  1374. script_id = quest.getFromPlayer(player);
  1375. if(script_id != null) {
  1376. script = script.getFromId(script_id);
  1377. if(script != null) {
  1378. setScriptVar("player", player);
  1379. script.callEvent("quest_term", script);
  1380. quest.term(script, player);
  1381. msg.prefix(player, "§dQuest", "Quest termed.");
  1382. }
  1383. }
  1384. }
  1385. modTimer(-50);
  1386. entity.teleport(player, location);
  1387. player.setHeadName(player);
  1388. player.showDefaultStacks(player);
  1389. if(world.isGamesName(to_world_name)) {
  1390. player.clearInventory(player);
  1391. inv = player.getInv(player);
  1392. inv.setItem(inv, 0, read.item("minecraft:compass"));
  1393. }
  1394. player.setTabName(player);
  1395. return true;
  1396. }
  1397. function playerdata.getSurvival(player_or_id) {
  1398. player_id = player.getValidId(player_or_id);
  1399. if(player_id == null) {
  1400. snuvi.debug(concat("invalid player_id ", player_id, " on playerdata.getSurvival"));
  1401. return;
  1402. }
  1403. map = getScriptVar("survival_data");
  1404. config = map.get(map, player_id);
  1405. if(config == null) {
  1406. playerdata.load(player_id, map, "survival_data");
  1407. config = map.get(map, player_id);
  1408. }
  1409. return config;
  1410. }
  1411. function playerdata.getGames(player_or_id) {
  1412. player_id = player.getValidId(player_or_id);
  1413. if(player_id == null) {
  1414. snuvi.debug(concat("invalid player_id ", player_id, " on playerdata.getGames"));
  1415. return;
  1416. }
  1417. map = getScriptVar("games_data");
  1418. config = map.get(map, player_id);
  1419. if(config == null) {
  1420. playerdata.load(player_id, map, "games_data");
  1421. config = map.get(map, player_id);
  1422. }
  1423. return config;
  1424. }
  1425. function playerdata.getStory(player_or_id) {
  1426. player_id = player.getValidId(player_or_id);
  1427. if(player_id == null) {
  1428. snuvi.debug(concat("invalid player_id ", player_id, " on playerdata.getStory"));
  1429. return;
  1430. }
  1431. map = getScriptVar("story_data");
  1432. config = map.get(map, player_id);
  1433. if(config == null) {
  1434. playerdata.load(player_id, map, "story_data");
  1435. config = map.get(map, player_id);
  1436. }
  1437. return config;
  1438. }
  1439. function playerdata.load(player_or_id, map, name) {
  1440. player_id = player.getValidId(player_or_id);
  1441. if(player_id == null) {
  1442. snuvi.debug(concat("invalid player_id ", player_id, " on playerdata.load"));
  1443. return;
  1444. }
  1445. config = map.get(map, player_id);
  1446. if(config == null) {
  1447. config = config.new(concat("scripts/configs/player_data/", name), player_id);
  1448. if(config.exists(config)) {
  1449. config.load(config);
  1450. }
  1451. map.add(map, player_id, config);
  1452. }
  1453. }
  1454. function player.getValidId(player_or_id) {
  1455. if(isPlayer(player_or_id)) {
  1456. return player.getId(player_or_id);
  1457. }
  1458. if(isDouble(player_or_id)) {
  1459. if(player.getNameFromId(player_or_id) != null) {
  1460. return player_or_id;
  1461. }
  1462. }
  1463. return null;
  1464. }
  1465. function player.getValid(player_or_id) {
  1466. if(isPlayer(player_or_id)) {
  1467. return player_or_id;
  1468. }
  1469. player = player.get(player.getUuidFromId(player_or_id));
  1470. if(player == null) {
  1471. return null;
  1472. }
  1473. return player;
  1474. }
  1475. //--------------------------------------------------
  1476. //Msg-Utils
  1477. //--------------------------------------------------
  1478. function msg.quest(player, speaker, line_now, line_max, message) {
  1479. msg(player, concat("[§b", text.number(line_now), "§r/§b", text.number(line_max), "§r] §a", speaker, " §r| ", concat("§e", message)));
  1480. }
  1481. function msg.chat(player, message) {
  1482. nickname = player.getNickName(player);
  1483. rank = getRank(player);
  1484. colorcode = text.subString(rank, 0, 2);
  1485. player_id = player.getId(player);
  1486. if(player_id == 35 || player_id == 62) {
  1487. nickname = concat(nickname, "§r][§e§l★");
  1488. rank = concat(rank, "\n§eSpecial VIP for Special Services");
  1489. }
  1490. live_tag = "";
  1491. if(player.isLive(player)) {
  1492. live_tag = "§f[§dLive§f]";
  1493. }
  1494. online_list = players.toList();
  1495. iter = list.iterator(online_list);
  1496. while(hasNext(iter)) {
  1497. p = next(iter);
  1498. if(player.hasMinigame(p) && player.isMuted(p)) {
  1499. continue;
  1500. }
  1501. msg(p, live_tag, "[", text.hover(concat(colorcode, nickname), rank), "§r] §r", message);
  1502. }
  1503. }
  1504. function msg.send(from_player, to_name, prefix, message, send_mail) {
  1505. p = read.player(to_name);
  1506. if(p == null) {
  1507. if(send_mail) {
  1508. mail.send(player.getName(from_player), to_name, message);
  1509. }
  1510. } else {
  1511. msg.prefix(p, prefix, message);
  1512. }
  1513. }
  1514. function msg.prefix(player, prefix, message) {
  1515. msg(player, concat("§r[", prefix, "§r] ", message));
  1516. }
  1517. function msg.online(prefix, message) {
  1518. msg("online", concat("§r[", prefix, "§r] "), message);
  1519. }
  1520. function msg.radius(prefix, message, location, radius) {
  1521. list = players.near(location, radius);
  1522. iter = list.iterator(list);
  1523. while(hasNext(iter)) {
  1524. msg.prefix(next(iter), prefix, message);
  1525. }
  1526. }
  1527. function msg.server(message) {
  1528. msg("online", text.hover("[§cServer§r]", "The center of Wusiness"), " ", text.replace(message, "&", "§"));
  1529. msg("SERVER", "[§cServer§r] ", text.replace(message, "&", "§"));
  1530. }
  1531. function msg.world(world, message) {
  1532. world_list = players.toWorldList(world);
  1533. iter = iterator(world_list);
  1534. while(hasNext(iter)) {
  1535. msg(next(iter), message);
  1536. }
  1537. }
  1538. function msg.survival(message) {
  1539. msg.world(world.getOverWorld(), message);
  1540. msg.world(world.getTheEnd(), message);
  1541. msg.world(world.getTheNether(), message);
  1542. }
  1543. function msg.story(message) {
  1544. msg.world(world.getStory(), message);
  1545. }
  1546. function msg.creative(message) {
  1547. msg.world(world.getCreative(), message);
  1548. }
  1549. function msg.games(message) {
  1550. msg.world(world.getGames(), message);
  1551. }
  1552. //--------------------------------------------------
  1553. //Item-Utils
  1554. //--------------------------------------------------
  1555. function item.getAir() {
  1556. return read.item("minecraft:air");
  1557. }
  1558. function item.isAmber(item) {
  1559. return text.item(item) == "{id:\"km:flawless_gem_stone\",Count:1b,tag:{color:13664802,display:{Name:'{\"text\":\"§fAmber\"}'}}}";
  1560. }
  1561. function item.isSapphire(item) {
  1562. return text.item(item) == "{id:\"km:flawless_gem_stone\",Count:1b,tag:{color:3289855,display:{Name:'{\"text\":\"§fSapphire\"}'}}}";
  1563. }
  1564. function item.isRuby(item) {
  1565. return text.item(item) == "{id:\"km:flawless_gem_stone\",Count:1b,tag:{color:16724530,display:{Name:'{\"text\":\"§fRuby\"}'}}}";
  1566. }
  1567. function item.getAmber() {
  1568. return read.item("{id:\"km:flawless_gem_stone\",Count:1b,tag:{color:13664802,display:{Name:'{\"text\":\"§fAmber\"}'}}}");
  1569. }
  1570. function item.getSapphire() {
  1571. return read.item("{id:\"km:flawless_gem_stone\",Count:1b,tag:{color:3289855,display:{Name:'{\"text\":\"§fSapphire\"}'}}}");
  1572. }
  1573. function item.getRuby() {
  1574. return read.item("{id:\"km:flawless_gem_stone\",Count:1b,tag:{color:16724530,display:{Name:'{\"text\":\"§fRuby\"}'}}}");
  1575. }
  1576. //--------------------------------------------------
  1577. //Player-Utils
  1578. //--------------------------------------------------
  1579. function player.canTeleport(player) {
  1580. if(player.hasMinigame(player)) {
  1581. return false;
  1582. }
  1583. if(player.isOnAdventure(player)) {
  1584. return false;
  1585. }
  1586. return true;
  1587. }
  1588. function player.hasClearInventory(player) {
  1589. inv = player.getInv(player);
  1590. for(slot = 0; slot < 36; slot++) {
  1591. if(item.getType(inv.getItem(inv, slot)) != "minecraft:air") {
  1592. return false;
  1593. }
  1594. }
  1595. if(item.getType(living.getEquip(player, "head")) != "minecraft:air") {
  1596. return false;
  1597. }
  1598. if(item.getType(living.getEquip(player, "chest")) != "minecraft:air") {
  1599. return false;
  1600. }
  1601. if(item.getType(living.getEquip(player, "legs")) != "minecraft:air") {
  1602. return false;
  1603. }
  1604. if(item.getType(living.getEquip(player, "feet")) != "minecraft:air") {
  1605. return false;
  1606. }
  1607. if(item.getType(living.getEquip(player, "offhand")) != "minecraft:air") {
  1608. return false;
  1609. }
  1610. return true;
  1611. }
  1612. function player.getJoinMessage(player_or_id) {
  1613. config = playerdata.getSurvival(player_or_id);
  1614. temp = config.getString(config, "message.join", "null");
  1615. if(temp == "null") {
  1616. return null;
  1617. }
  1618. return temp;
  1619. }
  1620. function player.setJoinMessage(player_or_id, message) {
  1621. config = playerdata.getSurvival(player_or_id);
  1622. config.set(config, "message.join", message);
  1623. config.saveAsync(config);
  1624. }
  1625. function player.getLeaveMessage(player_or_id) {
  1626. config = playerdata.getSurvival(player_or_id);
  1627. temp = config.getString(config, "message.leave", "null");
  1628. if(temp == "null") {
  1629. return null;
  1630. }
  1631. return temp;
  1632. }
  1633. function player.setLeaveMessage(player_or_id, message) {
  1634. config = playerdata.getSurvival(player_or_id);
  1635. config.set(config, "message.leave", message);
  1636. config.saveAsync(config);
  1637. }
  1638. function player.isLive(player) {
  1639. player_uuid = player.getUuid(player);
  1640. live_set = getScriptVar("live_set");
  1641. return set.contains(live_set, player_uuid);
  1642. }
  1643. function player.setLive(player, boolean) {
  1644. player_uuid = player.getUuid(player);
  1645. live_set = getScriptVar("live_set");
  1646. if(boolean) {
  1647. set.add(live_set, player_uuid);
  1648. } else {
  1649. set.remove(live_set, player_uuid);
  1650. }
  1651. }
  1652. function player.getFullName(player) {
  1653. player_name = player.getName(player);
  1654. nickname = removeFormat(player.getNickname(player));
  1655. if(nickname == player_name) {
  1656. personally_messages = true;
  1657. } else {
  1658. personally_messages = false;
  1659. }
  1660. if(personally_messages) {
  1661. full_name = concat("[", getRank(player), "§r] ", nickname);
  1662. } else {
  1663. full_name = concat("[§3User§r] ", nickname);
  1664. }
  1665. return full_name;
  1666. }
  1667. function player.setTabName(player) {
  1668. nickname = player.getNickname(player);
  1669. rank = getRank(player);
  1670. if(text.startswith(rank, "§", 0)) {
  1671. colorcode = text.subString(rank, 0, 2);
  1672. tab_name = concat(colorcode, nickname);
  1673. } else {
  1674. tab_name = nickname;
  1675. }
  1676. if(player.isAfk(player)) {
  1677. tab_name = concat(tab_name, " §5§o[Afk]");
  1678. }
  1679. if(player.isLive(player)) {
  1680. tab_name = concat(tab_name, " §f[§dLive§f]");
  1681. }
  1682. player.setDisplayName(player, tab_name);
  1683. }
  1684. function player.removeItemNbt(player, itemstack) {
  1685. //Make a copy
  1686. item_type = item.getType(itemstack);
  1687. amount = item.getAmount(itemstack);
  1688. my_item = read.item(item_type, amount);
  1689. //Loop the inventory
  1690. inv = player.getInv(player);
  1691. for(slot = 0; slot < inv.getSize(inv); slot++) {
  1692. item = inv.getItem(inv, slot);
  1693. if(item.getType(item) == item_type) {
  1694. diff = amount - item.getAmount(item);
  1695. if(diff > 0) {
  1696. amount = diff;
  1697. item.setAmount(item, 0);
  1698. } else {
  1699. item.setAmount(item, math.abs(diff));
  1700. air = item.getAir();
  1701. item.setAmount(air, 0);
  1702. return air;
  1703. }
  1704. }
  1705. }
  1706. item.setAmount(my_item, amount);
  1707. return my_item;
  1708. }
  1709. function player.removeItemTag(player, tag, amount) {
  1710. air = item.getAir();
  1711. inv = player.getInv(player);
  1712. for(slot = 0; slot < inv.getSize(inv); slot++) {
  1713. item = inv.getItem(inv, slot);
  1714. if(item.hasTag(tag, item)) {
  1715. diff = amount - item.getAmount(item);
  1716. if(diff > 0) {
  1717. item.setAmount(item, 0);
  1718. amount = diff;
  1719. } else {
  1720. item.setAmount(item, math.abs(diff));
  1721. amount = 0;
  1722. break;
  1723. }
  1724. }
  1725. }
  1726. item.setAmount(air, amount);
  1727. return air;
  1728. }
  1729. function player.showDebug(player, boolean) {
  1730. player_uuid = player.getUuid(player);
  1731. if(boolean) {
  1732. perm.registerPlayer(player_uuid, 16);
  1733. } else {
  1734. perm.unregisterPlayer(player_uuid, 16);
  1735. }
  1736. }
  1737. function player.showDefaultStacks(player) {
  1738. player_loc = entity.getLocation(player);
  1739. world_name = world.getName(loc.getWorld(player_loc));
  1740. stacks.clear(player);
  1741. if(world.isSurvName(world_name)) {
  1742. stacks.set(player, 0, "km:gear");
  1743. stacks.set(player, 1, "km:golden_scepter");
  1744. stacks.set(player, 2, "minecraft:red_bed");
  1745. } elseif(world_name == "games") {
  1746. stacks.set(player, 0, "km:gear");
  1747. } elseif(world_name == "story") {
  1748. stacks.set(player, 0, "km:gear");
  1749. stacks.set(player, 1, "km:golden_scepter");
  1750. } elseif(world_name == "creative") {
  1751. stacks.set(player, 0, "km:gear");
  1752. }
  1753. stacks.setActive(player, true);
  1754. }
  1755. function player.setSpeed(player, speed) {
  1756. living.setPersistentMovementSpeed(player, speed / 10);
  1757. living.setPersistentFlyingSpeed(player, speed / 10 * 4);
  1758. }
  1759. function player.hasBigPlotCreated(player_or_id) {
  1760. config = playerdata.getSurvival(player_or_id);
  1761. return config.getBool(config, "plot.big", false);
  1762. }
  1763. function player.setBigPlotCreated(player_or_id, boolean) {
  1764. config = playerdata.getSurvival(player_or_id);
  1765. config.set(config, "plot.big", boolean);
  1766. config.saveAsync(config);
  1767. }
  1768. function player.hasPlotRaised(player_or_id) {
  1769. config = playerdata.getSurvival(player_or_id);
  1770. return config.getBool(config, "plot.raised", false);
  1771. }
  1772. function player.setPlotRaised(player_or_id, boolean) {
  1773. config = playerdata.getSurvival(player_or_id);
  1774. config.set(config, "plot.raised", boolean);
  1775. config.saveAsync(config);
  1776. }
  1777. function player.usedHisFreePlot(player_or_id) {
  1778. config = playerdata.getSurvival(player_or_id);
  1779. return config.getBool(config, "plot.usedFree", false);
  1780. }
  1781. function player.setUsedFreePlot(player_or_id, boolean) {
  1782. config = playerdata.getSurvival(player_or_id);
  1783. config.set(config, "plot.usedFree", boolean);
  1784. config.saveAsync(config);
  1785. }
  1786. function player.activateSitting(player_or_id, boolean) {
  1787. config = playerdata.getSurvival(player_or_id);
  1788. config.set(config, "sitting", boolean);
  1789. config.saveAsync(config);
  1790. }
  1791. function player.hasSittingActivated(player_or_id) {
  1792. config = playerdata.getSurvival(player_or_id);
  1793. return config.getBool(config, "sitting", true);
  1794. }
  1795. function player.acceptTpaRequests(player_or_id, boolean) {
  1796. config = playerdata.getSurvival(player_or_id);
  1797. config.set(config, "tptoggle", boolean);
  1798. config.saveAsync(config);
  1799. }
  1800. function player.doesAcceptTpaRequests(player_or_id) {
  1801. config = playerdata.getSurvival(player_or_id);
  1802. return config.getBool(config, "tptoggle", true);
  1803. }
  1804. function player.getBackPos(player) {
  1805. config = playerdata.getSurvival(player);
  1806. location = config.getString(config, "backpos", "null");
  1807. if(location == "null") {
  1808. return null;
  1809. }
  1810. return read.location(location);
  1811. }
  1812. function player.setBackPos(player) {
  1813. config = playerdata.getSurvival(player);
  1814. config.set(config, "backpos", text.location(entity.getLocation(player)));
  1815. config.saveAsync(config);
  1816. }
  1817. function player.setBackPosLoc(player, location) {
  1818. config = playerdata.getSurvival(player);
  1819. config.set(config, "backpos", text.location(location));
  1820. config.saveAsync(config);
  1821. }
  1822. function player.clearBackPos(player) {
  1823. config = playerdata.getSurvival(player);
  1824. config.set(config, "backpos", "null");
  1825. config.saveAsync(config);
  1826. }
  1827. function entity.getFromDamageSource(damage_source) {
  1828. entity = damage.getImmediateSource(damage_source);
  1829. if(entity == null) {
  1830. return damage.getTrueSource(damage_source);
  1831. }
  1832. return entity;
  1833. }
  1834. function player.getFromDamageSource(damage_source) {
  1835. entity = damage.getImmediateSource(damage_source);
  1836. if(isPlayer(entity)) {
  1837. return entity;
  1838. }
  1839. entity = damage.getTrueSource(damage_source);
  1840. if(isPlayer(entity)) {
  1841. return entity;
  1842. }
  1843. return null;
  1844. }
  1845. function player.getJoins(player_or_id) {
  1846. if(isPlayer(player_or_id)) {
  1847. player_id = player.getId(player_or_id);
  1848. } else {
  1849. player_id = player_or_id;
  1850. }
  1851. stmt = databank.prepare("SELECT COUNT(join_time) FROM playtime WHERE player_id = ?;");
  1852. databank.setInt(stmt, 1, player_id);
  1853. result = databank.execute(stmt);
  1854. if(databank.next(result)) {
  1855. amount = databank.getLong(result, 1);
  1856. }
  1857. databank.close(result);
  1858. databank.close(stmt);
  1859. return amount;
  1860. }
  1861. function player.getTotalPlaytime(player_or_id) {
  1862. if(isPlayer(player_or_id)) {
  1863. player_id = player.getId(player_or_id);
  1864. } else {
  1865. player_id = player_or_id;
  1866. }
  1867. //Online seit
  1868. since_minutes = 0;
  1869. if(isOnline(player.getNameFromId(player_id))) {
  1870. stmt = databank.prepare("SELECT join_time FROM playtime WHERE player_id = ? AND leave_time IS NULL;");
  1871. databank.setInt(stmt, 1, player_id);
  1872. result = databank.execute(stmt);
  1873. while(databank.next(result)) {
  1874. since_minutes = (time.getMillis() - databank.getLong(result, 1)) / 1000 / 60;
  1875. }
  1876. databank.close(result);
  1877. databank.close(stmt);
  1878. }
  1879. //Spielzeit gesamt
  1880. stmt2 = databank.prepare("SELECT SUM(leave_time - join_time) FROM playtime WHERE player_id = ?;");
  1881. databank.setInt(stmt2, 1, player_id);
  1882. result = databank.execute(stmt2);
  1883. while(databank.next(result)) {
  1884. minutes = databank.getLong(result, 1) / 1000 / 60 + since_minutes;
  1885. }
  1886. databank.close(result);
  1887. databank.close(stmt2);
  1888. return minutes;
  1889. }
  1890. function player.hasInvIgnore(player_or_id) {
  1891. config = playerdata.getSurvival(player_or_id);
  1892. return config.getBool(config, "invignore", false);
  1893. }
  1894. function player.invIgnore(player_or_id, boolean) {
  1895. config = playerdata.getSurvival(player_or_id);
  1896. config.set(config, "invignore", boolean);
  1897. config.saveAsync(config);
  1898. }
  1899. function player.getClanId(player_or_id) {
  1900. config = playerdata.getSurvival(player_or_id);
  1901. return config.getDouble(config, "clan_id", -1);
  1902. }
  1903. function player.setClanId(player_or_id, clan_id) {
  1904. config = playerdata.getSurvival(player_or_id);
  1905. config.set(config, "clan_id", clan_id);
  1906. config.saveAsync(config);
  1907. }
  1908. function player.getClanRole(player_or_id) {
  1909. config = playerdata.getSurvival(player_or_id);
  1910. temp = config.getString(config, "clan_role", "null");
  1911. if(temp == "null") {
  1912. return null;
  1913. }
  1914. return temp;
  1915. }
  1916. function player.setClanRole(player_or_id, clan_id) {
  1917. config = playerdata.getSurvival(player_or_id);
  1918. config.set(config, "clan_role", clan_id);
  1919. config.saveAsync(config);
  1920. }
  1921. function player.isInClan(player_or_id) {
  1922. return player.getClanId(player_or_id) >= 0;
  1923. }
  1924. function player.isClanLeader(player_or_id) {
  1925. return player.getClanRole(player_or_id) == "leader";
  1926. }
  1927. function player.isClanMod(player_or_id) {
  1928. return player.getClanRole(player_or_id) == "mod";
  1929. }
  1930. function player.isClanMember(player_or_id) {
  1931. return player.getClanRole(player_or_id) == "member";
  1932. }
  1933. function player.isSameClan(player_or_id_1, player_or_id_2) {
  1934. id_1 = player.getClanId(player_or_id_1);
  1935. id_2 = player.getClanId(player_or_id_2);
  1936. if(id_1 < 0 || id_2 < 0) {
  1937. return false;
  1938. }
  1939. return id_1 == id_2;
  1940. }
  1941. function player.setHeadName(player) {
  1942. nickname = player.getNickname(player);
  1943. clan_string = "";
  1944. if(player.isInClan(player)) {
  1945. clan_id = player.getClanId(player);
  1946. clan_string = text.concat(" [§6", clan.getTag(clan_id), "§r]");
  1947. }
  1948. live_string = "";
  1949. if(player.isLive(player)) {
  1950. live_string = "§f[§dLive§f] ";
  1951. }
  1952. entity.setName(player, text.concat(live_string, nickname, clan_string));
  1953. }
  1954. function player.setAdventureAmounts(player_or_id, amount) {
  1955. config = playerdata.getSurvival(player_or_id);
  1956. config.set(config, "adventures", amount);
  1957. config.saveAsync(config);
  1958. }
  1959. function player.getAdventureAmounts(player_or_id) {
  1960. config = playerdata.getSurvival(player_or_id);
  1961. return config.getDouble(config, "adventures", 0);
  1962. }
  1963. function player.isOnAdventure(player_or_id) {
  1964. config = playerdata.getSurvival(player_or_id);
  1965. return config.getBool(config, "onadventure", false);
  1966. }
  1967. function player.setAdventure(player_or_id, boolean) {
  1968. config = playerdata.getSurvival(player_or_id);
  1969. config.set(config, "onadventure", boolean);
  1970. config.saveAsync(config);
  1971. }
  1972. function player.getAdventureStart(player_or_id) {
  1973. config = playerdata.getSurvival(player_or_id);
  1974. location = config.getString(config, "adventureloc", "null");
  1975. if(location == "null") {
  1976. return world.getServerSpawn();
  1977. }
  1978. return read.location(location);
  1979. }
  1980. function player.setAdventureStart(player_or_id, location) {
  1981. config = playerdata.getSurvival(player_or_id);
  1982. config.set(config, "adventureloc", text.location(location));
  1983. config.saveAsync(config);
  1984. }
  1985. function player.isMuted(player_or_id) {
  1986. config = playerdata.getSurvival(player_or_id);
  1987. return config.getBool(config, "muted", false);
  1988. }
  1989. function player.mute(player_or_id, boolean) {
  1990. config = playerdata.getSurvival(player_or_id);
  1991. config.set(config, "muted", boolean);
  1992. config.saveAsync(config);
  1993. }
  1994. function player.getSilentJoin(player_or_id) {
  1995. config = playerdata.getSurvival(player_or_id);
  1996. return config.getBool(config, "silentjoin", false);
  1997. }
  1998. function player.setSilentJoin(player_or_id, boolean) {
  1999. config = playerdata.getSurvival(player_or_id);
  2000. config.set(config, "silentjoin", boolean);
  2001. config.saveAsync(config);
  2002. }
  2003. function player.getAutoCloseDoor(player_or_id) {
  2004. config = playerdata.getSurvival(player_or_id);
  2005. return config.getBool(config, "door_auto_close", true);
  2006. }
  2007. function player.setAutoCloseDoor(player_or_id, boolean) {
  2008. config = playerdata.getSurvival(player_or_id);
  2009. config.set(config, "door_auto_close", boolean);
  2010. config.saveAsync(config);
  2011. }
  2012. function player.getNoPetDamage(player_or_id) {
  2013. config = playerdata.getSurvival(player_or_id);
  2014. return config.getBool(config, "pet_damage", true);
  2015. }
  2016. function player.setNoPetDamage(player_or_id, boolean) {
  2017. config = playerdata.getSurvival(player_or_id);
  2018. config.set(config, "pet_damage", boolean);
  2019. config.saveAsync(config);
  2020. }
  2021. function player.getTipLoop(player_or_id) {
  2022. config = playerdata.getSurvival(player_or_id);
  2023. return config.getBool(config, "tip_loop", true);
  2024. }
  2025. function player.setTipLoop(player_or_id, boolean) {
  2026. config = playerdata.getSurvival(player_or_id);
  2027. config.set(config, "tip_loop", boolean);
  2028. config.saveAsync(config);
  2029. }
  2030. function player.setVotePoints(player_or_id, amount) {
  2031. config = playerdata.getSurvival(player_or_id);
  2032. config.set(config, "votepoints", amount);
  2033. config.saveAsync(config);
  2034. }
  2035. function player.getVotePoints(player_or_id) {
  2036. config = playerdata.getSurvival(player_or_id);
  2037. return config.getDouble(config, "votepoints", 0);
  2038. }
  2039. function player.addVotePoints(player_or_id, amount) {
  2040. config = playerdata.getSurvival(player_or_id);
  2041. points = config.getDouble(config, "votepoints", 0) + amount;
  2042. config.set(config, "votepoints", points);
  2043. config.saveAsync(config);
  2044. }
  2045. function player.hasFirstJoin(player_or_id) {
  2046. config = playerdata.getSurvival(player_or_id);
  2047. return config.getBool(config, "firstjoin", true);
  2048. }
  2049. function player.setFirstJoin(player_or_id, boolean) {
  2050. config = playerdata.getSurvival(player_or_id);
  2051. config.set(config, "firstjoin", !boolean);
  2052. config.saveAsync(config);
  2053. }
  2054. function player.getShowcoords(player_or_id) {
  2055. config = playerdata.getSurvival(player_or_id);
  2056. return config.getBool(config, "showcoords", true);
  2057. }
  2058. function player.setShowcoords(player_or_id, bool) {
  2059. config = playerdata.getSurvival(player_or_id);
  2060. config.set(config, "showcoords", bool);
  2061. config.saveAsync(config);
  2062. }
  2063. function player.getFirstJoin(player_or_id) {
  2064. if(isPlayer(player_or_id)) {
  2065. player_id = player.getId(player_or_id);
  2066. } else {
  2067. player_id = player_or_id;
  2068. }
  2069. stmt = databank.prepare("SELECT MIN(join_time) FROM playtime WHERE player_id = ?;");
  2070. databank.setInt(stmt, 1, player_id);
  2071. result = databank.execute(stmt);
  2072. if(databank.next(result)) {
  2073. time = databank.getLong(result, 1);
  2074. }
  2075. databank.close(result);
  2076. databank.close(stmt);
  2077. return time;
  2078. }
  2079. function player.getLastJoin(player_or_id) {
  2080. if(isPlayer(player_or_id)) {
  2081. player_id = player.getId(player_or_id);
  2082. } else {
  2083. player_id = player_or_id;
  2084. }
  2085. stmt = databank.prepare("SELECT MAX(join_time) FROM playtime WHERE player_id = ?;");
  2086. databank.setInt(stmt, 1, player_id);
  2087. result = databank.execute(stmt);
  2088. if(databank.next(result)) {
  2089. time = databank.getLong(result, 1);
  2090. }
  2091. databank.close(result);
  2092. databank.close(stmt);
  2093. return time;
  2094. }
  2095. function player.blockCommands(player) {
  2096. list = getScriptVar("block_commands_list");
  2097. list.add(list, player.getUuid(player));
  2098. }
  2099. function player.unblockCommands(player) {
  2100. list = getScriptVar("block_commands_list");
  2101. player_uuid = player.getUuid(player);
  2102. while(list.contains(list, player_uuid)) {
  2103. list.remove(list, player_uuid);
  2104. }
  2105. }
  2106. function player.isCommandBlocked(player) {
  2107. list = getScriptVar("block_commands_list");
  2108. return list.contains(list, player.getUuid(player));
  2109. }
  2110. function player.checkHandsForItem(player, item_or_type) {
  2111. if(text.class(item_or_type) != "String") {
  2112. item_or_type = item.getType(item_or_type);
  2113. }
  2114. hand = living.getEquip(player, "hand");
  2115. if(item.getType(hand) == item_or_type) {
  2116. return true;
  2117. }
  2118. offhand = living.getEquip(player, "offhand");
  2119. return item.getType(offhand) == item_or_type;
  2120. }
  2121. function player.checkHandsForTag(player, tag) {
  2122. hand = living.getEquip(player, "hand");
  2123. if(item.hasTag(tag, hand)) {
  2124. return true;
  2125. }
  2126. offhand = living.getEquip(player, "offhand");
  2127. return item.hasTag(tag, offhand);
  2128. }
  2129. //--------------------------------------------------
  2130. //Block-Utils
  2131. //--------------------------------------------------
  2132. function block.gotWater(block, block_type, block_loc) {
  2133. if(block_type == "minecraft:water") {
  2134. return true;
  2135. }
  2136. value = block.property.getValue(block_loc, block.getProperty("waterlogged"));
  2137. if(value == null) {
  2138. return false;
  2139. }
  2140. return value;
  2141. }
  2142. function block.getSecondDoor(door_loc_1) {
  2143. prop_h_facing = block.getProperty("horizontal_facing");
  2144. state_facing = block.property.getValue(door_loc_1, prop_h_facing);
  2145. prop_hinge = block.getProperty("hinge");
  2146. state_hinge = block.property.getValue(door_loc_1, prop_hinge);
  2147. if(state_facing == "north") {
  2148. if(state_hinge == "right") {
  2149. door_loc_2 = loc.mod(door_loc_1, -1, 0, 0);
  2150. } else {
  2151. door_loc_2 = loc.mod(door_loc_1, 1, 0, 0);
  2152. }
  2153. } elseif(state_facing == "east") {
  2154. if(state_hinge == "right") {
  2155. door_loc_2 = loc.mod(door_loc_1, 0, 0, -1);
  2156. } else {
  2157. door_loc_2 = loc.mod(door_loc_1, 0, 0, 1);
  2158. }
  2159. } elseif(state_facing == "south") {
  2160. if(state_hinge == "right") {
  2161. door_loc_2 = loc.mod(door_loc_1, 1, 0, 0);
  2162. } else {
  2163. door_loc_2 = loc.mod(door_loc_1, -1, 0, 0);
  2164. }
  2165. } else {
  2166. if(state_hinge == "right") {
  2167. door_loc_2 = loc.mod(door_loc_1, 0, 0, 1);
  2168. } else {
  2169. door_loc_2 = loc.mod(door_loc_1, 0, 0, -1);
  2170. }
  2171. }
  2172. if(block.hasTag(block.getTag("minecraft:wooden_doors"), block.get(door_loc_2))) {
  2173. if(block.isSameDoorHalf(door_loc_1, door_loc_2)) {
  2174. state_hinge_2 = block.property.getValue(door_loc_2, prop_hinge);
  2175. if(state_hinge == "left" && state_hinge_2 == "right" || state_hinge == "right" && state_hinge_2 == "left") {
  2176. return door_loc_2;
  2177. }
  2178. }
  2179. }
  2180. return null;
  2181. }
  2182. function block.isSameDoorHalf(door_loc_1, door_loc_2) {
  2183. prop_d_half = block.getProperty("double_block_half");
  2184. state_half = block.property.getValue(door_loc_1, prop_d_half);
  2185. state_half_2 = block.property.getValue(door_loc_2, prop_d_half);
  2186. return state_half == state_half_2;
  2187. }
  2188. //--------------------------------------------------
  2189. //Money-Utils
  2190. //--------------------------------------------------
  2191. function hasEnoughMoney(player_or_id, price) {
  2192. return getMoney(player_or_id) >= price;
  2193. }
  2194. function getMoney(player_or_id) {
  2195. config = playerdata.getSurvival(player_or_id);
  2196. return config.getDouble(config, "money", 0);
  2197. }
  2198. function setMoney(player_or_id, money) {
  2199. config = playerdata.getSurvival(player_or_id);
  2200. config.set(config, "money", money);
  2201. config.saveAsync(config);
  2202. player = player.getValid(player_or_id);
  2203. if(player == null) {
  2204. return;
  2205. }
  2206. displayMoney(player, money);
  2207. }
  2208. function money.getBoostFactor() {
  2209. return getScriptVar("money_factor");
  2210. }
  2211. function money.setBoostFactor(factor) {
  2212. setScriptVar("money_factor", factor);
  2213. }
  2214. function money.addBoost(player_or_id, money) {
  2215. money *= money.getBoostFactor();
  2216. player = player.getValid(player_or_id);
  2217. if(player == null) {
  2218. return;
  2219. }
  2220. if(money.getBoostFactor() > 1) {
  2221. money.popUp(player, money, true);
  2222. }
  2223. addMoney(player, money);
  2224. }
  2225. function addMoney(player_or_id, money) {
  2226. if(money == 0) {
  2227. return;
  2228. }
  2229. config = playerdata.getSurvival(player_or_id);
  2230. new_money = config.getDouble(config, "money", 0) + money;
  2231. config.set(config, "money", new_money);
  2232. config.saveAsync(config);
  2233. player = player.getValid(player_or_id);
  2234. if(player == null) {
  2235. return;
  2236. }
  2237. displayMoney(player, new_money);
  2238. money.popUp(player, money, false);
  2239. }
  2240. function subMoney(player_or_id, money) {
  2241. if(money == 0) {
  2242. return;
  2243. }
  2244. config = playerdata.getSurvival(player_or_id);
  2245. new_money = config.getDouble(config, "money", 0) - money;
  2246. config.set(config, "money", new_money);
  2247. config.saveAsync(config);
  2248. player = player.getValid(player_or_id);
  2249. if(player == null) {
  2250. return;
  2251. }
  2252. displayMoney(player, new_money);
  2253. money.popUp(player, money * -1, false);
  2254. }
  2255. function money.popUp(player, money, boosted) {
  2256. if($boost_blocker == null) {
  2257. $boost_blocker = false;
  2258. }
  2259. if($boost_blocker) {
  2260. $boost_blocker = false;
  2261. return;
  2262. }
  2263. if(money == 0) {
  2264. return;
  2265. }
  2266. if(money > 0) {
  2267. pre = "+";
  2268. }
  2269. if(money < 0) {
  2270. pre = "-";
  2271. money *= -1;
  2272. }
  2273. if(boosted) {
  2274. $boost_blocker = true;
  2275. post = " §6§k#§rBoosted§6§k#";
  2276. } else {
  2277. post = "";
  2278. }
  2279. player.action(player, concat(pre, "§6", text.number(money), " §rsnuvi", post));
  2280. }
  2281. function displayMoney(player, money) {
  2282. a = money.split(money);
  2283. display.add(player, 0, concat("#23-1- ", text.number(a[0])));
  2284. display.add(player, 1, concat("#24-1- ", text.number(a[1])));
  2285. display.add(player, 2, concat("#25-1- ", text.number(a[2])));
  2286. }
  2287. function money.split(money) {
  2288. array = array.new(3);
  2289. gold = math.roundDown(money / 4096);
  2290. pre_silver = money % 4096;;
  2291. silver = math.roundDown(pre_silver / 64);
  2292. bronze = pre_silver % 64;
  2293. array[0] = gold;
  2294. array[1] = silver;
  2295. array[2] = bronze;
  2296. return array;
  2297. }
  2298. //--------------------------------------------------
  2299. //Plot-Utils
  2300. //--------------------------------------------------
  2301. function plot.getFromId(plot_id, world) {
  2302. iter = plot.iterator(world);
  2303. while(hasNext(iter)) {
  2304. plot = next(iter);
  2305. if(plot.getId(plot) == plot_id) {
  2306. return plot;
  2307. }
  2308. }
  2309. return null;
  2310. }
  2311. function plot.calcCost(world, arg1, arg2) {
  2312. //function plot.calcCost(world, length, width) {
  2313. //function plot.calcCost(world, loc1, loc2) {
  2314. if(isDouble(arg1)) {
  2315. length = arg1;
  2316. width = arg2;
  2317. } else {
  2318. x1 = loc.getX(arg1);
  2319. z1 = loc.getZ(arg1);
  2320. x2 = loc.getX(arg2);
  2321. z2 = loc.getZ(arg2);
  2322. length = math.abs(x1 - x2) + 1;
  2323. width = math.abs(z1 - z2) + 1;
  2324. }
  2325. if(world.getName(world) == "creative") {
  2326. factor = 1;
  2327. } else {
  2328. factor = 3;
  2329. }
  2330. return length * width * factor;
  2331. }
  2332. function plot.getIdFromLocation(location) {
  2333. list = plot.get(location);
  2334. if(list.getSize(list) == 0) {
  2335. plot_id = null;
  2336. } else {
  2337. plot = list.getIndex(list, 0);
  2338. plot_id = plot.getId(plot);
  2339. }
  2340. return plot_id;
  2341. }
  2342. function plot.getIdListFromLocation(location) {
  2343. list = plot.get(location);
  2344. for(i = 0; i < list.getSize(list); i++) {
  2345. plot = list.getIndex(list, i);
  2346. list.setIndex(list, i, plot.getId(plot));
  2347. }
  2348. return list;
  2349. }
  2350. function plot.addPlayer(plot, player_name) {
  2351. list = plot.getOwners(plot);
  2352. uuid = player.getUuid(player_name);
  2353. if(!list.contains(list, uuid)) {
  2354. list.add(list, uuid);
  2355. }
  2356. }
  2357. function plot.removePlayer(plot, player_name) {
  2358. list = plot.getOwners(plot);
  2359. uuid = player.getUuid(player_name);
  2360. list.remove(list, uuid);
  2361. player_id = player.getId(player.getUuid(player_name));
  2362. plot.removeRank(plot, player_id);
  2363. }
  2364. function plot.getOwnersString(plot) {
  2365. list = plot.getOwners(plot);
  2366. if(list.getSize(list) == 0) {
  2367. return "";
  2368. }
  2369. owners_list = list.new();
  2370. for(i = 0; i < list.getSize(list); i++) {
  2371. list.add(owners_list, player.getName(list.getIndex(list, i)));
  2372. }
  2373. return text.concatList(owners_list, " / ", 0, list.getSize(owners_list) - 1);
  2374. }
  2375. function plot.isLeader(plot, player_or_id) {
  2376. return plot.getRank(plot, player_or_id) == "leader";
  2377. }
  2378. function plot.getLeaderName(plot) {
  2379. plot_leader_id = plot.getLeaderId(plot);
  2380. if(plot_leader_id == null) {
  2381. return "";
  2382. }
  2383. return player.getNameFromId(plot_leader_id);
  2384. }
  2385. function plot.getLeaderId(plot) {
  2386. plot_id = plot.getId(plot);
  2387. stmt = databank.prepare("SELECT player_id FROM plotranks WHERE plot_id = ? AND rank = ?;");
  2388. databank.setInt(stmt, 1, plot_id);
  2389. databank.setString(stmt, 2, "leader");
  2390. result = databank.execute(stmt);
  2391. while(databank.next(result)) {
  2392. player_id = databank.getInt(result, 1);
  2393. }
  2394. databank.close(result);
  2395. databank.close(stmt);
  2396. return player_id;
  2397. }
  2398. function plot.setLeader(plot, player_or_id) {
  2399. plot.setRank(plot, player_or_id, "leader");
  2400. }
  2401. function plot.isMod(plot, player_or_id) {
  2402. return plot.getRank(plot, player_or_id) == "mod";
  2403. }
  2404. function plot.getMods(plot) {
  2405. list = list.new();
  2406. plot_id = plot.getId(plot);
  2407. stmt = databank.prepare("SELECT player_id FROM plotranks WHERE plot_id = ? AND rank = ?;");
  2408. databank.setInt(stmt, 1, plot_id);
  2409. databank.setString(stmt, 2, "mod");
  2410. result = databank.execute(stmt);
  2411. while(databank.next(result)) {
  2412. list.add(list, databank.getInt(result, 1));
  2413. }
  2414. databank.close(result);
  2415. databank.close(stmt);
  2416. return list;
  2417. }
  2418. function plot.setMod(plot, player_or_id) {
  2419. plot.setRank(plot, player_or_id, "mod");
  2420. }
  2421. function plot.canOpenChests(plot, player_or_id) {
  2422. return plot.getRank(plot, player_or_id) == "chest";
  2423. }
  2424. function plot.setChest(plot, player_or_id) {
  2425. plot.setRank(plot, player_or_id, "chest");
  2426. }
  2427. function plot.getChestRanks(plot) {
  2428. list = list.new();
  2429. plot_id = plot.getId(plot);
  2430. stmt = databank.prepare("SELECT player_id FROM plotranks WHERE plot_id = ? AND rank = ?;");
  2431. databank.setInt(stmt, 1, plot_id);
  2432. databank.setString(stmt, 2, "chest");
  2433. result = databank.execute(stmt);
  2434. while(databank.next(result)) {
  2435. list.add(list, databank.getInt(result, 1));
  2436. }
  2437. databank.close(result);
  2438. databank.close(stmt);
  2439. return list;
  2440. }
  2441. function plot.getRank(plot, player_or_id) {
  2442. if(isPlayer(player_or_id)) {
  2443. player_id = player.getId(player_or_id);
  2444. } else {
  2445. player_id = player_or_id;
  2446. }
  2447. plot_id = plot.getId(plot);
  2448. stmt = databank.prepare("SELECT rank FROM plotranks WHERE player_id = ? AND plot_id = ?;");
  2449. databank.setInt(stmt, 1, player_id);
  2450. databank.setInt(stmt, 2, plot_id);
  2451. result = databank.execute(stmt);
  2452. while(databank.next(result)) {
  2453. rank = databank.getString(result, 1);
  2454. }
  2455. databank.close(result);
  2456. databank.close(stmt);
  2457. return rank;
  2458. }
  2459. function plot.setRank(plot, player_or_id, rank) {
  2460. if(isPlayer(player_or_id)) {
  2461. player_id = player.getId(player_or_id);
  2462. } else {
  2463. player_id = player_or_id;
  2464. }
  2465. plot_id = plot.getId(plot);
  2466. stmt = databank.prepare("INSERT INTO plotranks (plot_id, player_id, rank) VALUES (?,?,?) ON DUPLICATE KEY UPDATE rank = ?");
  2467. databank.setInt(stmt, 1, plot_id);
  2468. databank.setInt(stmt, 2, player_id);
  2469. databank.setString(stmt, 3, rank);
  2470. databank.setString(stmt, 4, rank);
  2471. databank.workerExecute(stmt);
  2472. }
  2473. function plot.removeRank(plot, player_or_id) {
  2474. if(isPlayer(player_or_id)) {
  2475. player_id = player.getId(player_or_id);
  2476. } else {
  2477. player_id = player_or_id;
  2478. }
  2479. plot_id = plot.getId(plot);
  2480. stmt = databank.prepare("DELETE FROM plotranks WHERE player_id = ? AND plot_id = ?;");
  2481. databank.setInt(stmt, 1, player_id);
  2482. databank.setInt(stmt, 2, plot_id);
  2483. databank.workerExecute(stmt);
  2484. }
  2485. function plot.transferRanks(old_plot_id, new_plot_id) {
  2486. stmt = databank.prepare("UPDATE plotranks SET plot_id = ? WHERE plot_id = ?;");
  2487. databank.setInt(stmt, 1, new_plot_id);
  2488. databank.setInt(stmt, 2, old_plot_id);
  2489. databank.workerExecute(stmt);
  2490. }
  2491. function plot.removeAllPlayers(plot) {
  2492. list = plot.getOwners(plot);
  2493. iter = list.iterator(list);
  2494. while(hasNext(iter)) {
  2495. plot.removeRank(plot, player.getId(next(iter)));
  2496. }
  2497. }
  2498. function plot.setEdges(plot, location1, location2) {
  2499. //Alte Daten abrufen
  2500. plot_name = plot.getName(plot);
  2501. plot_id = plot.getId(plot);
  2502. list = plot.getOwners(plot);
  2503. flags = plot.getFlags(plot);
  2504. //Neues Plot erstellen und altes Plot löschen
  2505. plot.remove(plot, loc.getWorld(location1));
  2506. new_plot = plot.add(location1, location2, plot_id);
  2507. //Alte Daten auf neuem Plot setzen
  2508. plot.transferRanks(plot.getId(plot), plot.getId(new_plot));
  2509. plot.setName(new_plot, plot_name);
  2510. new_list = plot.getOwners(new_plot);
  2511. for(i = 0; i < list.getSize(list); i++) {
  2512. list.add(new_list, list.getIndex(list, i));
  2513. }
  2514. plot.setFlags(new_plot, flags, true);
  2515. return new_plot;
  2516. }
  2517. function getFlags(plot, getActive) { //getActive = true means getActiveFlags
  2518. flags = plot.getFlags(plot);
  2519. flags_true = list.new();
  2520. flags_false = list.new();
  2521. array = array.new(2);
  2522. array[0] = 512;
  2523. array[1] = "SUB_PLOT_FLAG";
  2524. if(flags >= 512) {
  2525. list.add(flags_true, array);
  2526. flags -= 512;
  2527. } else {
  2528. list.add(flags_false, array);
  2529. }
  2530. array = array.new(2);
  2531. array[0] = 256;
  2532. array[1] = "FREE_FLAG";
  2533. if(flags >= 256) {
  2534. list.add(flags_true, array);
  2535. flags -= 256;
  2536. } else {
  2537. list.add(flags_false, array);
  2538. }
  2539. array = array.new(2);
  2540. array[0] = 128;
  2541. array[1] = "CITY_FLAG";
  2542. if(flags >= 128) {
  2543. list.add(flags_true, array);
  2544. flags -= 128;
  2545. } else {
  2546. list.add(flags_false, array);
  2547. }
  2548. array = array.new(2);
  2549. array[0] = 64;
  2550. array[1] = "EXPLOSION_FLAG";
  2551. if(flags >= 64) {
  2552. list.add(flags_true, array);
  2553. flags -= 64;
  2554. } else {
  2555. list.add(flags_false, array);
  2556. }
  2557. array = array.new(2);
  2558. array[0] = 32;
  2559. array[1] = "ENTITY_INTERACT_FLAG";
  2560. if(flags >= 32) {
  2561. list.add(flags_true, array);
  2562. flags -= 32;
  2563. } else {
  2564. list.add(flags_false, array);
  2565. }
  2566. array = array.new(2);
  2567. array[0] = 16;
  2568. array[1] = "BLOCK_INTERACT_FLAG";
  2569. if(flags >= 16) {
  2570. list.add(flags_true, array);
  2571. flags -= 16;
  2572. } else {
  2573. list.add(flags_false, array);
  2574. }
  2575. array = array.new(2);
  2576. array[0] = 8;
  2577. array[1] = "HIT_AMBIENT_FLAG";
  2578. if(flags >= 8) {
  2579. list.add(flags_true, array);
  2580. flags -= 8;
  2581. } else {
  2582. list.add(flags_false, array);
  2583. }
  2584. array = array.new(2);
  2585. array[0] = 4;
  2586. array[1] = "BUCKET_FLAG";
  2587. if(flags >= 4) {
  2588. list.add(flags_true, array);
  2589. flags -= 4;
  2590. } else {
  2591. list.add(flags_false, array);
  2592. }
  2593. array = array.new(2);
  2594. array[0] = 2;
  2595. array[1] = "BREAK_FLAG";
  2596. if(flags >= 2) {
  2597. list.add(flags_true, array);
  2598. flags -= 2;
  2599. } else {
  2600. list.add(flags_false, array);
  2601. }
  2602. array = array.new(2);
  2603. array[0] = 1;
  2604. array[1] = "PLACE_FLAG";
  2605. if(flags >= 1) {
  2606. list.add(flags_true, array);
  2607. } else {
  2608. list.add(flags_false, array);
  2609. }
  2610. if(getActive) {
  2611. return flags_true;
  2612. } else {
  2613. return flags_false;
  2614. }
  2615. }
  2616. function plot.getType(plot) {
  2617. if(plot.isCity(plot)) {
  2618. type = "§4[§cCity§4]";
  2619. } elseif(plot.isFree(plot)) {
  2620. type = "§3[§bFree§3]";
  2621. } elseif(plot.isSub(plot)) {
  2622. type = "§6[§eSubPlot§6]";
  2623. } else {
  2624. type = "§6[§ePlot§6]";
  2625. }
  2626. return type;
  2627. }
  2628. function plot.isPlot(plot) {
  2629. return !plot.isCity(plot) && !plot.isFree(plot) && !plot.isSub(plot);
  2630. }
  2631. function plot.isExplosive(plot) {
  2632. return plot.hasFlags(plot, 64);
  2633. }
  2634. function plot.isCity(plot) {
  2635. return plot.hasFlags(plot, 128);
  2636. }
  2637. function plot.isFree(plot) {
  2638. return plot.hasFlags(plot, 256);
  2639. }
  2640. function plot.isSub(plot) {
  2641. return plot.hasFlags(plot, 512);
  2642. }
  2643. function plot.setCity(plot, boolean) {
  2644. plot.setFlags(plot, 128, boolean);
  2645. }
  2646. function plot.setFree(plot, boolean) {
  2647. plot.setFlags(plot, 256, boolean);
  2648. plot.setFlags(plot, 512, !boolean); //Sub-Plot entfernen
  2649. }
  2650. function plot.setSub(plot, boolean) {
  2651. plot.setFlags(plot, 512, boolean);
  2652. plot.setFlags(plot, 256, !boolean); //Free-Plot entfernen
  2653. }
  2654. //--------------------------------------------------
  2655. //Skill-Utils
  2656. //--------------------------------------------------
  2657. function skill.getAmount(player_or_id, tech_name) {
  2658. config = playerdata.getSurvival(player_or_id);
  2659. return config.getDouble(config, tech_name, 0);
  2660. }
  2661. function skill.setAmount(player_or_id, tech_name, amount) {
  2662. config = playerdata.getSurvival(player_or_id);
  2663. config.set(config, tech_name, amount);
  2664. config.saveAsync(config);
  2665. }
  2666. function skill.addAmount(player_or_id, tech_name, amount) {
  2667. config = playerdata.getSurvival(player_or_id);
  2668. config.set(config, tech_name, config.getDouble(config, tech_name, 0) + amount);
  2669. config.saveAsync(config);
  2670. }
  2671. function skill.isActivated(player_or_id, tech_name) {
  2672. config = playerdata.getSurvival(player_or_id);
  2673. return config.getBool(config, concat(tech_name, ".active"), true);
  2674. }
  2675. function skill.setActivated(player_or_id, tech_name, bool) {
  2676. config = playerdata.getSurvival(player_or_id);
  2677. config.set(config, concat(tech_name, ".active"), bool);
  2678. }
  2679. function skill.add(skill_name, tech_name, item, description, cost, permanent, active, toggleable) {
  2680. skill = array.new(8);
  2681. skill[0] = skill_name;
  2682. skill[1] = tech_name;
  2683. skill[2] = item;
  2684. skill[3] = description;
  2685. skill[4] = cost;
  2686. skill[5] = permanent;
  2687. skill[6] = active;
  2688. skill[7] = toggleable;
  2689. list.add(getScriptVar("skills"), skill);
  2690. }
  2691. function skill.get(tech_name) {
  2692. skill_list = getScriptVar("skills");
  2693. for(i = 0; i < list.getSize(skill_list); i++) {
  2694. array = list.getIndex(skill_list, i);
  2695. temp_tech_name = array[1];
  2696. if(temp_tech_name == tech_name) {
  2697. return array;
  2698. }
  2699. }
  2700. }
  2701. function skill.getShopItem(player_or_id, tech_name) {
  2702. if(tech_name == null) {
  2703. return item.getAir();
  2704. }
  2705. skill = skill.get(tech_name);
  2706. amount = skill.getAmount(player_or_id, tech_name);
  2707. permanent = skill[5];
  2708. if(permanent) {
  2709. if(amount == 0) {
  2710. text_property = concat("§fBought: §cNo §f(Permanent)");
  2711. } else {
  2712. text_property = concat("§fBought: §aYes §f(Permanent)");
  2713. }
  2714. } else {
  2715. text_property = concat("§fAmount you have: §e", text.number(amount));
  2716. }
  2717. active = skill[6];
  2718. if(active) {
  2719. type = "§fActive skill";
  2720. } else {
  2721. type = "§fPassive skill";
  2722. }
  2723. toggleable = skill[7];
  2724. if(toggleable) {
  2725. if(skill.isActivated(player_or_id, tech_name)) {
  2726. tog = "§fToggleable: §aActive";
  2727. } else {
  2728. tog = "§fToggleable: §cInactive";
  2729. }
  2730. } else {
  2731. tog = "§fNot toggleable";
  2732. }
  2733. skill_name = skill.getName(tech_name);
  2734. item = read.item(skill[2], 1, concat("§e§o", skill_name), concat("§fCost: §e", text.number(skill[4])), skill[3], type, tog, text_property);
  2735. return item;
  2736. }
  2737. function skill.getName(tech_name) {
  2738. skill_list = getScriptVar("skills");
  2739. for(i = 0; i < list.getSize(skill_list); i++) {
  2740. array = list.getIndex(skill_list, i);
  2741. temp_tech_name = array[1];
  2742. if(temp_tech_name == tech_name) {
  2743. return array[0];
  2744. }
  2745. }
  2746. }
  2747. function skill.getTechName(skill_name) {
  2748. skill_list = getScriptVar("skills");
  2749. for(i = 0; i < list.getSize(skill_list); i++) {
  2750. array = list.getIndex(skill_list, i);
  2751. temp_skill_name = array[0];
  2752. if(temp_skill_name == skill_name) {
  2753. return array[1];
  2754. }
  2755. }
  2756. }
  2757. function skill.getItem(skill_name) {
  2758. skill_list = getScriptVar("skills");
  2759. for(i = 0; i < list.getSize(skill_list); i++) {
  2760. array = list.getIndex(skill_list, i);
  2761. temp_skill_name = array[0];
  2762. if(temp_skill_name == skill_name) {
  2763. return array[2];
  2764. }
  2765. }
  2766. }
  2767. function skill.getDescription(skill_name) {
  2768. skill_list = getScriptVar("skills");
  2769. for(i = 0; i < list.getSize(skill_list); i++) {
  2770. array = list.getIndex(skill_list, i);
  2771. temp_skill_name = array[0];
  2772. if(temp_skill_name == skill_name) {
  2773. return array[3];
  2774. }
  2775. }
  2776. }
  2777. function skill.getCost(skill_name) {
  2778. skill_list = getScriptVar("skills");
  2779. for(i = 0; i < list.getSize(skill_list); i++) {
  2780. array = list.getIndex(skill_list, i);
  2781. temp_skill_name = array[0];
  2782. if(temp_skill_name == skill_name) {
  2783. return array[4];
  2784. }
  2785. }
  2786. }
  2787. function skill.isPermanent(skill_name) {
  2788. skill_list = getScriptVar("skills");
  2789. for(i = 0; i < list.getSize(skill_list); i++) {
  2790. array = list.getIndex(skill_list, i);
  2791. temp_skill_name = array[0];
  2792. if(temp_skill_name == skill_name) {
  2793. return array[5];
  2794. }
  2795. }
  2796. }
  2797. function skill.isActive(skill_name) {
  2798. skill_list = getScriptVar("skills");
  2799. for(i = 0; i < list.getSize(skill_list); i++) {
  2800. array = list.getIndex(skill_list, i);
  2801. temp_skill_name = array[0];
  2802. if(temp_skill_name == skill_name) {
  2803. return array[6];
  2804. }
  2805. }
  2806. }
  2807. function skill.isToggleable(skill_name) {
  2808. skill_list = getScriptVar("skills");
  2809. for(i = 0; i < list.getSize(skill_list); i++) {
  2810. array = list.getIndex(skill_list, i);
  2811. temp_skill_name = array[0];
  2812. if(temp_skill_name == skill_name) {
  2813. return array[7];
  2814. }
  2815. }
  2816. }
  2817. 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) {
  2818. inv = inv.new("333333333333333333");
  2819. inv.setItem(inv, 0, skill.getShopItem(player, tech_name1));
  2820. inv.setItem(inv, 1, skill.getShopItem(player, tech_name2));
  2821. inv.setItem(inv, 2, skill.getShopItem(player, tech_name3));
  2822. inv.setItem(inv, 3, skill.getShopItem(player, tech_name4));
  2823. inv.setItem(inv, 4, skill.getShopItem(player, tech_name5));
  2824. inv.setItem(inv, 5, skill.getShopItem(player, tech_name6));
  2825. inv.setItem(inv, 6, skill.getShopItem(player, tech_name7));
  2826. inv.setItem(inv, 7, skill.getShopItem(player, tech_name8));
  2827. inv.setItem(inv, 8, skill.getShopItem(player, tech_name9));
  2828. inv.setItem(inv, 9, skill.getShopItem(player, tech_name10));
  2829. inv.setItem(inv, 10, skill.getShopItem(player, tech_name11));
  2830. inv.setItem(inv, 11, skill.getShopItem(player, tech_name12));
  2831. inv.setItem(inv, 12, skill.getShopItem(player, tech_name13));
  2832. inv.setItem(inv, 13, skill.getShopItem(player, tech_name14));
  2833. inv.setItem(inv, 14, skill.getShopItem(player, tech_name15));
  2834. inv.setItem(inv, 15, skill.getShopItem(player, tech_name16));
  2835. inv.setItem(inv, 16, skill.getShopItem(player, tech_name17));
  2836. inv.setItem(inv, 17, skill.getShopItem(player, tech_name18));
  2837. inv.open(inv, player, "Skillshop");
  2838. }
  2839. function skill.showAll(from_player_or_id, to_player) {
  2840. inv = inv.new("333333333333333333333333333");
  2841. skill_list = getScriptVar("skills");
  2842. for(i = 0; i < list.getSize(skill_list); i++) {
  2843. a = list.getIndex(skill_list, i);
  2844. tech_name = a[1];
  2845. inv.setItem(inv, i, skill.getShopItem(from_player_or_id, tech_name));
  2846. }
  2847. from_player_id = player.getValidId(from_player_or_id);
  2848. if(from_player_id == player.getValidId(to_player)) {
  2849. inv_name = "Skills";
  2850. } else {
  2851. inv_name = concat("Skills von ", player.getNameFromId(from_player_id));
  2852. }
  2853. inv.open(inv, to_player, inv_name);
  2854. }
  2855. //--------------------------------------------------
  2856. //Loc-Utils
  2857. //--------------------------------------------------
  2858. function loc.getStringColon(loc) {
  2859. world_name = world.getName(loc.getWorld(loc));
  2860. x = text.number(loc.getX(loc));
  2861. y = text.number(loc.getY(loc));
  2862. z = text.number(loc.getZ(loc));
  2863. return concat(world_name, ":", x, ":", y, ":", z);
  2864. }
  2865. function loc.getStringSpace(loc) {
  2866. world_name = world.getName(loc.getWorld(loc));
  2867. x = text.number(loc.getX(loc));
  2868. y = text.number(loc.getY(loc));
  2869. z = text.number(loc.getZ(loc));
  2870. return concat(world_name, " ", x, " ", y, " ", z);
  2871. }
  2872. function loc.isSameWorld(loc1, loc2) {
  2873. return world.getName(loc.getWorld(loc1)) == world.getName(loc.getWorld(loc2));
  2874. }
  2875. function loc.getSubPlot(location) {
  2876. list = plot.get(location);
  2877. iter = list.iterator(list);
  2878. while(hasNext(iter)) {
  2879. plot = next(iter);
  2880. if(plot.isSub(plot)) {
  2881. return plot;
  2882. }
  2883. }
  2884. return null;
  2885. }
  2886. function loc.isCity(location) {
  2887. list = plot.get(location);
  2888. iter = list.iterator(list);
  2889. while(hasNext(iter)) {
  2890. plot = next(iter);
  2891. if(plot.isCity(plot)) {
  2892. return true;
  2893. }
  2894. }
  2895. return false;
  2896. }
  2897. function loc.hasPlotId(location, plot_id) {
  2898. return list.contains(plot.getIdListFromLocation(location), plot_id);
  2899. }
  2900. function loc.hasPlotName(location, plot_name) {
  2901. list = plot.get(location);
  2902. iter = list.iterator(list);
  2903. while(hasNext(iter)) {
  2904. plot = next(iter);
  2905. if(plot.getName(plot) == plot_name) {
  2906. return true;
  2907. }
  2908. }
  2909. return false;
  2910. }
  2911. function loc.isAir(location) {
  2912. type = block.getType(location);
  2913. return type == "minecraft:air" || type == "minecraft:cave_air";
  2914. }
  2915. function loc.isInSurvWorld(location) {
  2916. world_name = world.getName(loc.getWorld(location));
  2917. if(world_name == "overworld") {
  2918. return true;
  2919. } elseif(world_name == "the_end") {
  2920. return true;
  2921. } elseif(world_name == "the_nether") {
  2922. return true;
  2923. }
  2924. return false;
  2925. }
  2926. function loc.isInGamesWorld(location) {
  2927. return loc.getWorld(location) == world.getGames();
  2928. }
  2929. function loc.isInCreativeWorld(location) {
  2930. return loc.getWorld(location) == world.getCreative();
  2931. }
  2932. function loc.isInStoryWorld(location) {
  2933. return loc.getWorld(location) == world.getStory();
  2934. }
  2935. function loc.round(location) {
  2936. world = loc.getWorld(location);
  2937. x = math.round(loc.getX(location));
  2938. y = math.round(loc.getY(location));
  2939. z = math.round(loc.getZ(location));
  2940. return loc.new(world, x, y, z);
  2941. }
  2942. //--------------------------------------------------
  2943. //Survival-Utils
  2944. //--------------------------------------------------
  2945. function living.setAi(bool) {
  2946. config = getScriptVar("server_config");
  2947. config.set(config, "spawnWithAi", bool);
  2948. config.saveAsync(config);
  2949. }
  2950. function living.getAi() {
  2951. config = getScriptVar("server_config");
  2952. return config.getBool(config, "spawnWithAi", true);
  2953. }
  2954. function living.getHand(living) {
  2955. return living.getEquip(living, "hand");
  2956. }
  2957. //--------------------------------------------------
  2958. //Afk-Utils
  2959. //--------------------------------------------------
  2960. function player.isAfk(player) {
  2961. player_uuid = player.getUuid(player);
  2962. afk_map = getScriptVar("afk_map");
  2963. return map.contains(afk_map, player_uuid);
  2964. }
  2965. function player.setAfk(player, boolean) {
  2966. player_uuid = player.getUuid(player);
  2967. afk_map = getScriptVar("afk_map");
  2968. if(boolean) {
  2969. map.add(afk_map, player_uuid, loc.getYaw(entity.getLocation(player)));
  2970. } else {
  2971. map.remove(afk_map, player_uuid);
  2972. }
  2973. }
  2974. //--------------------------------------------------
  2975. //PvP-Utils
  2976. //--------------------------------------------------
  2977. function hasPvpOn(player_or_id) {
  2978. config = playerdata.getSurvival(player_or_id);
  2979. return config.getBool(config, "pvp", false);
  2980. }
  2981. function setPvp(player_or_id, bool) {
  2982. config = playerdata.getSurvival(player_or_id);
  2983. config.set(config, "pvp", bool);
  2984. config.saveAsync(config);
  2985. }
  2986. //--------------------------------------------------
  2987. //Rank-Utils
  2988. //--------------------------------------------------
  2989. function getRank(player_or_id) {
  2990. config = playerdata.getSurvival(player_or_id);
  2991. return config.getString(config, "rank", "§3User");
  2992. }
  2993. function setRank(player_or_id, rank) {
  2994. rank = text.replace(rank, "&", "§");
  2995. config = playerdata.getSurvival(player_or_id);
  2996. config.set(config, "rank", rank);
  2997. config.saveAsync(config);
  2998. }
  2999. function offerRank(player, tech_name) {
  3000. rank = rank.getFromTechName(tech_name);
  3001. msg(player, "§r[§6Commands§r] New rank available: ", text.hover(text.click(concat("[§", rank, "§r]"), concat("/setrank ", player.getName(player), " &", rank)), "Click to set"));
  3002. }
  3003. function rank.offerClan(clan_id, tech_name) {
  3004. leader_uuid = clan.getLeader(clan_id);
  3005. leader = player.get(leader_uuid);
  3006. if(leader == null) {
  3007. mail.send("marvinius", player.getName(leader_uuid), concat("New rank available: ", tech_name));
  3008. } else {
  3009. offerRank(leader, tech_name);
  3010. }
  3011. }
  3012. function rank.checkCriteria(player, tech_name) {
  3013. //Playtime
  3014. if(tech_name == "rank.newcomer") {
  3015. return player.getTotalPlaytime(player) >= 1200; //20 Stunden
  3016. }
  3017. if(tech_name == "rank.frequenter") {
  3018. return player.getTotalPlaytime(player) >= 6000; //100 Stunden
  3019. }
  3020. if(tech_name == "rank.legend") {
  3021. return player.getTotalPlaytime(player) >= 42000; //700 Stunden
  3022. }
  3023. //Adventure
  3024. if(tech_name == "rank.adventurer") {
  3025. return player.getAdventureAmounts(player) >= 1;
  3026. }
  3027. if(tech_name == "rank.explorer") {
  3028. return player.getAdventureAmounts(player) >= 5;
  3029. }
  3030. if(tech_name == "rank.pioneer") {
  3031. return player.getAdventureAmounts(player) >= 10;
  3032. }
  3033. //Clans
  3034. if(tech_name == "rank.commander") {
  3035. if(player.isClanLeader(player)) {
  3036. clan_id = player.getClanId(player);
  3037. return clan.getMembersAmount(clan_id) >= 5;
  3038. }
  3039. }
  3040. if(tech_name == "rank.chief") {
  3041. if(player.isClanLeader(player)) {
  3042. clan_id = player.getClanId(player);
  3043. return clan.getMembersAmount(clan_id) >= 10;
  3044. }
  3045. }
  3046. if(tech_name == "rank.lord") {
  3047. if(player.isClanLeader(player)) {
  3048. clan_id = player.getClanId(player);
  3049. return clan.getMembersAmount(clan_id) >= 15;
  3050. }
  3051. }
  3052. //Quests
  3053. if(tech_name == "rank.volunteer") {
  3054. return quest.getCounter(player) >= 15;
  3055. }
  3056. if(tech_name == "rank.friend") {
  3057. return quest.getCounter(player) >= 50;
  3058. }
  3059. if(tech_name == "rank.altruist") {
  3060. return quest.getCounter(player) >= 500;
  3061. }
  3062. //Plots
  3063. if(tech_name == "rank.settler") {
  3064. return player.usedHisFreePlot(player);
  3065. }
  3066. if(tech_name == "rank.colonizer") {
  3067. return player.hasBigPlotCreated(player);
  3068. }
  3069. if(tech_name == "rank.major") {
  3070. return player.hasPlotRaised(player);
  3071. }
  3072. //Team
  3073. if(tech_name == "rank.owner") {
  3074. return perm.has(player, "isOwner");
  3075. }
  3076. if(tech_name == "rank.admin") {
  3077. return perm.has(player, "isAdmin");
  3078. }
  3079. if(tech_name == "rank.builder") {
  3080. return perm.has(player, "isBuilder");
  3081. }
  3082. if(tech_name == "rank.dev") {
  3083. return perm.has(player, "isDev");
  3084. }
  3085. if(tech_name == "rank.moderator") {
  3086. return perm.has(player, "isMod");
  3087. }
  3088. if(tech_name == "rank.supporter") {
  3089. return perm.has(player, "isSupporter");
  3090. }
  3091. //Other
  3092. if(tech_name == "rank.vip") {
  3093. return perm.has(player, "isVIP");
  3094. }
  3095. if(tech_name == "rank.influencer") {
  3096. return perm.has(player, "isYT") || perm.has(player, "isStreamer");
  3097. }
  3098. if(tech_name == "rank.sponsor") {
  3099. return perm.has(player, "isSponsor");
  3100. }
  3101. if(tech_name == "rank.user") {
  3102. return true;
  3103. }
  3104. return perm.has(player, "setrank.other");
  3105. }
  3106. function rank.getRankArray() {
  3107. return getScriptVar("ranks");
  3108. }
  3109. function rank.getFromTechName(tech_name) {
  3110. a = rank.getRankArray();
  3111. a_size = array.getSize(a);
  3112. for(i = 0; i < a_size; i++) {
  3113. if(a[i, 0] == tech_name) {
  3114. return a[i, 1];
  3115. }
  3116. }
  3117. return null;
  3118. }
  3119. function rank.getTechName(rank) {
  3120. a = rank.getRankArray();
  3121. a_size = array.getSize(a);
  3122. for(i = 0; i < a_size; i++) {
  3123. if(a[i, 1] == rank) {
  3124. return a[i, 0];
  3125. }
  3126. }
  3127. return null;
  3128. }
  3129. function rank.choose(player, tech_name) {
  3130. rank = rank.getFromTechName(tech_name);
  3131. msg(player, text.click(concat(" [§", rank, "§r]"), concat("/setrank ", player.getName(player), " &", rank)));
  3132. }
  3133. function rank.showAll(player) {
  3134. a = rank.getRankArray();
  3135. a_size = array.getSize(a);
  3136. for(i = 0; i < a_size; i++) {
  3137. tech_name = a[i, 0];
  3138. if(rank.checkCriteria(player, tech_name)) {
  3139. rank.choose(player, tech_name);
  3140. }
  3141. }
  3142. }
  3143. //--------------------------------------------------
  3144. //Perm-Utils
  3145. //--------------------------------------------------
  3146. function givePerm(player_id, perm_id) {
  3147. stmt = databank.prepare("INSERT INTO playerperms (player_id, perm_id) VALUES (?,?);");
  3148. databank.setInt(stmt, 1, player_id);
  3149. databank.setInt(stmt, 2, perm_id);
  3150. databank.workerExecute(stmt);
  3151. perm.registerPlayer(player.getUuidFromID(player_id), perm_id);
  3152. }
  3153. function removePerm(player_id, perm_id) {
  3154. stmt = databank.prepare("DELETE FROM playerperms WHERE player_id = ? AND perm_id = ?;");
  3155. databank.setInt(stmt, 1, player_id);
  3156. databank.setInt(stmt, 2, perm_id);
  3157. databank.workerExecute(stmt);
  3158. perm.unregisterPlayer(player.getUuidFromID(player_id), perm_id);
  3159. }
  3160. function removeAllPermsTemporarly(player_id) {
  3161. perm.registerPlayer(player.getUuidFromID(player_id), 8);
  3162. permslist = getPermsFromPlayer(player_id);
  3163. for(i = 0; i < list.getSize(permslist); i++) {
  3164. perm_id = list.getIndex(permslist, i);
  3165. perm.unregisterPlayer(player.getUuidFromID(player_id), perm_id);
  3166. }
  3167. }
  3168. function reloadAllPerms(player_id) {
  3169. perm.unregisterPlayer(player.getUuidFromID(player_id), 8);
  3170. permslist = getPermsFromPlayer(player_id);
  3171. for(i = 0; i < list.getSize(permslist); i++) {
  3172. perm_id = list.getIndex(permslist, i);
  3173. perm.registerPlayer(player.getUuidFromID(player_id), perm_id);
  3174. }
  3175. }
  3176. function removeAllPerms(player_id) {
  3177. permslist = getPermsFromPlayer(player_id);
  3178. for(i = 0; i < list.getSize(permslist); i++) {
  3179. removePerm(player_id, list.getIndex(permslist, i));
  3180. }
  3181. }
  3182. function getPermsFromPlayer(player_id) {
  3183. permslist = list.new();
  3184. stmt = databank.prepare("SELECT perm_id FROM playerperms WHERE player_id = ?;");
  3185. databank.setInt(stmt, 1, player_id);
  3186. result = databank.execute(stmt);
  3187. while(databank.next(result)) {
  3188. list.add(permslist, databank.getInt(result, 1));
  3189. }
  3190. databank.close(result);
  3191. databank.close(stmt);
  3192. return permslist;
  3193. }
  3194. function registerAllPerms() {
  3195. stmt = databank.prepare("SELECT * FROM playerperms;");
  3196. result = databank.execute(stmt);
  3197. while(databank.next(result)) {
  3198. player_id = databank.getInt(result, 1);
  3199. perm_id = databank.getInt(result, 2);
  3200. perm.registerPlayer(player.getUuidFromID(player_id), perm_id);
  3201. }
  3202. databank.close(result);
  3203. databank.close(stmt);
  3204. }
  3205. function perm.setGroups(permgroups) {
  3206. setScriptVar("permgroups", permgroups);
  3207. }
  3208. function perm.getGroups() {
  3209. return getScriptVar("permgroups");
  3210. }
  3211. function perm.getNameFromId(permgroup_id) {
  3212. a = perm.getGroups();
  3213. for(i = 0; i < array.getSize(a); i++) {
  3214. if(a[i, 0] == permgroup_id) {
  3215. return a[i, 1];
  3216. }
  3217. }
  3218. return null;
  3219. }
  3220. function perm.getRankFromId(permgroup_id) {
  3221. a = perm.getGroups();
  3222. for(i = 0; i < array.getSize(a); i++) {
  3223. if(a[i, 0] == permgroup_id) {
  3224. return a[i, 2];
  3225. }
  3226. }
  3227. return null;
  3228. }
  3229. function perm.getIdFromGroupname(permgroup_name) {
  3230. a = perm.getGroups();
  3231. for(i = 0; i < array.getSize(a); i++) {
  3232. if(a[i, 1] == permgroup_name) {
  3233. return a[i, 0];
  3234. }
  3235. }
  3236. return null;
  3237. }
  3238. function perm.getRankFromGroupname(permgroup_name) {
  3239. a = perm.getGroups();
  3240. for(i = 0; i < array.getSize(a); i++) {
  3241. if(a[i, 1] == permgroup_name) {
  3242. return a[i, 2];
  3243. }
  3244. }
  3245. return null;
  3246. }
  3247. function perm.isGroupName(permgroup_name) {
  3248. a = perm.getGroups();
  3249. for(i = 0; i < array.getSize(a); i++) {
  3250. if(a[i, 1] == permgroup_name) {
  3251. return true;
  3252. }
  3253. }
  3254. return false;
  3255. }
  3256. function player.hasPermGroup(player_id, perm_id) {
  3257. permslist = getPermsFromPlayer(player_id);
  3258. return list.contains(permslist, perm_id);
  3259. }
  3260. //--------------------------------------------------
  3261. //Nickname-Utils
  3262. //--------------------------------------------------
  3263. function player.setNickName(player, nickname) {
  3264. map.add(getScriptVar("nicknames"), player.getUuid(player), nickname);
  3265. }
  3266. function player.getNickName(player) {
  3267. return map.getOrDefault(getScriptVar("nicknames"), player.getUuid(player), player.getName(player));
  3268. }
  3269. function player.removeNickName(player) {
  3270. map.remove(getScriptVar("nicknames"), player.getUuid(player));
  3271. }
  3272. //--------------------------------------------------
  3273. //Mail-Utils
  3274. //--------------------------------------------------
  3275. function mail.send(from_name, to_name, message) {
  3276. server_config = getScriptVar("server_config");
  3277. mail_id = config.getDouble(server_config, "mail_id", 0) + 1;
  3278. config.set(server_config, "mail_id", mail_id);
  3279. config.saveAsync(server_config);
  3280. from_id = player.getId(player.getUuid(from_name));
  3281. to_id = player.getId(player.getUuid(to_name));
  3282. stmt = databank.prepare("INSERT INTO mails (mail_id, from_id, to_id, readed, time, message) VALUES (?, ?, ?, ?, ?, ?);");
  3283. databank.setInt(stmt, 1, mail_id);
  3284. databank.setInt(stmt, 2, from_id);
  3285. databank.setInt(stmt, 3, to_id);
  3286. databank.setBool(stmt, 4, false);
  3287. databank.setLong(stmt, 5, time.getMillis());
  3288. databank.setString(stmt, 6, message);
  3289. databank.workerExecute(stmt);
  3290. //Wenn Spieler online, dann Pushmeldung veranlassen
  3291. p = read.player(to_name);
  3292. if(p != null) {
  3293. msg.prefix(p, "§bMail", concat("§rYou´ve got a new mail from §b", from_name, "."));
  3294. }
  3295. }
  3296. function mail.checkForNew(player) {
  3297. stmt = databank.prepare("SELECT mail_id, from_id, time, message FROM mails WHERE to_id = ? AND readed = false;");
  3298. to_id = player.getId(player);
  3299. databank.setInt(stmt, 1, to_id);
  3300. result = databank.execute(stmt);
  3301. nextrow = databank.next(result);
  3302. if(!nextrow) {
  3303. databank.close(result);
  3304. databank.close(stmt);
  3305. return;
  3306. }
  3307. newmails = 0;
  3308. while(nextrow) {
  3309. newmails++;
  3310. nextrow = databank.next(result);
  3311. }
  3312. databank.close(result);
  3313. databank.close(stmt);
  3314. if(newmails > 0) {
  3315. if(newmails > 1) {
  3316. msg.prefix(player, "§bMail", concat("§rYou´ve got §b", text.number(newmails), "§r new mails."));
  3317. } else {
  3318. msg.prefix(player, "§bMail", "§rYou´ve got §b1 §rnew mail.");
  3319. }
  3320. }
  3321. }
  3322. //--------------------------------------------------
  3323. //Friend-Utils
  3324. //--------------------------------------------------
  3325. function friend.check(player_id, friend_id) {
  3326. stmt = databank.prepare("SELECT friend_id FROM friends WHERE player_id = ? AND friend_id = ?;");
  3327. databank.setInt(stmt, 1, player_id);
  3328. databank.setInt(stmt, 2, friend_id);
  3329. result = databank.execute(stmt);
  3330. temp = false;
  3331. while(databank.next(result)) {
  3332. temp = true;
  3333. }
  3334. databank.close(result);
  3335. databank.close(stmt);
  3336. return temp;
  3337. }
  3338. function friend.add(player_id, friend_id) {
  3339. nowtime = time.getMillis();
  3340. stmt1 = databank.prepare("INSERT INTO friends (player_id, friend_id, time) VALUES (?, ?, ?);");
  3341. databank.setInt(stmt1, 1, player_id);
  3342. databank.setInt(stmt1, 2, friend_id);
  3343. databank.setLong(stmt1, 3, nowtime);
  3344. databank.workerExecute(stmt1);
  3345. stmt2 = databank.prepare("INSERT INTO friends (player_id, friend_id, time) VALUES (?, ?, ?);");
  3346. databank.setInt(stmt2, 1, friend_id);
  3347. databank.setInt(stmt2, 2, player_id);
  3348. databank.setLong(stmt2, 3, nowtime);
  3349. databank.workerExecute(stmt2);
  3350. }
  3351. function friend.delete(player_id, friend_id) {
  3352. stmt1 = databank.prepare("DELETE FROM friends WHERE player_id = ? AND friend_id = ?;");
  3353. databank.setInt(stmt1, 1, player_id);
  3354. databank.setInt(stmt1, 2, friend_id);
  3355. databank.workerExecute(stmt1);
  3356. stmt2 = databank.prepare("DELETE FROM friends WHERE player_id = ? AND friend_id = ?;");
  3357. databank.setInt(stmt2, 1, friend_id);
  3358. databank.setInt(stmt2, 2, player_id);
  3359. databank.workerExecute(stmt2);
  3360. }
  3361. function friend.getList(player_id) {
  3362. list = list.new();
  3363. stmt = databank.prepare("SELECT friend_id FROM friends WHERE player_id = ?;");
  3364. databank.setInt(stmt, 1, player_id);
  3365. result = databank.execute(stmt);
  3366. while(databank.next(result)) {
  3367. friend_id = databank.getInt(result, 1);
  3368. list.add(list, player.getNameFromId(friend_id));
  3369. }
  3370. databank.close(result);
  3371. databank.close(stmt);
  3372. return list;
  3373. }
  3374. //--------------------------------------------------
  3375. //Clan-Utils
  3376. //--------------------------------------------------
  3377. function clan.getIdList() {
  3378. file = file.new("scripts/configs/clan_data");
  3379. if(file.exists(file) && file.isDirectory(file)) {
  3380. list = file.getList(file);
  3381. }
  3382. id_list = list.new();
  3383. iter = list.iterator(list);
  3384. while(hasNext(iter)) {
  3385. element = next(iter);
  3386. file_name = file.getName(element);
  3387. file_name = text.replace(file_name, ".0.snuvic", "");
  3388. list.add(id_list, read.number(file_name));
  3389. }
  3390. return id_list;
  3391. }
  3392. function clan.loadData() {
  3393. list = clan.getIdList();
  3394. iter = list.iterator(list);
  3395. map = map.new();
  3396. while(hasNext(iter)) {
  3397. clan_id = next(iter);
  3398. config = config.new("scripts/configs/clan_data", clan_id);
  3399. if(config.exists(config)) {
  3400. config.load(config);
  3401. }
  3402. map.add(map, clan_id, config);
  3403. }
  3404. setScriptVar("clan_data", map);
  3405. }
  3406. function clan.getData(clan_id) {
  3407. if(clan_id == null) {
  3408. snuvi.debug("script termed. clan_id was null");
  3409. term();
  3410. }
  3411. map = getScriptVar("clan_data");
  3412. config = map.get(map, clan_id);
  3413. if(config == null) {
  3414. config = config.new("scripts/configs/clan_data", clan_id);
  3415. if(config.exists(config)) {
  3416. config.load(config);
  3417. }
  3418. map.add(map, clan_id, config);
  3419. }
  3420. return config;
  3421. }
  3422. function clan.setName(clan_id, name) {
  3423. config = clan.getData(clan_id);
  3424. config.set(config, "name", name);
  3425. config.saveAsync(config);
  3426. }
  3427. function clan.getName(clan_id) {
  3428. config = clan.getData(clan_id);
  3429. temp = config.getString(config, "name", "null");
  3430. if(temp == "null") {
  3431. return null;
  3432. }
  3433. return temp;
  3434. }
  3435. function clan.setTag(clan_id, tag) {
  3436. config = clan.getData(clan_id);
  3437. config.set(config, "tag", tag);
  3438. config.saveAsync(config);
  3439. }
  3440. function clan.getTag(clan_id) {
  3441. config = clan.getData(clan_id);
  3442. temp = config.getString(config, "tag", "null");
  3443. if(temp == "null") {
  3444. return null;
  3445. }
  3446. return temp;
  3447. }
  3448. function clan.setMoney(clan_id, money) {
  3449. config = clan.getData(clan_id);
  3450. config.set(config, "money", money);
  3451. config.saveAsync(config);
  3452. }
  3453. function clan.getMoney(clan_id) {
  3454. config = clan.getData(clan_id);
  3455. return config.getDouble(config, "money", 0);
  3456. }
  3457. function clan.addMoney(clan_id, money) {
  3458. config = clan.getData(clan_id);
  3459. new_money = config.getDouble(config, "money", 0) + money;
  3460. config.set(config, "money", new_money);
  3461. config.saveAsync(config);
  3462. }
  3463. function clan.subMoney(clan_id, money) {
  3464. config = clan.getData(clan_id);
  3465. new_money = config.getDouble(config, "money", 0) - money;
  3466. config.set(config, "money", new_money);
  3467. config.saveAsync(config);
  3468. }
  3469. function clan.setSpawn(clan_id, location) {
  3470. config = clan.getData(clan_id);
  3471. config.set(config, "spawn", text.location(location));
  3472. config.saveAsync(config);
  3473. }
  3474. function clan.getSpawn(clan_id) {
  3475. config = clan.getData(clan_id);
  3476. location = config.getString(config, "spawn", "null");
  3477. if(location == "null") {
  3478. return null;
  3479. }
  3480. return read.location(location);
  3481. }
  3482. function clan.getIdFromName(name) {
  3483. list = clan.getIdList();
  3484. iter = list.iterator(list);
  3485. while(hasNext(iter)) {
  3486. clan_id = next(iter);
  3487. if(clan.getName(clan_id) == name) {
  3488. return clan_id;
  3489. }
  3490. }
  3491. return null;
  3492. }
  3493. function clan.getIdFromTag(clan_tag) {
  3494. list = clan.getIdList();
  3495. iter = list.iterator(list);
  3496. while(hasNext(iter)) {
  3497. clan_id = next(iter);
  3498. if(clan.getTag(clan_id) == clan_tag) {
  3499. return clan_id;
  3500. }
  3501. }
  3502. return null;
  3503. }
  3504. function clan.isExistingTag(clan_tag) {
  3505. return !(clan.getIdFromTag(clan_tag) == null);
  3506. }
  3507. function clan.isExistingName(name) {
  3508. return !(clan.getIdFromName(name) == null);
  3509. }
  3510. function clan.getNextFreeId() {
  3511. server_config = getScriptVar("server_config");
  3512. id = config.getDouble(server_config, "clan.id.next", 0) + 1;
  3513. config.set(server_config, "clan.id.next", id);
  3514. config.saveAsync(server_config);
  3515. return id;
  3516. }
  3517. function clan.create(name, tag) {
  3518. clan_id = clan.getNextFreeId();
  3519. config = clan.getData(clan_id);
  3520. config.set(config, "name", name);
  3521. config.set(config, "tag", tag);
  3522. config.set(config, "members", 0);
  3523. config.save(config);
  3524. return clan_id;
  3525. }
  3526. function clan.getLeader(clan_id) {
  3527. list = clan.getMembersList(clan_id);
  3528. iter = list.iterator(list);
  3529. while(hasNext(iter)) {
  3530. player_uuid = next(iter);
  3531. player_id = player.getId(player_uuid);
  3532. if(player.isClanLeader(player_id)) {
  3533. return player_uuid;
  3534. }
  3535. }
  3536. return null;
  3537. }
  3538. function clan.getMembersAmount(clan_id) {
  3539. config = clan.getData(clan_id);
  3540. return config.getDouble(config, "members", 0);
  3541. }
  3542. function clan.setMembersAmount(clan_id, amount) {
  3543. config = clan.getData(clan_id);
  3544. config.set(config, "members", amount);
  3545. config.saveAsync(config);
  3546. }
  3547. function clan.addMember(clan_id, player_or_id, role) {
  3548. //Player
  3549. player.setClanId(player_or_id, clan_id);
  3550. player.setClanRole(player_or_id, role);
  3551. //Clan
  3552. new_amount = clan.getMembersAmount(clan_id) + 1;
  3553. if(isPlayer(player_or_id)) {
  3554. player_uuid = player.getUuid(player_or_id);
  3555. } else {
  3556. player_uuid = player.getUuidFromId(player_or_id);
  3557. }
  3558. config = clan.getData(clan_id);
  3559. config.set(config, text.concat("player_", new_amount), text(player_uuid));
  3560. config.set(config, "members", new_amount);
  3561. config.saveAsync(config);
  3562. }
  3563. function clan.removeMember(clan_id, player_or_id) {
  3564. //Player
  3565. player.setClanId(player_or_id, -1);
  3566. player.setClanRole(player_or_id, "null");
  3567. if(isPlayer(player_or_id)) {
  3568. player_uuid = player.getUuid(player_or_id);
  3569. } else {
  3570. player_uuid = player.getUuidFromId(player_or_id);
  3571. }
  3572. //Clan
  3573. config = clan.getData(clan_id);
  3574. amount = config.getDouble(config, "members", 0);
  3575. for(i = 1; i <= amount; i++) {
  3576. if(config.getString(config, text.concat("player_", i), "null") == text(player_uuid)) {
  3577. break;
  3578. }
  3579. }
  3580. if(i != amount) {
  3581. config.set(config, text.concat("player_", i), config.getString(config, text.concat("player_", amount), "null"));
  3582. }
  3583. config.set(config, text.concat("player_", amount), "null");
  3584. config.set(config, "members", amount - 1);
  3585. config.saveAsync(config);
  3586. }
  3587. function clan.delete(clan_id) {
  3588. //Members
  3589. list = clan.getMembersList(clan_id);
  3590. iter = list.iterator(list);
  3591. while(hasNext(iter)) {
  3592. player_uuid = next(iter);
  3593. player_id = player.getId(player_uuid);
  3594. player.setClanId(player_id, -1);
  3595. player.setClanRole(player_id, "null");
  3596. }
  3597. //Clan
  3598. config.delete(clan.getData(clan_id));
  3599. map.remove(getScriptVar("clan_data"), clan_id);
  3600. }
  3601. function clan.getMembersList(clan_id) {
  3602. list = list.new();
  3603. config = clan.getData(clan_id);
  3604. amount = config.getDouble(config, "members", 0);
  3605. for(i = 1; i <= amount; i++) {
  3606. player_uuid = read.uuid(config.getString(config, text.concat("player_", i), "null"));
  3607. list.add(list, player_uuid);
  3608. }
  3609. return list;
  3610. }
  3611. function clan.updateHeadNames(clan_id) {
  3612. list = clan.getMembersList(clan_id);
  3613. iter = list.iterator(list);
  3614. while(hasNext(iter)) {
  3615. p = player.get(next(iter));
  3616. if(p != null) {
  3617. player.setHeadName(p);
  3618. }
  3619. }
  3620. }
  3621. function clan.msg(clan_id, message) {
  3622. list = clan.getMembersList(clan_id);
  3623. iter = list.iterator(list);
  3624. while(hasNext(iter)) {
  3625. p = player.get(next(iter));
  3626. if(p != null) {
  3627. msg.prefix(p, "§2Clan", message);
  3628. }
  3629. }
  3630. }
  3631. function clan.mail(clan_id, from_name, message) {
  3632. list = clan.getMembersList(clan_id);
  3633. iter = list.iterator(list);
  3634. while(hasNext(iter)) {
  3635. to_name = player.getName(next(iter));
  3636. mail.send(from_name, to_name, message);
  3637. }
  3638. }
  3639. //--------------------------------------------------
  3640. //Party-Utils
  3641. //--------------------------------------------------
  3642. function player.isInParty(player) {
  3643. return player.getPartyId(player) != null;
  3644. }
  3645. function party.same(player1, player2) {
  3646. return player.getPartyId(player1) == player.getPartyId(player2);
  3647. }
  3648. function player.isPartyLeader(player) {
  3649. return player.getPartyRank(player) == "Leader";
  3650. }
  3651. function player.isPartyLeaderOrMod(player) {
  3652. return player.getPartyRank(player) != "Player";
  3653. }
  3654. function player.getPartyId(player) {
  3655. return map.get(getScriptVar("party_ids"), player.getUuid(player));
  3656. }
  3657. function player.setPartyId(player, party_id) {
  3658. map.add(getScriptVar("party_ids"), player.getUuid(player), party_id);
  3659. }
  3660. function player.delPartyId(player) {
  3661. map.remove(getScriptVar("party_ids"), player.getUuid(player));
  3662. }
  3663. function player.getPartyRank(player) {
  3664. return map.get(getScriptVar("party_ranks"), player.getUuid(player));
  3665. }
  3666. function player.setPartyRank(player, rank) {
  3667. map.add(getScriptVar("party_ranks"), player.getUuid(player), rank);
  3668. }
  3669. function player.delPartyRank(player) {
  3670. map.remove(getScriptVar("party_ranks"), player.getUuid(player));
  3671. }
  3672. function party.getList(party_id) {
  3673. return map.get(getScriptVar("party_lists"), party_id);
  3674. }
  3675. function party.setList(party_id, list) {
  3676. map = getScriptVar("party_lists");
  3677. map.add(map, party_id, list);
  3678. setScriptVar("party_lists", map);
  3679. }
  3680. function party.addPlayer(party_id, player) {
  3681. list.add(party.getList(party_id), player.getUuid(player));
  3682. player.setPartyId(player, party_id);
  3683. }
  3684. //--------------------------------------------------
  3685. //Scheduler-Utils
  3686. //--------------------------------------------------
  3687. function scheduler.add(data_array) {
  3688. list.add(getScriptVar("scheduler_list"), data_array);
  3689. }
  3690. function scheduler.addFly(ticks, player, bool) {
  3691. a = array.new(4);
  3692. a[0] = 0;
  3693. a[1] = ticks;
  3694. a[2] = player;
  3695. a[3] = bool;
  3696. scheduler.add(a);
  3697. }
  3698. function scheduler.msgPrefix(ticks, player, prefix, message) {
  3699. a = array.new(5);
  3700. a[0] = 1;
  3701. a[1] = ticks;
  3702. a[2] = player;
  3703. a[3] = prefix;
  3704. a[4] = message;
  3705. scheduler.add(a);
  3706. }
  3707. function scheduler.msg(ticks, player, message) {
  3708. a = array.new(4);
  3709. a[0] = 2;
  3710. a[1] = ticks;
  3711. a[2] = player;
  3712. a[3] = message;
  3713. scheduler.add(a);
  3714. }
  3715. function scheduler.setBlock(ticks, location, item_string, block_update) {
  3716. a = array.new(5);
  3717. a[0] = 3;
  3718. a[1] = ticks;
  3719. a[2] = location;
  3720. a[3] = item_string;
  3721. a[4] = block_update;
  3722. scheduler.add(a);
  3723. }
  3724. function scheduler.questFinish(ticks, script, player) {
  3725. a = array.new(4);
  3726. a[0] = 4;
  3727. a[1] = ticks;
  3728. a[2] = script;
  3729. a[3] = player;
  3730. scheduler.add(a);
  3731. }
  3732. function scheduler.setBurning(ticks, entity, seconds) {
  3733. a = array.new(4);
  3734. a[0] = 5;
  3735. a[1] = ticks;
  3736. a[2] = entity;
  3737. a[3] = seconds;
  3738. scheduler.add(a);
  3739. }
  3740. function scheduler.spawnEntity(ticks, type, location) {
  3741. a = array.new(4);
  3742. a[0] = 6;
  3743. a[1] = ticks;
  3744. a[2] = type;
  3745. a[3] = location;
  3746. scheduler.add(a);
  3747. }
  3748. function scheduler.removeEntity(ticks, entity) {
  3749. a = array.new(3);
  3750. a[0] = 7;
  3751. a[1] = ticks;
  3752. a[2] = entity;
  3753. scheduler.add(a);
  3754. }
  3755. function scheduler.giveItem(ticks, player, item) {
  3756. a = array.new(4);
  3757. a[0] = 8;
  3758. a[1] = ticks;
  3759. a[2] = player;
  3760. a[3] = item;
  3761. scheduler.add(a);
  3762. }
  3763. function scheduler.giveSingleItem(ticks, player, item, boolean) {
  3764. a = array.new(5);
  3765. a[0] = 9;
  3766. a[1] = ticks;
  3767. a[2] = player;
  3768. a[3] = item;
  3769. a[4] = boolean;
  3770. scheduler.add(a);
  3771. }
  3772. //--------------------------------------------------
  3773. //Hawkeye-Utils
  3774. //--------------------------------------------------
  3775. function hawkeye.getData(timeFrom, timeTo, location, radius, events, players, order) {
  3776. base_query = "SELECT * FROM hawkeye WHERE ";
  3777. and_query = " AND ";
  3778. //Events
  3779. where_query = hawkeye.getEventQuery(events);
  3780. if(where_query == -1) {
  3781. return "False input at e:";
  3782. }
  3783. //Players
  3784. player_query = hawkeye.getPlayerQuery(players);
  3785. if(player_query == -1) {
  3786. return "False input at p:";
  3787. }
  3788. if(text.length(where_query) == 0) {
  3789. where_query = player_query;
  3790. } elseif(text.length(player_query) != 0) {
  3791. where_query = concat(where_query, and_query, player_query);
  3792. }
  3793. //Location
  3794. location_query = hawkeye.getLocationQuery(location, radius);
  3795. if(text.length(where_query) == 0) {
  3796. where_query = location_query;
  3797. } elseif(text.length(location_query) != 0) {
  3798. where_query = concat(where_query, and_query, location_query);
  3799. }
  3800. //Time
  3801. time_query = hawkeye.getTimeQuery(timeFrom, timeTo);
  3802. if(text.length(where_query) == 0) {
  3803. where_query = time_query;
  3804. } elseif(text.length(time_query) != 0) {
  3805. where_query = concat(where_query, and_query, time_query);
  3806. }
  3807. //Safety check
  3808. if(text.length(where_query) == 0) {
  3809. return "No parameters found";
  3810. }
  3811. //Final Statement
  3812. stmt = databank.prepare(concat(base_query, where_query, " ORDER BY time ", order, ";"));
  3813. index = 1;
  3814. if(events != null) {
  3815. iter = list.iterator(events);
  3816. while(hasNext(iter)) {
  3817. databank.setString(stmt, index, next(iter));
  3818. index++;
  3819. }
  3820. }
  3821. if(players != null) {
  3822. iter = list.iterator(players);
  3823. while(hasNext(iter)) {
  3824. databank.setInt(stmt, index, player.getId(player.getUuid(next(iter))));
  3825. index++;
  3826. }
  3827. }
  3828. if(location != null && radius != null) {
  3829. databank.setInt(stmt, index++, loc.getX(location));
  3830. databank.setInt(stmt, index++, loc.getY(location));
  3831. databank.setInt(stmt, index++, loc.getZ(location));
  3832. databank.setInt(stmt, index++, radius);
  3833. }
  3834. if(timeFrom != null && timeTo != null) {
  3835. databank.setLong(stmt, index++, timeFrom);
  3836. databank.setLong(stmt, index++, timeTo);
  3837. }
  3838. l = list.new();
  3839. result = databank.execute(stmt);
  3840. while(databank.next(result)) {
  3841. a = array.new(6);
  3842. id = databank.getInt(result, 1);
  3843. a[0] = id; //id
  3844. a[1] = databank.getInt(result, 2); //player_id
  3845. a[2] = databank.getString(result, 3); //event
  3846. a[3] = loc.new(world.get(databank.getString(result, 4)), databank.getInt(result, 5), databank.getInt(result, 6), databank.getInt(result, 7)); //location
  3847. a[4] = databank.getLong(result, 8); //time
  3848. a[5] = databank.getString(result, 9); //text
  3849. list.add(l, a);
  3850. }
  3851. databank.close(result);
  3852. databank.close(stmt);
  3853. return l;
  3854. }
  3855. function hawkeye.getEventQuery(events) {
  3856. if(events == null) {
  3857. return "";
  3858. }
  3859. query = "event IN(";
  3860. c = 0;
  3861. iter = list.iterator(events);
  3862. while(hasNext(iter)) {
  3863. event = next(iter);
  3864. if(event != "block_break" && event != "block_place") {
  3865. return -1;
  3866. }
  3867. if(c == 0) {
  3868. query = concat(query, "?");
  3869. } else {
  3870. query = concat(query, ",?");
  3871. }
  3872. c++;
  3873. }
  3874. return concat(query, ")");
  3875. }
  3876. function hawkeye.getPlayerQuery(players) {
  3877. if(players == null) {
  3878. return "";
  3879. }
  3880. query = "player_id IN(";
  3881. c = 0;
  3882. iter = list.iterator(players);
  3883. while(hasNext(iter)) {
  3884. player_name = next(iter);
  3885. player_uuid = player.getUuid(player_name);
  3886. if(player_uuid == null) {
  3887. return -1;
  3888. }
  3889. if(c == 0) {
  3890. query = concat(query, "?");
  3891. } else {
  3892. query = concat(query, ",?");
  3893. }
  3894. c++;
  3895. }
  3896. return concat(query, ")");
  3897. }
  3898. function hawkeye.getLocationQuery(player_loc, radius) {
  3899. if(player_loc == null || radius == null) {
  3900. return "";
  3901. }
  3902. return "POWER(x - ?, 2) + POWER(y - ?, 2) + POWER(z - ?, 2) < POWER(?, 2)";
  3903. }
  3904. function hawkeye.getTimeQuery(timeFrom, timeTo) {
  3905. if(timeFrom == null || timeTo == null) {
  3906. return "";
  3907. }
  3908. return "time > ? AND time < ?";
  3909. }
  3910. function hawkeye.print(player, list, side) {
  3911. amount = list.getSize(list);
  3912. a = list.getIndex(list, side - 1);
  3913. msg.prefix(player, "§cHawkeye", concat("§7----- Page (§c", text.number(side), "§7/§c", text.number(amount), "§7) -----"));
  3914. msg(player, concat("§7| ID:", text.number(a[0]), " ", getTimeString(a[4])));
  3915. msg(player, concat("§7| §c", hawkeye.getEventName(read.number(a[2])), " ", player.getNameFromId(a[1])));
  3916. msg(player, concat("§7| ", loc.getStringSpace(a[3])));
  3917. msg(player, concat("§7| ", a[5]));
  3918. if(side == 1) {
  3919. backward = "§7<<<<";
  3920. if(amount == 1) {
  3921. forward = "§7>>>>";
  3922. } else {
  3923. forward = text.click("§c>>>>", concat("/hawkeye print ", side + 1));
  3924. }
  3925. } elseif(side >= amount) {
  3926. backward = text.click("§c<<<<", concat("/hawkeye print ", side - 1));
  3927. forward = "§7>>>>";
  3928. } else {
  3929. backward = text.click("§c<<<<", concat("/hawkeye print ", side - 1));
  3930. forward = text.click("§c>>>>", concat("/hawkeye print ", side + 1));
  3931. }
  3932. msg(player, backward, " ", forward);
  3933. msg(player, "§7-----------------------------");
  3934. }
  3935. function hawkeye.setDataList(player, list) {
  3936. map.add(getScriptVar("ha_data_lists"), player.getUuid(player), list);
  3937. }
  3938. function hawkeye.getDataList(player) {
  3939. return map.get(getScriptVar("ha_data_lists"), player.getUuid(player));
  3940. }
  3941. function hawkeye.setUndoList(player, list) {
  3942. map.add(getScriptVar("ha_undo_lists"), player.getUuid(player), list);
  3943. }
  3944. function hawkeye.getUndoList(player) {
  3945. return map.get(getScriptVar("ha_undo_lists"), player.getUuid(player));
  3946. }
  3947. function hawkeye.rollback(list) {
  3948. counter = 0;
  3949. for(i = 0; i < list.getSize(list); i++) {
  3950. a = list.getIndex(list, i);
  3951. event = a[2];
  3952. loc = a[3];
  3953. if(event == "1") {
  3954. block.set(loc, a[5], true);
  3955. counter++;
  3956. } elseif(event == "2") {
  3957. block.set(loc, "minecraft:air", true);
  3958. counter++;
  3959. }
  3960. }
  3961. return counter;
  3962. }
  3963. function hawkeye.undo(list) {
  3964. for(i = list.getSize(list) - 1; i >= 0; i--) {
  3965. a = list.getIndex(list, i);
  3966. event = a[2];
  3967. loc = a[3];
  3968. if(event == "1") {
  3969. block.set(loc, "minecraft:air", true);
  3970. } elseif(event == "2") {
  3971. block.set(loc, a[5], true);
  3972. }
  3973. }
  3974. }
  3975. //--------------------------------------------------
  3976. //
  3977. //--------------------------------------------------
  3978. function yeet (player, strength){
  3979. array = entity.getLook(player);
  3980. x = array[0] * (math.log(strength)+1);
  3981. y = math.abs(array[1]) * (math.log(strength)+1);
  3982. z = array[2] * (math.log(strength)+1);
  3983. entity.throw(player, x, y, z);
  3984. }