mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 14:38:48 +00:00
uyh7777777777777777777777777777777777
This commit is contained in:
1 parent
9f98f6a42d
commit
15f2c6c20f
7 files changed
+53
-32
No files matched your search
+44
-26
@@ -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("<color>", "<color:" + getColor() + ">");
|
||||
|
||||
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("<color>", "<color:" +
|
||||
@@ -125,7 +126,7 @@ public class SimpleChatChannel extends ChatChannel {
|
||||
|
||||
Bukkit.getPluginManager().callEvent(newEvent);
|
||||
|
||||
chatUser.sendMessage(newEvent.getComponent());
|
||||
chatUser.sendMessage(newEvent.getComponent(), MessageType.CHAT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +267,7 @@ public class SimpleChatChannel extends ChatChannel {
|
||||
|
||||
@Override
|
||||
public TextColor getColor() {
|
||||
return TextColor.fromHexString(getSetting("color"));
|
||||
return TextColor.fromHexString(getString("color"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -277,73 +278,73 @@ public class SimpleChatChannel extends ChatChannel {
|
||||
|
||||
@Override
|
||||
public Boolean isDefault() {
|
||||
return getSetting("default") == null ? false : getSetting("default");
|
||||
return getBoolean("default");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isIgnorable() {
|
||||
return getSetting("ignorable");
|
||||
return getBoolean("ignorable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean shouldBungee() {
|
||||
return getSetting("should-bungee");
|
||||
return getBoolean("should-bungee");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
String name = getSetting("name");
|
||||
String name = getString("name");
|
||||
return name == null ? key : name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getDistance() {
|
||||
return this.getSetting("distance");
|
||||
return getDouble("distance");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwitchMessage() {
|
||||
return getSetting("switch-message");
|
||||
return getString("switch-message");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwitchOtherMessage() {
|
||||
return getSetting("switch-other-message");
|
||||
return getString("switch-other-message");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToggleOffMessage() {
|
||||
return getSetting("toggle-off-message");
|
||||
return getString("toggle-off-message");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToggleOnMessage() {
|
||||
return getSetting("toggle-on-message");
|
||||
return getString("toggle-on-message");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToggleOtherOnMessage() {
|
||||
return getSetting("toggle-other-on");
|
||||
return getString("toggle-other-on");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToggleOtherOffMessage() {
|
||||
return getSetting("toggle-other-off");
|
||||
return getString("toggle-other-off");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCannotUseMessage() {
|
||||
return getSetting("cannot-use-channel");
|
||||
return getString("cannot-use-channel");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean shouldForwardFormatting() {
|
||||
return getSetting("forward-format");
|
||||
return getBoolean("forward-format");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean firstMatchingGroup() {
|
||||
return getSetting("first-matching-group");
|
||||
return getBoolean("first-matching-group");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -357,38 +358,55 @@ public class SimpleChatChannel extends ChatChannel {
|
||||
return itemPatterns;
|
||||
}
|
||||
|
||||
private <T> 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> 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();
|
||||
|
||||
+4
-1
@@ -28,7 +28,7 @@ public class ChannelRegisterEvent extends Event {
|
||||
private Registry<ChatChannel> registry;
|
||||
|
||||
public ChannelRegisterEvent(List<ChatChannel> registeredChannels, Registry<ChatChannel> 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<ChatChannel> getRegisteredChannels() {
|
||||
return registeredChannels;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ public class ChatComponentEvent extends Event implements Cancellable {
|
||||
}
|
||||
|
||||
public ChatComponentEvent(ChatUser user, ChatChannel chatChannel, TextComponent component, String originalMessage, List<ChatUser> recipients, boolean customPlayerFormat) {
|
||||
super(Bukkit.isPrimaryThread());
|
||||
super(!Bukkit.isPrimaryThread());
|
||||
|
||||
this.user = user;
|
||||
this.chatChannel = chatChannel;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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));
|
||||
|
||||
Reference in new issue
Block a user