12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352 |
- 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 setBackPos(player) {
- sgv(player, "backpos", text.location(entity.getLocation(player)));
- }
- function sendmessage(pname, topic, nachricht, boolean) { //Sendet eine Chat-Nachricht an einen Spieler. boolean = true heißt Mail geht raus, wenn Empfänger nicht online
- if(isOnline(pname)) {
- p = read.player(pname);
- player.speak(p, topic, nachricht);
- } elseif(boolean) {
- from_name = player.getName($player);
- mail.send(from_name, pname, nachricht);
- }
- }
- 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 checkInvChange(player, location) {
- if(event == "portal") {
- from_world = world.get($from);
- to_world = world.get($to);
- } else {
- from_world = loc.getWorld(entity.getLocation(player));
- to_world = loc.getWorld(location);
- }
- //Wenn ignore aktiviert --> kein Wechsel
- ignore = ggv(player, "invignore");
- if(ignore == null) {
- ignore = false;
- }
- if(!ignore) {
- //Wenn in selber Welt --> kein Wechsel
- if(from_world != to_world) {
- //Wenn beide Welten in derselben Liste sind --> kein Wechsel
- if(!(isSurvWorldName(world.getName(from_world)) && isSurvWorldName(world.getName(to_world)))) {
- savePlayerInventory(player, from_world);
- loadPlayerInventory(player, to_world);
- }
- }
- }
- }
- function savePlayerInventory(player, world) {
- world_name = world.getName(world);
- if(isSurvWorldName(world_name)) {
- pfad = "scripts/configs/default";
- } else {
- pfad = concat("scripts/configs/", world_name);
- }
- config = config.new(pfad, player.getId(player));
-
- //Allgemeine Daten
- config.set(config, "health", entity.getHealth(player));
- config.set(config, "hunger", player.getHunger(player));
- config.set(config, "saturation", player.getSaturation(player));
-
- //Inventare
- for(i = 0; i <= 35; i++) {
- config.set(config, concat("slot-", i), text.item(player.getInvSlot(player, i)));
- }
- for(i = 0; i <= 26; i++) {
- config.set(config, concat("eslot-", i), text.item(player.getEnderSlot(player, i)));
- }
- config.set(config, "offhand", text.item(entity.getEquip(player, "offhand")));
- config.set(config, "head", text.item(entity.getEquip(player, "head")));
- config.set(config, "chest", text.item(entity.getEquip(player, "chest")));
- config.set(config, "legs", text.item(entity.getEquip(player, "legs")));
- config.set(config, "feet", text.item(entity.getEquip(player, "feet")));
- config.set(config, "xp", player.getExp(player));
- config.set(config, "lvl", player.getLevel(player));
-
- entity.clearEffects(player);
- config.save(config);
- }
- 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 loadPlayerInventory(player, world) {
- world_name = world.getName(world);
- if(isSurvWorldName(world_name)) {
- pfad = "scripts/configs/default";
- } else {
- pfad = concat("scripts/configs/", world_name);
- }
- config = config.new(pfad, player.getId(player));
-
- if(!config.exists(config)) {
- return;
- }
- config.load(config);
-
- //Allgemeine Daten
- entity.setHealth(player, config.getDouble(config, "health", 1));
- player.setHunger(player, config.getDouble(config, "hunger", 1));
- player.setSaturation(player, config.getDouble(config, "saturation", 1));
-
- //Gamemode
- if(!perm.has(player, "isTeam")) {
- if(!player.isSpectator(player)) {
- if(world_name == "creative") {
- gm = "creative";
- } else {
- gm = "survival";
- }
- player.setGamemode(player, gm);
- }
- }
-
- //Inventare
- for(i = 0; i <= 35; i++) {
- player.setInvSlot(player, i, read.item(config.getString(config, concat("slot-", i), "minecraft:air")));
- }
- for(i = 0; i <= 26; i++) {
- player.setEnderSlot(player, i, read.item(config.getString(config, concat("eslot-", i), "minecraft:air")));
- }
- entity.setEquip(player, "offhand", read.item(config.getString(config, "offhand", "minecraft:air")));
- entity.setEquip(player, "head", read.item(config.getString(config, "head", "minecraft:air")));
- entity.setEquip(player, "chest", read.item(config.getString(config, "chest", "minecraft:air")));
- entity.setEquip(player, "legs", read.item(config.getString(config, "legs", "minecraft:air")));
- entity.setEquip(player, "feet", read.item(config.getString(config, "feet", "minecraft:air")));
- player.setExp(player, config.getDouble(config, "xp", 0));
- player.setLevel(player, config.getDouble(config, "lvl", 0));
- }
- 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) {
- onadventure = ggv(player, "onadventure");
- if(onadventure != null) {
- if(onadventure) {
- msg(player, "[§5Adventure§r] Teleport blocked. ", text.click("[§5Cancel Adenture?§r]", concat("/stopadventure ", player)));
- return false;
- }
- }
- if(backPos) {
- setBackPos(player);
- }
- checkInvChange(player, location);
- entity.teleport(player, location);
- world = loc.getWorld(location);
- stacks.setActive(player, false);
- display.reset(player);
- entity.setName(player, player.getName(player));
- world_name = world.getName(world);
- if(world_name == "gpvp_spawn") {
- if(!registerGpvpPlayer(player)) {
- joinGpvpWorld(player);
- }
- }
- if(isSurvWorldName(world_name)) {
- joinSurvWorld(player);
- }
- //Tabliste
- nickname = map.getOrDefault(getScriptVar("nicknames"), player.getUuid(player), player.getName(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 = world.get(loc.getCoord(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 speakPrefix(player, prefix, message) {;
- msg(player, "§r[", prefix, "§r] ", message);
- }
- function sendRadiusMessage(prefix, message, location, radius) {
- list = players.near(location, radius);
- for(i = 0; i < list.getSize(list); i++) {
- player = list.getIndex(list, i);
- speakPrefix(player, prefix, message);
- }
- }
- function getPlayerFromDamageSource(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 loc.isAir(location) {
- type = block.getType(location);
- return type == "minecraft:air" || type == "minecraft:cave_air";
- }
- 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 loc.isInGamesWorld(location) {
- return loc.getWorld(location) == getGamesWorld();
- }
- function getGamesWorld() {
- return world.get("games");
- }
- function getGamesSpawn() {
- return read.location(config.getString(getScriptVar("server_config"), "gamesspawn", "games:0:0:0"));
- }
- function getServerSpawn() {
- return read.location(config.getString(getScriptVar("server_config"), "serverspawn", "games:0:0:0"));
- }
- function getSurvivalSpawn() {
- return read.location(config.getString(getScriptVar("server_config"), "surv_spawn", "games:0:0:0"));
- }
- //--------------------------------------------------
- //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, 1);
- }
- 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, 1, concat("§2Adventure Ziel: §r", x, " ", y, " ", z));
- }
- //--------------------------------------------------
- //Money-Utils
- //--------------------------------------------------
- function getSameInvWorld(world) {
- world_name = world.getName(world);
- if(isSurvWorldName(world_name)) {
- world = world.get("overworld");
- }
- return world;
- }
- function hasEnoughMoney(player_id, moneyname, price) { //Zahl player_id, String moneyname, Zahl price
- playermoney = getMoney(player_id, moneyname);
- if(playermoney < price) {
- return false;
- }
- return true;
- }
- function isAdminshop(shopid) {
- if(gdmap.get("chestshops", shopid, "owner") == "AdminShop") {
- return true;
- }
- return false;
- }
- function getMoney(player_id, moneyname) {
- svar = getScriptVar("money_svar");
- player_map = map.get(svar, player_id);
- if(player_map == null) {
- //Aus Datenbank abrufen
- money = gdmap.getOrDefault("money", player_id, moneyname, 0);
- //Im Cache speichern
- player_map = map.new();
- map.add(player_map, moneyname, money);
- map.add(svar, player_id, player_map);
- setScriptVar("money_svar", svar);
- } else {
- //Aus Cache abrufen
- money = map.getOrDefault(player_map, moneyname, 0);
- }
- return money;
- }
- function setMoney(player_id, moneyname, money) {
- //In Datenbank speichern
- gdmap.add("money", player_id, moneyname, money);
- //Im Cache speichern
- svar = getScriptVar("money_svar");
- player_map = map.getOrDefault(svar, player_id, map.new());
- map.add(player_map, moneyname, money);
- map.add(svar, player_id, player_map);
- setScriptVar("money_svar", svar);
- if(moneyname == "survmoney") {
- player = read.player(player.getNameFromId(player_id));
- if(player != null) {
- displaySurvMoney(player, money);
- }
- }
- }
- function addMoney(player_id, moneyname, money) {
- setMoney(player_id, moneyname, getMoney(player_id, moneyname) + money);
- }
- function subMoney(player_id, moneyname, money) {
- setMoney(player_id, moneyname, getMoney(player_id, moneyname) - money);
- }
- //--------------------------------------------------
- //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) {
- player_uuid = player.getUuid(player);
- pvp_set = getScriptVar("pvp_set");
- if(set.contains(pvp_set, player_uuid)) {
- return true;
- }
- return false;
- }
- function setPvp(player, mode) {
- player_uuid = player.getUuid(player);
- pvp_set = getScriptVar("pvp_set");
- if(mode == "on") {
- set.add(pvp_set, player_uuid);
- } else {
- set.remove(pvp_set, player_uuid);
- }
- }
- //--------------------------------------------------
- //Rank-Utils
- //--------------------------------------------------
- function setRank(player_name, category, rank) {
- rank = text.replace(rank, "&", "§");
- stmt = databank.prepare("INSERT INTO chatranks (player_id, category, rank) VALUES (?,?,?) ON DUPLICATE KEY UPDATE chatranks.rank = ?;");
- player_uuid = player.getUuid(player_name);
- player_id = player.getId(player_uuid);
- databank.setInt(stmt, 1, player_id);
- databank.setString(stmt, 2, category);
- databank.setString(stmt, 3, rank);
- databank.setString(stmt, 4, rank);
- databank.workerExecute(stmt);
- }
- function getRank(player_id) {
- player_name = player.getNameFromId(player_id);
- player = read.player(player_name);
- world_name = world.getName(loc.getWorld(entity.getLocation(player)));
- if(isSurvWorldName(world_name)) {
- world_name = "survival";
- }
- stmt = databank.prepare("SELECT rank FROM chatranks WHERE player_id = ? AND category = ?;");
- databank.setInt(stmt, 1, player_id);
- databank.setString(stmt, 2, world_name);
- result = databank.execute(stmt);
- if(databank.next(result)) {
- rank = databank.getString(result, 1);
- } else {
- rank = "§bUser";
- }
- databank.close(result);
- databank.close(stmt);
- return rank;
- }
- function offerRank(player, rank) {
- rank2 = text.replace(rank, "§", "&");
- world_name = world.getName(loc.getWorld(entity.getLocation(player)));
- if(isSurvWorldName(world_name)) {
- world_name = "survival";
- }
- player.speak(player, "§6Commands", "Neuer Rang verfügbar: ", text.hover(text.click(concat("[", rank, "§r]"), concat("/setrank ", player.getName(player), " ", world_name, " ", rank2)), "Zum Auswählen klicken"));
- }
- //--------------------------------------------------
- //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(list.contains($permgroups, 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 setNickName(player, nickname) {
- map.add(getScriptVar("nicknames"), player.getUuid(player), nickname);
- }
- function getNickName(player) {
- return map.getOrDefault(getScriptVar("nicknames"), player.getUuid(player), player.getName(player));
- }
- function removeNickName(player) {
- map.remove(getScriptVar("nicknames"), player.getUuid(player));
- }
- function sendMessageToWorld(world, message) {
- world_name = world.getName(world);
- if(isSurvWorldName(world_name)) {
- worldlist = players.toWorldList(world.get("overworld"));
- 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.get("overworld"));
- 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);
- }
- }
- //--------------------------------------------------
- //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) {
- speakPrefix(player, "§bMail", concat("§rYou´ve got §b", text.number(newmails), "§r new mails."));
- } else {
- speakPrefix(player, "§bMail", "§rYou´ve got §b1 §rnew mail.");
- }
- }
- }
- //--------------------------------------------------
- //Friend-Utils
- //--------------------------------------------------
- function isAFriend(player_id, friend_id) {
- temp = false;
- 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)) {
- id = databank.getInt(result, 1);
- if(friend_id == id) {
- temp = true;
- }
- }
- databank.close(result);
- databank.close(stmt);
- return temp;
- }
- function addFriend(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 deleteFriend(player_id, friend_id) {
- stmt = databank.prepare("DELETE FROM friends WHERE player_id = ? AND friend_id = ?;");
- databank.setInt(stmt, 1, player_id);
- databank.setInt(stmt, 2, friend_id);
- databank.workerExecute(stmt);
- }
- function getFriendsList(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;
- }
|