Files
hamster-ball-bridge/src/main/java/cn/hamster3/service/bukkit/event/MessageSentEvent.java
2024-03-11 19:36:44 +08:00

58 lines
1.3 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package cn.hamster3.service.bukkit.event;
import cn.hamster3.service.common.entity.ServiceMessageInfo;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* 消息发送出去之后产生的事件
*/
@SuppressWarnings("unused")
public class MessageSentEvent extends MessageEvent {
private static final HandlerList handlers = new HandlerList();
private final boolean success;
private final Throwable cause;
public MessageSentEvent(ServiceMessageInfo info) {
super(info);
success = true;
cause = null;
}
public MessageSentEvent(ServiceMessageInfo messageInfo, Throwable cause) {
super(messageInfo);
success = false;
this.cause = cause;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* 消息是否成功发送出去了
*
* @return true代表成功发送
*/
public boolean isSuccess() {
return success;
}
/**
* 若消息发送失败,则失败原因为何
* 若发送成功则返回null
*
* @return 失败原因
*/
public Throwable getCause() {
return cause;
}
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
}