mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 22:15:45 +00:00
Refactor format handler
This commit is contained in:
1 parent
84c5c67674
commit
305e9162fa
28 files changed
+221
-190
No files matched your search
@@ -24,8 +24,8 @@ public class ChannelRegisterEvent extends Event {
|
||||
}
|
||||
|
||||
/** Relevant stuff **/
|
||||
private List<ChatChannel> registeredChannels;
|
||||
private Registry<ChatChannel> registry;
|
||||
private final List<ChatChannel> registeredChannels;
|
||||
private final Registry<ChatChannel> registry;
|
||||
|
||||
public ChannelRegisterEvent(List<ChatChannel> registeredChannels, Registry<ChatChannel> registry) {
|
||||
super(!Bukkit.isPrimaryThread());
|
||||
|
||||
@@ -34,8 +34,8 @@ public class ChannelSwitchEvent extends Event implements Cancellable {
|
||||
}
|
||||
|
||||
/** Relevant stuff **/
|
||||
private ChatChannel channel;
|
||||
private ChatUser user;
|
||||
private final ChatChannel channel;
|
||||
private final ChatUser user;
|
||||
private String failureMessage;
|
||||
|
||||
public ChannelSwitchEvent(ChatChannel channel, ChatUser user, String failureMessage) {
|
||||
|
||||
@@ -8,34 +8,27 @@ import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ChatComponentEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLERS_LIST = new HandlerList();
|
||||
private boolean isCancelled = false;
|
||||
|
||||
private ChatUser user;
|
||||
private @NotNull final ChatUser sender;
|
||||
private @Nullable final ChatUser target;
|
||||
private ChatChannel chatChannel;
|
||||
private TextComponent component;
|
||||
private String originalMessage;
|
||||
private List<ChatUser> recipients;
|
||||
private boolean customPlayerFormat;
|
||||
private final String originalMessage;
|
||||
|
||||
public ChatComponentEvent(ChatUser user, ChatChannel chatChannel, TextComponent component, String originalMessage, List<ChatUser> recipients) {
|
||||
this(user, chatChannel, component, originalMessage, recipients, false);
|
||||
}
|
||||
|
||||
public ChatComponentEvent(ChatUser user, ChatChannel chatChannel, TextComponent component, String originalMessage, List<ChatUser> recipients, boolean customPlayerFormat) {
|
||||
public ChatComponentEvent(ChatUser sender, ChatUser target, ChatChannel chatChannel, TextComponent component, String originalMessage) {
|
||||
super(!Bukkit.isPrimaryThread());
|
||||
|
||||
this.user = user;
|
||||
this.sender = sender;
|
||||
this.target = target;
|
||||
this.chatChannel = chatChannel;
|
||||
this.component = component;
|
||||
this.originalMessage = originalMessage;
|
||||
this.recipients = recipients;
|
||||
this.customPlayerFormat = customPlayerFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,8 +51,14 @@ public class ChatComponentEvent extends Event implements Cancellable {
|
||||
return HANDLERS_LIST;
|
||||
}
|
||||
|
||||
public ChatUser getUser() {
|
||||
return user;
|
||||
@NotNull
|
||||
public ChatUser getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ChatUser getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public ChatChannel getChannel() {
|
||||
@@ -78,15 +77,8 @@ public class ChatComponentEvent extends Event implements Cancellable {
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public List<ChatUser> getRecipients() {
|
||||
return recipients;
|
||||
}
|
||||
|
||||
public String getOriginalMessage() {
|
||||
return originalMessage;
|
||||
}
|
||||
|
||||
public boolean isCustomPlayerFormat() {
|
||||
return customPlayerFormat;
|
||||
}
|
||||
}
|
||||
@@ -13,15 +13,19 @@ public class ChatFormatEvent extends Event implements Cancellable {
|
||||
private static final HandlerList HANDLERS_LIST = new HandlerList();
|
||||
private boolean isCancelled = false;
|
||||
|
||||
private final ChatUser user;
|
||||
private final ChatUser sender;
|
||||
private final ChatUser target;
|
||||
|
||||
private ChatChannel chatChannel;
|
||||
private String format;
|
||||
private String message;
|
||||
|
||||
public ChatFormatEvent(ChatUser user, ChatChannel chatChannel, String format, String message) {
|
||||
public ChatFormatEvent(ChatUser sender, ChatUser target, ChatChannel chatChannel, String format, String message) {
|
||||
super(!Bukkit.isPrimaryThread());
|
||||
|
||||
this.user = user;
|
||||
this.sender = sender;
|
||||
this.target = target;
|
||||
|
||||
this.chatChannel = chatChannel;
|
||||
this.format = format;
|
||||
this.message = message;
|
||||
@@ -47,8 +51,12 @@ public class ChatFormatEvent extends Event implements Cancellable {
|
||||
return HANDLERS_LIST;
|
||||
}
|
||||
|
||||
public ChatUser getUser() {
|
||||
return user;
|
||||
public ChatUser getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public ChatUser getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public ChatChannel getChannel() {
|
||||
@@ -74,5 +82,4 @@ public class ChatFormatEvent extends Event implements Cancellable {
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package net.draycia.carbon.events;
|
||||
|
||||
import net.draycia.carbon.channels.ChatChannel;
|
||||
import net.draycia.carbon.storage.ChatUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PreChatFormatEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLERS_LIST = new HandlerList();
|
||||
private boolean isCancelled = false;
|
||||
|
||||
private final ChatUser user;
|
||||
private ChatChannel chatChannel;
|
||||
private String format;
|
||||
private String message;
|
||||
|
||||
public PreChatFormatEvent(ChatUser user, ChatChannel chatChannel, String format, String message) {
|
||||
super(!Bukkit.isPrimaryThread());
|
||||
|
||||
this.user = user;
|
||||
this.chatChannel = chatChannel;
|
||||
this.format = format;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return isCancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.isCancelled = cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS_LIST;
|
||||
}
|
||||
|
||||
public ChatUser getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public ChatChannel getChannel() {
|
||||
return chatChannel;
|
||||
}
|
||||
|
||||
public void setChannel(ChatChannel chatChannel) {
|
||||
this.chatChannel = chatChannel;
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat(String format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user