Restore ability to change message in ClientChatEvent (#9377)

This commit is contained in:
Paint_Ninja 2023-03-27 22:35:05 +01:00 committed by GitHub
parent b493a63fb6
commit 6e1de81ff5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 16 deletions

View file

@ -24,36 +24,37 @@ import org.jetbrains.annotations.ApiStatus;
@Cancelable
public class ClientChatEvent extends Event
{
// private String message;
private String message;
private final String originalMessage;
@ApiStatus.Internal
public ClientChatEvent(String message)
{
// this.setMessage(message);
this.setMessage(message);
this.originalMessage = Strings.nullToEmpty(message);
this.message = this.originalMessage;
}
/**
* {@return the message that will be sent to the server, if the event is not cancelled}
* {@return the message that will be sent to the server, if the event is not cancelled. This can be changed by mods}
*/
public String getMessage()
{
return this.originalMessage;
return this.message;
}
// /**
// * Sets the new message to be sent to the server, if the event is not cancelled.
// *
// * @param message the new message to be sent
// */
// public void setMessage(String message)
// {
// this.message = Strings.nullToEmpty(message);
// }
/**
* Sets the new message to be sent to the server, if the event is not cancelled.
*
* @param message the new message to be sent
*/
public void setMessage(String message)
{
this.message = Strings.nullToEmpty(message);
}
/**
* {@return the original message that was to be sent to the server}
* {@return the original message that was to be sent to the server. This cannot be changed by mods}
*/
public String getOriginalMessage()
{

View file

@ -18,7 +18,7 @@ public class ClientChatEventTest
{
if (event.getMessage().equals("Cancel"))
event.setCanceled(true);
// else if (event.getMessage().equals("Replace this text"))
// event.setMessage("Text replaced.");
else if (event.getMessage().equals("Replace this text"))
event.setMessage("Text replaced.");
}
}