chat.txt 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. modTimer(-50);
  2. event.load("chat");
  3. event.load("player_join");
  4. event.load("player_quit");
  5. event.load("living_death");
  6. config = config.new("scripts/configs", "server");
  7. if(config.exists(config)) {
  8. config.load(config);
  9. }
  10. crash = config.getBool(config, "crash", false);
  11. joinNews.createTable();
  12. cookie_time = 0;
  13. cookie = item.new(material.get("minecraft:cookie"));
  14. serverspawn = world.getServerSpawn();
  15. joinmessages = list.new();
  16. list.add(joinmessages, string.concat("joined Mundus Crassus."));
  17. list.add(joinmessages, string.concat("entered the sick world."));
  18. list.add(joinmessages, string.concat("is ready to discover new ores."));
  19. list.add(joinmessages, string.concat("turns everything upside down."));
  20. leavemeassages = list.new();
  21. list.add(leavemeassages, string.concat("has left Mundus Crassus."));
  22. list.add(leavemeassages, string.concat("has left the sick world."));
  23. list.add(leavemeassages, string.concat("came, saw and won."));
  24. list.add(leavemeassages, string.concat("faded in the face of copper."));
  25. colorcodedeath = "§9";
  26. death_prefix = "§0§lx §r";
  27. rank_playtime_list = list.new();
  28. defaultdeaths = list.new();
  29. list.add(defaultdeaths, string.concat(colorcodedeath, " bled out."));
  30. list.add(defaultdeaths, string.concat(colorcodedeath, " wanted to die."));
  31. list.add(defaultdeaths, string.concat(colorcodedeath, " isn't hungry anymore."));
  32. list.add(defaultdeaths, string.concat(colorcodedeath, " f***ing died."));
  33. list.add(defaultdeaths, string.concat(colorcodedeath, " now dines with ghosts."));
  34. list.add(defaultdeaths, string.concat(colorcodedeath, " visits kajetan in his heaven."));
  35. list.add(defaultdeaths, string.concat(colorcodedeath, " is judged by kajetan (god)."));
  36. list.add(defaultdeaths, string.concat(colorcodedeath, " got eaten by a cow."));
  37. list.add(defaultdeaths, string.concat(colorcodedeath, " got eaten by a sheep."));
  38. list.add(defaultdeaths, string.concat(colorcodedeath, " got eaten by a pig."));
  39. list.add(defaultdeaths, string.concat(colorcodedeath, " got eaten by a chicken."));
  40. list.add(defaultdeaths, string.concat(colorcodedeath, " got hit by a tree."));
  41. list.add(defaultdeaths, string.concat(colorcodedeath, " tried to go to heaven."));
  42. list.add(defaultdeaths, string.concat(colorcodedeath, " failed miserably."));
  43. list.add(defaultdeaths, string.concat(colorcodedeath, " is crying now."));
  44. list.add(defaultdeaths, string.concat(colorcodedeath, " bites the dust."));
  45. list.add(defaultdeaths, string.concat(colorcodedeath, " is no longer afraid of death."));
  46. list.add(defaultdeaths, string.concat(colorcodedeath, " met death."));
  47. list.add(defaultdeaths, string.concat(colorcodedeath, " bites the dust."));
  48. list.add(defaultdeaths, string.concat(colorcodedeath, " is ready for their funeral."));
  49. list.add(defaultdeaths, string.concat(colorcodedeath, " has to pay Marvin 50€."));
  50. list.add(defaultdeaths, string.concat(colorcodedeath, " needs necromancy."));
  51. list.add(defaultdeaths, string.concat(colorcodedeath, " is now in ghost town."));
  52. list.add(defaultdeaths, string.concat(colorcodedeath, " feels pretty stupid right now."));
  53. list.add(defaultdeaths, string.concat(colorcodedeath, " loves playing Minecraft."));
  54. list.add(defaultdeaths, string.concat(colorcodedeath, " has met inner peace through outer means."));
  55. list.add(defaultdeaths, string.concat(colorcodedeath, " used to love playing Minecraft."));
  56. list.add(defaultdeaths, string.concat(colorcodedeath, " regrets to stay alive."));
  57. list.add(defaultdeaths, string.concat(colorcodedeath, " has written their poetry."));
  58. list.add(defaultdeaths, string.concat(colorcodedeath, " is talked about in past tense now."));
  59. drowndeaths = list.new();
  60. list.add(drowndeaths, string.concat(colorcodedeath, " drowned."));
  61. list.add(drowndeaths, string.concat(colorcodedeath, " drank too much water."));
  62. list.add(drowndeaths, string.concat(colorcodedeath, " didn't grow gills fast enough."));
  63. list.add(drowndeaths, string.concat(colorcodedeath, " wanted to visit cthulhu."));
  64. list.add(drowndeaths, string.concat(colorcodedeath, " forgot they were in survival."));
  65. list.add(drowndeaths, string.concat(colorcodedeath, " noticed they couldn't swim."));
  66. list.add(drowndeaths, string.concat(colorcodedeath, " is in fact not a fish."));
  67. list.add(drowndeaths, string.concat(colorcodedeath, " is looking for the titanic."));
  68. list.add(drowndeaths, string.concat(colorcodedeath, " is looking for atlantic."));
  69. falldeaths = list.new();
  70. list.add(falldeaths, string.concat(colorcodedeath, " fell victim to gravitation."));
  71. list.add(falldeaths, string.concat(colorcodedeath, " tripped on a banana peal."));
  72. list.add(falldeaths, string.concat(colorcodedeath, " jumped into the depths."));
  73. list.add(falldeaths, string.concat(colorcodedeath, " jumped into death."));
  74. list.add(falldeaths, string.concat(colorcodedeath, " forgot their wings."));
  75. list.add(falldeaths, string.concat(colorcodedeath, " forgot their RedBell."));
  76. list.add(falldeaths, string.concat(colorcodedeath, " believed they can fly."));
  77. list.add(falldeaths, string.concat(colorcodedeath, " dived to their grave."));
  78. list.add(falldeaths, string.concat(colorcodedeath, " is in fact not a cat."));
  79. list.add(falldeaths, string.concat(colorcodedeath, " has been lied to by a parachute company."));
  80. firedeaths = list.new();
  81. list.add(firedeaths, string.concat(colorcodedeath, " looks hot today."));
  82. list.add(firedeaths, string.concat(colorcodedeath, " will be back."));
  83. list.add(firedeaths, string.concat(colorcodedeath, " could light a torch right now."));
  84. list.add(firedeaths, string.concat(colorcodedeath, " has been fired from pyromancy academy."));
  85. flydeaths = list.new();
  86. list.add(flydeaths, string.concat(colorcodedeath, " wanted to be a pilot."));
  87. list.add(flydeaths, string.concat(colorcodedeath, " is now a mashed potato."));
  88. list.add(flydeaths, string.concat(colorcodedeath, " returns to their nest."));
  89. list.add(flydeaths, string.concat(colorcodedeath, " made a crash landing."));
  90. list.add(flydeaths, string.concat(colorcodedeath, " needs a flight training."));
  91. list.add(flydeaths, string.concat(colorcodedeath, " was cast from heaven."));
  92. //andere damagecauses: fall, outOfWorld, arrow, drown (ertrinken), player, inWall, mob, magic, starve
  93. causetolist = map.new();
  94. map.add(causetolist, "fall", falldeaths);
  95. map.add(causetolist, "drown", drowndeaths);
  96. map.add(causetolist, "inFire", firedeaths);
  97. map.add(causetolist, "onFire", firedeaths);
  98. map.add(causetolist, "lava", firedeaths);
  99. map.add(causetolist, "flyIntoWall", flydeaths);
  100. map.add(causetolist, "player", list.new());
  101. online_list = players.toList();
  102. iter = iterator(online_list);
  103. while(hasNext(iter)) {
  104. rank.offerTimeScheduled(next(iter));
  105. }
  106. sgoto(1200, "minute_loop");
  107. msg.string("dev", "§bChat §rloaded");
  108. @wait
  109. wait();
  110. if(event == "living_death") {
  111. if(!isPlayer(living_entity)) {
  112. goto("wait");
  113. }
  114. player = living_entity;
  115. }
  116. player_name = player.getName(player);
  117. fullname = player.getFullName(player);
  118. ignoreGoto(event);
  119. goto("wait");
  120. @player_join
  121. first_join = player.isFirstJoin(player);
  122. if(first_join) {
  123. entity.teleport(player, serverspawn);
  124. msg.string("online", string.getSpacer());
  125. msg.string("online", string.concat(" §d§k# §eWelcome to our sick world §b", player_name, " §e!!! §d§k#"));
  126. msg.string("online", string.getSpacer());
  127. player.setFirstJoin(player, true);
  128. registerNewbie(player.getId(player), time.getMillis());
  129. }
  130. player.setHeadName(player);
  131. player.setLoggedIp(player, player.getIp(player));
  132. silentjoin = player.getSilentJoin(player);
  133. if(silentjoin) {
  134. message = null;
  135. } else {
  136. own_message = player.getJoinMessage(player);
  137. if(own_message == null || player.isNicked(player) || !player.usesCustomMessage(player)) {
  138. message = text.new(string.concat("§a§l> §r", fullname, " §9", list.getIndex(joinmessages, math.random(0, list.getSize(joinmessages) - 1))));
  139. } else {
  140. own_message = string.replace(own_message, "&", "§");
  141. message = text.new(string.concat("§a§l> §r", fullname, " §9", own_message));
  142. }
  143. }
  144. player_loc = entity.getLocation(player);
  145. //Inventory
  146. if(!crash) {
  147. inv.loadFromPlayer(player, player, loc.getWorld(player_loc));
  148. }
  149. giveCookie(player);
  150. player.setTabName(player);
  151. player.greet(player);
  152. sb.setTitle(player, text.new(string.concat(icon.getHeart(), "§6Mundus §cCrassus§f", icon.getHeart())));
  153. rank.offerTimeScheduled(player);
  154. money.display(player, money.get(player));
  155. if(perm.has("isDev", player)) {
  156. error_size = error.getSize();
  157. if(error_size > 0) {
  158. msg.prefix(player, "§cError", string.concat("There are ", string.number(error_size), " errors."));
  159. }
  160. }
  161. last_join_time = player.getLastJoin(player);
  162. if(last_join_time != null) {
  163. news_list = joinNews.getFromTime(last_join_time);
  164. joinNews.print(player, news_list);
  165. }
  166. goto("wait");
  167. function giveCookie(player) {
  168. if(players.getAmount() != 1) {
  169. return;
  170. }
  171. if(!player.isSurvival(player)) {
  172. return;
  173. }
  174. now_time = time.getMillis();
  175. if(now_time - $cookie_time > 300000) {
  176. $cookie_time = now_time;
  177. msg.string(player, "§dNobody was online. But now you are here. You make me smile. So here is a cookie for you :D");
  178. player.safeGiveItem(player, $cookie);
  179. }
  180. }
  181. @player_quit
  182. own_message = player.getLeaveMessage(player);
  183. if(own_message == null || player.isNicked(player) || !player.usesCustomMessage(player)) {
  184. message = text.new(string.concat("§c§l> §r", fullname, " §9", list.getIndex(leavemeassages, math.random(0, list.getSize(leavemeassages) - 1))));
  185. } else {
  186. own_message = string.replace(own_message, "&", "§");
  187. message = text.new(string.concat("§c§l> §r", fullname, " §9", own_message));
  188. }
  189. inv.saveForPlayer(player, player, loc.getWorld(entity.getLocation(player)));
  190. player.clearBackPos(player);
  191. rank.removeTimeOffert(player);
  192. goto("wait");
  193. @chat
  194. string_message = string.text(message);
  195. if(string.startsWith(string_message, "%", 0)) {
  196. cancel = true;
  197. goto("wait");
  198. }
  199. if(string.startsWith(string_message, "7", 0)) {
  200. length = string.length(string_message);
  201. space_index = read.number(string.indexOf(string_message, " ", 1));
  202. if(length > 1 && space_index == -1 || length > 1 && space_index > 1) {
  203. cancel = true;
  204. if(space_index == -1) {
  205. word = string.subString(string_message, 1, length);
  206. } else {
  207. word = string.subString(string_message, 1, space_index);
  208. }
  209. msg.prefix(player, "§6Commands", string.concat("You meant /", word, "?"));
  210. goto("wait");
  211. }
  212. }
  213. cancel = true;
  214. if(player.isMuted(player)) {
  215. msg.prefix(player, "§6Commands", "You are muted.");
  216. goto("wait");
  217. }
  218. if(player.isGameMuted(player)) {
  219. msg.prefix(player, "§6Commands", "You are muted (Minigame).");
  220. goto("wait");
  221. }
  222. if(perm.has("color", player)) {
  223. string_message = string.replace(string_message, "&", "§");
  224. }
  225. msg.chat(player, string_message);
  226. goto("wait");
  227. @living_death
  228. world = loc.getWorld(entity.getLocation(player));
  229. world_name = world.getName(world);
  230. if(world.isCreativeName(world_name)) {
  231. goto("wait");
  232. }
  233. if(world.isGamesName(world_name)) {
  234. goto("wait");
  235. }
  236. own_message = player.getDeathMessage(player);
  237. if(own_message == null || player.isNicked(player) || !player.usesCustomMessage(player)) {
  238. damage_type = damage.getType(damage_source);
  239. list = map.getOrDefault(causetolist, damage_type, defaultdeaths);
  240. if(damage_type == "player") {
  241. killer = player.getFromDamageSource(damage_source);
  242. killer_name = player.getName(killer);
  243. item = living.getHand(killer);
  244. if(item != null && item.hasName(item)) {
  245. 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."));
  246. } else {
  247. list.clear(list);
  248. list.add(list, string.concat(death_prefix, fullname, colorcodedeath, " got their last honour from ", killer_name, "."));
  249. list.add(list, string.concat(death_prefix, fullname, colorcodedeath, " died by ", killer_name, "'s hand."));
  250. list.add(list, string.concat(death_prefix, fullname, colorcodedeath, " was killed by ", killer_name, "."));
  251. list.add(list, string.concat(death_prefix, fullname, colorcodedeath, " lost a bet to ", killer_name, "."));
  252. list.add(list, string.concat(death_prefix, fullname, colorcodedeath, " was slain with love by ", killer_name, "."));
  253. list.add(list, string.concat(death_prefix, fullname, colorcodedeath, " is now forever married to ", killer_name, "."));
  254. list.add(list, string.concat(death_prefix, fullname, colorcodedeath, " was made ready for their funeral by ", killer_name, "."));
  255. message = text.new(list.getIndex(list, math.random(0, list.getSize(list) - 1)));
  256. }
  257. } else {
  258. message = text.new(string.concat(death_prefix, fullname, list.getIndex(list, math.random(0, list.getSize(list) - 1))));
  259. }
  260. } else {
  261. own_message = string.replace(own_message, "&", "§");
  262. message = text.new(string.concat(death_prefix, fullname, " §9", own_message));
  263. }
  264. msg.survival(message);
  265. msg.creative(message);
  266. goto("wait");
  267. function player.greet(player) {
  268. title.send(player, text.new("§cNice to see you §6"), text.new(player.getName(player)));
  269. }
  270. function rank.removeTimeOffert(player) {
  271. player_uuid = player.getUuid(player);
  272. list = $rank_playtime_list;
  273. for(i = 0; i < list.getSize(list); i++) {
  274. a = list.getIndex(list, i);
  275. if(player_uuid == a[0]) {
  276. list.removeIndex(list, i);
  277. return;
  278. }
  279. }
  280. }
  281. function rank.offerTimeScheduled(player) {
  282. a = array.new(3);
  283. a[0] = player.getUuid(player);
  284. playtime = playtime.getPlayerTotal(player);
  285. if(playtime < 1200) {
  286. diff = 1200 - playtime;
  287. a[1] = "rank.newcomer";
  288. } elseif(playtime < 6000) {
  289. diff = 6000 - playtime;
  290. a[1] = "rank.frequenter";
  291. } elseif(playtime < 42000) {
  292. diff = 42000 - playtime;
  293. a[1] = "rank.legend";
  294. } else {
  295. return;
  296. }
  297. if(diff > 1440) {
  298. return;
  299. }
  300. a[2] = time.getMillis() * diff * 60 * 1000;
  301. list.add($rank_playtime_list, a);
  302. }
  303. @minute_loop
  304. now_time = time.getMillis();
  305. iter = iterator($rank_playtime_list);
  306. while(hasNext(iter)) {
  307. a = next(iter);
  308. player_uuid = a[0];
  309. tech_name = a[1];
  310. time = a[2];
  311. if(time < now_time) {
  312. player = player.get(player_uuid);
  313. if(player != null) {
  314. offerRank(player, tech_name);
  315. if(tech_name == "rank.legend") {
  316. perm.addGroupToPlayer(player.getId(player), 18);
  317. }
  318. }
  319. remove(iter);
  320. }
  321. }
  322. sgoto(1200, "minute_loop");
  323. goto("wait");
  324. function joinNews.createTable() {
  325. databank.workerExecute(databank.prepare("
  326. CREATE TABLE IF NOT EXISTS join_news (
  327. id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
  328. message VARCHAR(512) NOT NULL,
  329. time BIGINT NOT NULL
  330. );
  331. "));
  332. }
  333. function joinNews.insert(message, time) {
  334. stmt = databank.prepare("INSERT INTO join_news (message, time) VALUES(?,?);");
  335. databank.setString(stmt, 1, message);
  336. databank.setLong(stmt, 2, time);
  337. databank.workerExecute(stmt);
  338. }
  339. function joinNews.getFromTime(last_join_time) {
  340. list = list.new();
  341. stmt = databank.prepare("SELECT message, time FROM join_news WHERE time > ? ORDER BY time DESC LIMIT ?;");
  342. databank.setLong(stmt, 1, last_join_time);
  343. databank.setInt(stmt, 2, 10);
  344. result = databank.execute(stmt);
  345. while(databank.next(result)) {
  346. a = array.new(2);
  347. a[0] = databank.getString(result, 1);
  348. a[1] = databank.getLong(result, 2);
  349. list.add(list, a);
  350. }
  351. databank.close(stmt);
  352. databank.close(result);
  353. return list;
  354. }
  355. function joinNews.print(player, news_list) {
  356. iter = iterator(news_list);
  357. while(hasNext(iter)) {
  358. a = next(iter);
  359. msg.prefix(player, "§4News", string.concat(time.getDateString(a[1]), " §7| §c", a[0]));
  360. }
  361. }