You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This discussion was converted from issue #280 on July 05, 2023 21:18.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
import { Command, BeforeEvents, PlayerClass, Timer, ChatClass, Formatter } from "../class.chain.js";
import { RankConfig } from "./config.js";
import { world, Player, EntityHealthComponent, system } from "@minecraft/server";
BeforeEvents.on("chat", async (data) => {
const { message, sender } = data;
if (message.startsWith(Command.getPrefix())) return;
data.cancel = true;
let rgbtext = "";
const RoleConfig = {
doctor: "§l§cD§4r",
supreme: "§cSUP§4REME",
legend:
§l§6of LEGEND
,rainbow: Formatter.rainbowText(rgbtext)
};
let RoleFree = ""
const player = new PlayerClass(sender);
let roleTag = player.getTagStartsWith("role:")?.slice(5) ?? RoleFree;
const rankTag = player.getTagStartsWith("rank:")?.slice(5) ?? RankConfig.defaultRank;
if (roleTag && RoleConfig[roleTag]) {
roleTag = RoleConfig[roleTag];
}
let displayTag = null;
if (!roleTag || roleTag !== ("legend" || "rainbow")) {
displayTag =
[${rankTag}§r]
;} else {
displayTag =
[${rankTag}§r] ${roleTag}
;}
let nameDisplay =
${displayTag} ${sender.nameTag}
;if (!player.getTagStartsWith("role:legend")?.slice(5)) {
nameDisplay =
${displayTag} ${sender.nameTag}
;} else {
nameDisplay =
${displayTag} §l§6${sender.nameTag} ${RoleConfig.legend}
;}
if (!player.getTagStartsWith("role:rainbow")?.slice(5)) {
nameDisplay =
${displayTag} ${sender.nameTag}
;} else {
rgbtext = sender.name;
nameDisplay =
${displayTag} ${sender.name}
;}
if (roleTag !== (player.getTagStartsWith("role:legend")?.slice(5) && player.getTagStartsWith("role:rainbow")?.slice(5))) {
nameDisplay =
${displayTag} ${sender.nameTag}
;} else {
rgbtext = sender.name;
nameDisplay =
${displayTag} ${sender.name} ${RoleConfig.legend}
;}
await Timer.sleep(2);
new ChatClass().broadcast({
text:
${nameDisplay} §r§l>§d>§r ${message}
,});
});
Issue Details
⚠ Do not edit this section. It is required for Discord to GitHub issue linking.
Beta Was this translation helpful? Give feedback.
All reactions