mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 14:38:51 +00:00
more progress
This commit is contained in:
1 parent
29bdcc8061
commit
9f496be5f3
66 files changed
+1179
-1153
No files matched your search
@@ -24,66 +24,66 @@ public class AliasedChannelCommand {
|
||||
@NonNull
|
||||
private final String commandName;
|
||||
|
||||
public AliasedChannelCommand(@NonNull CarbonChat carbonChat, @NonNull ChatChannel chatChannel) {
|
||||
public AliasedChannelCommand(@NonNull final CarbonChat carbonChat, @NonNull final ChatChannel chatChannel) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.chatChannel = chatChannel;
|
||||
|
||||
this.commandName = chatChannel.getKey();
|
||||
this.commandName = chatChannel.key();
|
||||
|
||||
LinkedHashMap<String, Argument> setChannelArguments = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> setChannelArguments = new LinkedHashMap<>();
|
||||
|
||||
new CommandAPICommand(commandName)
|
||||
new CommandAPICommand(this.commandName)
|
||||
.withArguments(setChannelArguments)
|
||||
.withPermission(CommandPermission.fromString("carbonchat.channel"))
|
||||
.executesPlayer(this::setChannel)
|
||||
.executesPlayer(this::channel)
|
||||
.register();
|
||||
|
||||
LinkedHashMap<String, Argument> sendMessageArguments = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> sendMessageArguments = new LinkedHashMap<>();
|
||||
sendMessageArguments.put("message", new GreedyStringArgument());
|
||||
|
||||
new CommandAPICommand(commandName)
|
||||
new CommandAPICommand(this.commandName)
|
||||
.withArguments(sendMessageArguments)
|
||||
.withPermission(CommandPermission.fromString("carbonchat.channel.message"))
|
||||
.executesPlayer(this::sendMessage)
|
||||
.register();
|
||||
}
|
||||
|
||||
private void setChannel(@NonNull Player player, @NonNull Object @NonNull [] args) {
|
||||
ChatUser user = carbonChat.getUserService().wrap(player);
|
||||
private void channel(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
final ChatUser user = this.carbonChat.getUserService().wrap(player);
|
||||
|
||||
if (user.getChannelSettings(getChatChannel()).ignored()) {
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, getChatChannel().getCannotUseMessage(),
|
||||
if (user.channelSettings(this.chatChannel()).ignored()) {
|
||||
user.sendMessage(this.carbonChat.getAdventureManager().processMessageWithPapi(player, this.chatChannel().cannotUseMessage(),
|
||||
"br", "\n",
|
||||
"color", "<" + getChatChannel().getChannelColor(user).toString() + ">",
|
||||
"channel", getChatChannel().getName()));
|
||||
"color", "<" + this.chatChannel().channelColor(user).toString() + ">",
|
||||
"channel", this.chatChannel().name()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
user.selectedChannel(getChatChannel());
|
||||
user.selectedChannel(this.chatChannel());
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, getChatChannel().getSwitchMessage(),
|
||||
user.sendMessage(this.carbonChat.getAdventureManager().processMessageWithPapi(player, this.chatChannel().switchMessage(),
|
||||
"br", "\n",
|
||||
"color", "<" + getChatChannel().getChannelColor(user).toString() + ">",
|
||||
"channel", getChatChannel().getName()));
|
||||
"color", "<" + this.chatChannel().channelColor(user).toString() + ">",
|
||||
"channel", this.chatChannel().name()));
|
||||
}
|
||||
|
||||
private void sendMessage(@NonNull Player player, @NonNull Object @NonNull [] args) {
|
||||
ChatUser user = carbonChat.getUserService().wrap(player);
|
||||
String message = (String) args[0];
|
||||
private void sendMessage(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
final ChatUser user = this.carbonChat.getUserService().wrap(player);
|
||||
final String message = (String) args[0];
|
||||
|
||||
Component component = getChatChannel().sendMessage(user, message, false);
|
||||
final Component component = this.chatChannel().sendMessage(user, message, false);
|
||||
|
||||
carbonChat.getAdventureManager().getAudiences().console().sendMessage(component);
|
||||
this.carbonChat.getAdventureManager().audiences().console().sendMessage(component);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public ChatChannel getChatChannel() {
|
||||
return chatChannel;
|
||||
public ChatChannel chatChannel() {
|
||||
return this.chatChannel;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getCommandName() {
|
||||
return commandName;
|
||||
public String commandName() {
|
||||
return this.commandName;
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class ChannelCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ChannelCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
public ChannelCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -30,17 +30,17 @@ public class ChannelCommand {
|
||||
|
||||
CommandUtils.handleDuplicateCommands(commandSettings);
|
||||
|
||||
LinkedHashMap<String, Argument> setChannelArguments = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> setChannelArguments = new LinkedHashMap<>();
|
||||
setChannelArguments.put("channel", CarbonUtils.channelArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(setChannelArguments)
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.channel"))
|
||||
.executesPlayer(this::setChannel)
|
||||
.executesPlayer(this::channel)
|
||||
.register();
|
||||
|
||||
LinkedHashMap<String, Argument> sendMessageArguments = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> sendMessageArguments = new LinkedHashMap<>();
|
||||
sendMessageArguments.put("channel", CarbonUtils.channelArgument());
|
||||
sendMessageArguments.put("message", new GreedyStringArgument());
|
||||
|
||||
@@ -52,35 +52,35 @@ public class ChannelCommand {
|
||||
.register();
|
||||
}
|
||||
|
||||
private void setChannel(@NonNull Player player, @NonNull Object @NonNull [] args) {
|
||||
ChatUser user = carbonChat.getUserService().wrap(player);
|
||||
ChatChannel channel = (ChatChannel) args[0];
|
||||
private void channel(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
final ChatUser user = this.carbonChat.getUserService().wrap(player);
|
||||
final ChatChannel channel = (ChatChannel) args[0];
|
||||
|
||||
if (user.getChannelSettings(channel).ignored()) {
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, channel.getCannotUseMessage(),
|
||||
if (user.channelSettings(channel).ignored()) {
|
||||
user.sendMessage(this.carbonChat.getAdventureManager().processMessageWithPapi(player, channel.cannotUseMessage(),
|
||||
"br", "\n",
|
||||
"color", "<" + channel.getChannelColor(user).toString() + ">",
|
||||
"channel", channel.getName()));
|
||||
"color", "<" + channel.channelColor(user).toString() + ">",
|
||||
"channel", channel.name()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
user.selectedChannel(channel);
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, channel.getSwitchMessage(),
|
||||
user.sendMessage(this.carbonChat.getAdventureManager().processMessageWithPapi(player, channel.switchMessage(),
|
||||
"br", "\n",
|
||||
"color", "<" + channel.getChannelColor(user).toString() + ">",
|
||||
"channel", channel.getName()));
|
||||
"color", "<" + channel.channelColor(user).toString() + ">",
|
||||
"channel", channel.name()));
|
||||
}
|
||||
|
||||
private void sendMessage(@NonNull Player player, @NonNull Object @NonNull [] args) {
|
||||
ChatUser user = carbonChat.getUserService().wrap(player);
|
||||
ChatChannel channel = (ChatChannel) args[0];
|
||||
String message = (String) args[1];
|
||||
private void sendMessage(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
final ChatUser user = this.carbonChat.getUserService().wrap(player);
|
||||
final ChatChannel channel = (ChatChannel) args[0];
|
||||
final String message = (String) args[1];
|
||||
|
||||
Component component = channel.sendMessage(user, message, false);
|
||||
final Component component = channel.sendMessage(user, message, false);
|
||||
|
||||
carbonChat.getAdventureManager().getAudiences().console().sendMessage(component);
|
||||
this.carbonChat.getAdventureManager().audiences().console().sendMessage(component);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class ChannelListCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ChannelListCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
public ChannelListCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -36,7 +36,7 @@ public class ChannelListCommand {
|
||||
|
||||
CommandUtils.handleDuplicateCommands(commandSettings);
|
||||
|
||||
LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(channelArguments)
|
||||
@@ -45,7 +45,7 @@ public class ChannelListCommand {
|
||||
.executesPlayer(this::executeSelf)
|
||||
.register();
|
||||
|
||||
LinkedHashMap<String, Argument> argumentsOther = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> argumentsOther = new LinkedHashMap<>();
|
||||
argumentsOther.put("player", CarbonUtils.onlineChatUserArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
@@ -56,31 +56,32 @@ public class ChannelListCommand {
|
||||
.register();
|
||||
}
|
||||
|
||||
public void executeSelf(@NonNull Player player, @NonNull Object @NonNull [] args) {
|
||||
Iterator<ChatChannel> allChannels = carbonChat.getChannelManager().getRegistry().values().iterator();
|
||||
ChatUser user = carbonChat.getUserService().wrap(player);
|
||||
public void executeSelf(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
final Iterator<ChatChannel> allChannels = this.carbonChat.getChannelManager().registry().values().iterator();
|
||||
final ChatUser user = this.carbonChat.getUserService().wrap(player);
|
||||
|
||||
getListAndSend(player, user, allChannels);
|
||||
this.listAndSend(player, user, allChannels);
|
||||
}
|
||||
|
||||
public void executeOther(@NonNull CommandSender sender, @NonNull Object @NonNull [] args) {
|
||||
Audience cmdSender = carbonChat.getAdventureManager().getAudiences().audience(sender);
|
||||
ChatUser user = (ChatUser) args[0];
|
||||
public void executeOther(@NonNull final CommandSender sender, @NonNull final Object @NonNull [] args) {
|
||||
final Audience cmdSender = this.carbonChat.getAdventureManager().audiences().audience(sender);
|
||||
final ChatUser user = (ChatUser) args[0];
|
||||
|
||||
if (!user.online()) {
|
||||
String mustBeOnline = carbonChat.getLanguage().getString("user-must-be-online");
|
||||
cmdSender.sendMessage(carbonChat.getAdventureManager().processMessage(mustBeOnline, "br", "\n", "player", user.offlinePlayer().getName()));
|
||||
final String mustBeOnline = this.carbonChat.getLanguage().getString("user-must-be-online");
|
||||
cmdSender.sendMessage(this.carbonChat.getAdventureManager().processMessage(mustBeOnline, "br", "\n", "player", user.offlinePlayer().getName()));
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<ChatChannel> allChannels = carbonChat.getChannelManager().getRegistry().values().iterator();
|
||||
getListAndSend(sender, user, allChannels);
|
||||
final Iterator<ChatChannel> allChannels = this.carbonChat.getChannelManager().registry().values().iterator();
|
||||
this.listAndSend(sender, user, allChannels);
|
||||
}
|
||||
|
||||
private void getListAndSend(@NonNull CommandSender sender, @NonNull ChatUser user, @NonNull Iterator<ChatChannel> allChannels) {
|
||||
private void listAndSend(@NonNull final CommandSender sender, @NonNull final ChatUser user,
|
||||
@NonNull final Iterator<ChatChannel> allChannels) {
|
||||
ChatChannel channel;
|
||||
List<ChatChannel> canSee = new ArrayList<>();
|
||||
List<ChatChannel> cannotSee = new ArrayList<>();
|
||||
final List<ChatChannel> canSee = new ArrayList<>();
|
||||
final List<ChatChannel> cannotSee = new ArrayList<>();
|
||||
|
||||
while (allChannels.hasNext()) {
|
||||
channel = allChannels.next();
|
||||
@@ -92,42 +93,41 @@ public class ChannelListCommand {
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<ChatChannel> visibleChannels = canSee.iterator();
|
||||
TextComponent.Builder availableList = TextComponent.builder("");
|
||||
final Iterator<ChatChannel> visibleChannels = canSee.iterator();
|
||||
final TextComponent.Builder availableList = TextComponent.builder("");
|
||||
|
||||
makeList(visibleChannels, availableList);
|
||||
this.makeList(visibleChannels, availableList);
|
||||
|
||||
String availableFormat = carbonChat.getLanguage().getString("available-channels-list");
|
||||
Component availableComponent = carbonChat.getAdventureManager().processMessage(availableFormat, "br", "\n");
|
||||
availableComponent = availableComponent.replaceFirstText(Pattern.compile(Pattern.quote("<list>")), (ac) -> availableList);
|
||||
final String availableFormat = this.carbonChat.getLanguage().getString("available-channels-list");
|
||||
Component availableComponent = this.carbonChat.getAdventureManager().processMessage(availableFormat, "br", "\n");
|
||||
availableComponent = availableComponent.replaceFirstText(Pattern.compile(Pattern.quote("<list>")), ac -> availableList);
|
||||
|
||||
Audience audience = carbonChat.getAdventureManager().getAudiences().audience(sender);
|
||||
final Audience audience = this.carbonChat.getAdventureManager().audiences().audience(sender);
|
||||
|
||||
audience.sendMessage(availableComponent);
|
||||
|
||||
if (sender.hasPermission("carbonchat.channellist.bypass") && !cannotSee.isEmpty()) {
|
||||
final Iterator<ChatChannel> invisibleChannels = cannotSee.iterator();
|
||||
final TextComponent.Builder unavailableList = TextComponent.builder("");
|
||||
|
||||
Iterator<ChatChannel> invisibleChannels = cannotSee.iterator();
|
||||
TextComponent.Builder unavailableList = TextComponent.builder("");
|
||||
this.makeList(invisibleChannels, unavailableList);
|
||||
|
||||
makeList(invisibleChannels, unavailableList);
|
||||
|
||||
String unavailableFormat = carbonChat.getLanguage().getString("unavailable-channels-list");
|
||||
Component unavailableComponent = carbonChat.getAdventureManager().processMessage(unavailableFormat, "br", "\n");
|
||||
unavailableComponent = unavailableComponent.replaceFirstText(Pattern.compile(Pattern.quote("<list>")), (uac) -> unavailableList);
|
||||
final String unavailableFormat = this.carbonChat.getLanguage().getString("unavailable-channels-list");
|
||||
Component unavailableComponent = this.carbonChat.getAdventureManager().processMessage(unavailableFormat, "br", "\n");
|
||||
unavailableComponent = unavailableComponent.replaceFirstText(Pattern.compile(Pattern.quote("<list>")), uac -> unavailableList);
|
||||
|
||||
audience.sendMessage(unavailableComponent);
|
||||
}
|
||||
}
|
||||
|
||||
private void makeList(@NonNull Iterator<@NonNull ChatChannel> iterator, TextComponent.@NonNull Builder list) {
|
||||
String listSeparator = carbonChat.getLanguage().getString("channel-list-separator", ", ");
|
||||
private void makeList(@NonNull final Iterator<@NonNull ChatChannel> iterator, final TextComponent.@NonNull Builder list) {
|
||||
final String listSeparator = this.carbonChat.getLanguage().getString("channel-list-separator", ", ");
|
||||
// TODO: Larry, why did you double assign the listSeparatorComponent?
|
||||
Component listSeparatorComponent = TextComponent.of(listSeparator);
|
||||
final Component listSeparatorComponent = TextComponent.of(listSeparator);
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
ChatChannel channel = iterator.next();
|
||||
list.append(TextComponent.of(channel.getName()));
|
||||
list.append(TextComponent.of(iterator.next().name()));
|
||||
|
||||
if (iterator.hasNext()) {
|
||||
list.append(listSeparatorComponent);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class ChatReloadCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ChatReloadCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
public ChatReloadCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -30,14 +30,14 @@ public class ChatReloadCommand {
|
||||
.register();
|
||||
}
|
||||
|
||||
private void execute(@NonNull CommandSender sender, @NonNull Object @NonNull [] args) {
|
||||
carbonChat.reloadConfig();
|
||||
carbonChat.reloadFilters();
|
||||
private void execute(@NonNull final CommandSender sender, @NonNull final Object @NonNull [] args) {
|
||||
this.carbonChat.reloadConfig();
|
||||
this.carbonChat.reloadFilters();
|
||||
|
||||
Component message = carbonChat.getAdventureManager().processMessage(carbonChat.getLanguage().getString("reloaded"),
|
||||
"br", "\n");
|
||||
final Component message = this.carbonChat.getAdventureManager()
|
||||
.processMessage(this.carbonChat.getLanguage().getString("reloaded"), "br", "\n");
|
||||
|
||||
carbonChat.getAdventureManager().getAudiences().audience(sender).sendMessage(message);
|
||||
this.carbonChat.getAdventureManager().audiences().audience(sender).sendMessage(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.draycia.carbon.commands;
|
||||
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
@@ -18,7 +17,7 @@ public class ClearChatCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ClearChatCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
public ClearChatCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -34,25 +33,25 @@ public class ClearChatCommand {
|
||||
.register();
|
||||
}
|
||||
|
||||
private void execute(@NonNull CommandSender sender, @NonNull Object @NonNull [] args) {
|
||||
String format = carbonChat.getModConfig().getString("clear-chat.message", "");
|
||||
Component component = carbonChat.getAdventureManager().processMessage(format, "br", "\n");
|
||||
private void execute(@NonNull final CommandSender sender, @NonNull final Object @NonNull [] args) {
|
||||
final String format = this.carbonChat.getModConfig().getString("clear-chat.message", "");
|
||||
final Component component = this.carbonChat.getAdventureManager().processMessage(format, "br", "\n");
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
ChatUser audience = carbonChat.getUserService().wrap(player);
|
||||
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||
final ChatUser audience = this.carbonChat.getUserService().wrap(player);
|
||||
|
||||
if (player.hasPermission("carbonchat.clearchat.exempt")) {
|
||||
String message = carbonChat.getLanguage().getString("clear-exempt");
|
||||
audience.sendMessage(carbonChat.getAdventureManager().processMessage(message, "player", sender.getName()));
|
||||
final String message = this.carbonChat.getLanguage().getString("clear-exempt");
|
||||
audience.sendMessage(this.carbonChat.getAdventureManager().processMessage(message, "player", sender.getName()));
|
||||
} else {
|
||||
for (int i = 0; i < carbonChat.getModConfig().getInt("clear-chat.message-count", 100); i++) {
|
||||
for (int i = 0; i < this.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", sender.getName()));
|
||||
final String message = this.carbonChat.getLanguage().getString("clear-notify");
|
||||
audience.sendMessage(this.carbonChat.getAdventureManager().processMessage(message, "player", sender.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class IgnoreCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public IgnoreCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
public IgnoreCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -30,7 +30,7 @@ public class IgnoreCommand {
|
||||
|
||||
CommandUtils.handleDuplicateCommands(commandSettings);
|
||||
|
||||
LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
|
||||
channelArguments.put("player", CarbonUtils.chatUserArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
@@ -41,28 +41,28 @@ public class IgnoreCommand {
|
||||
.register();
|
||||
}
|
||||
|
||||
private void execute(@NonNull Player player, @NonNull Object @NonNull [] args) {
|
||||
ChatUser targetUser = (ChatUser) args[0];
|
||||
ChatUser user = carbonChat.getUserService().wrap(player);
|
||||
private void execute(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
final ChatUser targetUser = (ChatUser) args[0];
|
||||
final ChatUser user = this.carbonChat.getUserService().wrap(player);
|
||||
|
||||
if (user.isIgnoringUser(targetUser)) {
|
||||
user.setIgnoringUser(targetUser, false);
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player,
|
||||
carbonChat.getLanguage().getString("not-ignoring-user"),
|
||||
if (user.ignoringUser(targetUser)) {
|
||||
user.ignoringUser(targetUser, false);
|
||||
user.sendMessage(this.carbonChat.getAdventureManager().processMessageWithPapi(player,
|
||||
this.carbonChat.getLanguage().getString("not-ignoring-user"),
|
||||
"br", "\n", "player", targetUser.offlinePlayer().getName()));
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(carbonChat, () -> {
|
||||
Permission permission = carbonChat.getPermission();
|
||||
String format;
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.carbonChat, () -> {
|
||||
final Permission permission = this.carbonChat.getPermission();
|
||||
final String format;
|
||||
|
||||
if (permission.playerHas(null, targetUser.offlinePlayer(), "carbonchat.ignore.exempt")) {
|
||||
format = carbonChat.getLanguage().getString("ignore-exempt");
|
||||
format = this.carbonChat.getLanguage().getString("ignore-exempt");
|
||||
} else {
|
||||
user.setIgnoringUser(targetUser, true);
|
||||
format = carbonChat.getLanguage().getString("ignoring-user");
|
||||
user.ignoringUser(targetUser, true);
|
||||
format = this.carbonChat.getLanguage().getString("ignoring-user");
|
||||
}
|
||||
|
||||
Component message = carbonChat.getAdventureManager().processMessageWithPapi(player, format,
|
||||
final Component message = this.carbonChat.getAdventureManager().processMessageWithPapi(player, format,
|
||||
"br", "\n", "sender", player.getDisplayName(), "player",
|
||||
targetUser.offlinePlayer().getName());
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class MeCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public MeCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
public MeCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -30,7 +30,7 @@ public class MeCommand {
|
||||
|
||||
CommandUtils.handleDuplicateCommands(commandSettings);
|
||||
|
||||
LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
|
||||
channelArguments.put("message", new GreedyStringArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
@@ -41,28 +41,28 @@ public class MeCommand {
|
||||
.register();
|
||||
}
|
||||
|
||||
private void execute(@NonNull Player player, @NonNull Object @NonNull [] args) {
|
||||
String message = ((String) args[0]).replace("</pre>", "");
|
||||
String format = PlaceholderAPI.setPlaceholders(player, carbonChat.getLanguage().getString("me"));
|
||||
private void execute(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
final String message = ((String) args[0]).replace("</pre>", "");
|
||||
String format = PlaceholderAPI.setPlaceholders(player, this.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",
|
||||
final Component component = this.carbonChat.getAdventureManager().processMessage(format, "br", "\n",
|
||||
"displayname", player.getDisplayName(), "message", message);
|
||||
|
||||
ChatUser user = carbonChat.getUserService().wrap(player);
|
||||
final ChatUser user = this.carbonChat.getUserService().wrap(player);
|
||||
|
||||
if (user.isShadowMuted()) {
|
||||
if (user.shadowMuted()) {
|
||||
user.sendMessage(component);
|
||||
} else {
|
||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||
if (carbonChat.getUserService().wrap(onlinePlayer).isIgnoringUser(user)) {
|
||||
for (final Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||
if (this.carbonChat.getUserService().wrap(onlinePlayer).ignoringUser(user)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
carbonChat.getAdventureManager().getAudiences().player(onlinePlayer).sendMessage(component);
|
||||
this.carbonChat.getAdventureManager().audiences().player(onlinePlayer).sendMessage(component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class MessageCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public MessageCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
public MessageCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -28,7 +28,7 @@ public class MessageCommand {
|
||||
|
||||
CommandUtils.handleDuplicateCommands(commandSettings);
|
||||
|
||||
LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
|
||||
arguments.put("player", CarbonUtils.chatUserArgument());
|
||||
arguments.put("message", new GreedyStringArgument());
|
||||
|
||||
@@ -40,11 +40,11 @@ public class MessageCommand {
|
||||
.register();
|
||||
}
|
||||
|
||||
private void execute(@NonNull Player player, @NonNull Object @NonNull [] args) {
|
||||
ChatUser targetUser = (ChatUser) args[0];
|
||||
String message = (String) args[1];
|
||||
private void execute(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
final ChatUser targetUser = (ChatUser) args[0];
|
||||
final String message = (String) args[1];
|
||||
|
||||
ChatUser sender = carbonChat.getUserService().wrap(player);
|
||||
final ChatUser sender = this.carbonChat.getUserService().wrap(player);
|
||||
|
||||
targetUser.sendMessage(sender, message);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class MuteCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public MuteCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
public MuteCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -31,7 +31,7 @@ public class MuteCommand {
|
||||
|
||||
CommandUtils.handleDuplicateCommands(commandSettings);
|
||||
|
||||
LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
|
||||
arguments.put("player", CarbonUtils.chatUserArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
@@ -42,31 +42,31 @@ public class MuteCommand {
|
||||
.register();
|
||||
}
|
||||
|
||||
private void execute(@NonNull CommandSender sender, @NonNull Object @NonNull [] args) {
|
||||
ChatUser user = (ChatUser) args[0];
|
||||
Audience audience = carbonChat.getAdventureManager().getAudiences().audience(sender);
|
||||
private void execute(@NonNull final CommandSender sender, @NonNull final Object @NonNull [] args) {
|
||||
final ChatUser user = (ChatUser) args[0];
|
||||
final Audience audience = this.carbonChat.getAdventureManager().audiences().audience(sender);
|
||||
|
||||
if (user.isShadowMuted()) {
|
||||
user.setMuted(false);
|
||||
String format = carbonChat.getLanguage().getString("no-longer-muted");
|
||||
if (user.shadowMuted()) {
|
||||
user.muted(false);
|
||||
final String format = this.carbonChat.getLanguage().getString("no-longer-muted");
|
||||
|
||||
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
|
||||
final Component message = this.carbonChat.getAdventureManager().processMessage(format, "br", "\n",
|
||||
"player", user.offlinePlayer().getName());
|
||||
|
||||
audience.sendMessage(message);
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(carbonChat, () -> {
|
||||
Permission permission = carbonChat.getPermission();
|
||||
String format;
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.carbonChat, () -> {
|
||||
final Permission permission = this.carbonChat.getPermission();
|
||||
final String format;
|
||||
|
||||
if (permission.playerHas(null, user.offlinePlayer(), "carbonchat.mute.exempt")) {
|
||||
format = carbonChat.getLanguage().getString("mute-exempt");
|
||||
format = this.carbonChat.getLanguage().getString("mute-exempt");
|
||||
} else {
|
||||
user.setMuted(true);
|
||||
format = carbonChat.getLanguage().getString("is-now-muted");
|
||||
user.muted(true);
|
||||
format = this.carbonChat.getLanguage().getString("is-now-muted");
|
||||
}
|
||||
|
||||
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
|
||||
final Component message = this.carbonChat.getAdventureManager().processMessage(format, "br", "\n",
|
||||
"player", user.offlinePlayer().getName());
|
||||
|
||||
audience.sendMessage(message);
|
||||
|
||||
@@ -21,7 +21,7 @@ public class NicknameCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public NicknameCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
public NicknameCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -30,7 +30,7 @@ public class NicknameCommand {
|
||||
|
||||
CommandUtils.handleDuplicateCommands(commandSettings);
|
||||
|
||||
LinkedHashMap<String, Argument> selfArguments = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> selfArguments = new LinkedHashMap<>();
|
||||
selfArguments.put("nickname", new StringArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
@@ -40,7 +40,7 @@ public class NicknameCommand {
|
||||
.executesPlayer(this::executeSelf)
|
||||
.register();
|
||||
|
||||
LinkedHashMap<String, Argument> otherArguments = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> otherArguments = new LinkedHashMap<>();
|
||||
otherArguments.put("player", CarbonUtils.chatUserArgument());
|
||||
otherArguments.put("nickname", new StringArgument());
|
||||
|
||||
@@ -52,9 +52,9 @@ public class NicknameCommand {
|
||||
.register();
|
||||
}
|
||||
|
||||
private void executeSelf(@NonNull Player player, @NonNull Object @NonNull [] args) {
|
||||
private void executeSelf(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
String nickname = (String) args[0];
|
||||
ChatUser sender = carbonChat.getUserService().wrap(player);
|
||||
final ChatUser sender = this.carbonChat.getUserService().wrap(player);
|
||||
|
||||
if (nickname.equalsIgnoreCase("off") || nickname.equalsIgnoreCase(player.getName())) {
|
||||
nickname = null;
|
||||
@@ -62,22 +62,22 @@ public class NicknameCommand {
|
||||
|
||||
sender.nickname(nickname);
|
||||
|
||||
String message;
|
||||
final String message;
|
||||
|
||||
if (nickname == null) {
|
||||
message = carbonChat.getLanguage().getString("nickname-reset");
|
||||
message = this.carbonChat.getLanguage().getString("nickname-reset");
|
||||
} else {
|
||||
message = carbonChat.getLanguage().getString("nickname-set");
|
||||
message = this.carbonChat.getLanguage().getString("nickname-set");
|
||||
}
|
||||
|
||||
sender.sendMessage(carbonChat.getAdventureManager().processMessage(
|
||||
sender.sendMessage(this.carbonChat.getAdventureManager().processMessage(
|
||||
message, "nickname", nickname == null ? "" : nickname,
|
||||
"user", sender.offlinePlayer().getName()));
|
||||
}
|
||||
|
||||
private void executeOther(@NonNull CommandSender sender, @NonNull Object @NonNull [] args) {
|
||||
Audience user = carbonChat.getAdventureManager().getAudiences().audience(sender);
|
||||
ChatUser target = (ChatUser) args[0];
|
||||
private void executeOther(@NonNull final CommandSender sender, @NonNull final Object @NonNull [] args) {
|
||||
final Audience user = this.carbonChat.getAdventureManager().audiences().audience(sender);
|
||||
final ChatUser target = (ChatUser) args[0];
|
||||
String nickname = (String) args[1];
|
||||
|
||||
if (nickname.equalsIgnoreCase("off") ||
|
||||
@@ -87,15 +87,15 @@ public class NicknameCommand {
|
||||
|
||||
target.nickname(nickname);
|
||||
|
||||
String message;
|
||||
final String message;
|
||||
|
||||
if (nickname == null) {
|
||||
message = carbonChat.getLanguage().getString("other-nickname-reset");
|
||||
message = this.carbonChat.getLanguage().getString("other-nickname-reset");
|
||||
} else {
|
||||
message = carbonChat.getLanguage().getString("other-nickname-set");
|
||||
message = this.carbonChat.getLanguage().getString("other-nickname-set");
|
||||
}
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessage(
|
||||
user.sendMessage(this.carbonChat.getAdventureManager().processMessage(
|
||||
message, "nickname", nickname == null ? "" : nickname,
|
||||
"user", target.offlinePlayer().getName()));
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class ReplyCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ReplyCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
public ReplyCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -28,7 +28,7 @@ public class ReplyCommand {
|
||||
|
||||
CommandUtils.handleDuplicateCommands(commandSettings);
|
||||
|
||||
LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
|
||||
arguments.put("message", new GreedyStringArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
@@ -39,26 +39,30 @@ public class ReplyCommand {
|
||||
.register();
|
||||
}
|
||||
|
||||
private void execute(@NonNull Player player, @NonNull Object @NonNull [] args) {
|
||||
String input = (String) args[0];
|
||||
private void execute(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
final String input = (String) args[0];
|
||||
|
||||
ChatUser user = carbonChat.getUserService().wrap(player);
|
||||
final ChatUser user = this.carbonChat.getUserService().wrap(player);
|
||||
|
||||
if (input.isEmpty()) {
|
||||
final String message = this.carbonChat.getLanguage().getString("reply-message-blank");
|
||||
final Component component = this.carbonChat.getAdventureManager().processMessage(message, "br", "\n");
|
||||
|
||||
if (input == null || input.isEmpty()) {
|
||||
String message = carbonChat.getLanguage().getString("reply-message-blank");
|
||||
Component component = carbonChat.getAdventureManager().processMessage(message, "br", "\n");
|
||||
user.sendMessage(component);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.getReplyTarget() == null) {
|
||||
String message = carbonChat.getLanguage().getString("no-reply-target");
|
||||
Component component = carbonChat.getAdventureManager().processMessage(message, "br", "\n");
|
||||
if (user.replyTarget() == null) {
|
||||
final String message = this.carbonChat.getLanguage().getString("no-reply-target");
|
||||
final Component component = this.carbonChat.getAdventureManager().processMessage(message, "br", "\n");
|
||||
|
||||
user.sendMessage(component);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ChatUser targetUser = carbonChat.getUserService().wrap(user.getReplyTarget());
|
||||
final ChatUser targetUser = this.carbonChat.getUserService().wrap(user.replyTarget());
|
||||
|
||||
targetUser.sendMessage(user, input);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class SetColorCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public SetColorCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
public SetColorCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -30,9 +30,9 @@ public class SetColorCommand {
|
||||
|
||||
CommandUtils.handleDuplicateCommands(commandSettings);
|
||||
|
||||
for (ChatChannel channel : carbonChat.getChannelManager().getRegistry().values()) {
|
||||
LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
|
||||
arguments.put("channel", new LiteralArgument(channel.getKey()));
|
||||
for (final ChatChannel channel : this.carbonChat.getChannelManager().registry().values()) {
|
||||
final LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
|
||||
arguments.put("channel", new LiteralArgument(channel.key()));
|
||||
arguments.put("color", CarbonUtils.textColorArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
@@ -40,26 +40,26 @@ public class SetColorCommand {
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.setcolor"))
|
||||
.executesPlayer((player, args) -> {
|
||||
TextColor color = (TextColor) args[0];
|
||||
ChatUser user = carbonChat.getUserService().wrap(player);
|
||||
final TextColor color = (TextColor) args[0];
|
||||
final ChatUser user = this.carbonChat.getUserService().wrap(player);
|
||||
|
||||
if (!player.hasPermission("carbonchat.setcolor." + channel.getKey())) {
|
||||
if (!player.hasPermission("carbonchat.setcolor." + channel.key())) {
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player,
|
||||
carbonChat.getLanguage().getString("cannot-set-color"),
|
||||
this.carbonChat.getLanguage().getString("cannot-set-color"),
|
||||
"br", "\n", "input", color.asHexString(),
|
||||
"channel", channel.getName()));
|
||||
"channel", channel.name()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
UserChannelSettings settings = user.getChannelSettings(channel);
|
||||
final UserChannelSettings settings = user.channelSettings(channel);
|
||||
|
||||
settings.color(color);
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player,
|
||||
carbonChat.getLanguage().getString("channel-color-set"),
|
||||
this.carbonChat.getLanguage().getString("channel-color-set"),
|
||||
"br", "\n", "color", "<color:" + color.asHexString() + ">", "channel",
|
||||
channel.getName(), "hex", color.asHexString()));
|
||||
channel.name(), "hex", color.asHexString()));
|
||||
})
|
||||
.register();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ShadowMuteCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ShadowMuteCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
public ShadowMuteCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -31,7 +31,7 @@ public class ShadowMuteCommand {
|
||||
|
||||
CommandUtils.handleDuplicateCommands(commandSettings);
|
||||
|
||||
LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
|
||||
arguments.put("player", CarbonUtils.chatUserArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
@@ -42,31 +42,31 @@ public class ShadowMuteCommand {
|
||||
.register();
|
||||
}
|
||||
|
||||
private void execute(@NonNull CommandSender sender, @NonNull Object @NonNull [] args) {
|
||||
ChatUser user = (ChatUser) args[0];
|
||||
Audience audience = carbonChat.getAdventureManager().getAudiences().audience(sender);
|
||||
private void execute(@NonNull final CommandSender sender, @NonNull final Object @NonNull [] args) {
|
||||
final ChatUser user = (ChatUser) args[0];
|
||||
final Audience audience = this.carbonChat.getAdventureManager().audiences().audience(sender);
|
||||
|
||||
if (user.isShadowMuted()) {
|
||||
user.setShadowMuted(false);
|
||||
String format = carbonChat.getLanguage().getString("no-longer-shadow-muted");
|
||||
if (user.shadowMuted()) {
|
||||
user.shadowMuted(false);
|
||||
final String format = this.carbonChat.getLanguage().getString("no-longer-shadow-muted");
|
||||
|
||||
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
|
||||
final Component message = this.carbonChat.getAdventureManager().processMessage(format, "br", "\n",
|
||||
"player", user.offlinePlayer().getName());
|
||||
|
||||
audience.sendMessage(message);
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(carbonChat, () -> {
|
||||
Permission permission = carbonChat.getPermission();
|
||||
String format;
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.carbonChat, () -> {
|
||||
final Permission permission = this.carbonChat.getPermission();
|
||||
final String format;
|
||||
|
||||
if (permission.playerHas(null, user.offlinePlayer(), "carbonchat.shadowmute.exempt")) {
|
||||
format = carbonChat.getLanguage().getString("shadow-mute-exempt");
|
||||
format = this.carbonChat.getLanguage().getString("shadow-mute-exempt");
|
||||
} else {
|
||||
user.setShadowMuted(true);
|
||||
format = carbonChat.getLanguage().getString("is-now-shadow-muted");
|
||||
user.shadowMuted(true);
|
||||
format = this.carbonChat.getLanguage().getString("is-now-shadow-muted");
|
||||
}
|
||||
|
||||
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
|
||||
final Component message = this.carbonChat.getAdventureManager().processMessage(format, "br", "\n",
|
||||
"player", user.offlinePlayer().getName());
|
||||
|
||||
audience.sendMessage(message);
|
||||
|
||||
@@ -22,7 +22,7 @@ public class SpyChannelCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public SpyChannelCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
public SpyChannelCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -31,7 +31,7 @@ public class SpyChannelCommand {
|
||||
|
||||
CommandUtils.handleDuplicateCommands(commandSettings);
|
||||
|
||||
LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
|
||||
channelArguments.put("channel", CarbonUtils.channelArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
@@ -41,7 +41,7 @@ public class SpyChannelCommand {
|
||||
.executesPlayer(this::execute)
|
||||
.register();
|
||||
|
||||
LinkedHashMap<String, Argument> whisperArguments = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> whisperArguments = new LinkedHashMap<>();
|
||||
whisperArguments.put("channel", new LiteralArgument("whispers"));
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
@@ -51,7 +51,7 @@ public class SpyChannelCommand {
|
||||
.executesPlayer(this::executeWhispers)
|
||||
.register();
|
||||
|
||||
LinkedHashMap<String, Argument> everythingArguments = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> everythingArguments = new LinkedHashMap<>();
|
||||
everythingArguments.put("channel", new LiteralArgument("*"));
|
||||
everythingArguments.put("should-spy", new BooleanArgument());
|
||||
|
||||
@@ -63,68 +63,68 @@ public class SpyChannelCommand {
|
||||
.register();
|
||||
}
|
||||
|
||||
private void execute(@NonNull Player player, @NonNull Object @NonNull [] args) {
|
||||
ChatChannel chatChannel = (ChatChannel) args[0];
|
||||
ChatUser user = carbonChat.getUserService().wrap(player);
|
||||
private void execute(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
final ChatChannel chatChannel = (ChatChannel) args[0];
|
||||
final ChatUser user = this.carbonChat.getUserService().wrap(player);
|
||||
|
||||
String message;
|
||||
final String message;
|
||||
|
||||
UserChannelSettings settings = user.getChannelSettings(chatChannel);
|
||||
final UserChannelSettings settings = user.channelSettings(chatChannel);
|
||||
|
||||
if (settings.spying()) {
|
||||
settings.spying(false);
|
||||
message = carbonChat.getLanguage().getString("spy-toggled-off");
|
||||
message = this.carbonChat.getLanguage().getString("spy-toggled-off");
|
||||
} else {
|
||||
settings.spying(true);
|
||||
message = carbonChat.getLanguage().getString("spy-toggled-on");
|
||||
message = this.carbonChat.getLanguage().getString("spy-toggled-on");
|
||||
}
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, message, "br", "\n",
|
||||
"color", "<color:" + chatChannel.getChannelColor(user).toString() + ">", "channel", chatChannel.getName()));
|
||||
user.sendMessage(this.carbonChat.getAdventureManager().processMessageWithPapi(player, message, "br", "\n",
|
||||
"color", "<color:" + chatChannel.channelColor(user).toString() + ">", "channel", chatChannel.name()));
|
||||
}
|
||||
|
||||
private void executeWhispers(@NonNull Player player, @NonNull Object @NonNull [] args) {
|
||||
ChatUser user = carbonChat.getUserService().wrap(player);
|
||||
private void executeWhispers(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
final ChatUser user = this.carbonChat.getUserService().wrap(player);
|
||||
|
||||
String message;
|
||||
final String message;
|
||||
|
||||
if (user.isSpyingWhispers()) {
|
||||
user.setSpyingWhispers(false);
|
||||
message = carbonChat.getLanguage().getString("spy-whispers-off");
|
||||
if (user.spyingwhispers()) {
|
||||
user.spyingWhispers(false);
|
||||
message = this.carbonChat.getLanguage().getString("spy-whispers-off");
|
||||
} else {
|
||||
user.setSpyingWhispers(true);
|
||||
message = carbonChat.getLanguage().getString("spy-whispers-on");
|
||||
user.spyingWhispers(true);
|
||||
message = this.carbonChat.getLanguage().getString("spy-whispers-on");
|
||||
}
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, message, "br", "\n"));
|
||||
user.sendMessage(this.carbonChat.getAdventureManager().processMessageWithPapi(player, message, "br", "\n"));
|
||||
}
|
||||
|
||||
private void executeEverything(@NonNull Player player, @NonNull Object @NonNull [] args) {
|
||||
Boolean shouldSpy = (Boolean) args[0];
|
||||
private void executeEverything(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
final Boolean shouldSpy = (Boolean) args[0];
|
||||
|
||||
ChatUser user = carbonChat.getUserService().wrap(player);
|
||||
final ChatUser user = this.carbonChat.getUserService().wrap(player);
|
||||
|
||||
String message;
|
||||
final String message;
|
||||
|
||||
if (shouldSpy) {
|
||||
user.setSpyingWhispers(true);
|
||||
user.spyingWhispers(true);
|
||||
|
||||
for (ChatChannel channel : carbonChat.getChannelManager().getRegistry().values()) {
|
||||
user.getChannelSettings(channel).spying(true);
|
||||
for (final ChatChannel channel : this.carbonChat.getChannelManager().registry().values()) {
|
||||
user.channelSettings(channel).spying(true);
|
||||
}
|
||||
|
||||
message = carbonChat.getLanguage().getString("spy-everything-off");
|
||||
message = this.carbonChat.getLanguage().getString("spy-everything-off");
|
||||
} else {
|
||||
user.setSpyingWhispers(false);
|
||||
user.spyingWhispers(false);
|
||||
|
||||
for (ChatChannel channel : carbonChat.getChannelManager().getRegistry().values()) {
|
||||
user.getChannelSettings(channel).spying(false);
|
||||
for (final ChatChannel channel : this.carbonChat.getChannelManager().registry().values()) {
|
||||
user.channelSettings(channel).spying(false);
|
||||
}
|
||||
|
||||
message = carbonChat.getLanguage().getString("spy-everything-on");
|
||||
message = this.carbonChat.getLanguage().getString("spy-everything-on");
|
||||
}
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, message, "br", "\n"));
|
||||
user.sendMessage(this.carbonChat.getAdventureManager().processMessageWithPapi(player, message, "br", "\n"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class SudoChannelCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public SudoChannelCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
public SudoChannelCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -30,7 +30,7 @@ public class SudoChannelCommand {
|
||||
|
||||
CommandUtils.handleDuplicateCommands(commandSettings);
|
||||
|
||||
LinkedHashMap<String, Argument> setOtherChannelArguments = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> setOtherChannelArguments = new LinkedHashMap<>();
|
||||
setOtherChannelArguments.put("player", CarbonUtils.onlineChatUserArgument());
|
||||
setOtherChannelArguments.put("channel", CarbonUtils.channelArgument());
|
||||
|
||||
@@ -39,11 +39,11 @@ public class SudoChannelCommand {
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.channel.others"))
|
||||
.executes((sender, args) -> {
|
||||
this.setOtherChannel(sender, (ChatUser) args[0], (ChatChannel) args[1]);
|
||||
this.otherChannel(sender, (ChatUser) args[0], (ChatChannel) args[1]);
|
||||
})
|
||||
.register();
|
||||
|
||||
LinkedHashMap<String, Argument> sendMessageOtherArguments = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> sendMessageOtherArguments = new LinkedHashMap<>();
|
||||
sendMessageOtherArguments.put("player", CarbonUtils.onlineChatUserArgument());
|
||||
sendMessageOtherArguments.put("channel", CarbonUtils.channelArgument());
|
||||
sendMessageOtherArguments.put("message", new GreedyStringArgument());
|
||||
@@ -58,24 +58,26 @@ public class SudoChannelCommand {
|
||||
.register();
|
||||
}
|
||||
|
||||
private void setOtherChannel(@NonNull CommandSender sender, @NonNull ChatUser user, @NonNull ChatChannel channel) {
|
||||
private void otherChannel(@NonNull final CommandSender sender, @NonNull final ChatUser user, @NonNull final ChatChannel channel) {
|
||||
user.selectedChannel(channel);
|
||||
|
||||
String message = channel.getSwitchMessage();
|
||||
String otherMessage = channel.getSwitchOtherMessage();
|
||||
final String message = channel.switchMessage();
|
||||
final String otherMessage = channel.switchOtherMessage();
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessage(message, "br", "\n",
|
||||
"color", "<color:" + channel.getChannelColor(user).toString() + ">", "channel", channel.getName()));
|
||||
user.sendMessage(this.carbonChat.getAdventureManager().processMessage(message, "br", "\n",
|
||||
"color", "<color:" + channel.channelColor(user).toString() + ">", "channel", channel.name()));
|
||||
|
||||
carbonChat.getAdventureManager().getAudiences().audience(sender).sendMessage(carbonChat.getAdventureManager().processMessage(otherMessage, "br", "\n",
|
||||
"color", "<color:" + channel.getChannelColor(user).toString() + ">", "channel", channel.getName(),
|
||||
"player", user.offlinePlayer().getName()));
|
||||
this.carbonChat.getAdventureManager().audiences().audience(sender).sendMessage(
|
||||
this.carbonChat.getAdventureManager().processMessage(otherMessage, "br", "\n",
|
||||
"color", "<color:" + channel.channelColor(user).toString() + ">", "channel", channel.name(),
|
||||
"player", user.offlinePlayer().getName()));
|
||||
}
|
||||
|
||||
private void sendMessageOther(@NonNull CommandSender sender, @NonNull ChatUser user, @NonNull ChatChannel channel, @NonNull String message) {
|
||||
Component component = channel.sendMessage(user, message, false);
|
||||
private void sendMessageOther(@NonNull final CommandSender sender, @NonNull final ChatUser user,
|
||||
@NonNull final ChatChannel channel, @NonNull final String message) {
|
||||
final Component component = channel.sendMessage(user, message, false);
|
||||
|
||||
carbonChat.getAdventureManager().getAudiences().console().sendMessage(component);
|
||||
this.carbonChat.getAdventureManager().audiences().console().sendMessage(component);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class ToggleCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ToggleCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
public ToggleCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -30,7 +30,7 @@ public class ToggleCommand {
|
||||
|
||||
CommandUtils.handleDuplicateCommands(commandSettings);
|
||||
|
||||
LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
|
||||
channelArguments.put("channel", CarbonUtils.channelArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
@@ -40,7 +40,7 @@ public class ToggleCommand {
|
||||
.executesPlayer(this::executeSelf)
|
||||
.register();
|
||||
|
||||
LinkedHashMap<String, Argument> argumentsOther = new LinkedHashMap<>();
|
||||
final LinkedHashMap<String, Argument> argumentsOther = new LinkedHashMap<>();
|
||||
argumentsOther.put("players", CarbonUtils.chatUserArgument());
|
||||
argumentsOther.put("channel", CarbonUtils.channelArgument());
|
||||
|
||||
@@ -52,52 +52,53 @@ public class ToggleCommand {
|
||||
.register();
|
||||
}
|
||||
|
||||
private void executeSelf(@NonNull Player player, @NonNull Object @NonNull [] args) {
|
||||
ChatUser user = carbonChat.getUserService().wrap(player);
|
||||
ChatChannel channel = (ChatChannel) args[0];
|
||||
private void executeSelf(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
final ChatUser user = this.carbonChat.getUserService().wrap(player);
|
||||
final ChatChannel channel = (ChatChannel) args[0];
|
||||
|
||||
String message;
|
||||
final String message;
|
||||
|
||||
UserChannelSettings settings = user.getChannelSettings(channel);
|
||||
final UserChannelSettings settings = user.channelSettings(channel);
|
||||
|
||||
if (!channel.isIgnorable()) {
|
||||
message = channel.getCannotIgnoreMessage();
|
||||
if (!channel.ignorable()) {
|
||||
message = channel.cannotIgnoreMessage();
|
||||
} else if (settings.ignored()) {
|
||||
settings.ignoring(false);
|
||||
message = channel.getToggleOffMessage();
|
||||
message = channel.toggleOffMessage();
|
||||
} else {
|
||||
settings.ignoring(true);
|
||||
message = channel.getToggleOnMessage();
|
||||
message = channel.toggleOnMessage();
|
||||
}
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, message, "br", "\n",
|
||||
"color", "<color:" + channel.getChannelColor(user).toString() + ">", "channel", channel.getName()));
|
||||
user.sendMessage(this.carbonChat.getAdventureManager().processMessageWithPapi(player, message, "br", "\n",
|
||||
"color", "<color:" + channel.channelColor(user).toString() + ">", "channel", channel.name()));
|
||||
}
|
||||
|
||||
private void executeOther(@NonNull CommandSender sender, @NonNull Object @NonNull [] args) {
|
||||
ChatUser user = (ChatUser) args[0];
|
||||
ChatChannel channel = (ChatChannel) args[1];
|
||||
private void executeOther(@NonNull final CommandSender sender, @NonNull final Object @NonNull [] args) {
|
||||
final ChatUser user = (ChatUser) args[0];
|
||||
final ChatChannel channel = (ChatChannel) args[1];
|
||||
|
||||
String message;
|
||||
String otherMessage;
|
||||
final String message;
|
||||
final String otherMessage;
|
||||
|
||||
UserChannelSettings settings = user.getChannelSettings(channel);
|
||||
final UserChannelSettings settings = user.channelSettings(channel);
|
||||
|
||||
if (settings.ignored()) {
|
||||
settings.ignoring(false);
|
||||
message = channel.getToggleOffMessage();
|
||||
otherMessage = channel.getToggleOtherOffMessage();
|
||||
message = channel.toggleOffMessage();
|
||||
otherMessage = channel.toggleOtherOffMessage();
|
||||
} else {
|
||||
settings.ignoring(true);
|
||||
message = channel.getToggleOnMessage();
|
||||
otherMessage = channel.getToggleOtherOnMessage();
|
||||
message = channel.toggleOnMessage();
|
||||
otherMessage = channel.toggleOtherOnMessage();
|
||||
}
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessage(message, "br", "\n",
|
||||
"color", "<color:" + channel.getChannelColor(user).toString() + ">", "channel", channel.getName()));
|
||||
user.sendMessage(this.carbonChat.getAdventureManager().processMessage(message, "br", "\n",
|
||||
"color", "<color:" + channel.channelColor(user).toString() + ">", "channel", channel.name()));
|
||||
|
||||
carbonChat.getAdventureManager().getAudiences().audience(sender).sendMessage(carbonChat.getAdventureManager().processMessage(otherMessage,
|
||||
"br", "\n", "color", "<color:" + channel.getChannelColor(user).toString() + ">",
|
||||
"channel", channel.getName(), "player", user.offlinePlayer().getName()));
|
||||
this.carbonChat.getAdventureManager().audiences().audience(sender).sendMessage(
|
||||
this.carbonChat.getAdventureManager().processMessage(otherMessage,
|
||||
"br", "\n", "color", "<color:" + channel.channelColor(user).toString() + ">",
|
||||
"channel", channel.name(), "player", user.offlinePlayer().getName()));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user