123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373 |
- function snuvi.debug(message) {
- msg("dev", concat("[§eDebug§r] ", message));
- }
- function perm.no(player, perm) {
- player.speak(player, "§6§zPerms", "You have no permission for §c", perm, "§r.");
- }
- function checkIfEverOnline(player_name) {
- if(player.getUuid(player_name) == null) {
- return false;
- }
- return true;
- }
- function isOnline(player_name) {
- if(read.player(player_name) == null) {
- return false;
- }
- return true;
- }
- function map.sort(map, ascending) {
- map_size = map.getSize(map);
- my_array = array.new(map_size, 2);
- //Map in 2 Arrays verwandeln
- i = 0;
- iter = map.iterator(map);
- while(hasNext(iter)) {
- element = next(iter);
- key = map.getKey(element);
- value = map.getValue(element);
- my_array[i, 0] = key;
- my_array[i, 1] = value;
- i++;
- }
- //Array sortieren
- if(ascending) {
- for(i = 0; i < map_size - 1; i++) {
- for(j = i + 1; j < map_size; j++) {
- if(my_array[j, 1] < my_array[i, 1]) {
- g = my_array[i, 0];
- h = my_array[i, 1];
- my_array[i, 0] = my_array[j, 0];
- my_array[i, 1] = my_array[j, 1];
- my_array[j, 0] = g;
- my_array[j, 1] = h;
- }
- }
- }
- } else {
- for(i = 0; i < map_size - 1; i++) {
- for(j = i + 1; j < map_size; j++) {
- if(my_array[j, 1] > my_array[i, 1]) {
- g = my_array[i, 0];
- h = my_array[i, 1];
- my_array[i, 0] = my_array[j, 0];
- my_array[i, 1] = my_array[j, 1];
- my_array[j, 0] = g;
- my_array[j, 1] = h;
- }
- }
- }
- }
- return my_array;
- }
- function getSpacer() {
- return("§0-------------------------------------------------");
- }
- function getDirection(yaw) {
- while(yaw < 0) {
- yaw += 360;
- }
- while(yaw >= 360) {
- yaw -= 360;
- }
- if(yaw > 60 && yaw < 120) {
- direction = "west";
- } elseif(yaw > 150 && yaw < 210) {
- direction = "north";
- } elseif(yaw > 240 && yaw < 300) {
- direction = "east";
- } elseif(yaw > 330 || yaw < 30) {
- direction = "south";
- } else {
- return null;
- }
- return direction;
- }
- function correctTimeFormat(textnumber) {
- if(text.length(textnumber) == 1) {
- textnumber = concat("0", textnumber);
- }
- return textnumber;
- }
- function isGamesWorldName(world_name) {
- return world_name == "games";
- }
- function isSurvWorldName(world_name) {
- if(world_name == "overworld") {
- return true;
- } elseif(world_name == "the_end") {
- return true;
- } elseif(world_name == "the_nether") {
- return true;
- }
- return false;
- }
- function safeGiveItemPlayer(player, item) {
- rest_item = player.giveItem(player, item);
- item.drop(entity.getLocation(player), rest_item);
- }
- function setBlockIfNotAir(location, block) {
- if(block.getType(location) == "minecraft:air") {
- block.set(location, block, true);
- return true;
- }
- return false;
- }
- function teleportPlayer(player, location, backPos) { //Deprecated
- return player.teleport(player, location, backPos);
- }
- function player.teleport(player, location, backPos) {
- if(player.isOnAdventure(player)) {
- msg(player, "[§5Adventure§r] Teleport blocked. ", text.click("[§5Cancel Adventure?§r]", concat("/stopadventure ", player)));
- return false;
- }
- if(backPos) {
- player.setBackPos(player);
- }
- inv.checkForChange(player, location);
- entity.teleport(player, location);
- world = loc.getWorld(location);
- display.reset(player);
- entity.setName(player, player.getName(player));
- world_name = world.getName(world);
- if(isGamesWorldName(world_name)) {
- joinGamesWorld(player);
- }
- if(isSurvWorldName(world_name)) {
- joinSurvWorld(player);
- }
- if(world.isCreativeWorldName(world_name)) {
- world.joinCreative(player);
- }
- //Tabliste
- nickname = player.getNickName(player);
- if(isAfk(player)) {
- player.setDisplayName(player, concat("§7§m", nickname));
- } else {
- rank = getRank(player.getId(player));
- colorcode = text.subString(rank, 0, 2);
- player.setDisplayName(player, concat(colorcode, nickname));
- }
- return true;
- }
- function getBlockLocation(location) {
- world = loc.getWorld(location, "w");
- bx = loc.getCoord(location, "bx");
- by = loc.getCoord(location, "by");
- bz = loc.getCoord(location, "bz");
- return loc.new(world, bx, by, bz);
- }
- function getDateString(time) {
- calendar = time.new(time);
- return concat(text.number(time.getDay(calendar)), ".", text.number(time.getMonth(calendar)), ".", text.number(time.getYear(calendar)));
- }
- function time.getClockString(time) {
- return concat(text.number(math.roundDown(time / 60)), " min ", text.number(math.round(time % 60)), " s");
- }
- function getTimeString(millis) {
- calendar = time.new(millis);
- day = time.getDay(calendar);
- month = time.getMonth(calendar);
- year = time.getYear(calendar);
- hour = time.getHour(calendar);
- minute = time.getMinute(calendar);
- if(month < 10) {
- month = concat("0", text.number(month));
- } else {
- month = text.number(month);
- }
- if(day < 10) {
- day = concat("0", text.number(day));
- } else {
- day = text.number(day);
- }
- if(hour < 10) {
- hour = concat("0", text.number(hour));
- } else {
- hour = text.number(hour);
- }
- if(minute < 10) {
- minute = concat("0", text.number(minute));
- } else {
- minute = text.number(minute);
- }
- timestring = concat(day, ".", month, ".", text.number(year), " ", hour, ":", minute);
- return timestring;
- }
- function player.hasMinigame(player) {
- id_set = player.getMinigameIds(player);
- if(set.getSize(id_set) > 0) {
- return true;
- }
- return false;
- }
- function player.getMinigameIds(player) {
- set = data.get(player, "minigames_set");
- if(set == null) {
- set = set.new();
- data.set(player, "minigames_set", set);
- }
- return set;
- }
- function tjr.getWholeModule(player_or_id) {
- if(isPlayer(player_or_id)) {
- player_or_id = player.getId(player_or_id);
- }
- return ranking.getPoints("tjrranks", player_or_id);
- }
- //Gibt die Rekord-Punkte eines Spielers zurück
- function ranking.getPoints(rankingtable, player_id) {
- stmt = databank.prepare(concat("SELECT points FROM ", rankingtable, " WHERE player_id = ?;"));
- databank.setInt(stmt, 1, player_id);
- result = databank.execute(stmt);
- if(databank.next(result)) {
- points = databank.getInt(result, 1);
- } else {
- points = 0;
- }
- databank.close(result);
- databank.close(stmt);
- return points;
- }
- //--------------------------------------------------
- //World-Utils
- //--------------------------------------------------
- function getGamesWorld() { //Deprecated
- return world.getGames();
- }
- function world.getServerSpawn() {
- return read.location(config.getString(getScriptVar("server_config"), "serverspawn", "games:0:0:0"));
- }
- function world.getGamesSpawn() {
- return read.location(config.getString(getScriptVar("server_config"), "gamesspawn", "games:0:0:0"));
- }
- function world.getCreativeSpawn() {
- return read.location(config.getString(getScriptVar("server_config"), "creativespawn", "games:0:0:0"));
- }
- function world.getOverWorld() {
- return world.get("overworld");
- }
- function world.getGames() {
- return world.get("games");
- }
- function world.getCreative() {
- return world.get("creative");
- }
- function world.joinCreative(player) {
-
- }
- function world.isCreativeWorldName(world_name) {
- return world_name == "creative";
- }
- //--------------------------------------------------
- //Inv-Utils
- //--------------------------------------------------
- function inv.checkForChange(player, location) {
- from_world = loc.getWorld(entity.getLocation(player));
- to_world = loc.getWorld(location);
- //Wenn ignore aktiviert --> kein Wechsel
- ignore = player.hasInvIgnore(player);
- if(ignore == null) {
- ignore = false;
- }
- if(ignore) {
- return;
- }
- from_world_name = world.getName(from_world);
- to_world_name = world.getName(to_world);
- //Wenn in selber Welt --> kein Wechsel
- if(from_world == to_world) {
- return;
- }
- //Wenn beide Welten in derselben Liste sind --> kein Wechsel
- if(isSurvWorldName(from_world_name) && isSurvWorldName(to_world_name)) {
- return;
- }
- //Weltwechsel
- entity.clearEffects(player);
- inv.saveForPlayer(player, player, from_world);
- inv.loadFromPlayer(player, player, to_world);
- if(!perm.has(player, "isTeam")) {
- if(!player.isSpectator(player)) {
- if(to_world_name == "creative") {
- gm = "creative";
- } else {
- gm = "survival";
- }
- player.setGamemode(player, gm);
- }
- }
- }
- function inv.saveForPlayer(sec_player, for_player_or_id, world) {
- if(isPlayer(for_player_or_id)) {
- for_player_or_id = player.getId(for_player_or_id);
- }
- world_name = world.getName(world);
- if(isSurvWorldName(world_name)) {
- pfad = "scripts/configs/default";
- } else {
- pfad = concat("scripts/configs/", world_name);
- }
- config = config.new(pfad, for_player_or_id);
-
- //Allgemeine Daten
- if(for_player_or_id == player.getId(sec_player)) {
- config.set(config, "health", entity.getHealth(sec_player));
- config.set(config, "hunger", player.getHunger(sec_player));
- config.set(config, "saturation", player.getSaturation(sec_player));
- config.set(config, "xp", player.getExp(sec_player));
- config.set(config, "lvl", player.getLevel(sec_player));
- }
-
- //Inventare
- for(i = 0; i <= 35; i++) {
- config.set(config, concat("slot-", i), text.item(player.getInvSlot(sec_player, i)));
- }
- for(i = 0; i <= 26; i++) {
- config.set(config, concat("eslot-", i), text.item(player.getEnderSlot(sec_player, i)));
- }
- config.set(config, "offhand", text.item(entity.getEquip(sec_player, "offhand")));
- config.set(config, "head", text.item(entity.getEquip(sec_player, "head")));
- config.set(config, "chest", text.item(entity.getEquip(sec_player, "chest")));
- config.set(config, "legs", text.item(entity.getEquip(sec_player, "legs")));
- config.set(config, "feet", text.item(entity.getEquip(sec_player, "feet")));
-
- config.save(config);
- }
- function inv.loadFromPlayer(sec_player, from_player_or_id, world) {
- if(isPlayer(from_player_or_id)) {
- from_player_or_id = player.getId(from_player_or_id);
- }
- world_name = world.getName(world);
- if(isSurvWorldName(world_name)) {
- pfad = "scripts/configs/default";
- } else {
- pfad = concat("scripts/configs/", world_name);
- }
- config = config.new(pfad, from_player_or_id);
-
- if(!config.exists(config)) {
- return;
- }
- config.load(config);
-
- //Allgemeine Daten
- if(from_player_or_id == player.getId(sec_player)) {
- entity.setHealth(sec_player, config.getDouble(config, "health", 20));
- player.setHunger(sec_player, config.getDouble(config, "hunger", 20));
- player.setSaturation(sec_player, config.getDouble(config, "saturation", 5));
- player.setExp(sec_player, config.getDouble(config, "xp", 0));
- player.setLevel(sec_player, config.getDouble(config, "lvl", 0));
- }
-
- //Inventare
- for(i = 0; i <= 35; i++) {
- player.setInvSlot(sec_player, i, read.item(config.getString(config, concat("slot-", i), "minecraft:air")));
- }
- for(i = 0; i <= 26; i++) {
- player.setEnderSlot(sec_player, i, read.item(config.getString(config, concat("eslot-", i), "minecraft:air")));
- }
- entity.setEquip(sec_player, "offhand", read.item(config.getString(config, "offhand", "minecraft:air")));
- entity.setEquip(sec_player, "head", read.item(config.getString(config, "head", "minecraft:air")));
- entity.setEquip(sec_player, "chest", read.item(config.getString(config, "chest", "minecraft:air")));
- entity.setEquip(sec_player, "legs", read.item(config.getString(config, "legs", "minecraft:air")));
- entity.setEquip(sec_player, "feet", read.item(config.getString(config, "feet", "minecraft:air")));
- }
- //--------------------------------------------------
- //Text-Utils
- //--------------------------------------------------
- function text.upperFirstLetter(string) {
- length = text.length(string);
- first_letter = text.subString(string, 0, 1);
- rest = text.substring(string, 1, length);
- return concat(text.toUpperCase(first_letter), rest);
- }
- //--------------------------------------------------
- //Showcoords-Utils
- //--------------------------------------------------
- function showCoords.get(player_or_id) {
- config = playerdata.getSurvival(player_or_id);
- return config.getBool(config, "showcoords", false);
- }
- function showCoords.set(player_or_id, bool) {
- config = playerdata.getSurvival(player_or_id);
- config.set(config, "showcoords", bool);
- config.saveAsync(config);
- }
- //--------------------------------------------------
- //Quest-Utils
- //--------------------------------------------------
- function quest.display(player, quest_name, stage, all_stages) {
- sb.add(player, 1, concat("§dQuest: ", quest_name, " [", text.number(stage), "/", text.number(all_stages), "]"));
- }
- function quest.removeDisplay(player) {
- sb.remove(player, 1);
- }
- function quest.addPlayer(script, player) {
- quest_ids = getScriptVar("quest_ids");
- map.add(quest_ids, player.getUuid(player), script.getId(script));
- }
- function quest.removePlayer(player) {
- quest_ids = getScriptVar("quest_ids");
- map.remove(quest_ids, player.getUuid(player));
- }
- function player.hasQuest2(player) {
- quest_ids = getScriptVar("quest_ids");
- return map.contains(quest_ids, player.getUuid(player));
- }
- function quest.getFromPlayer(player) {
- quest_ids = getScriptVar("quest_ids");
- return map.get(quest_ids, player.getUuid(player));
- }
- function quest.getCounter(player_or_id) {
- config = playerdata.getSurvival(player_or_id);
- return config.getDouble(config, "quests_solved", 0);
- }
- function quest.setCounter(player_or_id, amount) {
- config = playerdata.getSurvival(player_or_id);
- config.set(config, "quests_solved", amount);
- config.saveAsync(config);
- }
- function quest.addCounter(player_or_id, amount) {
- config = playerdata.getSurvival(player_or_id);
- config.set(config, "quests_solved", config.getDouble(config, "quests_solved", 0) + amount);
- config.saveAsync(config);
- }
- function quest.finish(script, player) {
- quest.addCounter(player, 1);
- quest.term(script, player);
- }
- function quest.term(script, player) {
- quest.removeDisplay(player);
- quest.removePlayer(player);
- script.term(script);
- }
- //--------------------------------------------------
- //Teleporter-Utils
- //--------------------------------------------------
- function isATpTransmitter(chest_loc) {
- loc = loc.mod(chest_loc, 0, 0 ,0);
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "minecraft:glowstone") {
- return false;
- }
- loc.add(loc, 2, 0, 0);
- if(block.getType(loc) != "minecraft:glowstone") {
- return false;
- }
- loc.add(loc, -1, 0, -1);
- if(block.getType(loc) != "minecraft:glowstone") {
- return false;
- }
- loc.add(loc, 0, 0, 2);
- if(block.getType(loc) != "minecraft:glowstone") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 2, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, -2);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -2, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, 1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, 1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, 1);
- if(block.getType(loc) != "minecraft:stone_brick_slab") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "minecraft:stone_brick_slab") {
- return false;
- }
- loc.add(loc, 0, 0, -1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, -1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, -1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, -1);
- if(block.getType(loc) != "minecraft:stone_brick_slab") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "minecraft:stone_brick_slab") {
- return false;
- }
- loc.add(loc, 1, 1, 2);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, -1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, 2);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 1, -1);
- if(block.getType(loc) != "km:copper_block") {
- return false;
- }
- loc.add(loc, 0, 1, 0);
- if(block.getType(loc) != "km:copper_block") {
- return false;
- }
- loc.add(loc, -2, -4, -2);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, -1, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, -1, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, 4);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 1, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 1, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 4, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, -1, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, -1, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, -4);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 1, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 1, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, -3, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, 1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, 1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, 1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, 1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, -1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, -1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, -1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "minecraft:stone_bricks") {
- return false;
- }
- loc.add(loc, -2, 0, 0);
- if(block.getType(loc) != "minecraft:stone_bricks") {
- return false;
- }
- loc.add(loc, 0, 0, 2);
- if(block.getType(loc) != "minecraft:stone_bricks") {
- return false;
- }
- loc.add(loc, 2, 0, 0);
- if(block.getType(loc) != "minecraft:stone_bricks") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, -1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, -1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- return true;
- }
- function isATpReceiver(chest_loc) {
- loc = loc.mod(chest_loc, 0, 0 ,0);
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "minecraft:glowstone") {
- return false;
- }
- loc.add(loc, 2, 0, 0);
- if(block.getType(loc) != "minecraft:glowstone") {
- return false;
- }
- loc.add(loc, -1, 0, -1);
- if(block.getType(loc) != "minecraft:glowstone") {
- return false;
- }
- loc.add(loc, 0, 0, 2);
- if(block.getType(loc) != "minecraft:glowstone") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 2, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, -2);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -2, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, 1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, 1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, 1);
- if(block.getType(loc) != "minecraft:dark_prismarine_slab") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "minecraft:dark_prismarine_slab") {
- return false;
- }
- loc.add(loc, 0, 0, -1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, -1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, -1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, -1);
- if(block.getType(loc) != "minecraft:dark_prismarine_slab") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "minecraft:dark_prismarine_slab") {
- return false;
- }
- loc.add(loc, 1, 1, 2);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, -1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, 2);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -2, -2, -3);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, -1, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, -1, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, 4);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 1, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 1, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 4, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, -1, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, -1, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, -4);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 1, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 1, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, -3, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, 1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, 1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, 1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, 1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, -1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, -1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 0, 0, -1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "minecraft:dark_prismarine") {
- return false;
- }
- loc.add(loc, -2, 0, 0);
- if(block.getType(loc) != "minecraft:dark_prismarine") {
- return false;
- }
- loc.add(loc, 0, 0, 2);
- if(block.getType(loc) != "minecraft:dark_prismarine") {
- return false;
- }
- loc.add(loc, 2, 0, 0);
- if(block.getType(loc) != "minecraft:dark_prismarine") {
- return false;
- }
- loc.add(loc, -1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, -1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, 1, 0, 0);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- loc.add(loc, -1, 0, -1);
- if(block.getType(loc) != "km:bronze_block") {
- return false;
- }
- return true;
- }
- function setWalls(chest_loc, item_type) {
- block.set(loc.mod(chest_loc, 2, -1, -1), item_type);
- block.set(loc.mod(chest_loc, 2, -1, 0), item_type);
- block.set(loc.mod(chest_loc, 2, -1, 1), item_type);
- block.set(loc.mod(chest_loc, -2, -1, -1), item_type);
- block.set(loc.mod(chest_loc, -2, -1, 0), item_type);
- block.set(loc.mod(chest_loc, -2, -1, 1), item_type);
- block.set(loc.mod(chest_loc, -1, -1, 2), item_type);
- block.set(loc.mod(chest_loc, 0, -1, 2), item_type);
- block.set(loc.mod(chest_loc, 1, -1, 2), item_type);
- block.set(loc.mod(chest_loc, -1, -1, -2), item_type);
- block.set(loc.mod(chest_loc, 0, -1, -2), item_type);
- block.set(loc.mod(chest_loc, 1, -1, -2), item_type);
-
- block.set(loc.mod(chest_loc, 2, -2, -1), item_type);
- block.set(loc.mod(chest_loc, 2, -2, 0), item_type);
- block.set(loc.mod(chest_loc, 2, -2, 1), item_type);
- block.set(loc.mod(chest_loc, -2, -2, -1), item_type);
- block.set(loc.mod(chest_loc, -2, -2, 0), item_type);
- block.set(loc.mod(chest_loc, -2, -2, 1), item_type);
- block.set(loc.mod(chest_loc, -1, -2, 2), item_type);
- block.set(loc.mod(chest_loc, 0, -2, 2), item_type);
- block.set(loc.mod(chest_loc, 1, -2, 2), item_type);
- block.set(loc.mod(chest_loc, -1, -2, -2), item_type);
- block.set(loc.mod(chest_loc, 0, -2, -2), item_type);
- block.set(loc.mod(chest_loc, 1, -2, -2), item_type);
-
- block.set(loc.mod(chest_loc, 2, -3, -1), item_type);
- block.set(loc.mod(chest_loc, 2, -3, 0), item_type);
- block.set(loc.mod(chest_loc, 2, -3, 1), item_type);
- block.set(loc.mod(chest_loc, -2, -3, -1), item_type);
- block.set(loc.mod(chest_loc, -2, -3, 0), item_type);
- block.set(loc.mod(chest_loc, -2, -3, 1), item_type);
- block.set(loc.mod(chest_loc, -1, -3, 2), item_type);
- block.set(loc.mod(chest_loc, 0, -3, 2), item_type);
- block.set(loc.mod(chest_loc, 1, -3, 2), item_type);
- block.set(loc.mod(chest_loc, -1, -3, -2), item_type);
- block.set(loc.mod(chest_loc, 0, -3, -2), item_type);
- block.set(loc.mod(chest_loc, 1, -3, -2), item_type);
- }
- function removeAdventureDisplay(player) {
- display.remove(player, 10);
- }
- function addAdventureDisplay(player, location) {
- x = text.number(loc.getX(location));
- y = text.number(loc.getY(location));
- z = text.number(loc.getZ(location));
- display.add(player, 10, concat("§2Adventure Target: §r", x, " ", y, " ", z));
- }
- //--------------------------------------------------
- //Player-Data-Utils
- //--------------------------------------------------
- function playerdata.getSurvival(player_or_id) {
- if(isPlayer(player_or_id)) {
- player_id = player.getId(player_or_id);
- } else {
- player_id = player_or_id;
- loadData(player_id, getScriptVar("survival_data"), "survival_data");
- }
- //On player_login data is needed, but the data isn't loaded yet, so the config can be null at this point
- config = map.get(getScriptVar("survival_data"), player_id);
- if(config == null) {
- loadData(player_id, getScriptVar("survival_data"), "survival_data");
- config = map.get(getScriptVar("survival_data"), player_id);
- }
- return config;
- }
- function playerdata.getGames(player_or_id) {
- if(isPlayer(player_or_id)) {
- player_id = player.getId(player_or_id);
- } else {
- player_id = player_or_id;
- loadData(player_id, getScriptVar("games_data"), "games_data");
- }
- //On player_login data is needed, but the data isn't loaded yet, so the config can be null at this point
- config = map.get(getScriptVar("games_data"), player_id);
- if(config == null) {
- loadData(player_id, getScriptVar("games_data"), "games_data");
- config = map.get(getScriptVar("games_data"), player_id);
- }
- return config;
- }
- function loadData(player_or_id, map, name) {
- if(isPlayer(player_or_id)) {
- player_id = player.getId(player_or_id);
- } else {
- player_id = player_or_id;
- }
- config = map.get(map, player_id);
- if(config == null) {
- config = config.new(concat("scripts/configs/player_data/", name), player_id);
- if(config.exists(config)) {
- config.load(config);
- }
- map.add(map, player_id, config);
- }
- }
- //--------------------------------------------------
- //Msg-Utils
- //--------------------------------------------------
- function msg.quest(player, speaker, line_now, line_max, message) {
- msg(player, concat("[§b", text.number(line_now), "§r/§b", text.number(line_max), "§r] §a", speaker, " §r| ", concat("§e", message)));
- }
- function sendMessageToWorld(world, message) {
- world_name = world.getName(world);
- if(isSurvWorldName(world_name)) {
- worldlist = players.toWorldList(world.getOverWorld());
- for(i = 0; i < list.getSize(worldlist); i++) {
- msg(list.getIndex(worldlist, i), message);
- }
- worldlist = players.toWorldList(world.get("the_end"));
- for(i = 0; i < list.getSize(worldlist); i++) {
- msg(list.getIndex(worldlist, i), message);
- }
- worldlist = players.toWorldList(world.get("the_nether"));
- for(i = 0; i < list.getSize(worldlist); i++) {
- msg(list.getIndex(worldlist, i), message);
- }
- return;
- }
- worldlist = players.toWorldList(world);
- for(i = 0; i < list.getSize(worldlist); i++) {
- msg(list.getIndex(worldlist, i), message);
- }
- }
- function sendMessageToWorld2(world, message1, message2) {
- world_name = world.getName(world);
- if(isSurvWorldName(world_name)) {
- worldlist = players.toWorldList(world.getOverWorld());
- for(i = 0; i < list.getSize(worldlist); i++) {
- msg(list.getIndex(worldlist, i), message1, message2);
- }
- worldlist = players.toWorldList(world.get("the_end"));
- for(i = 0; i < list.getSize(worldlist); i++) {
- msg(list.getIndex(worldlist, i), message1, message2);
- }
- worldlist = players.toWorldList(world.get("the_nether"));
- for(i = 0; i < list.getSize(worldlist); i++) {
- msg(list.getIndex(worldlist, i), message1, message2);
- }
- return;
- }
- worldlist = players.toWorldList(world);
- for(i = 0; i < list.getSize(worldlist); i++) {
- msg(list.getIndex(worldlist, i), message1, message2);
- }
- }
- function sendOnlineMessage(player, message) {
- nickname = player.getNickName(player);
- rank = getRank(player);
- colorcode = text.subString(rank, 0, 2);
- if(player.getId(player) == 35) {
- nickname = concat(nickname, "§r][§e§l★");
- rank = concat(rank, "\n§eSpecial VIP for Special Services");
- }
- online_list = players.toList();
- iter = list.iterator(online_list);
- while(hasNext(iter)) {
- p = next(iter);
- if(player.hasMinigame(p) && player.isMuted(p)) {
- continue;
- }
- msg(p, "[", text.hover(concat(colorcode, nickname), rank), "§r] §r", message);
- }
- }
- function sendmessage(pname, prefix, nachricht, boolean) { //Deprecated
- player.sendMessage($player, pname, prefix, nachricht, boolean);
- }
- function player.sendMessage(from_player, to_name, prefix, message, send_mail) {
- p = read.player(to_name);
- if(p == null) {
- mail.send(player.getName(from_player), to_name, message);
- } elseif(send_mail) {
- player.speakPrefix(p, prefix, message);
- }
- }
- function speakPrefix(player, prefix, message) { //Deprecated
- msg.prefix(player, prefix, message);
- }
- function player.speakPrefix(player, prefix, message) { //Deprecated
- msg.prefix(player, prefix, message);
- }
- function msg.prefix(player, prefix, message) {
- msg(player, concat("§r[", prefix, "§r] ", message));
- }
- function msg.radius(prefix, message, location, radius) {
- list = players.near(location, radius);
- iter = list.iterator(list);
- while(hasNext(iter)) {
- player.speakPrefix(next(iter), prefix, message);
- }
- }
- //--------------------------------------------------
- //Player-Utils
- //--------------------------------------------------
- function player.showDebug(player, boolean) {
- player_uuid = player.getUuid(player);
- if(boolean) {
- perm.registerPlayer(player_uuid, 16);
- } else {
- perm.unregisterPlayer(player_uuid, 16);
- }
- }
- function player.showDefaultStacks(player) {
- stacks.clear(player);
- stacks.set(player, 0, "km:gear");
- }
- function player.setSpeed(player, speed) {
- living.setMovementSpeed(player, speed / 10);
- living.setFlyingSpeed(player, speed / 10 * 4);
- }
- function player.hasEnoughFreeArea(player, area) {
- free_area = player.getFreePlotArea(player);
- if(free_area == -1) {
- return true;
- }
- used_area = player.getUsedPlotArea(player);
- new_area = used_area + area;
- return new_area < free_area;
- }
- function player.getFreePlotArea(player) {
- if(perm.has(player, "plot.other")) {
- return -1;
- }
- if(perm.has(player, "isVIP") || perm.has(player, "isTeam")) {
- return 16000;
- }
- return 4000;
- }
- function player.getUsedPlotArea(player_or_id) {
- config = playerdata.getSurvival(player_or_id);
- return config.getDouble(config, "plot.usedsize", 0);
- }
- function player.setUsedPlotArea(player_or_id, amount) {
- config = playerdata.getSurvival(player_or_id);
- config.set(config, "plot.usedsize", amount);
- config.saveAsync(config);
- }
- function player.activateSitting(player_or_id, boolean) {
- config = playerdata.getSurvival(player_or_id);
- config.set(config, "sitting", boolean);
- config.saveAsync(config);
- }
- function player.hasSittingActivated(player_or_id) {
- config = playerdata.getSurvival(player_or_id);
- return config.getBool(config, "sitting", true);
- }
- function player.acceptTpaRequests(player_or_id, boolean) {
- config = playerdata.getSurvival(player_or_id);
- config.set(config, "tptoggle", boolean);
- config.saveAsync(config);
- }
- function player.doesAcceptTpaRequests(player_or_id) {
- config = playerdata.getSurvival(player_or_id);
- return config.getBool(config, "tptoggle", true);
- }
- function player.getBackPos(player) {
- config = playerdata.getSurvival(player);
- location = config.getString(config, "backpos", "null");
- if(location == "null") {
- location = null;
- } else {
- location = read.location(location);
- }
- return location;
- }
- function player.setBackPos(player) {
- config = playerdata.getSurvival(player);
- config.set(config, "backpos", text.location(entity.getLocation(player)));
- config.saveAsync(config);
- }
- function player.clearBackPos(player) {
- config = playerdata.getSurvival(player);
- config.set(config, "backpos", "null");
- config.saveAsync(config);
- }
- function player.getFromDamageSource(damage_source) {
- entity = damage.getImmediateSource(damage_source);
- if(isPlayer(entity)) {
- return entity;
- }
- entity = damage.getTrueSource(damage_source);
- if(isPlayer(entity)) {
- return entity;
- }
- return null;
- }
- function player.getJoins(player_or_id) {
- if(isPlayer(player_or_id)) {
- player_id = player.getId(player_or_id);
- } else {
- player_id = player_or_id;
- }
- stmt = databank.prepare("SELECT COUNT(join_time) FROM playtime WHERE player_id = ?;");
- databank.setInt(stmt, 1, player_id);
- result = databank.execute(stmt);
- if(databank.next(result)) {
- amount = databank.getLong(result, 1);
- }
- databank.close(result);
- databank.close(stmt);
- return amount;
- }
- function player.getTotalPlaytime(player_or_id) {
- if(isPlayer(player_or_id)) {
- player_id = player.getId(player_or_id);
- } else {
- player_id = player_or_id;
- }
- //Online seit
- since_minutes = 0;
- if(isOnline(player.getNameFromId(player_id))) {
- stmt = databank.prepare("SELECT join_time FROM playtime WHERE player_id = ? AND leave_time IS NULL;");
- databank.setInt(stmt, 1, player_id);
- result = databank.execute(stmt);
- while(databank.next(result)) {
- since_minutes = (time.getMillis() - databank.getLong(result, 1)) / 1000 / 60;
- }
- databank.close(result);
- databank.close(stmt);
- }
- //Spielzeit gesamt
- stmt2 = databank.prepare("SELECT SUM(leave_time - join_time) FROM playtime WHERE player_id = ?;");
- databank.setInt(stmt2, 1, player_id);
- result = databank.execute(stmt2);
- while(databank.next(result)) {
- minutes = databank.getLong(result, 1) / 1000 / 60 + since_minutes;
- }
- databank.close(result);
- databank.close(stmt2);
- return minutes;
- }
- function player.hasInvIgnore(player_or_id) {
- config = playerdata.getSurvival(player_or_id);
- return config.getBool(config, "invignore", false);
- }
- function player.invIgnore(player_or_id, boolean) {
- config = playerdata.getSurvival(player_or_id);
- config.set(config, "invignore", boolean);
- config.saveAsync(config);
- }
- function player.setAdventureAmounts(player_or_id, amount) {
- config = playerdata.getSurvival(player_or_id);
- config.set(config, "adventures", amount);
- config.saveAsync(config);
- }
- function player.getAdventureAmounts(player_or_id) {
- config = playerdata.getSurvival(player_or_id);
- return config.getDouble(config, "adventures", 0);
- }
- function player.isOnAdventure(player_or_id) {
- config = playerdata.getSurvival(player_or_id);
- return config.getBool(config, "onadventure", false);
- }
- function player.setAdventure(player_or_id, boolean) {
- config = playerdata.getSurvival(player_or_id);
- config.set(config, "onadventure", boolean);
- config.saveAsync(config);
- }
- function player.getAdventureStart(player_or_id) {
- config = playerdata.getSurvival(player_or_id);
- location = config.getString(config, "adventureloc", "null");
- if(location == "null") {
- location = world.getServerSpawn();
- } else {
- location = read.location(location);
- }
- return location;
- }
- function player.setAdventureStart(player_or_id, location) {
- config = playerdata.getSurvival(player_or_id);
- config.set(config, "adventureloc", text.location(location));
- config.saveAsync(config);
- }
- function player.isMuted(player_or_id) {
- config = playerdata.getSurvival(player_or_id);
- return config.getBool(config, "muted", false);
- }
- function player.mute(player_or_id, boolean) {
- config = playerdata.getSurvival(player_or_id);
- config.set(config, "muted", boolean);
- config.saveAsync(config);
- }
- function player.getSilentJoin(player_or_id) {
- config = playerdata.getSurvival(player_or_id);
- return config.getBool(config, "silentjoin", false);
- }
- function player.setSilentJoin(player_or_id, boolean) {
- config = playerdata.getSurvival(player_or_id);
- config.set(config, "silentjoin", boolean);
- config.saveAsync(config);
- }
- function player.getAutoCloseDoor(player_or_id) {
- config = playerdata.getSurvival(player_or_id);
- return config.getBool(config, "door_auto_close", true);
- }
- function player.setAutoCloseDoor(player_or_id, boolean) {
- config = playerdata.getSurvival(player_or_id);
- config.set(config, "door_auto_close", boolean);
- config.saveAsync(config);
- }
- function player.hasFirstJoin(player_or_id) {
- config = playerdata.getSurvival(player_or_id);
- return config.getBool(config, "firstjoin", true);
- }
- function player.setFirstJoin(player_or_id, boolean) {
- config = playerdata.getSurvival(player_or_id);
- config.set(config, "firstjoin", !boolean);
- config.saveAsync(config);
- }
- function player.getFirstJoin(player_or_id) {
- if(isPlayer(player_or_id)) {
- player_id = player.getId(player_or_id);
- } else {
- player_id = player_or_id;
- }
- stmt = databank.prepare("SELECT MIN(join_time) FROM playtime WHERE player_id = ?;");
- databank.setInt(stmt, 1, player_id);
- result = databank.execute(stmt);
- if(databank.next(result)) {
- time = databank.getLong(result, 1);
- }
- databank.close(result);
- databank.close(stmt);
- return time;
- }
- function player.getLastJoin(player_or_id) {
- if(isPlayer(player_or_id)) {
- player_id = player.getId(player_or_id);
- } else {
- player_id = player_or_id;
- }
- stmt = databank.prepare("SELECT MAX(join_time) FROM playtime WHERE player_id = ?;");
- databank.setInt(stmt, 1, player_id);
- result = databank.execute(stmt);
- if(databank.next(result)) {
- time = databank.getLong(result, 1);
- }
- databank.close(result);
- databank.close(stmt);
- return time;
- }
- function player.blockCommands(player) {
- list = getScriptVar("block_commands_list");
- list.add(list, player.getUuid(player));
- }
- function player.unblockCommands(player) {
- list = getScriptVar("block_commands_list");
- player_uuid = player.getUuid(player);
- while(list.contains(list, player_uuid)) {
- list.remove(list, player_uuid);
- }
- }
- function player.isCommandBlocked(player) {
- list = getScriptVar("block_commands_list");
- return list.contains(list, player.getUuid(player));
- }
- //--------------------------------------------------
- //Block-Utils
- //--------------------------------------------------
- function block.getSecondDoor(door_loc_1) {
- prop_h_facing = block.getProperty("horizontal_facing");
- state_facing = block.getState(door_loc_1, prop_h_facing);
- prop_hinge = block.getProperty("hinge");
- state_hinge = block.getState(door_loc_1, prop_hinge);
- if(state_facing == "north") {
- if(state_hinge == "right") {
- door_loc_2 = loc.mod(door_loc_1, -1, 0, 0);
- } else {
- door_loc_2 = loc.mod(door_loc_1, 1, 0, 0);
- }
- } elseif(state_facing == "east") {
- if(state_hinge == "right") {
- door_loc_2 = loc.mod(door_loc_1, 0, 0, -1);
- } else {
- door_loc_2 = loc.mod(door_loc_1, 0, 0, 1);
- }
- } elseif(state_facing == "south") {
- if(state_hinge == "right") {
- door_loc_2 = loc.mod(door_loc_1, 1, 0, 0);
- } else {
- door_loc_2 = loc.mod(door_loc_1, -1, 0, 0);
- }
- } else {
- if(state_hinge == "right") {
- door_loc_2 = loc.mod(door_loc_1, 0, 0, 1);
- } else {
- door_loc_2 = loc.mod(door_loc_1, 0, 0, -1);
- }
- }
- if(block.isDoor(door_loc_2)) {
- if(block.isSameDoorHalf(door_loc_1, door_loc_2)) {
- state_hinge_2 = block.getState(door_loc_2, prop_hinge);
- if(state_hinge == "left" && state_hinge_2 == "right" || state_hinge == "right" && state_hinge_2 == "left") {
- return door_loc_2;
- }
- }
- }
- return null;
- }
- function block.isSameDoorHalf(door_loc_1, door_loc_2) {
- prop_d_half = block.getProperty("double_block_half");
- state_half = block.getState(door_loc_1, prop_d_half);
- state_half_2 = block.getState(door_loc_2, prop_d_half);
- return state_half == state_half_2;
- }
- //--------------------------------------------------
- //Money-Utils
- //--------------------------------------------------
- function hasEnoughMoney(player_or_id, price) {
- return getMoney(player_or_id) >= price;
- }
- function getMoney(player_or_id) {
- config = playerdata.getSurvival(player_or_id);
- return config.getDouble(config, "money", 0);
- }
- function setMoney(player_or_id, money) {
- config = playerdata.getSurvival(player_or_id);
- config.set(config, "money", money);
- config.saveAsync(config);
- if(isPlayer(player_or_id)) {
- displayMoney(player_or_id, money);
- return;
- }
- if(player.get(player.getUuidFromId(player_or_id)) != null) {
- displayMoney(player_or_id, money);
- }
- }
- function addMoney(player_or_id, money) {
- config = playerdata.getSurvival(player_or_id);
- new_money = config.getDouble(config, "money", 0) + money;
- config.set(config, "money", new_money);
- config.saveAsync(config);
- if(isPlayer(player_or_id)) {
- displayMoney(player_or_id, new_money);
- return;
- }
- player = player.get(player.getUuidFromId(player_or_id));
- if(player != null) {
- displayMoney(player, new_money);
- }
- }
- function subMoney(player_or_id, money) {
- config = playerdata.getSurvival(player_or_id);
- new_money = config.getDouble(config, "money", 0) - money;
- config.set(config, "money", new_money);
- config.saveAsync(config);
- if(isPlayer(player_or_id)) {
- displayMoney(player_or_id, new_money);
- return;
- }
- player = player.get(player.getUuidFromId(player_or_id));
- if(player != null) {
- displayMoney(player, new_money);
- }
- }
- function displayMoney(player, money) {
- a = money.split(money);
- display.add(player, 0, concat("#23-1- ", text.number(a[0])));
- display.add(player, 1, concat("#24-1- ", text.number(a[1])));
- display.add(player, 2, concat("#25-1- ", text.number(a[2])));
- }
- function money.split(money) {
- array = array.new(3);
- gold = math.roundDown(money / 4096);
- pre_silver = money % 4096;;
- silver = math.roundDown(pre_silver / 64);
- bronze = pre_silver % 64;
- array[0] = gold;
- array[1] = silver;
- array[2] = bronze;
- return array;
- }
- //--------------------------------------------------
- //Plot-Utils
- //--------------------------------------------------
- function plot.getIdFromLocation(location) {
- list = plot.get(location);
- if(list.getSize(list) == 0) {
- plot_id = null;
- } else {
- plot = list.getIndex(list, 0);
- plot_id = plot.getId(plot);
- }
- return plot_id;
- }
- function plot.addPlayer(plot, player_name) {
- list = plot.getOwners(plot);
- uuid = player.getUuid(player_name);
- if(!list.contains(list, uuid)) {
- list.add(list, uuid);
- }
- }
- function plot.removePlayer(plot, player_name) {
- list = plot.getOwners(plot);
- uuid = player.getUuid(player_name);
- list.remove(list, uuid);
- player_id = player.getId(player.getUuid(player_name));
- plot.removeRank(plot, player_id);
- }
- function plot.getOwnersString(plot) {
- list = plot.getOwners(plot);
- if(list.getSize(list) == 0) {
- return "";
- }
- owners_list = list.new();
- for(i = 0; i < list.getSize(list); i++) {
- list.add(owners_list, player.getName(list.getIndex(list, i)));
- }
- return text.concatList(owners_list, " / ", 0, list.getSize(owners_list) - 1);
- }
- function plot.isLeader(plot, player_id) {
- return plot.getRank(plot, player_id) == "leader";
- }
- function getPlotLeader(plot) {
- plot_id = plot.getId(plot);
- stmt = databank.prepare("SELECT player_id FROM plotranks WHERE plot_id = ? AND rank = ?;");
- databank.setInt(stmt, 1, plot_id);
- databank.setString(stmt, 2, "leader");
- result = databank.execute(stmt);
- while(databank.next(result)) {
- player_id = databank.getInt(result, 1);
- }
- databank.close(result);
- databank.close(stmt);
- return player_id;
- }
- function plot.getRank(plot, player_id) {
- plot_id = plot.getId(plot);
- stmt = databank.prepare("SELECT rank FROM plotranks WHERE player_id = ? AND plot_id = ?;");
- databank.setInt(stmt, 1, player_id);
- databank.setInt(stmt, 2, plot_id);
- result = databank.execute(stmt);
- while(databank.next(result)) {
- rank = databank.getString(result, 1);
- }
- databank.close(result);
- databank.close(stmt);
- return rank;
- }
- function plot.setRank(plot, player_id, rank) {
- plot_id = plot.getId(plot);
- stmt = databank.prepare("INSERT INTO plotranks (plot_id, player_id, rank) VALUES (?,?,?)");
- databank.setInt(stmt, 1, plot_id);
- databank.setInt(stmt, 2, player_id);
- databank.setString(stmt, 3, rank);
- databank.workerExecute(stmt);
- }
- function plot.removeRank(plot, player_id) {
- plot_id = plot.getId(plot);
- stmt = databank.prepare("DELETE FROM plotranks WHERE player_id = ? AND plot_id = ?;");
- databank.setInt(stmt, 1, player_id);
- databank.setInt(stmt, 2, plot_id);
- databank.workerExecute(stmt);
- }
- function plot.removeAllPlayers(plot) {
- list = plot.getOwners(plot);
- iter = list.iterator(list);
- while(hasNext(iter)) {
- plot.removeRank(plot, player.getId(next(iter)));
- }
- }
- function plot.setEdges(plot, location1, location2) {
- //Alte Daten abrufen
- plot_name = plot.getName(plot);
- list = plot.getOwners(plot);
- flags = plot.getFlags(plot);
- //Neues Plot erstellen und altes Plot löschen
- new_plot = plot.add(location1, location2);
- world = loc.getWorld(location1);
- plot.remove(plot, world);
- //Alte Daten auf neuem Plot setzen
- plot.setName(new_plot, plot_name);
- new_list = plot.getOwners(new_plot);
- for(i = 0; i < list.getSize(list); i++) {
- list.add(new_list, list.getIndex(list, i));
- }
- plot.setFlags(new_plot, flags, true);
- }
- function getFlags(plot, getActive) { //getActive = true means getActiveFlags
- flags = plot.getFlags(plot);
- flags_true = list.new();
- flags_false = list.new();
- array = array.new(2);
- array[0] = 128;
- array[1] = "FARM_FLAG";
- if(flags >= 128) {
- list.add(flags_true, array);
- flags -= 128;
- } else {
- list.add(flags_false, array);
- }
- array = array.new(2);
- array[0] = 64;
- array[1] = "EXPLOSION_FLAG";
- if(flags >= 64) {
- list.add(flags_true, array);
- flags -= 64;
- } else {
- list.add(flags_false, array);
- }
- array = array.new(2);
- array[0] = 32;
- array[1] = "ENTITY_INTERACT_FLAG";
- if(flags >= 32) {
- list.add(flags_true, array);
- flags -= 32;
- } else {
- list.add(flags_false, array);
- }
- array = array.new(2);
- array[0] = 16;
- array[1] = "BLOCK_INTERACT_FLAG";
- if(flags >= 16) {
- list.add(flags_true, array);
- flags -= 16;
- } else {
- list.add(flags_false, array);
- }
- array = array.new(2);
- array[0] = 8;
- array[1] = "HIT_AMBIENT_FLAG";
- if(flags >= 8) {
- list.add(flags_true, array);
- flags -= 8;
- } else {
- list.add(flags_false, array);
- }
- array = array.new(2);
- array[0] = 4;
- array[1] = "BUCKET_FLAG";
- if(flags >= 4) {
- list.add(flags_true, array);
- flags -= 4;
- } else {
- list.add(flags_false, array);
- }
- array = array.new(2);
- array[0] = 2;
- array[1] = "BREAK_FLAG";
- if(flags >= 2) {
- list.add(flags_true, array);
- flags -= 2;
- } else {
- list.add(flags_false, array);
- }
- array = array.new(2);
- array[0] = 1;
- array[1] = "PLACE_FLAG";
- if(flags >= 1) {
- list.add(flags_true, array);
- } else {
- list.add(flags_false, array);
- }
- if(getActive) {
- return flags_true;
- } else {
- return flags_false;
- }
- }
- //--------------------------------------------------
- //Skill-Utils
- //--------------------------------------------------
- function skill.getAmount(player_or_id, tech_name) {
- config = playerdata.getSurvival(player_or_id);
- return config.getDouble(config, tech_name, 0);
- }
- function skill.setAmount(player_or_id, tech_name, amount) {
- config = playerdata.getSurvival(player_or_id);
- config.set(config, tech_name, amount);
- config.saveAsync(config);
- }
- function skill.addAmount(player_or_id, tech_name, amount) {
- config = playerdata.getSurvival(player_or_id);
- config.set(config, tech_name, config.getDouble(config, tech_name, 0) + amount);
- config.saveAsync(config);
- }
- function skill.add(skill_name, tech_name, item, description, cost, permanent) {
- skill = array.new(6);
- skill[0] = skill_name;
- skill[1] = tech_name;
- skill[2] = item;
- skill[3] = description;
- skill[4] = cost;
- skill[5] = permanent;
- list.add(getScriptVar("skills"), skill);
- }
- function skill.get(skill_name) {
- skill_list = getScriptVar("skills");
- for(i = 0; i < list.getSize(skill_list); i++) {
- array = list.getIndex(skill_list, i);
- temp_skill_name = array[0];
- if(temp_skill_name == skill_name) {
- return array;
- }
- }
- }
- function skill.getShopItem(player, skill_name) {
- if(skill_name == null) {
- return read.item("minecraft:air");
- }
- skill = skill.get(skill_name);
- config = playerdata.getSurvival(player);
- amount = config.getDouble(config, skill[1], 0);
- if(skill[5]) {
- prop = "Permanent";
- if(amount == 0) {
- text = concat("Bought: No");
- } else {
- text = concat("Bought: Yes");
- }
- } else {
- prop = "Levelable";
- text = concat("Amount you have: ", text.number(amount));
- }
- item = read.item(skill[2], 1, skill_name, concat("Cost: ", text.number(skill[4])), skill[3], prop, text);
- return item;
- }
- function skill.getTechName(skill_name) {
- skill_list = getScriptVar("skills");
- for(i = 0; i < list.getSize(skill_list); i++) {
- array = list.getIndex(skill_list, i);
- temp_skill_name = array[0];
- if(temp_skill_name == skill_name) {
- return array[1];
- }
- }
- }
- function skill.getItem(skill_name) {
- skill_list = getScriptVar("skills");
- for(i = 0; i < list.getSize(skill_list); i++) {
- array = list.getIndex(skill_list, i);
- temp_skill_name = array[0];
- if(temp_skill_name == skill_name) {
- return array[2];
- }
- }
- }
- function skill.getDescription(skill_name) {
- skill_list = getScriptVar("skills");
- for(i = 0; i < list.getSize(skill_list); i++) {
- array = list.getIndex(skill_list, i);
- temp_skill_name = array[0];
- if(temp_skill_name == skill_name) {
- return array[3];
- }
- }
- }
- function skill.getCost(skill_name) {
- skill_list = getScriptVar("skills");
- for(i = 0; i < list.getSize(skill_list); i++) {
- array = list.getIndex(skill_list, i);
- temp_skill_name = array[0];
- if(temp_skill_name == skill_name) {
- return array[4];
- }
- }
- }
- function skill.isPermanent(skill_name) {
- skill_list = getScriptVar("skills");
- for(i = 0; i < list.getSize(skill_list); i++) {
- array = list.getIndex(skill_list, i);
- temp_skill_name = array[0];
- if(temp_skill_name == skill_name) {
- return array[5];
- }
- }
- }
- function skill.showShop(player, skill_name1, skill_name2, skill_name3, skill_name4, skill_name5, skill_name6, skill_name7, skill_name8, skill_name9) {
- inv = inv.new(333333333);
- inv.setItem(inv, 0, skill.getShopItem(player, skill_name1));
- inv.setItem(inv, 1, skill.getShopItem(player, skill_name2));
- inv.setItem(inv, 2, skill.getShopItem(player, skill_name3));
- inv.setItem(inv, 3, skill.getShopItem(player, skill_name4));
- inv.setItem(inv, 4, skill.getShopItem(player, skill_name5));
- inv.setItem(inv, 5, skill.getShopItem(player, skill_name6));
- inv.setItem(inv, 6, skill.getShopItem(player, skill_name7));
- inv.setItem(inv, 7, skill.getShopItem(player, skill_name8));
- inv.setItem(inv, 8, skill.getShopItem(player, skill_name9));
- inv.open(inv, player, "Skillshop");
- }
- //--------------------------------------------------
- //Loc-Utils
- //--------------------------------------------------
- function loc.isAir(location) {
- type = block.getType(location);
- return type == "minecraft:air" || type == "minecraft:cave_air";
- }
- function loc.isInGamesWorld(location) {
- return loc.getWorld(location) == world.getGames();
- }
- function loc.isInCreativeWorld(location) {
- return loc.getWorld(location) == world.getCreative();
- }
- //--------------------------------------------------
- //Survival-Utils
- //--------------------------------------------------
- function joinSurvWorld(player) {
- displayMoney(player, getMoney(player));
- }
- function living.setAi(bool) {
- config = getScriptVar("server_config");
- config.set(config, "spawnWithAi", bool);
- config.saveAsync(config);
- }
- function living.getAi() {
- config = getScriptVar("server_config");
- return config.getBool(config, "spawnWithAi", true);
- }
- //--------------------------------------------------
- //Games-Utils
- //--------------------------------------------------
- function joinGamesWorld(player) {
- minigame.displayElo(player, minigame.getElo(player));
- }
- function minigame.displayElo(player, elo) {
- display.add(player, 101, concat("§b§tElo: §r", text.number(elo)));
- }
- function minigame.setElo(player_or_id, elo) {
- config = playerdata.getGames(player_or_id);
- config.set(config, "game_elo", elo);
- config.saveAsync(config);
- if(isPlayer(player_or_id)) {
- minigame.displayElo(player_or_id, elo);
- }
- }
- function minigame.getElo(player_or_id) {
- config = playerdata.getGames(player_or_id);
- return config.getDouble(config, "game_elo", 0);
- }
- function minigame.addElo(player_or_id, elo) {
- config = playerdata.getGames(player_or_id);
- new_elo = config.getDouble(config, "game_elo", 0) + elo;
- config.set(config, "game_elo", new_elo);
- config.saveAsync(config);
- if(isPlayer(player_or_id)) {
- minigame.displayElo(player_or_id, new_elo);
- player.speakPrefix(player_or_id, "§b§tElo", concat("§r+§e", text.number(elo)));
- }
- }
- //--------------------------------------------------
- //Afk-Utils
- //--------------------------------------------------
- function isAfk(player) {
- player_uuid = player.getUuid(player);
- afk_map = getScriptVar("afk_map");
- if(map.contains(afk_map, player_uuid)) {
- return true;
- }
- return false;
- }
- function setAfk(player, boolean) {
- player_uuid = player.getUuid(player);
- afk_map = getScriptVar("afk_map");
- if(boolean) {
- map.add(afk_map, player_uuid, loc.getYaw(entity.getLocation(player)));
- } else {
- map.remove(afk_map, player_uuid);
- }
- }
- //--------------------------------------------------
- //PvP-Utils
- //--------------------------------------------------
- function hasPvpOn(player_or_id) {
- config = playerdata.getSurvival(player_or_id);
- return config.getBool(config, "pvp", false);
- }
- function setPvp(player_or_id, bool) {
- config = playerdata.getSurvival(player_or_id);
- config.set(config, "pvp", bool);
- config.save(config);
- }
- //--------------------------------------------------
- //Rank-Utils
- //--------------------------------------------------
- function getRank(player_or_id) {
- config = playerdata.getSurvival(player_or_id);
- return config.getString(config, "rank", "§bUser");
- }
- function setRank(player_or_id, rank) {
- rank = text.replace(rank, "&", "§");
- config = playerdata.getSurvival(player_or_id);
- config.set(config, "rank", rank);
- config.save(config);
- }
- function offerRank(player, rank) {
- rank2 = text.replace(rank, "§", "&");
- player.speak(player, "§6Commands", "New rank available: ", text.hover(text.click(concat("[", rank, "§r]"), concat("/setrank ", player.getName(player), " ", rank2)), "Click to set"));
- }
- //--------------------------------------------------
- //Perm-Utils
- //--------------------------------------------------
- function givePerm(player_id, perm_id) {
- stmt = databank.prepare("INSERT INTO playerperms (player_id, perm_id) VALUES (?,?);");
- databank.setInt(stmt, 1, player_id);
- databank.setInt(stmt, 2, perm_id);
- databank.workerExecute(stmt);
- perm.registerPlayer(player.getUuidFromID(player_id), perm_id);
- }
- function removePerm(player_id, perm_id) {
- stmt = databank.prepare("DELETE FROM playerperms WHERE player_id = ? AND perm_id = ?;");
- databank.setInt(stmt, 1, player_id);
- databank.setInt(stmt, 2, perm_id);
- databank.workerExecute(stmt);
- perm.unregisterPlayer(player.getUuidFromID(player_id), perm_id);
- }
- function removeAllPermsTemporarly(player_id) {
- perm.registerPlayer(player.getUuidFromID(player_id), 8);
- permslist = getPermsFromPlayer(player_id);
- for(i = 0; i < list.getSize(permslist); i++) {
- perm_id = list.getIndex(permslist, i);
- perm.unregisterPlayer(player.getUuidFromID(player_id), perm_id);
- }
- }
- function reloadAllPerms(player_id) {
- perm.unregisterPlayer(player.getUuidFromID(player_id), 8);
- permslist = getPermsFromPlayer(player_id);
- for(i = 0; i < list.getSize(permslist); i++) {
- perm_id = list.getIndex(permslist, i);
- perm.registerPlayer(player.getUuidFromID(player_id), perm_id);
- }
- }
- function removeAllPerms(player_id) {
- permslist = getPermsFromPlayer(player_id);
- for(i = 0; i < list.getSize(permslist); i++) {
- removePerm(player_id, list.getIndex(permslist, i));
- }
- }
- function isAPermGroup(permstring) {
- if(map.contains($permgroupsmap, text.toLowerCase(permstring))) {
- return true;
- }
- return false;
- }
- function getPermsFromPlayer(player_id) {
- list.new(permslist);
- stmt = databank.prepare("SELECT perm_id FROM playerperms WHERE player_id = ?;");
- databank.setInt(stmt, 1, player_id);
- result = databank.execute(stmt);
- while(databank.next(result)) {
- list.add(permslist, databank.getInt(result, 1));
- }
- databank.close(result);
- databank.close(stmt);
- return permslist;
- }
- function hasPermAlready(player_id, perm_id) {
- permslist = getPermsFromPlayer(player_id);
- if(list.contains(permslist, perm_id)) {
- return true;
- } else {
- return false;
- }
- }
- function registerAllPerms() {
- stmt = databank.prepare("SELECT * FROM playerperms;");
- result = databank.execute(stmt);
- while(databank.next(result)) {
- player_id = databank.getInt(result, 1);
- perm_id = databank.getInt(result, 2);
- perm.registerPlayer(player.getUuidFromID(player_id), perm_id);
- }
- databank.close(result);
- databank.close(stmt);
- }
- //--------------------------------------------------
- //Nickname-Utils
- //--------------------------------------------------
- function player.setNickName(player, nickname) {
- map.add(getScriptVar("nicknames"), player.getUuid(player), nickname);
- }
- function player.getNickName(player) {
- return map.getOrDefault(getScriptVar("nicknames"), player.getUuid(player), player.getName(player));
- }
- function player.removeNickName(player) {
- map.remove(getScriptVar("nicknames"), player.getUuid(player));
- }
- //--------------------------------------------------
- //Mail-Utils
- //--------------------------------------------------
- function mail.send(from_name, to_name, message) {
- server_config = getScriptVar("server_config");
- mail_id = config.getDouble(server_config, "mail_id", 0) + 1;
- config.set(server_config, "mail_id", mail_id);
- config.saveAsync(server_config);
-
- from_id = player.getId(player.getUuid(from_name));
- to_id = player.getId(player.getUuid(to_name));
-
- stmt = databank.prepare("INSERT INTO mails (mail_id, from_id, to_id, readed, time, message) VALUES (?, ?, ?, ?, ?, ?);");
- databank.setInt(stmt, 1, mail_id);
- databank.setInt(stmt, 2, from_id);
- databank.setInt(stmt, 3, to_id);
- databank.setBool(stmt, 4, false);
- databank.setLong(stmt, 5, time.getMillis());
- databank.setString(stmt, 6, message);
- databank.workerExecute(stmt);
-
- //Wenn Spieler online, dann Pushmeldung veranlassen
- p = read.player(to_name);
- if(p != null) {
- player.speak(p, "§bMail", concat("§rYou´ve got a new mail from §b", from_name, "."));
- }
- }
- function mail.checkForNew(player) {
- stmt = databank.prepare("SELECT mail_id, from_id, time, message FROM mails WHERE to_id = ? AND readed = false;");
- to_id = player.getId(player);
- databank.setInt(stmt, 1, to_id);
- result = databank.execute(stmt);
- nextrow = databank.next(result);
- if(!nextrow) {
- databank.close(result);
- databank.close(stmt);
- return;
- }
- newmails = 0;
- while(nextrow) {
- newmails++;
- nextrow = databank.next(result);
- }
- databank.close(result);
- databank.close(stmt);
- if(newmails > 0) {
- if(newmails > 1) {
- player.speakPrefix(player, "§bMail", concat("§rYou´ve got §b", text.number(newmails), "§r new mails."));
- } else {
- player.speakPrefix(player, "§bMail", "§rYou´ve got §b1 §rnew mail.");
- }
- }
- }
- //--------------------------------------------------
- //Friend-Utils
- //--------------------------------------------------
- function friend.check(player_id, friend_id) {
- stmt = databank.prepare("SELECT friend_id FROM friends WHERE player_id = ? AND friend_id = ?;");
- databank.setInt(stmt, 1, player_id);
- databank.setInt(stmt, 2, friend_id);
- result = databank.execute(stmt);
- temp = false;
- while(databank.next(result)) {
- temp = true;
- }
- databank.close(result);
- databank.close(stmt);
- return temp;
- }
- function friend.add(player_id, friend_id) {
- nowtime = time.getMillis();
-
- stmt1 = databank.prepare("INSERT INTO friends (player_id, friend_id, time) VALUES (?, ?, ?);");
- databank.setInt(stmt1, 1, player_id);
- databank.setInt(stmt1, 2, friend_id);
- databank.setLong(stmt1, 3, nowtime);
- databank.workerExecute(stmt1);
-
- stmt2 = databank.prepare("INSERT INTO friends (player_id, friend_id, time) VALUES (?, ?, ?);");
- databank.setInt(stmt2, 1, friend_id);
- databank.setInt(stmt2, 2, player_id);
- databank.setLong(stmt2, 3, nowtime);
- databank.workerExecute(stmt2);
- }
- function friend.delete(player_id, friend_id) {
- stmt1 = databank.prepare("DELETE FROM friends WHERE player_id = ? AND friend_id = ?;");
- databank.setInt(stmt1, 1, player_id);
- databank.setInt(stmt1, 2, friend_id);
- databank.workerExecute(stmt1);
-
- stmt2 = databank.prepare("DELETE FROM friends WHERE player_id = ? AND friend_id = ?;");
- databank.setInt(stmt2, 1, friend_id);
- databank.setInt(stmt2, 2, player_id);
- databank.workerExecute(stmt2);
- }
- function friend.getList(player_id) {
- list.new(list);
- stmt = databank.prepare("SELECT friend_id FROM friends WHERE player_id = ?;");
- databank.setInt(stmt, 1, player_id);
- result = databank.execute(stmt);
- while(databank.next(result)) {
- friend_id = databank.getInt(result, 1);
- list.add(list, player.getNameFromId(friend_id));
- }
- databank.close(result);
- databank.close(stmt);
- return list;
- }
|