u_general.txt 99 KB

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