<commit_before>/*
 *    Copyright 2016 5zig
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package eu.the5zig.mod.event;

/**
 * Called, when the client has received a chat message from the server.
 */
public class ChatEvent extends Event implements Cancelable {

	/**
	 * The message of the server.
	 */
	private String message;
	/**
	 * An object that represents a minecraft internal chat component. Used internally to send messages to the second chat.
	 */
	private Object chatComponent;

	/**
	 * Indicates whether the event has been cancelled.
	 */
	private boolean cancelled;

	public ChatEvent(String message, Object chatComponent) {
		this.message = message;
		this.chatComponent = chatComponent;
	}

	/**
	 * @return the chat message that has been received.
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * @return the minecraft internal chat component.
	 */
	public Object getChatComponent() {
		return chatComponent;
	}

	@Override
	public boolean isCancelled() {
		return cancelled;
	}

	@Override
	public void setCancelled(boolean cancelled) {
		this.cancelled = cancelled;
	}
}
<commit_msg>Add setMessage to chat event<commit_after>/*
 *    Copyright 2016 5zig
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package eu.the5zig.mod.event;

/**
 * Called, when the client has received a chat message from the server.
 */
public class ChatEvent extends Event implements Cancelable {

	/**
	 * The message of the server.
	 */
	private String originalMessage;
	/**
	 * Can be changed by plugins.
	 */
	private String message;
	/**
	 * An object that represents a minecraft internal chat component. Used internally to send messages to the second chat.
	 */
	private Object chatComponent;

	/**
	 * Indicates whether the event has been cancelled.
	 */
	private boolean cancelled;

	public ChatEvent(String message, Object chatComponent) {
		this.originalMessage = message;
		this.chatComponent = chatComponent;
	}

	/**
	 * @return the chat message that has been received.
	 */
	public String getMessage() {
		return originalMessage;
	}

	/**
	 * Changes the chat message. The message will be only changed if {@link #isCancelled()} is {@code false}.
	 * Note, that {@link #getMessage()} still returns the original message to maintain compatibility.
	 *
	 * @param message the new message.
	 */
	public void setMessage(String message) {
		if (message == null || !message.equals(originalMessage)) {
			this.message = message;
		}
	}

	/**
	 * @return the chat message that has been changed by plugins or {@code null}, if the chat message has not been changed.
	 */
	public String getAlteredMessage() {
		return message;
	}

	/**
	 * @return the minecraft internal chat component.
	 */
	public Object getChatComponent() {
		return chatComponent;
	}

	@Override
	public boolean isCancelled() {
		return cancelled;
	}

	@Override
	public void setCancelled(boolean cancelled) {
		this.cancelled = cancelled;
	}
}

{'fraction_non_alphanumeric': 0.08513816280806571, 'fraction_numerical': 0.004978839930296241, 'mean_word_length': 3.3484848484848486, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5817531', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1062, 'n_words': 457}