chat.txt 9.7 KB

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