A set of events that fire before an actual action occurs. In most cases, you can potentially cancel or modify the impending event. Note that in before events any APIs that modify gameplay state will not function and will throw an error. (e.g., dimension.spawnEntity)

Implements

Constructors

Accessors

  • get modifiedChatMessageFormat(): {
        getAll(): Globals.SubscribedEvent<
            "andexdb.beforeEvents.modifiedChatMessageFormat",
            never,
        >[];
        subscribe(
            callback: string,
        ): Globals.SubscribedEvent<
            "andexdb.beforeEvents.modifiedChatMessageFormat",
        >;
        unsubscribe(
            subscription: Globals.SubscribedEvent<
                "andexdb.beforeEvents.modifiedChatMessageFormat",
            >,
        ): void;
    }

    This event is triggered before a modified chat message is formatted.

    This is triggered by the chat ranks system of the add-on, if the chat ranks system is disabled this event will never fire.

    This property can be read in early-execution mode.

    Returns {
        getAll(): Globals.SubscribedEvent<
            "andexdb.beforeEvents.modifiedChatMessageFormat",
            never,
        >[];
        subscribe(
            callback: string,
        ): Globals.SubscribedEvent<
            "andexdb.beforeEvents.modifiedChatMessageFormat",
        >;
        unsubscribe(
            subscription: Globals.SubscribedEvent<
                "andexdb.beforeEvents.modifiedChatMessageFormat",
            >,
        ): void;
    }

    • getAll:function
      • Gets all event subscriptions to this event type.

        Returns Globals.SubscribedEvent<"andexdb.beforeEvents.modifiedChatMessageFormat", never>[]

        The event subscriptions.

    • subscribe:function
      • Creates a new event subscription.

        Parameters

        • callback: string

        Returns Globals.SubscribedEvent<"andexdb.beforeEvents.modifiedChatMessageFormat">

        This function can't be called in read-only mode.

        This function can be called in early-execution mode.

        If the event callback is an empty string.

        If the event callback is not a string.

        If the event callback is not a valid stringified JavaScript function.

    • unsubscribe:function
      • Deletes the provided event subscription.

        Parameters

        Returns void

        This function can't be called in read-only mode.

        This function can be called in early-execution mode.

        If the subscription is not an instance of SubscribedEvent.

        If the subscription is not for the andexdb.beforeEvents.modifiedChatMessageFormat event.

    function preventMessagesContainingHerobrine() {
    const chatCallback = Events.andexdb.beforeEvents.modifiedChatMessageFormat.subscribe(`(eventData) => {
    if (eventData.message.includes("Herobrine")) {
    eventData.cancel = true;
    }
    }`);
    }
    function replaceEveryAInMessagesWithB() {
    const chatCallback = Events.andexdb.beforeEvents.modifiedChatMessageFormat.subscribe(`(eventData) => {
    eventData.message = eventData.message.replaceAll("a", "b");
    }`);
    }
  • get modifiedChatMessageFormatFinalization(): {
        getAll(): Globals.SubscribedEvent<
            "andexdb.beforeEvents.modifiedChatMessageFormatFinalization",
            never,
        >[];
        subscribe(
            callback: string,
        ): Globals.SubscribedEvent<
            "andexdb.beforeEvents.modifiedChatMessageFormatFinalization",
        >;
        unsubscribe(
            subscription: Globals.SubscribedEvent<
                "andexdb.beforeEvents.modifiedChatMessageFormatFinalization",
            >,
        ): void;
    }

    This event is triggered before a formatted chat message is finalized.

    This event allows you do do things like change the evaluated ranks, name tag, and more.

    This is triggered by the chat ranks system of the add-on, if the chat ranks system is disabled this event will never fire.

    This property can be read in early-execution mode.

    Returns {
        getAll(): Globals.SubscribedEvent<
            "andexdb.beforeEvents.modifiedChatMessageFormatFinalization",
            never,
        >[];
        subscribe(
            callback: string,
        ): Globals.SubscribedEvent<
            "andexdb.beforeEvents.modifiedChatMessageFormatFinalization",
        >;
        unsubscribe(
            subscription: Globals.SubscribedEvent<
                "andexdb.beforeEvents.modifiedChatMessageFormatFinalization",
            >,
        ): void;
    }

    • getAll:function
      • Gets all event subscriptions to this event type.

        Returns Globals.SubscribedEvent<
            "andexdb.beforeEvents.modifiedChatMessageFormatFinalization",
            never,
        >[]

        The event subscriptions.

    • subscribe:function
      • Creates a new event subscription.

        Parameters

        • callback: string

        Returns Globals.SubscribedEvent<
            "andexdb.beforeEvents.modifiedChatMessageFormatFinalization",
        >

        This function can't be called in read-only mode.

        This function can be called in early-execution mode.

        If the event callback is an empty string.

        If the event callback is not a string.

        If the event callback is not a valid stringified JavaScript function.

    • unsubscribe:function
      • Deletes the provided event subscription.

        Parameters

        Returns void

        This function can't be called in read-only mode.

        This function can be called in early-execution mode.

        If the subscription is not an instance of SubscribedEvent.

        If the subscription is not for the andexdb.beforeEvents.modifiedChatMessageFormatFinalization event.

    function changeDisplayNamesOfPlayersSendingMessagesContainingHerobrine() {
    const chatCallback = Events.andexdb.beforeEvents.modifiedChatMessageFormatFinalization.subscribe(`(eventData) => {
    if (eventData.tokenData.message.includes("Herobrine")) {
    eventData.tokenData.name = "<Herobrine>";
    eventData.tokenData.nameb = "Herobrine";
    }
    }`);
    }
    function addAAAARankToAllMessages() {
    const chatCallback = Events.andexdb.beforeEvents.modifiedChatMessageFormatFinalization.subscribe(`(eventData) => {
    eventData.tokenData.ranks.push("AAAA");
    }`);
    }
    function messUpPlayersMessagesIfTheySetMessUpMyMessages() {
    Events.andexdb.beforeEvents.modifiedChatMessageFormat.subscribe(`(event) => {
    if (event.message.includes("mess up my message")) {
    event.message = event.message
    .replaceAll(/([a-z])([a-z])([a-z])([a-z])([a-z])/g, "$5$3$4$2$1")
    .replaceAll(/([a-z])([a-z])([a-z])/g, "$3$1$2")
    .replaceAll(/([a-z])([a-z])/g, "$2$1");
    }
    };`);
  • get modifiedChatMessageSend(): {
        getAll(): Globals.SubscribedEvent<
            "andexdb.beforeEvents.modifiedChatMessageSend",
            never,
        >[];
        subscribe(
            callback: string,
        ): Globals.SubscribedEvent<"andexdb.beforeEvents.modifiedChatMessageSend">;
        unsubscribe(
            subscription: Globals.SubscribedEvent<
                "andexdb.beforeEvents.modifiedChatMessageSend",
            >,
        ): void;
    }

    This event is triggered before a modified chat message is sent.

    This is triggered by the chat ranks system of the add-on, if the chat ranks system is disabled this event will never fire.

    This property can be read in early-execution mode.

    Returns {
        getAll(): Globals.SubscribedEvent<
            "andexdb.beforeEvents.modifiedChatMessageSend",
            never,
        >[];
        subscribe(
            callback: string,
        ): Globals.SubscribedEvent<"andexdb.beforeEvents.modifiedChatMessageSend">;
        unsubscribe(
            subscription: Globals.SubscribedEvent<
                "andexdb.beforeEvents.modifiedChatMessageSend",
            >,
        ): void;
    }

    • getAll:function
      • Gets all event subscriptions to this event type.

        Returns Globals.SubscribedEvent<"andexdb.beforeEvents.modifiedChatMessageSend", never>[]

        The event subscriptions.

    • subscribe:function
      • Creates a new event subscription.

        Parameters

        • callback: string

        Returns Globals.SubscribedEvent<"andexdb.beforeEvents.modifiedChatMessageSend">

        This function can't be called in read-only mode.

        This function can be called in early-execution mode.

        If the event callback is an empty string.

        If the event callback is not a string.

        If the event callback is not a valid stringified JavaScript function.

    • unsubscribe:function
      • Deletes the provided event subscription.

        Parameters

        Returns void

        This function can't be called in read-only mode.

        This function can be called in early-execution mode.

        If the subscription is not an instance of SubscribedEvent.

        If the subscription is not for the andexdb.beforeEvents.modifiedChatMessageSend event.

    function preventMessagesContainingHerobrine() {
    const chatCallback = Events.andexdb.beforeEvents.modifiedChatMessageSend.subscribe(`(eventData) => {
    if (eventData.message.includes("Herobrine")) {
    eventData.cancel = true;
    }
    }`);
    }
    function replaceEveryAInMessagesIncludingNameTagsAndRanksWithB() {
    const chatCallback = Events.andexdb.beforeEvents.modifiedChatMessageSend.subscribe(`(eventData) => {
    eventData.message = eventData.message.replaceAll("a", "b");
    }`);
    }