u_general.txt 112 KB

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