u_general.txt 114 KB

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