mirror of
https://github.com/MinecraftForge/MinecraftForge
synced 2026-08-22 04:26:10 -04:00
Restore ability to change message in ClientChatEvent (#9377)
This commit is contained in:
parent
b493a63fb6
commit
6e1de81ff5
2 changed files with 17 additions and 16 deletions
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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.");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue