Skip to content

SignEdit ​

com.jsmacrosce.jsmacros.client.api.event.impl.player.EventSignEdit

Since1.2.7Cancellable

Fires when the local player opens a sign editing screen. Cancelling the event or setting closeScreen prevents the screen from opening and sends the edited text to the server.
Changed text is also applied to the local sign immediately. signText starts with the sign's current text; only its first four entries are used, missing entries become empty, and null blanks all four lines.

js
JsMacros.on("SignEdit", JavaWrapper.methodToJava(function (event) {
 const text = event.signText;  
 if (text === null) {
   return;  
 }
 let blocked = false;  
 for (const line of text) {
   if (line.includes("badWord")) {
     blocked = true;  
   }
 }
 if (blocked) {
   // rewrite the text, then send the edit without ever opening the editor
   let i = 0;  
   while (i !== text.size()) {
     text.set(i, text.get(i).replaceAll("badWord", "***"));  
     i += 1;  
   }
   event.cancel();  
   return;  
 }
 Chat.log(`Editing sign at ${event.pos.x}, ${event.pos.y}, ${event.pos.z}`);  
}))

Constructors ​

new EventSignEdit ​

new EventSignEdit(List<String> signText, int x, int y, int z, boolean front)#
Initializes the event with its client core, block position, edited text, and sign side. The supplied coordinates are integer block coordinates stored in a new Pos3D; front is stored unchanged. signText is stored as the supplied list reference, including null, without copying or normalizing it.

Parameters:

  • signText: the text list to retain, or null
  • x: the block-coordinate x position
  • y: the block-coordinate y position
  • z: the block-coordinate z position
  • front: whether the edited side is the front; false denotes the back

Fields ​

closeScreen ​

closeScreen: boolean#
Whether to send the edit without opening the screen; defaults to false. Setting it to true has the same effect as cancelling the event.

front ​

front: boolean#
true when editing the front side; false when editing the back side.

pos ​

pos: Pos3Dread-only#
The sign's block position in block coordinates.

signText ​

signText: List<String>#
The sign's four text lines, initially copied from the current sign text. Only the first four entries are used; missing entries become empty, and null blanks all four lines.

Methods ​

toString ​

toString(): String#
Returns a diagnostic string containing the event name and current position in the form %s:{"pos": [%s]}; the position is enclosed in square brackets. It omits the text, side, and screen-close flag, and is not a serialization of the full event.
Returns: the event name and current position in diagnostic format