From cb060225f1d5a706f29958fdf93699f2f2edb7e3 Mon Sep 17 00:00:00 2001 From: Draycia Date: Mon, 29 Jun 2020 08:45:28 -0700 Subject: [PATCH] Add per channel bungee toggle --- .../simplechat/channels/ChatChannel.java | 3 +++ .../channels/impls/SimpleChatChannel.java | 19 +++++++++++++++++-- .../simplechat/managers/ChannelManager.java | 4 ++++ src/main/resources/config.yml | 1 + 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/draycia/simplechat/channels/ChatChannel.java b/src/main/java/net/draycia/simplechat/channels/ChatChannel.java index b4c2bea3..142406a6 100644 --- a/src/main/java/net/draycia/simplechat/channels/ChatChannel.java +++ b/src/main/java/net/draycia/simplechat/channels/ChatChannel.java @@ -42,6 +42,8 @@ public abstract class ChatChannel { */ public abstract boolean isIgnorable(); + public abstract boolean shouldBungee(); + /** * @return The name of this channel. */ @@ -139,6 +141,7 @@ public abstract class ChatChannel { public abstract ChatChannel.Builder setToggleOffMessage(String toggleOffMessage); public abstract ChatChannel.Builder setToggleOnMessage(String toggleOnMessage); public abstract ChatChannel.Builder setShouldForwardFormatting(boolean forwardFormatting); + public abstract ChatChannel.Builder setShouldBungee(boolean shouldBungee); } } diff --git a/src/main/java/net/draycia/simplechat/channels/impls/SimpleChatChannel.java b/src/main/java/net/draycia/simplechat/channels/impls/SimpleChatChannel.java index b52c8e89..bdad4d31 100644 --- a/src/main/java/net/draycia/simplechat/channels/impls/SimpleChatChannel.java +++ b/src/main/java/net/draycia/simplechat/channels/impls/SimpleChatChannel.java @@ -39,6 +39,7 @@ public class SimpleChatChannel extends ChatChannel { private String toggleOffMessage; private String toggleOnMessage; private boolean forwardFormatting; + private boolean shouldBungee; private DiscordWebhook discordWebhook = null; @@ -46,7 +47,7 @@ public class SimpleChatChannel extends ChatChannel { private SimpleChatChannel() { } - SimpleChatChannel(TextColor color, long id, Map formats, String webhook, boolean isDefault, boolean ignorable, String name, double distance, String switchMessage, String toggleOffMessage, String toggleOnMessage, boolean forwardFormatting, SimpleChat simpleChat) { + SimpleChatChannel(TextColor color, long id, Map formats, String webhook, boolean isDefault, boolean ignorable, String name, double distance, String switchMessage, String toggleOffMessage, String toggleOnMessage, boolean forwardFormatting, boolean shouldBungee, SimpleChat simpleChat) { this.color = color; this.id = id; this.formats = formats; @@ -59,6 +60,7 @@ public class SimpleChatChannel extends ChatChannel { this.toggleOffMessage = toggleOffMessage; this.toggleOnMessage = toggleOnMessage; this.forwardFormatting = forwardFormatting; + this.shouldBungee = shouldBungee; this.simpleChat = simpleChat; @@ -277,6 +279,11 @@ public class SimpleChatChannel extends ChatChannel { return ignorable; } + @Override + public boolean shouldBungee() { + return shouldBungee; + } + @Override public String getName() { return name; @@ -325,6 +332,7 @@ public class SimpleChatChannel extends ChatChannel { private String toggleOffMessage = "You can no longer see chat!"; private String toggleOnMessage = "You can now see chat!"; private boolean forwardFormatting = true; + private boolean shouldBungee = false; private Builder() { } @@ -334,7 +342,7 @@ public class SimpleChatChannel extends ChatChannel { @Override public SimpleChatChannel build(SimpleChat simpleChat) { - return new SimpleChatChannel(color, id, formats, webhook, isDefault, ignorable, name, distance, switchMessage, toggleOffMessage, toggleOnMessage, forwardFormatting, simpleChat); + return new SimpleChatChannel(color, id, formats, webhook, isDefault, ignorable, name, distance, switchMessage, toggleOffMessage, toggleOnMessage, forwardFormatting, shouldBungee, simpleChat); } @Override @@ -425,6 +433,13 @@ public class SimpleChatChannel extends ChatChannel { return this; } + + @Override + public Builder setShouldBungee(boolean shouldBungee) { + this.shouldBungee = shouldBungee; + + return this; + } } } diff --git a/src/main/java/net/draycia/simplechat/managers/ChannelManager.java b/src/main/java/net/draycia/simplechat/managers/ChannelManager.java index 18e03701..c17b0c20 100644 --- a/src/main/java/net/draycia/simplechat/managers/ChannelManager.java +++ b/src/main/java/net/draycia/simplechat/managers/ChannelManager.java @@ -97,6 +97,10 @@ public class ChannelManager { builder.setShouldForwardFormatting(section.getBoolean("forward-format")); } + if (section.contains("should-bungee")) { + builder.setShouldBungee(section.getBoolean("should-bungee")); + } + ChatChannel channel = builder.build(simpleChat); if (channel.isTownChat() || channel.isNationChat() || channel.isAllianceChat()) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index a76d32d6..68da0b0d 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -19,6 +19,7 @@ channels: ignorable: true # Removing this option defaults to 'true' distance: -1 # Set to -1, comment out, or remove to disable distance checking forward-format: true # Removing this option defaults to 'true'. Forces all other servers to use this server's formatting for this channel. + should-bungee: true # Removing this option defaults to 'false'. Enables/disables cross server chat for this channel. bot-token: -1