123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390 |
- modTimer(-50);
- event.load("chat");
- event.load("player_join");
- event.load("player_quit");
- event.load("living_death");
- config = config.new("scripts/configs", "server");
- if(config.exists(config)) {
- config.load(config);
- }
- crash = config.getBool(config, "crash", false);
- joinNews.createTable();
- cookie_time = 0;
- cookie = item.new(material.get("minecraft:cookie"));
- serverspawn = world.getServerSpawn();
- joinmessages = list.new();
- list.add(joinmessages, string.concat("joined Mundus Crassus."));
- list.add(joinmessages, string.concat("entered the sick world."));
- list.add(joinmessages, string.concat("is ready to discover new ores."));
- list.add(joinmessages, string.concat("turns everything upside down."));
- leavemeassages = list.new();
- list.add(leavemeassages, string.concat("has left Mundus Crassus."));
- list.add(leavemeassages, string.concat("has left the sick world."));
- list.add(leavemeassages, string.concat("came, saw and won."));
- list.add(leavemeassages, string.concat("faded in the face of copper."));
- colorcodedeath = "§9";
- death_prefix = "§0§lx §r";
- rank_playtime_list = list.new();
- defaultdeaths = list.new();
- list.add(defaultdeaths, string.concat(colorcodedeath, " bled out."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " wanted to die."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " isn't hungry anymore."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " f***ing died."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " now dines with ghosts."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " visits kajetan in his heaven."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " is judged by kajetan (god)."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " got eaten by a cow."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " got eaten by a sheep."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " got eaten by a pig."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " got eaten by a chicken."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " got hit by a tree."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " tried to go to heaven."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " failed miserably."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " is crying now."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " bites the dust."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " is no longer afraid of death."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " met death."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " bites the dust."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " is ready for their funeral."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " has to pay Marvin 50€."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " needs necromancy."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " is now in ghost town."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " feels pretty stupid right now."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " loves playing Minecraft."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " has met inner peace through outer means."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " used to love playing Minecraft."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " regrets to stay alive."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " has written their poetry."));
- list.add(defaultdeaths, string.concat(colorcodedeath, " is talked about in past tense now."));
- drowndeaths = list.new();
- list.add(drowndeaths, string.concat(colorcodedeath, " drowned."));
- list.add(drowndeaths, string.concat(colorcodedeath, " drank too much water."));
- list.add(drowndeaths, string.concat(colorcodedeath, " didn't grow gills fast enough."));
- list.add(drowndeaths, string.concat(colorcodedeath, " wanted to visit cthulhu."));
- list.add(drowndeaths, string.concat(colorcodedeath, " forgot they were in survival."));
- list.add(drowndeaths, string.concat(colorcodedeath, " noticed they couldn't swim."));
- list.add(drowndeaths, string.concat(colorcodedeath, " is in fact not a fish."));
- list.add(drowndeaths, string.concat(colorcodedeath, " is looking for the titanic."));
- list.add(drowndeaths, string.concat(colorcodedeath, " is looking for atlantic."));
- falldeaths = list.new();
- list.add(falldeaths, string.concat(colorcodedeath, " fell victim to gravitation."));
- list.add(falldeaths, string.concat(colorcodedeath, " tripped on a banana peal."));
- list.add(falldeaths, string.concat(colorcodedeath, " jumped into the depths."));
- list.add(falldeaths, string.concat(colorcodedeath, " jumped into death."));
- list.add(falldeaths, string.concat(colorcodedeath, " forgot their wings."));
- list.add(falldeaths, string.concat(colorcodedeath, " forgot their RedBell."));
- list.add(falldeaths, string.concat(colorcodedeath, " believed they can fly."));
- list.add(falldeaths, string.concat(colorcodedeath, " dived to their grave."));
- list.add(falldeaths, string.concat(colorcodedeath, " is in fact not a cat."));
- list.add(falldeaths, string.concat(colorcodedeath, " has been lied to by a parachute company."));
- firedeaths = list.new();
- list.add(firedeaths, string.concat(colorcodedeath, " looks hot today."));
- list.add(firedeaths, string.concat(colorcodedeath, " will be back."));
- list.add(firedeaths, string.concat(colorcodedeath, " could light a torch right now."));
- list.add(firedeaths, string.concat(colorcodedeath, " has been fired from pyromancy academy."));
- flydeaths = list.new();
- list.add(flydeaths, string.concat(colorcodedeath, " wanted to be a pilot."));
- list.add(flydeaths, string.concat(colorcodedeath, " is now a mashed potato."));
- list.add(flydeaths, string.concat(colorcodedeath, " returns to their nest."));
- list.add(flydeaths, string.concat(colorcodedeath, " made a crash landing."));
- list.add(flydeaths, string.concat(colorcodedeath, " needs a flight training."));
- list.add(flydeaths, string.concat(colorcodedeath, " was cast from heaven."));
- //andere damagecauses: fall, outOfWorld, arrow, drown (ertrinken), player, inWall, mob, magic, starve
- causetolist = map.new();
- map.add(causetolist, "fall", falldeaths);
- map.add(causetolist, "drown", drowndeaths);
- map.add(causetolist, "inFire", firedeaths);
- map.add(causetolist, "onFire", firedeaths);
- map.add(causetolist, "lava", firedeaths);
- map.add(causetolist, "flyIntoWall", flydeaths);
- map.add(causetolist, "player", list.new());
- online_list = players.toList();
- iter = iterator(online_list);
- while(hasNext(iter)) {
- rank.offerTimeScheduled(next(iter));
- }
- sgoto(1200, "minute_loop");
- msg.string("dev", "§bChat §rloaded");
- @wait
- wait();
- if(event == "living_death") {
- if(!isPlayer(living_entity)) {
- goto("wait");
- }
- player = living_entity;
- }
- player_name = player.getName(player);
- fullname = player.getFullName(player);
- ignoreGoto(event);
- goto("wait");
- @player_join
- first_join = player.isFirstJoin(player);
- if(first_join) {
- entity.teleport(player, serverspawn);
- msg.string("online", string.getSpacer());
- msg.string("online", string.concat(" §d§k# §eWelcome to our sick world §b", player_name, " §e!!! §d§k#"));
- msg.string("online", string.getSpacer());
- player.setFirstJoin(player, true);
- registerNewbie(player.getId(player), time.getMillis());
- }
- player.setHeadName(player);
- player.setLoggedIp(player, player.getIp(player));
- silentjoin = player.getSilentJoin(player);
- if(silentjoin) {
- message = null;
- } else {
- own_message = player.getJoinMessage(player);
- if(own_message == null || player.isNicked(player) || !player.usesCustomMessage(player)) {
- message = text.new(string.concat("§a§l> §r", fullname, " §9", list.getIndex(joinmessages, math.random(0, list.getSize(joinmessages) - 1))));
- } else {
- own_message = string.replace(own_message, "&", "§");
- message = text.new(string.concat("§a§l> §r", fullname, " §9", own_message));
- }
- }
- player_loc = entity.getLocation(player);
- //Inventory
- if(!crash) {
- inv.loadFromPlayer(player, player, loc.getWorld(player_loc));
- }
- giveCookie(player);
- player.setTabName(player);
- player.greet(player);
- sb.setTitle(player, text.new(string.concat(icon.getHeart(), "§6Mundus §cCrassus§f", icon.getHeart())));
- rank.offerTimeScheduled(player);
- money.display(player, money.get(player));
- if(perm.has("isDev", player)) {
- error_size = error.getSize();
- if(error_size > 0) {
- msg.prefix(player, "§cError", string.concat("There are ", string.number(error_size), " errors."));
- }
- }
- last_join_time = player.getLastJoin(player);
- if(last_join_time != null) {
- news_list = joinNews.getFromTime(last_join_time);
- joinNews.print(player, news_list);
- }
- goto("wait");
- function giveCookie(player) {
- if(players.getAmount() != 1) {
- return;
- }
- if(!player.isSurvival(player)) {
- return;
- }
- now_time = time.getMillis();
- if(now_time - $cookie_time > 300000) {
- $cookie_time = now_time;
- msg.string(player, "§dNobody was online. But now you are here. You make me smile. So here is a cookie for you :D");
- player.safeGiveItem(player, $cookie);
- }
- }
- @player_quit
- own_message = player.getLeaveMessage(player);
- if(own_message == null || player.isNicked(player) || !player.usesCustomMessage(player)) {
- message = text.new(string.concat("§c§l> §r", fullname, " §9", list.getIndex(leavemeassages, math.random(0, list.getSize(leavemeassages) - 1))));
- } else {
- own_message = string.replace(own_message, "&", "§");
- message = text.new(string.concat("§c§l> §r", fullname, " §9", own_message));
- }
- inv.saveForPlayer(player, player, loc.getWorld(entity.getLocation(player)));
- player.clearBackPos(player);
- rank.removeTimeOffert(player);
- goto("wait");
- @chat
- string_message = string.text(message);
- if(string.startsWith(string_message, "%", 0)) {
- cancel = true;
- goto("wait");
- }
- if(string.startsWith(string_message, "7", 0)) {
- length = string.length(string_message);
- space_index = read.number(string.indexOf(string_message, " ", 1));
- if(length > 1 && space_index == -1 || length > 1 && space_index > 1) {
- cancel = true;
- if(space_index == -1) {
- word = string.subString(string_message, 1, length);
- } else {
- word = string.subString(string_message, 1, space_index);
- }
- msg.prefix(player, "§6Commands", string.concat("You meant /", word, "?"));
- goto("wait");
- }
- }
- cancel = true;
- if(player.isMuted(player)) {
- msg.prefix(player, "§6Commands", "You are muted.");
- goto("wait");
- }
- if(player.isGameMuted(player)) {
- msg.prefix(player, "§6Commands", "You are muted (Minigame).");
- goto("wait");
- }
- if(perm.has("color", player)) {
- string_message = string.replace(string_message, "&", "§");
- }
- msg.chat(player, string_message);
- goto("wait");
- @living_death
- world = loc.getWorld(entity.getLocation(player));
- world_name = world.getName(world);
- if(world.isCreativeName(world_name)) {
- goto("wait");
- }
- if(world.isGamesName(world_name)) {
- goto("wait");
- }
- own_message = player.getDeathMessage(player);
- if(own_message == null || player.isNicked(player) || !player.usesCustomMessage(player)) {
- damage_type = damage.getType(damage_source);
- list = map.getOrDefault(causetolist, damage_type, defaultdeaths);
- if(damage_type == "player") {
- killer = player.getFromDamageSource(damage_source);
- killer_name = player.getName(killer);
- item = living.getHand(killer);
- if(item != null && item.hasName(item)) {
- message = text.merge(text.new(string.concat(death_prefix, fullname, colorcodedeath, " was killed by ", killer_name, " with ")), text.item(text.new(string.concat("§b§o", string.text(item.getName(item)))), item), text.new("§9."));
- } else {
- list.clear(list);
- list.add(list, string.concat(death_prefix, fullname, colorcodedeath, " got their last honour from ", killer_name, "."));
- list.add(list, string.concat(death_prefix, fullname, colorcodedeath, " died by ", killer_name, "'s hand."));
- list.add(list, string.concat(death_prefix, fullname, colorcodedeath, " was killed by ", killer_name, "."));
- list.add(list, string.concat(death_prefix, fullname, colorcodedeath, " lost a bet to ", killer_name, "."));
- list.add(list, string.concat(death_prefix, fullname, colorcodedeath, " was slain with love by ", killer_name, "."));
- list.add(list, string.concat(death_prefix, fullname, colorcodedeath, " is now forever married to ", killer_name, "."));
- list.add(list, string.concat(death_prefix, fullname, colorcodedeath, " was made ready for their funeral by ", killer_name, "."));
- message = text.new(list.getIndex(list, math.random(0, list.getSize(list) - 1)));
- }
- } else {
- message = text.new(string.concat(death_prefix, fullname, list.getIndex(list, math.random(0, list.getSize(list) - 1))));
- }
- } else {
- own_message = string.replace(own_message, "&", "§");
- message = text.new(string.concat(death_prefix, fullname, " §9", own_message));
- }
- msg.survival(message);
- msg.creative(message);
- goto("wait");
- function player.greet(player) {
- title.send(player, text.new("§cNice to see you §6"), text.new(player.getName(player)));
- }
- function rank.removeTimeOffert(player) {
- player_uuid = player.getUuid(player);
- list = $rank_playtime_list;
- for(i = 0; i < list.getSize(list); i++) {
- a = list.getIndex(list, i);
- if(player_uuid == a[0]) {
- list.removeIndex(list, i);
- return;
- }
- }
- }
- function rank.offerTimeScheduled(player) {
- a = array.new(3);
- a[0] = player.getUuid(player);
- playtime = playtime.getPlayerTotal(player);
- if(playtime < 1200) {
- diff = 1200 - playtime;
- a[1] = "rank.newcomer";
- } elseif(playtime < 6000) {
- diff = 6000 - playtime;
- a[1] = "rank.frequenter";
- } elseif(playtime < 42000) {
- diff = 42000 - playtime;
- a[1] = "rank.legend";
- } else {
- return;
- }
- if(diff > 1440) {
- return;
- }
- a[2] = time.getMillis() * diff * 60 * 1000;
- list.add($rank_playtime_list, a);
- }
- @minute_loop
- now_time = time.getMillis();
- iter = iterator($rank_playtime_list);
- while(hasNext(iter)) {
- a = next(iter);
- player_uuid = a[0];
- tech_name = a[1];
- time = a[2];
- if(time < now_time) {
- player = player.get(player_uuid);
- if(player != null) {
- offerRank(player, tech_name);
- if(tech_name == "rank.legend") {
- perm.addGroupToPlayer(player.getId(player), 18);
- }
- }
- remove(iter);
- }
- }
- sgoto(1200, "minute_loop");
- goto("wait");
- function joinNews.createTable() {
- databank.workerExecute(databank.prepare("
- CREATE TABLE IF NOT EXISTS join_news (
- id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
- message VARCHAR(512) NOT NULL,
- time BIGINT NOT NULL
- );
- "));
- }
- function joinNews.insert(message, time) {
- stmt = databank.prepare("INSERT INTO join_news (message, time) VALUES(?,?);");
- databank.setString(stmt, 1, message);
- databank.setLong(stmt, 2, time);
- databank.workerExecute(stmt);
- }
- function joinNews.getFromTime(last_join_time) {
- list = list.new();
- stmt = databank.prepare("SELECT message, time FROM join_news WHERE time > ? ORDER BY time DESC LIMIT ?;");
- databank.setLong(stmt, 1, last_join_time);
- databank.setInt(stmt, 2, 10);
- result = databank.execute(stmt);
- while(databank.next(result)) {
- a = array.new(2);
- a[0] = databank.getString(result, 1);
- a[1] = databank.getLong(result, 2);
- list.add(list, a);
- }
- databank.close(stmt);
- databank.close(result);
- return list;
- }
- function joinNews.print(player, news_list) {
- iter = iterator(news_list);
- while(hasNext(iter)) {
- a = next(iter);
- msg.prefix(player, "§4News", string.concat(time.getDateString(a[1]), " §7| §c", a[0]));
- }
- }
|