update to built-in modules style

This commit is contained in:
Larry committed 2020-08-22 13:17:28 -06:00
commit 9d3e893ca9
85 files changed
+455 -702

No files matched your search

@@ -0,0 +1,50 @@
package net.draycia.carbon.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.ConditionFailedException;
import co.aikar.commands.annotation.*;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.channels.ChatChannel;
import net.draycia.carbon.storage.ChatUser;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@CommandAlias("%channelName")
@CommandPermission("carbonchat.switch")
public class AliasedChannelCommand extends BaseCommand {
@Dependency
private CarbonChat carbonChat;
private final ChatChannel chatChannel;
public AliasedChannelCommand(ChatChannel chatChannel) {
this.chatChannel = chatChannel;
}
@Default
@Syntax("[message]")
public void baseCommand(Player player, @Optional String[] args) {
ChatUser user = carbonChat.getUserService().wrap(player);
if (!chatChannel.canPlayerUse(user)) {
throw new ConditionFailedException(chatChannel.getCannotUseMessage());
}
if (args == null || args.length == 0) {
user.setSelectedChannel(getChatChannel());
user.sendMessage(carbonChat.getAdventureManager().processMessage(getChatChannel().getSwitchMessage(),
"color", "<" + getChatChannel().getChannelColor(user).toString() + ">",
"channel", getChatChannel().getName()));
} else {
Bukkit.getScheduler().runTaskAsynchronously(carbonChat, () -> {
getChatChannel().sendMessage(user, String.join(" ", args), false);
});
}
}
public ChatChannel getChatChannel() {
return chatChannel;
}
}
@@ -0,0 +1,57 @@
package net.draycia.carbon.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.channels.ChatChannel;
import net.draycia.carbon.storage.ChatUser;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandAlias("ch|channel|switch")
@CommandPermission("carbonchat.switch")
public class ChannelCommand extends BaseCommand {
@Dependency
private CarbonChat carbonChat;
@Default
@CommandCompletion("@chatchannel")
@Syntax("<channel> [message]")
public void baseCommand(Player player, @Conditions("canuse:true") ChatChannel channel, @Optional String[] args) {
ChatUser user = carbonChat.getUserService().wrap(player);
if (args == null || args.length == 0) {
user.setSelectedChannel(channel);
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, channel.getSwitchMessage(),
"br", "\n",
"color", "<" + channel.getChannelColor(user).toString() + ">",
"channel", channel.getName()));
} else {
Bukkit.getScheduler().runTaskAsynchronously(carbonChat, () -> {
channel.sendMessage(user, String.join(" ", args), false);
});
}
}
@CommandPermission("carbonchat.switch.others")
@Subcommand("other")
@CommandCompletion("@chatchannel @players")
@Syntax("<channel> <user>")
public void baseCommand(CommandSender sender, @Conditions("exists:true") ChatChannel channel, ChatUser user) {
user.setSelectedChannel(channel);
String message = channel.getSwitchMessage();
String otherMessage = channel.getSwitchOtherMessage();
user.sendMessage(carbonChat.getAdventureManager().processMessage(message, "br", "\n",
"color", "<color:" + channel.getChannelColor(user).toString() + ">", "channel", channel.getName()));
carbonChat.getAdventureManager().getAudiences().audience(sender).sendMessage(carbonChat.getAdventureManager().processMessage(otherMessage, "br", "\n",
"color", "<color:" + channel.getChannelColor(user).toString() + ">", "channel", channel.getName(),
"player", user.asOfflinePlayer().getName()));
}
}
@@ -0,0 +1,92 @@
package net.draycia.carbon.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.channels.ChatChannel;
import net.draycia.carbon.storage.ChatUser;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.*;
import java.util.List;
@CommandAlias("chlist|channellist")
@CommandPermission("carbonchat.channellist")
public class ChannelListCommand extends BaseCommand {
@Dependency
private CarbonChat carbonChat;
@Default
@Syntax("[player]")
public void baseCommand(Player player) {
TextComponent.Builder component = TextComponent.builder("");
Iterator<ChatChannel> allChannels = carbonChat.getChannelManager().getRegistry().values().iterator();
ChatUser user = carbonChat.getUserService().wrap(player);
getChannelLists(player, user, allChannels, component);
user.sendMessage(component.build());
}
@CommandPermission("carbonchat.channellist.others")
@Subcommand("user")
@CommandCompletion("@players")
@Syntax("<player>")
public void baseCommand(Player player, ChatUser user) {
ChatUser cmdSender = carbonChat.getUserService().wrap(player);
TextComponent.Builder component = TextComponent.builder("");
Iterator<ChatChannel> allChannels = carbonChat.getChannelManager().getRegistry().values().iterator();
getChannelLists(player, user, allChannels, component);
cmdSender.sendMessage(component.build());
}
private void getChannelLists(CommandSender player, ChatUser user, Iterator<ChatChannel> allChannels, TextComponent.Builder component) {
ChatChannel channel;
List<ChatChannel> canSee = new ArrayList<>();
List<ChatChannel> cannotSee = new ArrayList<>();
while (allChannels.hasNext()) {
channel = allChannels.next();
if (channel.canPlayerSee(user, true)) {
canSee.add(channel);
} else {
cannotSee.add(channel);
}
}
Iterator<ChatChannel> visibleChannels = canSee.iterator();
component.append(TextComponent.of("Available Channels: ").color(NamedTextColor.GREEN));
makeList(visibleChannels, component);
component.append("\n").build();
if (player.hasPermission("carbonchat.channellist.bypass")) {
Iterator<ChatChannel> invisibleChannels = cannotSee.iterator();
component.append(TextComponent.of("Unavailable Channels: ").color(NamedTextColor.RED));
makeList(invisibleChannels, component);
}
}
private void makeList(Iterator<ChatChannel> iterator, TextComponent.Builder component) {
while (iterator.hasNext()) {
ChatChannel chatChannel = iterator.next();
component.append(TextComponent.of(chatChannel.getName()));
if (iterator.hasNext()) {
component.append(TextComponent.of(", "));
} else {
component.append(TextComponent.of(". "));
}
}
}
}
@@ -0,0 +1,34 @@
package net.draycia.carbon.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Default;
import co.aikar.commands.annotation.Dependency;
import net.draycia.carbon.CarbonChat;
import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
@CommandAlias("chatreload|creload")
@CommandPermission("carbonchat.reload")
public class ChatReloadCommand extends BaseCommand {
@Dependency
private CarbonChat carbonChat;
@Default
public void baseCommand(CommandSender sender) {
carbonChat.reloadConfig();
carbonChat.getChannelManager().reload();
Component message = carbonChat.getAdventureManager().processMessage(carbonChat.getLanguage().getString("reloaded"),
"br", "\n");
carbonChat.getAdventureManager().getAudiences().audience(sender).sendMessage(message);
// TODO: Ensure the command list is updated when reloading.
// If new channels are added, their commands should appear to players.
}
}
@@ -0,0 +1,50 @@
package net.draycia.carbon.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Default;
import co.aikar.commands.annotation.Dependency;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.storage.ChatUser;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandAlias("clearchat|cc")
@CommandPermission("carbonchat.clearchat.clear")
public class ClearChatCommand extends BaseCommand {
@Dependency
private CarbonChat carbonChat;
@Default
public void baseCommand(CommandSender issuer) {
String format = carbonChat.getModConfig().getString("clear-chat.message", "");
Component component = carbonChat.getAdventureManager().processMessage(format, "br", "\n");
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.hasPermission("carbonchat.clearchat.exempt")) {
continue;
}
ChatUser audience = carbonChat.getUserService().wrap(player);
for (int i = 0; i < carbonChat.getModConfig().getInt("clear-chat.message-count", 100); i++) {
audience.sendMessage(component);
}
if (player.hasPermission("carbonchat.clearchat.notify")) {
String message = carbonChat.getLanguage().getString("clear-notify");
audience.sendMessage(carbonChat.getAdventureManager().processMessage(message, "player", issuer.getName()));
}
if (player.hasPermission("carbonchat.clearchat.exempt")) {
String message = carbonChat.getLanguage().getString("clear-exempt");
audience.sendMessage(carbonChat.getAdventureManager().processMessage(message, "player", issuer.getName()));
}
}
}
}
@@ -0,0 +1,47 @@
package net.draycia.carbon.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.storage.ChatUser;
import net.kyori.adventure.text.Component;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@CommandAlias("ignore")
@CommandPermission("carbonchat.ignore")
public class IgnoreCommand extends BaseCommand {
@Dependency
private CarbonChat carbonChat;
@Default
@CommandCompletion("@players")
@Syntax("<player>")
public void baseCommand(Player player, ChatUser targetUser) {
ChatUser user = carbonChat.getUserService().wrap(player);
if (user.isIgnoringUser(targetUser)) {
user.setIgnoringUser(targetUser, false);
user.sendMessage(processMessage(player, carbonChat.getLanguage().getString("not-ignoring-user")));
} else {
Bukkit.getScheduler().runTaskAsynchronously(carbonChat, () -> {
Permission permission = carbonChat.getPermission();
if (permission.playerHas(null, targetUser.asOfflinePlayer(), "carbonchat.ignore.exempt")) {
user.sendMessage(processMessage(player, carbonChat.getLanguage().getString("ignore-exempt")));
} else {
user.setIgnoringUser(targetUser, true);
user.sendMessage(processMessage(player, carbonChat.getLanguage().getString("ignoring-user")));
}
});
}
}
private Component processMessage(Player player, String message) {
return carbonChat.getAdventureManager().processMessageWithPapi(player, message, "br", "\n");
}
}
@@ -0,0 +1,51 @@
package net.draycia.carbon.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import me.clip.placeholderapi.PlaceholderAPI;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.storage.ChatUser;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@CommandAlias("me|rp")
@CommandPermission("carbonchat.me")
public class MeCommand extends BaseCommand {
@Dependency
private CarbonChat carbonChat;
@Default
@Syntax("<message>")
public void baseCommand(Player player, String... args) {
if (args == null || args.length == 0) {
return;
}
String message = String.join(" ", args).replace("</pre>", "");
String format = PlaceholderAPI.setPlaceholders(player, carbonChat.getLanguage().getString("me"));
if (!player.hasPermission("carbonchat.me.formatting")) {
format = format.replace("<message>", "<pre><message></pre>");
}
Component component = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
"displayname", player.getDisplayName(), "message", message);
ChatUser user = carbonChat.getUserService().wrap(player);
if (user.isShadowMuted()) {
user.sendMessage(component);
} else {
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
if (carbonChat.getUserService().wrap(onlinePlayer).isIgnoringUser(user)) {
continue;
}
carbonChat.getAdventureManager().getAudiences().player(onlinePlayer).sendMessage(component);
}
}
}
}
@@ -0,0 +1,28 @@
package net.draycia.carbon.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.storage.ChatUser;
import org.bukkit.entity.Player;
@CommandAlias("msg|whisper|message|w")
@CommandPermission("carbonchat.message")
public class MessageCommand extends BaseCommand {
@Dependency
private CarbonChat carbonChat;
@Default
@CommandCompletion("@players")
@Syntax("<player> <message>")
public void baseCommand(Player player, ChatUser targetUser, String... args) {
if (args.length == 0) {
return;
}
ChatUser sender = carbonChat.getUserService().wrap(player);
targetUser.sendMessage(sender, String.join(" ", args));
}
}
@@ -0,0 +1,54 @@
package net.draycia.carbon.commands;
import co.aikar.commands.annotation.*;
import co.aikar.commands.BaseCommand;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.storage.ChatUser;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@CommandAlias("mute")
@CommandPermission("carbonchat.mute")
public class MuteCommand extends BaseCommand {
@Dependency
private CarbonChat carbonChat;
@Default
@CommandCompletion("@players")
@Syntax("<player>")
public void baseCommand(CommandSender sender, ChatUser targetUser) {
Audience audience = carbonChat.getAdventureManager().getAudiences().audience(sender);
if (targetUser.isMuted()) {
targetUser.setMuted(false);
String format = carbonChat.getLanguage().getString("no-longer-muted");
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
"player", targetUser.asOfflinePlayer().getName());
audience.sendMessage(message);
} else {
Bukkit.getScheduler().runTaskAsynchronously(carbonChat, () -> {
Permission permission = carbonChat.getPermission();
String format;
if (permission.playerHas(null, targetUser.asOfflinePlayer(), "carbonchat.mute.exempt")) {
format = carbonChat.getLanguage().getString("mute-exempt");
} else {
targetUser.setMuted(true);
format = carbonChat.getLanguage().getString("is-now-muted");
}
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
"player", targetUser.asOfflinePlayer().getName());
audience.sendMessage(message);
});
}
}
}
@@ -0,0 +1,66 @@
package net.draycia.carbon.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.storage.ChatUser;
import org.bukkit.entity.Player;
@CommandAlias("nick|nickname")
@CommandPermission("carbonchat.nickname")
public class NicknameCommand extends BaseCommand {
@Dependency
private CarbonChat carbonChat;
@Default
@Syntax("<nickname> [player]")
public void baseCommand(Player player, String nickname, @Optional ChatUser target) {
ChatUser sender = carbonChat.getUserService().wrap(player);
// Reset nickname
if (nickname.equalsIgnoreCase("off")) {
nickname = null;
}
// Reset other player's nickname
if (target != null && nickname != null && nickname.equals(target.asOfflinePlayer().getName())) {
nickname = null;
}
// Reset own nickname
if (target == null && nickname != null && nickname.equals(sender.asOfflinePlayer().getName())) {
nickname = null;
}
if (target != null) {
target.setNickname(nickname);
String message;
if (nickname == null) {
message = carbonChat.getLanguage().getString("other-nickname-reset");
} else {
message = carbonChat.getLanguage().getString("other-nickname-set");
}
sender.sendMessage(carbonChat.getAdventureManager().processMessage(
message, "nickname", nickname == null ? "" : nickname,
"user", target.asOfflinePlayer().getName()));
} else {
sender.setNickname(nickname);
String message;
if (nickname == null) {
message = carbonChat.getLanguage().getString("nickname-reset");
} else {
message = carbonChat.getLanguage().getString("nickname-set");
}
sender.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player,
message, "nickname", nickname == null ? "" : nickname));
}
}
}
@@ -0,0 +1,39 @@
package net.draycia.carbon.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.storage.ChatUser;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player;
@CommandAlias("reply|r")
@CommandPermission("carbonchat.reply")
public class ReplyCommand extends BaseCommand {
@Dependency
private CarbonChat carbonChat;
@Default
@Syntax("<message>")
public void baseCommand(Player player, String... args) {
if (args.length == 0) {
return;
}
ChatUser user = carbonChat.getUserService().wrap(player);
if (user.getReplyTarget() == null) {
String message = carbonChat.getLanguage().getString("no-reply-target");
Component component = carbonChat.getAdventureManager().processMessage(message, "br", "\n");
user.sendMessage(component);
return;
}
ChatUser targetUser = carbonChat.getUserService().wrap(user.getReplyTarget());
targetUser.sendMessage(user, String.join(" ", args));
}
}
@@ -0,0 +1,42 @@
package net.draycia.carbon.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.ConditionFailedException;
import co.aikar.commands.annotation.*;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.channels.ChatChannel;
import net.draycia.carbon.storage.ChatUser;
import net.draycia.carbon.storage.UserChannelSettings;
import net.kyori.adventure.text.format.TextColor;
import org.bukkit.entity.Player;
@CommandAlias("setcolor")
@CommandPermission("carbonchat.setcolor")
public class SetColorCommand extends BaseCommand {
@Dependency
private CarbonChat carbonChat;
@Default
@CommandCompletion("@chatchannel")
@Syntax("<channel> <color>")
public void baseCommand(Player player, @Conditions("canuse:true") ChatChannel channel, String color) {
if (channel == null || color == null) {
throw new ConditionFailedException("Channel or Color not supplied!");
}
ChatUser user = carbonChat.getUserService().wrap(player);
if (!player.hasPermission("carbonchat.setcolor." + channel.getKey())) {
throw new ConditionFailedException("You can't set colors for this channel!");
}
UserChannelSettings settings = user.getChannelSettings(channel);
settings.setColor(TextColor.fromHexString(color));
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, carbonChat.getLanguage().getString("channel-color-set"),
"br", "\n", "color", "<color:" + color + ">", "channel", channel.getName(), "hex", color));
}
}
@@ -0,0 +1,53 @@
package net.draycia.carbon.commands;
import co.aikar.commands.annotation.*;
import co.aikar.commands.BaseCommand;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.storage.ChatUser;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@CommandAlias("shadowmute|sm|smute")
@CommandPermission("carbonchat.shadowmute")
public class ShadowMuteCommand extends BaseCommand {
@Dependency
private CarbonChat carbonChat;
@Default
@CommandCompletion("@players")
@Syntax("<player>")
public void baseCommand(CommandSender sender, ChatUser targetUser) {
Audience audience = carbonChat.getAdventureManager().getAudiences().audience(sender);
if (targetUser.isShadowMuted()) {
targetUser.setShadowMuted(false);
String format = carbonChat.getLanguage().getString("no-longer-shadow-muted");
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
"player", targetUser.asOfflinePlayer().getName());
audience.sendMessage(message);
} else {
Bukkit.getScheduler().runTaskAsynchronously(carbonChat, () -> {
Permission permission = carbonChat.getPermission();
String format;
if (permission.playerHas(null, targetUser.asOfflinePlayer(), "carbonchat.shadowmute.exempt")) {
format = carbonChat.getLanguage().getString("shadow-mute-exempt");
} else {
targetUser.setShadowMuted(true);
format = carbonChat.getLanguage().getString("is-now-shadow-muted");
}
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
"player", targetUser.asOfflinePlayer().getName());
audience.sendMessage(message);
});
}
}
}
@@ -0,0 +1,57 @@
package net.draycia.carbon.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.channels.ChatChannel;
import net.draycia.carbon.storage.ChatUser;
import net.draycia.carbon.storage.UserChannelSettings;
import org.bukkit.entity.Player;
@CommandAlias("spych|spychannel|spy")
@CommandPermission("carbonchat.spy")
public class SpyChannelCommand extends BaseCommand {
@Dependency
private CarbonChat carbonChat;
@Default
@CommandCompletion("@channel")
@Syntax("<channel>")
public void baseCommand(Player player, @Conditions("exists:true") ChatChannel channel) {
ChatUser user = carbonChat.getUserService().wrap(player);
String message;
UserChannelSettings settings = user.getChannelSettings(channel);
if (settings.isSpying()) {
settings.setSpying(false);
message = carbonChat.getLanguage().getString("spy-toggled-off");
} else {
settings.setSpying(true);
message = carbonChat.getLanguage().getString("spy-toggled-on");
}
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, message, "br", "\n",
"color", "<color:" + channel.getChannelColor(user).toString() + ">", "channel", channel.getName()));
}
@Subcommand("whispers")
public void whispersCommand(Player player) {
ChatUser user = carbonChat.getUserService().wrap(player);
String message;
if (user.isSpyingWhispers()) {
user.setSpyingWhispers(false);
message = carbonChat.getLanguage().getString("spy-whispers-off");
} else {
user.setSpyingWhispers(true);
message = carbonChat.getLanguage().getString("spy-whispers-on");
}
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, message, "br", "\n"));
}
}
@@ -0,0 +1,68 @@
package net.draycia.carbon.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.channels.ChatChannel;
import net.draycia.carbon.storage.ChatUser;
import net.draycia.carbon.storage.UserChannelSettings;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandAlias("tch|togglec|togglechannel|toggle")
@CommandPermission("carbonchat.toggle")
public class ToggleCommand extends BaseCommand {
@Dependency
private CarbonChat carbonChat;
@Default
@CommandCompletion("@chatchannel @players")
@Syntax("<channel>")
public void baseCommand(Player player, @Conditions("canuse:true") ChatChannel channel) {
ChatUser user = carbonChat.getUserService().wrap(player);
String message;
UserChannelSettings settings = user.getChannelSettings(channel);
if (settings.isIgnored()) {
settings.setIgnoring(false);
message = channel.getToggleOffMessage();
} else {
settings.setIgnoring(true);
message = channel.getToggleOnMessage();
}
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, message, "br", "\n",
"color", "<color:" + channel.getChannelColor(user).toString() + ">", "channel", channel.getName()));
}
@CommandPermission("carbonchat.toggle.others")
@Subcommand("other")
@CommandCompletion("@chatchannel @players")
@Syntax("<channel> <player>")
public void baseCommand(CommandSender sender, @Conditions("canuse:true") ChatChannel channel, ChatUser user) {
String message;
String otherMessage;
UserChannelSettings settings = user.getChannelSettings(channel);
if (settings.isIgnored()) {
settings.setIgnoring(false);
message = channel.getToggleOffMessage();
otherMessage = channel.getToggleOtherOffMessage();
} else {
settings.setIgnoring(true);
message = channel.getToggleOnMessage();
otherMessage = channel.getToggleOtherOnMessage();
}
user.sendMessage(carbonChat.getAdventureManager().processMessage(message, "br", "\n",
"color", "<color:" + channel.getChannelColor(user).toString() + ">", "channel", channel.getName()));
carbonChat.getAdventureManager().getAudiences().audience(sender).sendMessage(carbonChat.getAdventureManager().processMessage(otherMessage,
"br", "\n", "color", "<color:" + channel.getChannelColor(user).toString() + ">",
"channel", channel.getName(), "player", user.asOfflinePlayer().getName()));
}
}