chat.txt 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. event.load("chat");
  2. event.load("player_login");
  3. event.load("player_logout");
  4. event.load("living_death");
  5. cookie_time = 0;
  6. cookie = read.item("minecraft:cookie");
  7. serverspawn = world.getServerSpawn();
  8. joinmessages = list.new();
  9. list.add(joinmessages, concat("joined Mundus Crassus."));
  10. list.add(joinmessages, concat("entered the sick world."));
  11. list.add(joinmessages, concat("is ready to discover new ores."));
  12. list.add(joinmessages, concat("turns everything upside down."));
  13. leavemeassages = list.new();
  14. list.add(leavemeassages, concat("has left Mundus Crassus."));
  15. list.add(leavemeassages, concat("has left the sick world."));
  16. list.add(leavemeassages, concat("came, saw and won."));
  17. list.add(leavemeassages, concat("faded in the face of copper."));
  18. nomessageworlds = list.new();
  19. list.add(nomessageworlds, world.get("games"));
  20. colorcodedeath = "§9";
  21. death_prefix = "§0§lx §r";
  22. headlist = list.new();
  23. headlist2 = list.new();
  24. defaultdeaths = list.new();
  25. list.add(defaultdeaths, concat(colorcodedeath, " bled out."));
  26. list.add(defaultdeaths, concat(colorcodedeath, " wanted to die."));
  27. list.add(defaultdeaths, concat(colorcodedeath, " isn't hungry anymore."));
  28. list.add(defaultdeaths, concat(colorcodedeath, " f***ing died."));
  29. list.add(defaultdeaths, concat(colorcodedeath, " now dines with ghosts."));
  30. list.add(defaultdeaths, concat(colorcodedeath, " visits kajetan in his heaven."));
  31. list.add(defaultdeaths, concat(colorcodedeath, " is judged by kajetan (god)."));
  32. drowndeaths = list.new();
  33. list.add(drowndeaths, concat(colorcodedeath, " drowned."));
  34. list.add(drowndeaths, concat(colorcodedeath, " drank too much water."));
  35. list.add(drowndeaths, concat(colorcodedeath, " didn't grow gills fast enough."));
  36. list.add(drowndeaths, concat(colorcodedeath, " wanted to visit cthulhu."));
  37. list.add(drowndeaths, concat(colorcodedeath, " forgot he was in survival."));
  38. list.add(drowndeaths, concat(colorcodedeath, " believed he can fly."));
  39. falldeaths = list.new();
  40. list.add(falldeaths, concat(colorcodedeath, " fell victim to gravitation."));
  41. list.add(falldeaths, concat(colorcodedeath, " tripped on a banana peal."));
  42. list.add(falldeaths, concat(colorcodedeath, " jumped into the depths."));
  43. list.add(falldeaths, concat(colorcodedeath, " jumped into death."));
  44. list.add(falldeaths, concat(colorcodedeath, " forgot their wings."));
  45. list.add(falldeaths, concat(colorcodedeath, " forgot their RedBull."));
  46. firedeaths = list.new();
  47. list.add(firedeaths, concat(colorcodedeath, " looks hot today."));
  48. //andere damagecauses: fall, outOfWorld, arrow, drown (ertrinken), player, inWall, mob, magic, starve
  49. causetolist = map.new();
  50. map.add(causetolist, "fall", falldeaths);
  51. map.add(causetolist, "drown", drowndeaths);
  52. map.add(causetolist, "inFire", firedeaths);
  53. map.add(causetolist, "onFire", firedeaths);
  54. map.add(causetolist, "lava", firedeaths);
  55. map.add(causetolist, "player", list.new());
  56. setScriptVar("rank_playtime_list", list.new());
  57. online_list = players.toList();
  58. iter = list.iterator(online_list);
  59. while(hasNext(iter)) {
  60. rank.offerTimeScheduled(next(iter));
  61. }
  62. msg("dev", "§bChat §rloaded");
  63. @wait
  64. wait();
  65. if(event == "living_death") {
  66. if(!isPlayer(living_entity)) {
  67. goto("wait");
  68. }
  69. player = living_entity;
  70. }
  71. player_name = player.getName(player);
  72. nickname = player.getNickname(player);
  73. player_id = player.getId(player);
  74. //Wenn der Spieler keinen Nicknamen hat, werden die personalisierten Nachrichten geschickt, falls solche vorhanden sind
  75. if(removeFormat(nickname) == player_name) {
  76. send_personally_messages = true;
  77. } else {
  78. send_personally_messages = false;
  79. }
  80. fullname = player.getFullName(player);
  81. ignoreGoto(event);
  82. goto("wait");
  83. @player_login
  84. first_join = player.hasFirstJoin(player_id);
  85. if(first_join) {
  86. entity.teleport(player, serverspawn);
  87. msg("online", concat("§bWelcome to our sick world §e", player_name, " §b!!!"));
  88. player.setFirstJoin(player_id, true);
  89. }
  90. player.setHeadName(player);
  91. silentjoin = player.getSilentJoin(player);
  92. if(!silentjoin) {
  93. message = text.convert(player.getJoinMessage(player));
  94. if(message == null || !send_personally_messages) {
  95. message = concat("§a§l> §r", fullname, " §9", list.getIndex(joinmessages, math.random(0, list.getSize(joinmessages) - 1)));
  96. } else {
  97. message = concat("§a§l> §r", fullname, " §9", message);
  98. }
  99. msg("online", message);
  100. }
  101. player_loc = entity.getLocation(player);
  102. //Inventory
  103. inv.loadFromPlayer(player, player, loc.getWorld(player_loc));
  104. //Keks geben, wenn man als einziger Spieler auf den Server joint und im Survival-Mode ist und der letzte Keks seit 5 Minuten vergeben wurde
  105. if(players.getAmount() == 1) {
  106. if(!loc.isInGamesWorld(player_loc)) {
  107. if(player.isSurvival(player)) {
  108. now_time = time.getMillis();
  109. if(now_time - cookie_time > 300000) {
  110. cookie_time = now_time;
  111. msg(player, "§dHere is a cookie for you :D");
  112. safeGiveItemPlayer(player, cookie);
  113. }
  114. }
  115. }
  116. }
  117. player.setTabName(player);
  118. player.greet(player);
  119. player.showDefaultStacks(player);
  120. stacks.setActive(player, true);
  121. rank.offerTimeScheduled(player);
  122. displayMoney(player, getMoney(player));
  123. //send marvinius amount of errors
  124. if(player_id == 2) {
  125. error_size = error.getSize();
  126. if(error_size > 0) {
  127. msg.prefix(player, "§cError", concat("There are ", text.number(error_size), " errors."));
  128. }
  129. }
  130. goto("wait");
  131. @player_logout
  132. message = text.convert(player.getLeaveMessage(player));
  133. if(message == null || !send_personally_messages) {
  134. message = concat("§c§l> §r", fullname, " §9", list.getIndex(leavemeassages, math.random(0, list.getSize(leavemeassages) - 1)));
  135. } else {
  136. message = concat("§c§l> §r", fullname, " §9", message);
  137. }
  138. msg("online", message);
  139. inv.saveForPlayer(player, player, loc.getWorld(entity.getLocation(player)));
  140. player.clearBackPos(player);
  141. rank.removeTimeOffert(player);
  142. goto("wait");
  143. @chat
  144. if(text.startsWith(message, "7", 0)) {
  145. length = text.length(message);
  146. space_index = read.number(text.indexOf(message, " ", 1));
  147. if(length > 1 && space_index == -1 || length > 1 && space_index > 1) {
  148. cancel = true;
  149. if(space_index == -1) {
  150. word = text.subString(message, 1, length);
  151. } else {
  152. word = text.subString(message, 1, space_index);
  153. }
  154. msg.prefix(player, "§6Commands", concat("You meant /", word, "?"));
  155. goto("wait");
  156. }
  157. }
  158. cancel = true;
  159. if(player.isMuted(player)) {
  160. //minigames check this for themselves. cause: global mute for e.g. specs/ghosts, but spec/ghost chat should be possible without "you are muted" message
  161. if(!player.hasMinigame(player)) {
  162. msg.prefix(player, "§6Commands", "You are muted.");
  163. }
  164. goto("wait");
  165. }
  166. if(perm.has(player, "color")) {
  167. message = text.replace(message, "&", "§");
  168. }
  169. if(text.startsWith(message, "https://", 0)) {
  170. message = text.link(message, message);
  171. }
  172. sendOnlineMessage(player, message);
  173. goto("wait");
  174. @living_death
  175. world = loc.getWorld(entity.getLocation(player));
  176. if(list.contains(nomessageworlds, world)) {
  177. goto("wait");
  178. }
  179. damage_type = damage.getType(damage_source);
  180. list = map.getOrDefault(causetolist, damage_type, defaultdeaths);
  181. if(damage_type == "player") {
  182. killer = player.getFromDamageSource(damage_source);
  183. killer_name = player.getName(killer);
  184. item = entity.getEquip(killer, "hand");
  185. if(item.hasName(item)) {
  186. message1 = concat(death_prefix, fullname, colorcodedeath, " killed by ", killer_name, " with ");
  187. message2 = item.getFullText(item);
  188. sendMessageToWorld2(world, message1, message2);
  189. goto("wait");
  190. }
  191. list.clear(list);
  192. list.add(list, concat(death_prefix, fullname, colorcodedeath, " got their last honour from ", killer_name, "."));
  193. list.add(list, concat(death_prefix, fullname, colorcodedeath, " died by ", killer_name, "'s hand."));
  194. list.add(list, concat(death_prefix, fullname, colorcodedeath, " was killed by ", killer_name, "."));
  195. list.add(list, concat(death_prefix, fullname, colorcodedeath, " lost a bet to ", killer_name, "."));
  196. message = list.getIndex(list, math.random(0, list.getSize(list) - 1));
  197. } else {
  198. message = concat(death_prefix, fullname, list.getIndex(list, math.random(0, list.getSize(list) - 1)));
  199. }
  200. sendMessageToWorld(world, message);
  201. goto("wait");
  202. function player.greet(player) {
  203. player_name = player.getName(player);
  204. title.reset(player);
  205. title.setSub(player, concat("§cNice to see you §6", player_name));
  206. title.send(player, "");
  207. list.add($headlist, player);
  208. sgoto(20, "showHead");
  209. }
  210. @showHead
  211. p = list.getIndex(headlist, 0);
  212. list.removeIndex(headlist, 0);
  213. p_name = player.getName(p);
  214. head.add(p, 0, p_name, 0.4, 0.1, 0.2, 0.35);
  215. list.add($headlist2, p);
  216. sgoto(60, "removeHead");
  217. goto("wait");
  218. @removeHead
  219. p = list.getIndex(headlist2, 0);
  220. list.removeIndex(headlist2, 0);
  221. head.remove(p, 0);
  222. goto("wait");
  223. function rank.removeTimeOffert(player) {
  224. player_uuid = player.getUuid(player);
  225. list = getScriptVar("rank_playtime_list");
  226. for(i = 0; i < list.getSize(list); i++) {
  227. a = list.getIndex(list, i);
  228. if(player_uuid == a[0]) {
  229. list.removeIndex(list, i);
  230. return;
  231. }
  232. }
  233. }
  234. function rank.offerTimeScheduled(player) {
  235. list = getScriptVar("rank_playtime_list");
  236. a = array.new(2);
  237. a[0] = player.getUuid(player);
  238. playtime = playtime.getPlayerTotal(player);
  239. if(playtime < 1200) {
  240. diff = 1200 - playtime;
  241. a[1] = "rank.newcomer";
  242. } elseif(playtime < 6000) {
  243. diff = 6000 - playtime;
  244. a[1] = "rank.frequenter";
  245. } elseif(playtime < 42000) {
  246. diff = 42000 - playtime;
  247. a[1] = "rank.legend";
  248. } else {
  249. return;
  250. }
  251. if(diff > 1440) {
  252. return;
  253. }
  254. list.add(list, a);
  255. sgoto(diff * 60 * 20, "offerTimeRank");
  256. }
  257. @offerTimeRank
  258. list = getScriptVar("rank_playtime_list");
  259. if(list.getSize(list) == 0) {
  260. goto("wait");
  261. }
  262. a = list.getIndex(list, 0);
  263. list.removeIndex(list, 0);
  264. player_uuid = a[0];
  265. tech_name = a[1];
  266. player = player.get(player_uuid);
  267. if(player != null) {
  268. offerRank(player, tech_name);
  269. }
  270. goto("wait");