diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/channels/ChatChannel.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/channels/ChatChannel.java index 6ead372f..837d689d 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/channels/ChatChannel.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/channels/ChatChannel.java @@ -25,11 +25,11 @@ public interface ChatChannel extends Audience { @NonNull TextColor channelColor(@NonNull CarbonUser user); @NonNull - Map parseMessage(@NonNull PlayerUser user, @NonNull String message, boolean fromRemote); + Map parseMessage(@NonNull PlayerUser user, @NonNull String message); @NonNull Map parseMessage(@NonNull PlayerUser user, @NonNull Collection<@NonNull PlayerUser> recipients, - @NonNull String message, boolean fromRemote); + @NonNull String message); boolean canPlayerUse(@NonNull PlayerUser user); diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/channels/EmptyTextChannel.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/channels/EmptyTextChannel.java index 8ef11b98..61cb4ff2 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/channels/EmptyTextChannel.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/channels/EmptyTextChannel.java @@ -106,12 +106,12 @@ public class EmptyTextChannel implements TextChannel { } @Override - public @NonNull Map parseMessage(final @NonNull PlayerUser user, final @NonNull String message, final boolean fromRemote) { + public @NonNull Map parseMessage(final @NonNull PlayerUser user, final @NonNull String message) { return Collections.emptyMap(); } @Override - public @NonNull Map parseMessage(final @NonNull PlayerUser user, final @NonNull Collection<@NonNull PlayerUser> recipients, final @NonNull String message, final boolean fromRemote) { + public @NonNull Map parseMessage(final @NonNull PlayerUser user, final @NonNull Collection<@NonNull PlayerUser> recipients, final @NonNull String message) { return Collections.emptyMap(); } diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/users/PlayerUser.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/users/PlayerUser.java index 71c69923..b9b972bf 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/users/PlayerUser.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/users/PlayerUser.java @@ -19,11 +19,7 @@ public interface PlayerUser extends CarbonUser { @NonNull String nickname(); - default void nickname(final @Nullable String nickname) { - this.nickname(nickname, false); - } - - void nickname(@Nullable String nickname, boolean fromRemote); + void nickname(@Nullable String nickname); @NonNull String displayName(); @@ -33,7 +29,7 @@ public interface PlayerUser extends CarbonUser { @Nullable TextColor customChatColor(); - void customChatColor(@Nullable TextColor customChatColor, boolean fromRemote); + void customChatColor(@Nullable TextColor customChatColor); @NonNull String parsePlaceholders(@NonNull String input); @@ -43,70 +39,38 @@ public interface PlayerUser extends CarbonUser { boolean spyingWhispers(); - default void spyingWhispers(final boolean spyingWhispers) { - this.spyingWhispers(spyingWhispers, false); - } - - void spyingWhispers(boolean spyingWhispers, boolean fromRemote); + void spyingWhispers(boolean spyingWhispers); boolean muted(); - default void muted(final boolean muted) { - this.muted(muted, false); - } - - void muted(boolean muted, boolean fromRemote); + void muted(boolean muted); boolean shadowMuted(); - default void shadowMuted(final boolean shadowMuted) { - this.shadowMuted(shadowMuted, false); - } - - void shadowMuted(boolean shadowMuted, boolean fromRemote); + void shadowMuted(boolean shadowMuted); @Nullable UUID replyTarget(); - default void replyTarget(final @Nullable UUID target) { - this.replyTarget(target, false); - } - default void replyTarget(final @Nullable PlayerUser user) { if (user == null) { - this.replyTarget((UUID) null, false); + this.replyTarget((UUID) null); } else { - this.replyTarget(user.uuid(), false); + this.replyTarget(user.uuid()); } } - void replyTarget(@Nullable UUID target, boolean fromRemote); - - default void replyTarget(final @Nullable PlayerUser user, final boolean fromRemote) { - if (user == null) { - this.replyTarget((UUID) null, fromRemote); - } else { - this.replyTarget(user.uuid(), fromRemote); - } - } + void replyTarget(@Nullable UUID target); boolean ignoringUser(@NonNull UUID uuid); - void ignoringUser(@NonNull UUID uuid, boolean ignoring, boolean fromRemote); - - default void ignoringUser(final @NonNull UUID uuid, final boolean ignoring) { - this.ignoringUser(uuid, ignoring, false); - } + void ignoringUser(@NonNull UUID uuid, boolean ignoring); default boolean ignoringUser(final @NonNull PlayerUser user) { return this.ignoringUser(user.uuid()); } - default void ignoringUser(final @NonNull PlayerUser user, final boolean ignoring, final boolean fromRemote) { - this.ignoringUser(user.uuid(), ignoring, fromRemote); - } - - default void ignoringUser(final @NonNull PlayerUser user, final boolean ignoring) { - this.ignoringUser(user.uuid(), ignoring, false); + default void ignoringUser(final @NonNull PlayerUser user, boolean ignoring) { + this.ignoringUser(user.uuid(), ignoring); } @NonNull Iterable ignoredChatUsers(); @@ -125,11 +89,7 @@ public interface PlayerUser extends CarbonUser { @Nullable ChatChannel selectedChannel(); - default void selectedChannel(final @NonNull ChatChannel channel) { - this.selectedChannel(channel, false); - } - - void selectedChannel(@NonNull ChatChannel channel, boolean fromRemote); + void selectedChannel(@NonNull ChatChannel channel); void clearSelectedChannel(); diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/users/UserChannelSettings.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/users/UserChannelSettings.java index ff46cb85..20ac877b 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/users/UserChannelSettings.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/users/UserChannelSettings.java @@ -7,27 +7,15 @@ public interface UserChannelSettings { boolean spying(); - default void spying(final boolean spying) { - this.spying(spying, false); - } - - void spying(boolean spying, boolean fromRemote); + void spying(boolean spying); boolean ignored(); - void ignoring(boolean ignored, boolean fromRemote); - - default void ignoring(final boolean ignored) { - this.ignoring(ignored, false); - } + void ignoring(boolean ignored); @Nullable TextColor color(); - default void color(final @Nullable TextColor color) { - this.color(color, false); - } - - void color(@Nullable TextColor color, boolean fromRemote); + void color(@Nullable TextColor color); } diff --git a/CarbonChat-Bukkit/src/main/java/net/draycia/carbon/bukkit/listeners/BukkitChatHandler.java b/CarbonChat-Bukkit/src/main/java/net/draycia/carbon/bukkit/listeners/BukkitChatHandler.java index c165713f..1ebb6453 100644 --- a/CarbonChat-Bukkit/src/main/java/net/draycia/carbon/bukkit/listeners/BukkitChatHandler.java +++ b/CarbonChat-Bukkit/src/main/java/net/draycia/carbon/bukkit/listeners/BukkitChatHandler.java @@ -70,7 +70,7 @@ public class BukkitChatHandler implements Listener { if (event.isAsynchronous()) { final Map messages = - selectedChannel.parseMessage(user, event.getMessage(), false); + selectedChannel.parseMessage(user, event.getMessage()); for (final Map.Entry entry : messages.entrySet()) { if (entry.getValue().equals(Component.empty())) { @@ -87,7 +87,7 @@ public class BukkitChatHandler implements Listener { } else { Bukkit.getScheduler().runTaskAsynchronously(this.carbonChat, () -> { selectedChannel.sendComponentsAndLog(user.identity(), - selectedChannel.parseMessage(user, event.getMessage(), false)); + selectedChannel.parseMessage(user, event.getMessage())); // if (this.carbonChat.getConfig().getBoolean("show-tips")) { // this.carbonChat.logger().info("Tip: Sync chat event! I cannot set the message format due to this. :("); diff --git a/CarbonChat-Bukkit/src/main/java/net/draycia/carbon/bukkit/users/BukkitPlayerUser.java b/CarbonChat-Bukkit/src/main/java/net/draycia/carbon/bukkit/users/BukkitPlayerUser.java index 005fcff5..494ef4cd 100644 --- a/CarbonChat-Bukkit/src/main/java/net/draycia/carbon/bukkit/users/BukkitPlayerUser.java +++ b/CarbonChat-Bukkit/src/main/java/net/draycia/carbon/bukkit/users/BukkitPlayerUser.java @@ -142,7 +142,7 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single { } @Override - public void nickname(@Nullable String newNickname, final boolean fromRemote) { + public void nickname(@Nullable String newNickname) { this.nickname = newNickname; final OfflinePlayer player = Bukkit.getOfflinePlayer(this.uuid()); @@ -160,19 +160,6 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single { onlinePlayer.setPlayerListName(newNickname); } } - - if (!fromRemote) { - final String nick = this.nickname; - - if (nick == null) { - this.carbonChat.messageManager().sendMessage("nickname-reset", this.uuid(), byteArray -> { - }); - } else { - this.carbonChat.messageManager().sendMessage("nickname", this.uuid(), byteArray -> { - byteArray.writeUTF(nick); - }); - } - } } @Override @@ -204,19 +191,8 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single { } @Override - public void customChatColor(final @Nullable TextColor customChatColor, final boolean fromRemote) { + public void customChatColor(final @Nullable TextColor customChatColor) { this.customChatColor = customChatColor; - - if (!fromRemote) { - if (customChatColor == null) { - this.carbonChat.messageManager().sendMessage("custom-chat-color-reset", this.uuid(), byteArray -> { - }); - } else { - this.carbonChat.messageManager().sendMessage("custom-chat-color", this.uuid(), byteArray -> { - byteArray.writeUTF(customChatColor.asHexString()); - }); - } - } } @Override @@ -241,7 +217,7 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single { } @Override - public void selectedChannel(final @NonNull ChatChannel chatChannel, final boolean fromRemote) { + public void selectedChannel(final @NonNull ChatChannel chatChannel) { final String failureMessage = chatChannel.switchFailureMessage(); final ChannelSwitchEvent event = new ChannelSwitchEvent(chatChannel, this, failureMessage); @@ -258,12 +234,6 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single { this.selectedChannelKey = chatChannel.key(); this.selectedChannel = chatChannel; - if (!fromRemote) { - this.carbonChat.messageManager().sendMessage("selected-channel", this.uuid(), byteArray -> { - byteArray.writeUTF(chatChannel.key()); - }); - } - final OfflinePlayer player = Bukkit.getOfflinePlayer(this.uuid()); if (player.isOnline()) { @@ -284,20 +254,12 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single { } @Override - public void ignoringUser(final @NonNull UUID uuid, final boolean ignoring, final boolean fromRemote) { + public void ignoringUser(final @NonNull UUID uuid, final boolean ignoring) { if (ignoring) { this.ignoredUsers.add(uuid); } else { this.ignoredUsers.remove(uuid); } - - if (!fromRemote) { - this.carbonChat.messageManager().sendMessage("ignoring-user", this.uuid(), byteArray -> { - byteArray.writeLong(uuid.getMostSignificantBits()); - byteArray.writeLong(uuid.getLeastSignificantBits()); - byteArray.writeBoolean(ignoring); - }); - } } @Override @@ -357,14 +319,8 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single { } @Override - public void muted(final boolean muted, final boolean fromRemote) { + public void muted(final boolean muted) { this.muted = muted; - - if (!fromRemote) { - this.carbonChat.messageManager().sendMessage("muted", this.uuid(), byteArray -> { - byteArray.writeBoolean(muted); - }); - } } @Override @@ -373,14 +329,8 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single { } @Override - public void shadowMuted(final boolean shadowMuted, final boolean fromRemote) { + public void shadowMuted(final boolean shadowMuted) { this.shadowMuted = shadowMuted; - - if (!fromRemote) { - this.carbonChat.messageManager().sendMessage("shadow-muted", this.uuid(), byteArray -> { - byteArray.writeBoolean(shadowMuted); - }); - } } @Override @@ -394,26 +344,14 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single { } @Override - public void replyTarget(final @Nullable UUID target, final boolean fromRemote) { + public void replyTarget(final @Nullable UUID target) { this.replyTarget = target; - - if (!fromRemote) { - if (target != null) { - this.carbonChat.messageManager().sendMessage("reply-target", this.uuid(), byteArray -> { - byteArray.writeLong(target.getMostSignificantBits()); - byteArray.writeLong(target.getLeastSignificantBits()); - }); - } else { - this.carbonChat.messageManager().sendMessage("reply-target-reset", this.uuid(), byteArray -> { - }); - } - } } @Override public @NonNull UserChannelSettings channelSettings(final @NonNull ChatChannel channel) { return this.channelSettings.computeIfAbsent(channel.key(), name -> { - return new SimpleUserChannelSettings(this.uuid, channel.key()); + return new SimpleUserChannelSettings(this.uuid); }); } @@ -422,14 +360,8 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single { } @Override - public void spyingWhispers(final boolean spyingWhispers, final boolean fromRemote) { + public void spyingWhispers(final boolean spyingWhispers) { this.spyingWhispers = spyingWhispers; - - if (!fromRemote) { - this.carbonChat.messageManager().sendMessage("spying-whispers", this.uuid(), byteArray -> { - byteArray.writeBoolean(spyingWhispers); - }); - } } @Override diff --git a/CarbonChat-Bukkit/src/main/java/net/draycia/carbon/bukkit/users/SimpleUserChannelSettings.java b/CarbonChat-Bukkit/src/main/java/net/draycia/carbon/bukkit/users/SimpleUserChannelSettings.java index 9422dfdc..edf377e6 100644 --- a/CarbonChat-Bukkit/src/main/java/net/draycia/carbon/bukkit/users/SimpleUserChannelSettings.java +++ b/CarbonChat-Bukkit/src/main/java/net/draycia/carbon/bukkit/users/SimpleUserChannelSettings.java @@ -17,12 +17,10 @@ public class SimpleUserChannelSettings implements UserChannelSettings { private boolean ignored; private @Nullable String color; private @NonNull UUID uuid; - private @NonNull String channel; @SuppressWarnings("initialization.fields.uninitialized") - public SimpleUserChannelSettings(final @NonNull UUID uuid, final @NonNull String channel) { + public SimpleUserChannelSettings(final @NonNull UUID uuid) { this.uuid = uuid; - this.channel = channel; } private @NonNull CarbonUser user() { @@ -35,15 +33,8 @@ public class SimpleUserChannelSettings implements UserChannelSettings { } @Override - public void spying(final boolean spying, final boolean fromRemote) { + public void spying(final boolean spying) { this.spying = spying; - - if (!fromRemote) { - this.carbonChat.messageService().sendMessage("spying-channel", this.uuid, byteArray -> { - byteArray.writeUTF(this.channel); - byteArray.writeBoolean(spying); - }); - } } @Override @@ -52,15 +43,8 @@ public class SimpleUserChannelSettings implements UserChannelSettings { } @Override - public void ignoring(final boolean ignored, final boolean fromRemote) { + public void ignoring(final boolean ignored) { this.ignored = ignored; - - if (!fromRemote) { - this.carbonChat.messageService().sendMessage("ignoring-channel", this.uuid, byteArray -> { - byteArray.writeUTF(this.channel); - byteArray.writeBoolean(ignored); - }); - } } @Override @@ -73,25 +57,12 @@ public class SimpleUserChannelSettings implements UserChannelSettings { } @Override - public void color(final @Nullable TextColor color, final boolean fromRemote) { + public void color(final @Nullable TextColor color) { if (color == null) { this.color = null; } else { this.color = color.asHexString(); } - - if (!fromRemote) { - final String newColor = this.color; - - if (newColor == null || newColor.isEmpty()) { - this.carbonChat.messageService().sendMessage("channel-color-reset", this.uuid, byteArray -> { - }); - } else { - this.carbonChat.messageService().sendMessage("channel-color", this.uuid, byteArray -> { - byteArray.writeUTF(newColor); - }); - } - } } } diff --git a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/channels/CarbonChatChannel.java b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/channels/CarbonChatChannel.java index 99000b54..f50f0fc4 100644 --- a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/channels/CarbonChatChannel.java +++ b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/channels/CarbonChatChannel.java @@ -106,7 +106,7 @@ public class CarbonChatChannel implements TextChannel { // } @Override - public @NonNull Map parseMessage(final @NonNull PlayerUser user, final @NonNull Collection<@NonNull PlayerUser> recipients, final @NonNull String message, final boolean fromRemote) { + public @NonNull Map parseMessage(final @NonNull PlayerUser user, final @NonNull Collection<@NonNull PlayerUser> recipients, final @NonNull String message) { //this.updateUserNickname(user); final MessageContextEvent event = new MessageContextEvent(this, user); @@ -226,7 +226,8 @@ public class CarbonChatChannel implements TextChannel { } } - if (user.online() && !fromRemote && this.crossServer()) { + // TODO: Rethink how cross server messaging works. There should be no recursion inherent in the design. + if (user.online() && this.crossServer()) { this.sendMessageToBungee(user.uuid(), consoleEvent.component()); } @@ -263,8 +264,8 @@ public class CarbonChatChannel implements TextChannel { } @Override - public @NonNull Map parseMessage(final @NonNull PlayerUser user, final @NonNull String message, final boolean fromRemote) { - return this.parseMessage(user, this.audiences(), message, fromRemote); + public @NonNull Map parseMessage(final @NonNull PlayerUser user, final @NonNull String message) { + return this.parseMessage(user, this.audiences(), message); } public @NonNull String format(final @NonNull PlayerUser user) { diff --git a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/channels/CarbonWhisperChannel.java b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/channels/CarbonWhisperChannel.java index 2404f6ab..00eee864 100644 --- a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/channels/CarbonWhisperChannel.java +++ b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/channels/CarbonWhisperChannel.java @@ -64,15 +64,14 @@ public class CarbonWhisperChannel implements WhisperChannel { } @Override - public @NonNull Map parseMessage(final @NonNull PlayerUser user, final @NonNull String message, - final boolean fromRemote) { - return this.parseMessage(user, Collections.singleton(this.audience()), message, fromRemote); + public @NonNull Map parseMessage(final @NonNull PlayerUser user, final @NonNull String message) { + return this.parseMessage(user, Collections.singleton(this.audience()), message); } @Override public @NonNull Map parseMessage(final @NonNull PlayerUser user, final @NonNull Collection<@NonNull PlayerUser> recipients, - final @NonNull String message, final boolean fromRemote) { + final @NonNull String message) { final Map result = new HashMap<>(); // Formats diff --git a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/AliasedChannelCommand.java b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/AliasedChannelCommand.java index dd6a30e0..e5f7e737 100644 --- a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/AliasedChannelCommand.java +++ b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/AliasedChannelCommand.java @@ -61,7 +61,7 @@ public class AliasedChannelCommand { context.getOptional("message").ifPresent(message -> { this.chatChannel().sendComponentsAndLog( context.getSender().identity(), - this.chatChannel().parseMessage(user, message, false)); + this.chatChannel().parseMessage(user, message)); }); } diff --git a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/ChannelCommand.java b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/ChannelCommand.java index e5e1816e..e3d84853 100644 --- a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/ChannelCommand.java +++ b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/ChannelCommand.java @@ -66,8 +66,7 @@ public class ChannelCommand { if (!this.canUse(user, channel)) return; - channel.sendComponentsAndLog(context.getSender().identity(), channel.parseMessage(user, - message, false)); + channel.sendComponentsAndLog(context.getSender().identity(), channel.parseMessage(user, message)); } private boolean canUse(final PlayerUser user, final ChatChannel channel) { diff --git a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/SudoChannelCommand.java b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/SudoChannelCommand.java index c9f29301..0a949e06 100644 --- a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/SudoChannelCommand.java +++ b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/SudoChannelCommand.java @@ -76,7 +76,7 @@ public class SudoChannelCommand { final ChatChannel channel = context.get("channel"); final String message = context.get("message"); - channel.sendComponentsAndLog(user.identity(), channel.parseMessage(user, message, false)); + channel.sendComponentsAndLog(user.identity(), channel.parseMessage(user, message)); } } diff --git a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/messaging/MessageManager.java b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/messaging/MessageManager.java index 192323c9..2db069a6 100644 --- a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/messaging/MessageManager.java +++ b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/messaging/MessageManager.java @@ -8,7 +8,6 @@ import net.draycia.carbon.api.channels.ChatChannel; import net.draycia.carbon.api.users.PlayerUser; import net.kyori.adventure.identity.Identity; import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.TextColor; import org.checkerframework.checker.nullness.qual.NonNull; import java.util.UUID; @@ -29,90 +28,6 @@ public class MessageManager { } private void registerDefaultListeners() { - this.messageService().registerUserMessageListener("nickname", (user, byteArray) -> { - final String nickname = byteArray.readUTF(); - final String message = this.carbonChat.translations().nicknameSet(); - - user.nickname(nickname, true); - user.sendMessage(Identity.nil(), this.carbonChat.messageProcessor() - .processMessage(message, "nickname", nickname)); - }); - - this.messageService().registerUserMessageListener("nickname-reset", (user, byteArray) -> { - final String message = this.carbonChat.translations().nicknameReset(); - - user.nickname(null, true); - user.sendMessage(Identity.nil(), this.carbonChat.messageProcessor().processMessage(message)); - }); - - this.messageService().registerUserMessageListener("selected-channel", (user, byteArray) -> { - final ChatChannel channel = this.carbonChat.channelRegistry().get(byteArray.readUTF()); - - if (channel != null) { - user.selectedChannel(channel, true); - } - }); - - this.messageService().registerUserMessageListener("spying-whispers", (user, byteArray) -> { - user.spyingWhispers(byteArray.readBoolean(), true); - }); - - this.messageService().registerUserMessageListener("muted", (user, byteArray) -> { - user.muted(byteArray.readBoolean(), true); - }); - - this.messageService().registerUserMessageListener("shadow-muted", (user, byteArray) -> { - user.shadowMuted(byteArray.readBoolean(), true); - }); - - this.messageService().registerUserMessageListener("reply-target", (user, byteArray) -> { - user.replyTarget(new UUID(byteArray.readLong(), byteArray.readLong()), true); - }); - - this.messageService().registerUserMessageListener("reply-target-reset", (user, byteArray) -> { - user.replyTarget((UUID) null, true); - }); - - this.messageService().registerUserMessageListener("ignoring-user", (user, byteArray) -> { - user.ignoringUser(new UUID(byteArray.readLong(), byteArray.readLong()), byteArray.readBoolean(), true); - }); - - this.messageService().registerUserMessageListener("ignoring-channel", (user, byteArray) -> { - final ChatChannel channel = this.carbonChat.channelRegistry().get(byteArray.readUTF()); - - if (channel != null) { - user.channelSettings(channel) - .ignoring(byteArray.readBoolean(), true); - } - }); - - this.messageService().registerUserMessageListener("spying-channel", (user, byteArray) -> { - final ChatChannel channel = this.carbonChat.channelRegistry().get(byteArray.readUTF()); - - if (channel != null) { - user.channelSettings(channel) - .spying(byteArray.readBoolean(), true); - } - }); - - this.messageService().registerUserMessageListener("channel-color", (user, byteArray) -> { - final ChatChannel channel = this.carbonChat.channelRegistry().get(byteArray.readUTF()); - - if (channel != null) { - user.channelSettings(channel) - .color(TextColor.fromHexString(byteArray.readUTF()), true); - } - }); - - this.messageService().registerUserMessageListener("channel-color-reset", (user, byteArray) -> { - final ChatChannel channel = this.carbonChat.channelRegistry().get(byteArray.readUTF()); - - if (channel != null) { - user.channelSettings(channel) - .color(null, true); - } - }); - this.messageService().registerUUIDMessageListener("channel-component", (uuid, byteArray) -> { final ChatChannel channel = this.carbonChat.channelRegistry().get(byteArray.readUTF()); final PlayerUser user = this.carbonChat.userService().wrap(uuid); @@ -152,14 +67,6 @@ public class MessageManager { "target", target.displayName(), "sender", sender.displayName())); } }); - - this.messageService().registerUserMessageListener("custom-chat-color-reset", (user, byteArray) -> { - user.customChatColor(null, true); - }); - - this.messageService().registerUserMessageListener("custom-chat-color", (user, byteArray) -> { - user.customChatColor(TextColor.fromHexString(byteArray.readUTF()), true); - }); } public @NonNull MessageService messageService() { diff --git a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/users/MySQLUserService.java b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/users/MySQLUserService.java index 75610ec3..540877b1 100644 --- a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/users/MySQLUserService.java +++ b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/users/MySQLUserService.java @@ -189,18 +189,18 @@ public class MySQLUserService imple final ChatChannel channel = this.carbonChat.channelRegistry().getOrDefault(users.get("channel")); - user.selectedChannel(channel, true); + user.selectedChannel(channel); final String nickname = users.get("nickname"); if (nickname != null) { - user.nickname(nickname, true); + user.nickname(nickname); } - user.muted(users.get("muted"), true); - user.shadowMuted(users.get("shadowmuted"), true); - user.spyingWhispers(users.get("spyingwhispers"), true); - user.customChatColor(users.get("customchatcolor"), true); + user.muted(users.get("muted")); + user.shadowMuted(users.get("shadowmuted")); + user.spyingWhispers(users.get("spyingwhispers")); + user.customChatColor(users.get("customchatcolor")); final String whisperPingKey = users.get("whisperpingkey"); final Float whisperPingVolume = users.get("whisperpingvolume"); @@ -234,19 +234,19 @@ public class MySQLUserService imple if (chatChannel != null) { final UserChannelSettings settings = user.channelSettings(chatChannel); - settings.spying(channelSetting.get("spying"), true); - settings.ignoring(channelSetting.get("ignored"), true); + settings.spying(channelSetting.get("spying")); + settings.ignoring(channelSetting.get("ignored")); final String color = channelSetting.get("color"); if (color != null) { - settings.color(TextColor.fromHexString(color), true); + settings.color(TextColor.fromHexString(color)); } } } for (final DbRow ignoredUser : ignoredUsers) { - user.ignoringUser(UUID.fromString(ignoredUser.get("user")), true, true); + user.ignoringUser(UUID.fromString(ignoredUser.get("user")), true); } } catch (final SQLException exception) { exception.printStackTrace();