From 508ad88e262632c874e2a41801d83e71fe914688 Mon Sep 17 00:00:00 2001 From: Draycia Date: Tue, 15 Sep 2020 18:07:08 -0700 Subject: [PATCH] Make ChatChannel an interface --- .../carbon/api/channels/ChatChannel.java | 94 +++++++------------ .../carbon/channels/CarbonChatChannel.java | 4 +- 2 files changed, 36 insertions(+), 62 deletions(-) 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 2476eb16..5d257b72 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 @@ -12,14 +12,13 @@ import java.util.Collection; import java.util.List; import java.util.regex.Pattern; -public abstract class ChatChannel implements ForwardingAudience { +public interface ChatChannel extends ForwardingAudience { /** * Gets a list of {@link ChatUser}s to send channel messages to. * @return All {@link ChatUser}s that can see messages in this channel. */ - @NonNull - public abstract List audiences(); + @NonNull List audiences(); /** * Gets the {@link TextColor} the supplied {@link ChatUser} has set for this channel. @@ -27,111 +26,86 @@ public abstract class ChatChannel implements ForwardingAudience { * @param user The user that may have a color set. * @return The color the user may have set, otherwise the channel's color. */ - @Nullable - public abstract TextColor channelColor(@NonNull ChatUser user); + @Nullable TextColor channelColor(@NonNull ChatUser user); /** * Gets the string format for the specified group. * @param group The group. * @return The string format for the specified group. */ - @Nullable - public abstract String format(@NonNull String group); + @Nullable String format(@NonNull String group); /** * If this channel is the channel players get when they join for the first time. * Also the fallback channel in case the code is unable to find any given channel. * @return If this is the default channel. */ - public abstract boolean isDefault(); + boolean isDefault(); /** * If this channel can be ignored, such as through the /toggle command. * @return IF this channel can be ignored / toggled. */ - public abstract boolean ignorable(); + boolean ignorable(); /** * If this channel syncs between servers, typically through the messaging service. * @return If this channel syncs between servers, typically through the messaging service. */ - public abstract boolean crossServer(); + boolean crossServer(); - @NonNull - public abstract String name(); + @NonNull String name(); - @NonNull - public abstract String key(); + @NonNull String key(); - @Nullable - public abstract String messagePrefix(); + @Nullable String messagePrefix(); - @Nullable - public abstract String aliases(); + @Nullable String aliases(); - @Nullable - public abstract String switchMessage(); + @Nullable String switchMessage(); - @Nullable - public abstract String switchOtherMessage(); + @Nullable String switchOtherMessage(); - @Nullable - public abstract String switchFailureMessage(); + @Nullable String switchFailureMessage(); - @Nullable - public abstract String cannotIgnoreMessage(); + @Nullable String cannotIgnoreMessage(); - @Nullable - public abstract String toggleOffMessage(); + @Nullable String toggleOffMessage(); - @Nullable - public abstract String toggleOnMessage(); + @Nullable String toggleOnMessage(); - @Nullable - public abstract String toggleOtherOnMessage(); + @Nullable String toggleOtherOnMessage(); - @Nullable - public abstract String toggleOtherOffMessage(); + @Nullable String toggleOtherOffMessage(); - @Nullable - public abstract String cannotUseMessage(); + @Nullable String cannotUseMessage(); - public abstract boolean primaryGroupOnly(); + boolean primaryGroupOnly(); - public abstract boolean honorsRecipientList(); + boolean honorsRecipientList(); - public abstract boolean permissionGroupMatching(); + boolean permissionGroupMatching(); - public abstract boolean shouldCancelChatEvent(); + boolean shouldCancelChatEvent(); - public abstract boolean testContext(@NonNull ChatUser sender, @NonNull ChatUser target); + boolean testContext(@NonNull ChatUser sender, @NonNull ChatUser target); - @NonNull - public abstract List<@NonNull Pattern> itemLinkPatterns(); + @NonNull List<@NonNull Pattern> itemLinkPatterns(); - @Nullable - public abstract Context context(@NonNull String key); + @Nullable Context context(@NonNull String key); - @NonNull - public abstract List<@NonNull String> groupOverrides(); + @NonNull List<@NonNull String> groupOverrides(); - public abstract boolean canPlayerUse(@NonNull ChatUser user); + boolean canPlayerUse(@NonNull ChatUser user); - public abstract boolean canPlayerSee(@NonNull ChatUser sender, @NonNull ChatUser target, boolean checkSpying); + boolean canPlayerSee(@NonNull ChatUser sender, @NonNull ChatUser target, boolean checkSpying); - public abstract boolean canPlayerSee(@NonNull ChatUser target, boolean checkSpying); + boolean canPlayerSee(@NonNull ChatUser target, boolean checkSpying); - @NonNull - public abstract Component sendMessage(@NonNull ChatUser user, @NonNull String message, boolean fromBungee); + @NonNull Component sendMessage(@NonNull ChatUser user, @NonNull String message, boolean fromBungee); - @NonNull - public abstract Component sendMessage(@NonNull ChatUser user, @NonNull Collection<@NonNull ChatUser> recipients, @NonNull String message, boolean fromBungee); + @NonNull Component sendMessage(@NonNull ChatUser user, @NonNull Collection<@NonNull ChatUser> recipients, @NonNull String message, boolean fromBungee); - public abstract void sendComponent(@NonNull ChatUser user, @NonNull Component component); - - @Nullable - public String processPlaceholders(@NonNull final ChatUser user, @Nullable final String input) { - return input; - } + void sendComponent(@NonNull ChatUser user, @NonNull Component component); } diff --git a/CarbonChat-Bukkit/src/main/java/net/draycia/carbon/channels/CarbonChatChannel.java b/CarbonChat-Bukkit/src/main/java/net/draycia/carbon/channels/CarbonChatChannel.java index 129a5f88..deeb36c6 100644 --- a/CarbonChat-Bukkit/src/main/java/net/draycia/carbon/channels/CarbonChatChannel.java +++ b/CarbonChat-Bukkit/src/main/java/net/draycia/carbon/channels/CarbonChatChannel.java @@ -29,7 +29,7 @@ import java.util.Collections; import java.util.List; import java.util.regex.Pattern; -public class CarbonChatChannel extends ChatChannel { +public class CarbonChatChannel implements ChatChannel { @NonNull private final String key; @@ -164,7 +164,7 @@ public class CarbonChatChannel extends ChatChannel { "message", formatEvent.message()); if (this.isUserSpying(user, target)) { - final String prefix = this.processPlaceholders(user, this.carbonChat.getConfig().getString("spy-prefix")); + final String prefix = this.carbonChat.getConfig().getString("spy-prefix"); formatComponent = (TextComponent) MiniMessage.get().parse(prefix, "color", targetColor.asHexString()).append(formatComponent);