Improve / fix ignorable setting, fixes #33

This commit is contained in:
Draycia committed 2020-08-25 00:07:34 -07:00
1 parent 92505974d7
commit a8e3267be4
4 files changed
+15 -1

No files matched your search

@@ -56,6 +56,8 @@ public abstract class ChatChannel implements ForwardingAudience {
public abstract String getSwitchFailureMessage(); public abstract String getSwitchFailureMessage();
public abstract String getCannotIgnoreMessage();
/** /**
* @return The message to be send to the player when toggling this channel off. * @return The message to be send to the player when toggling this channel off.
*/ */
@@ -45,6 +45,10 @@ public class CarbonChatChannel extends ChatChannel {
@Override @Override
public Boolean canPlayerUse(ChatUser user) { public Boolean canPlayerUse(ChatUser user) {
if (user.getChannelSettings(this).isIgnored()) {
return false;
}
return user.asPlayer().hasPermission("carbonchat.channels." + getName() + ".use"); return user.asPlayer().hasPermission("carbonchat.channels." + getName() + ".use");
} }
@@ -402,6 +406,11 @@ public class CarbonChatChannel extends ChatChannel {
return getString("switch-failure-message"); return getString("switch-failure-message");
} }
@Override
public String getCannotIgnoreMessage() {
return getString("cannot-ignore-message");
}
@Override @Override
public String getToggleOffMessage() { public String getToggleOffMessage() {
return getString("toggle-off-message"); return getString("toggle-off-message");
@@ -26,7 +26,9 @@ public class ToggleCommand extends BaseCommand {
UserChannelSettings settings = user.getChannelSettings(channel); UserChannelSettings settings = user.getChannelSettings(channel);
if (settings.isIgnored()) { if (!channel.isIgnorable()) {
message = channel.getCannotIgnoreMessage();
} else if (settings.isIgnored()) {
settings.setIgnoring(false); settings.setIgnoring(false);
message = channel.getToggleOffMessage(); message = channel.getToggleOffMessage();
} else { } else {
+1
View File
@@ -16,6 +16,7 @@ default:
toggle-other-on: '<gray><player> <reset><gray>can now see <color><channel> <gray>chat!' toggle-other-on: '<gray><player> <reset><gray>can now see <color><channel> <gray>chat!'
toggle-other-off: '<gray><player> <reset><gray>can no longer see <color><channel> <gray>chat!' toggle-other-off: '<gray><player> <reset><gray>can no longer see <color><channel> <gray>chat!'
cannot-use-channel: 'You cannot use that channel!' cannot-use-channel: 'You cannot use that channel!'
cannot-ignore-message: '<red>You cannot ignore that channel!'
formats: formats:
# Placeholders: <username>, <displayname>, <channel>, <server>, <message>, <primaryrole>, <color> # Placeholders: <username>, <displayname>, <channel>, <server>, <message>, <primaryrole>, <color>
# Also supports PlaceholderAPI # Also supports PlaceholderAPI