diff --git a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/channels/impls/SimpleChatChannel.java b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/channels/impls/SimpleChatChannel.java index 5572fb99..56edd279 100644 --- a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/channels/impls/SimpleChatChannel.java +++ b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/channels/impls/SimpleChatChannel.java @@ -5,6 +5,7 @@ import net.draycia.simplechat.channels.ChatChannel; import net.draycia.simplechat.events.ChatComponentEvent; import net.draycia.simplechat.events.ChatFormatEvent; import net.draycia.simplechat.storage.ChatUser; +import net.kyori.adventure.audience.MessageType; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.format.TextColor; import net.kyori.adventure.text.Component; @@ -97,9 +98,9 @@ public class SimpleChatChannel extends ChatChannel { if (isUserSpying(user, chatUser)) { prefix = prefix.replace("", ""); - chatUser.sendMessage(simpleChat.processMessage(prefix).append(componentEvent.getComponent())); + chatUser.sendMessage(simpleChat.processMessage(prefix).append(componentEvent.getComponent()), MessageType.CHAT); } else if (componentEvent.getRecipients().contains(chatUser)) { - chatUser.sendMessage(componentEvent.getComponent()); + chatUser.sendMessage(componentEvent.getComponent(), MessageType.CHAT); } } else { prefix = prefix.replace("", " T getSetting(String key) { + private String getString(String key) { ConfigurationSection channelsSection = simpleChat.getConfig().getConfigurationSection("channels"); ConfigurationSection section = channelsSection.getConfigurationSection(getKey()); if (section != null && section.contains(key)) { - return (T)section.get(key); + return section.getString(key); } ConfigurationSection defaultSection = simpleChat.getConfig().getConfigurationSection("default"); if (defaultSection != null && defaultSection.contains(key)) { - return (T)defaultSection.get(key); + return defaultSection.getString(key); } return null; } - private T getSetting(String key, T def) { + private boolean getBoolean(String key) { ConfigurationSection channelsSection = simpleChat.getConfig().getConfigurationSection("channels"); ConfigurationSection section = channelsSection.getConfigurationSection(getKey()); if (section != null && section.contains(key)) { - return (T)section.get(key, def); + return section.getBoolean(key); } ConfigurationSection defaultSection = simpleChat.getConfig().getConfigurationSection("default"); if (defaultSection != null && defaultSection.contains(key)) { - return (T)defaultSection.get(key, def); + return defaultSection.getBoolean(key); } - return null; + return false; + } + + private double getDouble(String key) { + ConfigurationSection channelsSection = simpleChat.getConfig().getConfigurationSection("channels"); + ConfigurationSection section = channelsSection.getConfigurationSection(getKey()); + + if (section != null && section.contains(key)) { + return section.getDouble(key); + } + + ConfigurationSection defaultSection = simpleChat.getConfig().getConfigurationSection("default"); + + if (defaultSection != null && defaultSection.contains(key)) { + return defaultSection.getDouble(key); + } + + return 0; } @Override @@ -398,7 +416,7 @@ public class SimpleChatChannel extends ChatChannel { @Override public String getAliases() { - String aliases = getSetting("aliases"); + String aliases = getString("aliases"); if (aliases == null) { return getKey(); diff --git a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/ChannelRegisterEvent.java b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/ChannelRegisterEvent.java index 234257d6..bdc1d629 100644 --- a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/ChannelRegisterEvent.java +++ b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/ChannelRegisterEvent.java @@ -28,7 +28,7 @@ public class ChannelRegisterEvent extends Event { private Registry registry; public ChannelRegisterEvent(List registeredChannels, Registry registry) { - super(Bukkit.isPrimaryThread()); + super(!Bukkit.isPrimaryThread()); this.registeredChannels = registeredChannels; this.registry = registry; @@ -38,4 +38,7 @@ public class ChannelRegisterEvent extends Event { registry.register(chatChannel.getKey(), chatChannel); } + public List getRegisteredChannels() { + return registeredChannels; + } } diff --git a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/ChannelSwitchEvent.java b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/ChannelSwitchEvent.java index f0f7c170..c00fb901 100644 --- a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/ChannelSwitchEvent.java +++ b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/ChannelSwitchEvent.java @@ -25,7 +25,7 @@ public class ChannelSwitchEvent extends Event { private ChatUser user; public ChannelSwitchEvent(ChatChannel channel, ChatUser user) { - super(Bukkit.isPrimaryThread()); + super(!Bukkit.isPrimaryThread()); this.channel = channel; this.user = user; diff --git a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/ChatComponentEvent.java b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/ChatComponentEvent.java index 18a42e5f..1d964805 100644 --- a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/ChatComponentEvent.java +++ b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/ChatComponentEvent.java @@ -28,7 +28,7 @@ public class ChatComponentEvent extends Event implements Cancellable { } public ChatComponentEvent(ChatUser user, ChatChannel chatChannel, TextComponent component, String originalMessage, List recipients, boolean customPlayerFormat) { - super(Bukkit.isPrimaryThread()); + super(!Bukkit.isPrimaryThread()); this.user = user; this.chatChannel = chatChannel; diff --git a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/ChatFormatEvent.java b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/ChatFormatEvent.java index 774dc20c..e03e4443 100644 --- a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/ChatFormatEvent.java +++ b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/ChatFormatEvent.java @@ -19,7 +19,7 @@ public class ChatFormatEvent extends Event implements Cancellable { private String message; public ChatFormatEvent(ChatUser user, ChatChannel chatChannel, String format, String message) { - super(Bukkit.isPrimaryThread()); + super(!Bukkit.isPrimaryThread()); this.user = user; this.chatChannel = chatChannel; diff --git a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/PrivateMessageEvent.java b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/PrivateMessageEvent.java index e74c74b8..a03034e4 100644 --- a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/PrivateMessageEvent.java +++ b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/events/PrivateMessageEvent.java @@ -28,7 +28,7 @@ public class PrivateMessageEvent extends Event { private final String message; public PrivateMessageEvent(ChatUser sender, ChatUser target, Component senderComponent, Component targetComponent, String message) { - super(Bukkit.isPrimaryThread()); + super(!Bukkit.isPrimaryThread()); this.sender = sender; this.target = target; diff --git a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/storage/impl/SimpleChatUser.java b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/storage/impl/SimpleChatUser.java index cf4188f6..ad884b1f 100644 --- a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/storage/impl/SimpleChatUser.java +++ b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/storage/impl/SimpleChatUser.java @@ -75,7 +75,7 @@ public class SimpleChatUser implements ChatUser, ForwardingAudience { @Override public void setSelectedChannel(ChatChannel chatChannel) { - this.selectedChannel = chatChannel.getName(); + this.selectedChannel = chatChannel.getKey(); syncToRedis(); Bukkit.getPluginManager().callEvent(new ChannelSwitchEvent(chatChannel, this));