Beta
Gets all event subscriptions to this event type.
The event subscriptions.
Creates a new event subscription.
Deletes the provided event subscription.
This event is triggered after a chat message has been broadcast or sent to players.
This property can be read in early-execution mode.
import { world, DimensionLocation } from "@minecraft/server";
function customCommand(targetLocation: DimensionLocation) {
const chatCallback = Events.world.beforeEvents.chatSend.subscribe(`(eventData) => {
if (eventData.message.includes("cancel")) {
// Cancel event if the message contains "cancel"
eventData.cancel = true;
} else {
const args = eventData.message.split(" ");
if (args.length > 0) {
switch (args[0].toLowerCase()) {
case "echo":
// Send a modified version of chat message
world.sendMessage(`Echo '${eventData.message.substring(4).trim()}'`);
break;
case "help":
world.sendMessage(`Available commands: echo <message>`);
break;
}
}
}
}`);
}
Gets all event subscriptions to this event type.
The event subscriptions.
Creates a new event subscription.
Deletes the provided event subscription.
Gets all event subscriptions to this event type.
The event subscriptions.
Creates a new event subscription.
Deletes the provided event subscription.
Gets all event subscriptions to this event type.
The event subscriptions.
Creates a new event subscription.
Deletes the provided event subscription.
Gets all event subscriptions to this event type.
The event subscriptions.
Creates a new event subscription.
Deletes the provided event subscription.
Gets all event subscriptions to this event type.
The event subscriptions.
Creates a new event subscription.
Deletes the provided event subscription.
Gets all event subscriptions to this event type.
The event subscriptions.
Creates a new event subscription.
Deletes the provided event subscription.
Gets all event subscriptions to this event type.
The event subscriptions.
Creates a new event subscription.
Deletes the provided event subscription.
Gets all event subscriptions to this event type.
The event subscriptions.
Creates a new event subscription.
Deletes the provided event subscription.
Gets all event subscriptions to this event type.
The event subscriptions.
Creates a new event subscription.
Deletes the provided event subscription.
Beta
Gets all event subscriptions to this event type.
The event subscriptions.
Creates a new event subscription.
Deletes the provided event subscription.
Gets all event subscriptions to this event type.
The event subscriptions.
Creates a new event subscription.
Deletes the provided event subscription.
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