mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 14:38:49 +00:00
Progress on CarbonChat-Common
This commit is contained in:
1 parent
508ad88e26
commit
64295c84ea
60 files changed
+889
-556
No files matched your search
+72
-60
@@ -1,5 +1,12 @@
|
||||
package net.draycia.carbon;
|
||||
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.adventure.CarbonTranslations;
|
||||
import net.draycia.carbon.api.adventure.MessageProcessor;
|
||||
import net.draycia.carbon.api.channels.ChannelRegistry;
|
||||
import net.draycia.carbon.api.commands.CommandSettingsRegistry;
|
||||
import net.draycia.carbon.common.adventure.FormatType;
|
||||
import net.draycia.carbon.common.messaging.EmptyMessageService;
|
||||
import net.draycia.carbon.listeners.contexts.DistanceContext;
|
||||
import net.draycia.carbon.listeners.contexts.EconomyContext;
|
||||
import net.draycia.carbon.listeners.contexts.FilterContext;
|
||||
@@ -22,10 +29,9 @@ import net.draycia.carbon.listeners.events.ShadowMuteHandler;
|
||||
import net.draycia.carbon.listeners.events.UrlLinkHandler;
|
||||
import net.draycia.carbon.listeners.events.UserFormattingHandler;
|
||||
import net.draycia.carbon.listeners.events.WhisperPingHandler;
|
||||
import net.draycia.carbon.managers.AdventureManager;
|
||||
import net.draycia.carbon.managers.ChannelManager;
|
||||
import net.draycia.carbon.common.adventure.AdventureManager;
|
||||
import net.draycia.carbon.managers.CommandManager;
|
||||
import net.draycia.carbon.messaging.MessageManager;
|
||||
import net.draycia.carbon.common.messaging.MessageManager;
|
||||
import net.draycia.carbon.api.users.UserService;
|
||||
import net.draycia.carbon.storage.impl.JSONUserService;
|
||||
import net.draycia.carbon.storage.impl.MySQLUserService;
|
||||
@@ -33,36 +39,40 @@ import net.draycia.carbon.util.CarbonPlaceholders;
|
||||
import net.draycia.carbon.util.FunctionalityConstants;
|
||||
import net.draycia.carbon.util.Metrics;
|
||||
import dev.jorel.commandapi.CommandAPI;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.spongepowered.configurate.BasicConfigurationNode;
|
||||
import org.spongepowered.configurate.objectmapping.ObjectMappingException;
|
||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public final class CarbonChat extends JavaPlugin {
|
||||
public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
|
||||
private static final int BSTATS_PLUGIN_ID = 8720;
|
||||
|
||||
private Permission permission;
|
||||
|
||||
private CommandManager commandManager;
|
||||
private ChannelManager channelManager;
|
||||
private AdventureManager adventureManager;
|
||||
|
||||
private ChannelRegistry channelRegistry;
|
||||
private CommandSettingsRegistry commandSettings;
|
||||
private AdventureManager messageProcessor;
|
||||
|
||||
private UserService userService;
|
||||
private MessageManager messageManager;
|
||||
|
||||
private YamlConfiguration modConfig;
|
||||
private YamlConfiguration languageConfig;
|
||||
private YamlConfiguration commandsConfig;
|
||||
|
||||
private FilterContext filterContext;
|
||||
|
||||
private CarbonTranslations translations;
|
||||
|
||||
public static final LegacyComponentSerializer LEGACY =
|
||||
LegacyComponentSerializer.builder()
|
||||
.extractUrls()
|
||||
@@ -90,26 +100,17 @@ public final class CarbonChat extends JavaPlugin {
|
||||
this.saveResource("moderation.yml", false);
|
||||
}
|
||||
|
||||
if (!(new File(this.getDataFolder(), "language.yml").exists())) {
|
||||
this.saveResource("language.yml", false);
|
||||
}
|
||||
|
||||
if (!(new File(this.getDataFolder(), "commands.yml").exists())) {
|
||||
this.saveResource("commands.yml", false);
|
||||
}
|
||||
|
||||
this.loadModConfig();
|
||||
this.loadLanguage();
|
||||
this.reloadConfig();
|
||||
|
||||
// Setup Adventure
|
||||
this.adventureManager = new AdventureManager(this);
|
||||
this.messageProcessor = new AdventureManager(BukkitAudiences.create(this), FormatType.MINIMESSAGE); // TODO: get format type from config
|
||||
|
||||
// Setup vault and permissions
|
||||
this.permission = this.getServer().getServicesManager().getRegistration(Permission.class).getProvider();
|
||||
|
||||
// Initialize managers
|
||||
this.channelManager = new ChannelManager(this);
|
||||
this.messageManager = new MessageManager(this);
|
||||
this.channelRegistry = new ChannelRegistry();
|
||||
this.messageManager = new MessageManager(this, new EmptyMessageService()); // TODO: get message service from config
|
||||
this.commandManager = new CommandManager(this);
|
||||
|
||||
final String storageType = this.getConfig().getString("storage.type");
|
||||
@@ -169,25 +170,41 @@ public final class CarbonChat extends JavaPlugin {
|
||||
|
||||
this.loadModConfig();
|
||||
this.loadLanguage();
|
||||
this.loadCommandsConfig();
|
||||
this.loadCommandSettings();
|
||||
}
|
||||
|
||||
private void loadLanguage() {
|
||||
final File languageFile = new File(this.getDataFolder(), "language.yml");
|
||||
final YamlConfigurationLoader languageLoader = YamlConfigurationLoader.builder().setFile(languageFile).build();
|
||||
|
||||
try {
|
||||
final BasicConfigurationNode languageNode = languageLoader.load();
|
||||
this.translations = CarbonTranslations.loadFrom(languageNode);
|
||||
languageLoader.save(languageNode);
|
||||
} catch (final IOException | ObjectMappingException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private void loadCommandSettings() {
|
||||
if (!(new File(this.getDataFolder(), "carbon-commands.yml").exists())) {
|
||||
this.saveResource("carbon-commands.yml", false);
|
||||
}
|
||||
|
||||
final File commandSettingsFile = new File(this.getDataFolder(), "carbon-commands.yml");
|
||||
final YamlConfigurationLoader commandSettingsLoader = YamlConfigurationLoader.builder().setFile(commandSettingsFile).build();
|
||||
|
||||
try {
|
||||
final BasicConfigurationNode commandSettingsNode = commandSettingsLoader.load();
|
||||
this.commandSettings = CommandSettingsRegistry.loadFrom(commandSettingsNode);
|
||||
commandSettingsLoader.save(commandSettingsNode);
|
||||
} catch (final IOException | ObjectMappingException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadFilters() {
|
||||
this.filterContext.reloadFilters();
|
||||
}
|
||||
|
||||
private void loadModConfig() {
|
||||
this.modConfig = YamlConfiguration.loadConfiguration(new File(this.getDataFolder(), "moderation.yml"));
|
||||
}
|
||||
|
||||
private void loadLanguage() {
|
||||
this.languageConfig = YamlConfiguration.loadConfiguration(new File(this.getDataFolder(), "language.yml"));
|
||||
}
|
||||
|
||||
private void loadCommandsConfig() {
|
||||
this.commandsConfig = YamlConfiguration.loadConfiguration(new File(this.getDataFolder(), "commands.yml"));
|
||||
}
|
||||
|
||||
private void registerContexts() {
|
||||
this.filterContext = new FilterContext(this);
|
||||
|
||||
@@ -210,21 +227,6 @@ public final class CarbonChat extends JavaPlugin {
|
||||
new DistanceContext();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public YamlConfiguration moderationConfig() {
|
||||
return this.modConfig;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public YamlConfiguration commandsConfig() {
|
||||
return this.commandsConfig;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public YamlConfiguration language() {
|
||||
return this.languageConfig;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Permission permission() {
|
||||
return this.permission;
|
||||
@@ -235,11 +237,6 @@ public final class CarbonChat extends JavaPlugin {
|
||||
return this.commandManager;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public ChannelManager channelManager() {
|
||||
return this.channelManager;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MessageManager messageManager() {
|
||||
return this.messageManager;
|
||||
@@ -250,8 +247,23 @@ public final class CarbonChat extends JavaPlugin {
|
||||
return this.userService;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public AdventureManager adventureManager() {
|
||||
return this.adventureManager;
|
||||
@Override
|
||||
public @NonNull ChannelRegistry channelRegistry() {
|
||||
return this.channelRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull CommandSettingsRegistry commandSettingsRegistry() {
|
||||
return this.commandSettings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull CarbonTranslations translations() {
|
||||
return this.translations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull MessageProcessor messageProcessor() {
|
||||
return this.messageProcessor;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.draycia.carbon.channels;
|
||||
|
||||
import net.draycia.carbon.util.CarbonUtils;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.events.ChatComponentEvent;
|
||||
@@ -35,19 +35,19 @@ public class CarbonChatChannel implements ChatChannel {
|
||||
private final String key;
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
@Nullable
|
||||
private final ConfigurationSection config;
|
||||
|
||||
public CarbonChatChannel(@NonNull final String key, @NonNull final CarbonChat carbonChat, @Nullable final ConfigurationSection config) {
|
||||
public CarbonChatChannel(@NonNull final String key, @NonNull final CarbonChatBukkit carbonChat, @Nullable final ConfigurationSection config) {
|
||||
this.key = key;
|
||||
this.carbonChat = carbonChat;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public CarbonChat carbonChat() {
|
||||
public CarbonChatBukkit carbonChat() {
|
||||
return this.carbonChat;
|
||||
}
|
||||
|
||||
@@ -88,8 +88,8 @@ public class CarbonChatChannel implements ChatChannel {
|
||||
String nickname = user.nickname();
|
||||
|
||||
if (nickname != null) {
|
||||
final Component component = this.carbonChat.adventureManager().processMessage(nickname);
|
||||
nickname = CarbonChat.LEGACY.serialize(component);
|
||||
final Component component = this.carbonChat.messageProcessor().processMessage(nickname);
|
||||
nickname = CarbonChatBukkit.LEGACY.serialize(component);
|
||||
|
||||
player.setDisplayName(nickname);
|
||||
|
||||
@@ -155,7 +155,7 @@ public class CarbonChatChannel implements ChatChannel {
|
||||
|
||||
final TextColor targetColor = this.channelColor(target);
|
||||
|
||||
TextComponent formatComponent = (TextComponent) this.carbonChat.adventureManager().processMessage(formatEvent.format(),
|
||||
TextComponent formatComponent = (TextComponent) this.carbonChat.messageProcessor().processMessage(formatEvent.format(),
|
||||
"br", "\n",
|
||||
"displayname", displayName,
|
||||
"color", "<" + targetColor.asHexString() + ">",
|
||||
@@ -185,7 +185,7 @@ public class CarbonChatChannel implements ChatChannel {
|
||||
|
||||
final TextColor targetColor = this.channelColor(user);
|
||||
|
||||
final TextComponent consoleFormat = (TextComponent) this.carbonChat.adventureManager().processMessage(consoleFormatEvent.format(),
|
||||
final TextComponent consoleFormat = (TextComponent) this.carbonChat.messageProcessor().processMessage(consoleFormatEvent.format(),
|
||||
"br", "\n",
|
||||
"displayname", displayName,
|
||||
"color", "<" + targetColor.asHexString() + ">",
|
||||
@@ -324,7 +324,7 @@ public class CarbonChatChannel implements ChatChannel {
|
||||
public void sendMessageToBungee(@NonNull final Player player, @NonNull final Component component) {
|
||||
this.carbonChat.messageManager().sendMessage("channel-component", player.getUniqueId(), byteArray -> {
|
||||
byteArray.writeUTF(this.key());
|
||||
byteArray.writeUTF(this.carbonChat.adventureManager().audiences().gsonSerializer().serialize(component));
|
||||
byteArray.writeUTF(this.carbonChat.messageProcessor().audiences().gsonSerializer().serialize(component));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -4,7 +4,7 @@ import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import dev.jorel.commandapi.arguments.GreedyStringArgument;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -16,7 +16,7 @@ import java.util.LinkedHashMap;
|
||||
public class AliasedChannelCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
@NonNull
|
||||
private final ChatChannel chatChannel;
|
||||
@@ -24,7 +24,7 @@ public class AliasedChannelCommand {
|
||||
@NonNull
|
||||
private final String commandName;
|
||||
|
||||
public AliasedChannelCommand(@NonNull final CarbonChat carbonChat, @NonNull final ChatChannel chatChannel) {
|
||||
public AliasedChannelCommand(@NonNull final CarbonChatBukkit carbonChat, @NonNull final ChatChannel chatChannel) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.chatChannel = chatChannel;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class AliasedChannelCommand {
|
||||
final ChatUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
|
||||
if (user.channelSettings(this.chatChannel()).ignored()) {
|
||||
user.sendMessage(this.carbonChat.adventureManager().processMessageWithPapi(player, this.chatChannel().cannotUseMessage(),
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(this.chatChannel().cannotUseMessage(),
|
||||
"br", "\n",
|
||||
"color", "<" + this.chatChannel().channelColor(user).toString() + ">",
|
||||
"channel", this.chatChannel().name()));
|
||||
@@ -69,7 +69,7 @@ public class AliasedChannelCommand {
|
||||
|
||||
final Component component = this.chatChannel().sendMessage(user, message, false);
|
||||
|
||||
this.carbonChat.adventureManager().audiences().console().sendMessage(component);
|
||||
this.carbonChat.messageProcessor().audiences().console().sendMessage(component);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@@ -7,7 +7,7 @@ import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import dev.jorel.commandapi.arguments.GreedyStringArgument;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -19,9 +19,9 @@ import java.util.LinkedHashMap;
|
||||
public class ChannelCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public ChannelCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
public ChannelCommand(@NonNull final CarbonChatBukkit carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -57,7 +57,7 @@ public class ChannelCommand {
|
||||
final ChatChannel channel = (ChatChannel) args[0];
|
||||
|
||||
if (user.channelSettings(channel).ignored()) {
|
||||
user.sendMessage(this.carbonChat.adventureManager().processMessageWithPapi(player, channel.cannotUseMessage(),
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(channel.cannotUseMessage(),
|
||||
"br", "\n",
|
||||
"color", "<" + channel.channelColor(user).toString() + ">",
|
||||
"channel", channel.name()));
|
||||
@@ -75,7 +75,7 @@ public class ChannelCommand {
|
||||
|
||||
final Component component = channel.sendMessage(user, message, false);
|
||||
|
||||
this.carbonChat.adventureManager().audiences().console().sendMessage(component);
|
||||
this.carbonChat.messageProcessor().audiences().console().sendMessage(component);
|
||||
}
|
||||
|
||||
}
|
||||
+29
-16
@@ -5,7 +5,7 @@ import net.draycia.carbon.util.CommandUtils;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.commands.CommandSettings;
|
||||
@@ -27,9 +27,9 @@ import java.util.regex.Pattern;
|
||||
public class ChannelListCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public ChannelListCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
public ChannelListCommand(@NonNull final CarbonChatBukkit carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -59,25 +59,32 @@ public class ChannelListCommand {
|
||||
}
|
||||
|
||||
public void executeSelf(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
final Iterator<ChatChannel> allChannels = this.carbonChat.channelManager().registry().iterator();
|
||||
final Iterator<ChatChannel> allChannels = this.carbonChat.channelRegistry().iterator();
|
||||
final ChatUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
|
||||
this.listAndSend(player, user, allChannels);
|
||||
}
|
||||
|
||||
public void executeOther(@NonNull final CommandSender sender, @NonNull final Object @NonNull [] args) {
|
||||
final Audience cmdSender = this.carbonChat.adventureManager().audiences().audience(sender);
|
||||
final Audience cmdSender;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
cmdSender = this.carbonChat.userService().wrap(((Player) sender).getUniqueId());
|
||||
} else {
|
||||
cmdSender = this.carbonChat.messageProcessor().audiences().console();
|
||||
}
|
||||
|
||||
final ChatUser user = (ChatUser) args[0];
|
||||
|
||||
final OfflinePlayer player = Bukkit.getOfflinePlayer(user.uuid());
|
||||
|
||||
if (!player.isOnline()) {
|
||||
final String mustBeOnline = this.carbonChat.language().getString("user-must-be-online");
|
||||
cmdSender.sendMessage(this.carbonChat.adventureManager().processMessage(mustBeOnline, "br", "\n", "player", player.getName()));
|
||||
final String mustBeOnline = this.carbonChat.translations().userMustBeOnline();
|
||||
cmdSender.sendMessage(this.carbonChat.messageProcessor().processMessage(mustBeOnline, "br", "\n", "player", player.getName()));
|
||||
return;
|
||||
}
|
||||
|
||||
final Iterator<ChatChannel> allChannels = this.carbonChat.channelManager().registry().iterator();
|
||||
final Iterator<ChatChannel> allChannels = this.carbonChat.channelRegistry().iterator();
|
||||
this.listAndSend(sender, user, allChannels);
|
||||
}
|
||||
|
||||
@@ -102,13 +109,19 @@ public class ChannelListCommand {
|
||||
|
||||
this.makeList(visibleChannels, availableList);
|
||||
|
||||
final String availableFormat = this.carbonChat.language().getString("available-channels-list");
|
||||
Component availableComponent = this.carbonChat.adventureManager().processMessage(availableFormat, "br", "\n");
|
||||
final String availableFormat = this.carbonChat.translations().availableChannelsList();
|
||||
Component availableComponent = this.carbonChat.messageProcessor().processMessage(availableFormat, "br", "\n");
|
||||
availableComponent = availableComponent.replaceFirstText(Pattern.compile(Pattern.quote("<list>")), ac -> availableList);
|
||||
|
||||
final Audience audience = this.carbonChat.adventureManager().audiences().audience(sender);
|
||||
final Audience cmdSender;
|
||||
|
||||
audience.sendMessage(availableComponent);
|
||||
if (sender instanceof Player) {
|
||||
cmdSender = this.carbonChat.userService().wrap(((Player) sender).getUniqueId());
|
||||
} else {
|
||||
cmdSender = this.carbonChat.messageProcessor().audiences().console();
|
||||
}
|
||||
|
||||
cmdSender.sendMessage(availableComponent);
|
||||
|
||||
if (sender.hasPermission("carbonchat.channellist.bypass") && !cannotSee.isEmpty()) {
|
||||
final Iterator<ChatChannel> invisibleChannels = cannotSee.iterator();
|
||||
@@ -116,16 +129,16 @@ public class ChannelListCommand {
|
||||
|
||||
this.makeList(invisibleChannels, unavailableList);
|
||||
|
||||
final String unavailableFormat = this.carbonChat.language().getString("unavailable-channels-list");
|
||||
Component unavailableComponent = this.carbonChat.adventureManager().processMessage(unavailableFormat, "br", "\n");
|
||||
final String unavailableFormat = this.carbonChat.translations().unavailableChannelsList();
|
||||
Component unavailableComponent = this.carbonChat.messageProcessor().processMessage(unavailableFormat, "br", "\n");
|
||||
unavailableComponent = unavailableComponent.replaceFirstText(Pattern.compile(Pattern.quote("<list>")), uac -> unavailableList);
|
||||
|
||||
audience.sendMessage(unavailableComponent);
|
||||
cmdSender.sendMessage(unavailableComponent);
|
||||
}
|
||||
}
|
||||
|
||||
private void makeList(@NonNull final Iterator<@NonNull ChatChannel> iterator, final TextComponent.@NonNull Builder list) {
|
||||
final String listSeparator = this.carbonChat.language().getString("channel-list-separator", ", ");
|
||||
final String listSeparator = this.carbonChat.translations().channelListSeparator();
|
||||
// TODO: Larry, why did you double assign the listSeparatorComponent?
|
||||
final Component listSeparatorComponent = TextComponent.of(listSeparator);
|
||||
|
||||
|
||||
@@ -4,17 +4,19 @@ import net.draycia.carbon.api.commands.CommandSettings;
|
||||
import net.draycia.carbon.util.CommandUtils;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class ChatReloadCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public ChatReloadCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
public ChatReloadCommand(@NonNull final CarbonChatBukkit carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -34,10 +36,18 @@ public class ChatReloadCommand {
|
||||
this.carbonChat.reloadConfig();
|
||||
this.carbonChat.reloadFilters();
|
||||
|
||||
final Component message = this.carbonChat.adventureManager()
|
||||
.processMessage(this.carbonChat.language().getString("reloaded"), "br", "\n");
|
||||
final Component message = this.carbonChat.messageProcessor()
|
||||
.processMessage(this.carbonChat.translations().reloaded().replace("br", "\n"));
|
||||
|
||||
this.carbonChat.adventureManager().audiences().audience(sender).sendMessage(message);
|
||||
final Audience cmdSender;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
cmdSender = this.carbonChat.userService().wrap(((Player) sender).getUniqueId());
|
||||
} else {
|
||||
cmdSender = this.carbonChat.messageProcessor().audiences().console();
|
||||
}
|
||||
|
||||
cmdSender.sendMessage(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import net.draycia.carbon.api.commands.CommandSettings;
|
||||
import net.draycia.carbon.util.CommandUtils;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -15,9 +15,9 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
public class ClearChatCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public ClearChatCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
public ClearChatCommand(@NonNull final CarbonChatBukkit carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -35,14 +35,14 @@ public class ClearChatCommand {
|
||||
|
||||
private void execute(@NonNull final CommandSender sender, @NonNull final Object @NonNull [] args) {
|
||||
final String format = this.carbonChat.moderationConfig().getString("clear-chat.message", "");
|
||||
final Component component = this.carbonChat.adventureManager().processMessage(format, "br", "\n");
|
||||
final Component component = this.carbonChat.messageProcessor().processMessage(format, "br", "\n");
|
||||
|
||||
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||
final ChatUser audience = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
|
||||
if (player.hasPermission("carbonchat.clearchat.exempt")) {
|
||||
final String message = this.carbonChat.language().getString("clear-exempt");
|
||||
audience.sendMessage(this.carbonChat.adventureManager().processMessage(message, "player", sender.getName()));
|
||||
final String message = this.carbonChat.translations().clearExempt();
|
||||
audience.sendMessage(this.carbonChat.messageProcessor().processMessage(message, "player", sender.getName()));
|
||||
} else {
|
||||
for (int i = 0; i < this.carbonChat.moderationConfig().getInt("clear-chat.message-count", 100); i++) {
|
||||
audience.sendMessage(component);
|
||||
@@ -50,8 +50,8 @@ public class ClearChatCommand {
|
||||
}
|
||||
|
||||
if (player.hasPermission("carbonchat.clearchat.notify")) {
|
||||
final String message = this.carbonChat.language().getString("clear-notify");
|
||||
audience.sendMessage(this.carbonChat.adventureManager().processMessage(message, "player", sender.getName()));
|
||||
final String message = this.carbonChat.translations().clearNotify();
|
||||
audience.sendMessage(this.carbonChat.messageProcessor().processMessage(message, "player", sender.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.draycia.carbon.util.CommandUtils;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
@@ -20,9 +20,9 @@ import java.util.LinkedHashMap;
|
||||
public class IgnoreCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public IgnoreCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
public IgnoreCommand(@NonNull final CarbonChatBukkit carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -50,8 +50,8 @@ public class IgnoreCommand {
|
||||
|
||||
if (user.ignoringUser(targetUser)) {
|
||||
user.ignoringUser(targetUser, false);
|
||||
user.sendMessage(this.carbonChat.adventureManager().processMessageWithPapi(player,
|
||||
this.carbonChat.language().getString("not-ignoring-user"),
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(
|
||||
this.carbonChat.translations().notIgnoringUser(),
|
||||
"br", "\n", "player", offlinePlayer.getName()));
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.carbonChat, () -> {
|
||||
@@ -59,13 +59,13 @@ public class IgnoreCommand {
|
||||
final String format;
|
||||
|
||||
if (permission.playerHas(null, offlinePlayer, "carbonchat.ignore.exempt")) {
|
||||
format = this.carbonChat.language().getString("ignore-exempt");
|
||||
format = this.carbonChat.translations().ignoreExempt();
|
||||
} else {
|
||||
user.ignoringUser(targetUser, true);
|
||||
format = this.carbonChat.language().getString("ignoring-user");
|
||||
format = this.carbonChat.translations().ignoringUser();
|
||||
}
|
||||
|
||||
final Component message = this.carbonChat.adventureManager().processMessageWithPapi(player, format,
|
||||
final Component message = this.carbonChat.messageProcessor().processMessage(format,
|
||||
"br", "\n", "sender", player.getDisplayName(), "player", offlinePlayer.getName());
|
||||
|
||||
user.sendMessage(message);
|
||||
|
||||
@@ -5,7 +5,7 @@ import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import dev.jorel.commandapi.arguments.GreedyStringArgument;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.commands.CommandSettings;
|
||||
import net.draycia.carbon.util.CommandUtils;
|
||||
@@ -19,9 +19,9 @@ import java.util.LinkedHashMap;
|
||||
public class MeCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public MeCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
public MeCommand(@NonNull final CarbonChatBukkit carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -43,13 +43,13 @@ public class MeCommand {
|
||||
|
||||
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.language().getString("me"));
|
||||
String format = PlaceholderAPI.setPlaceholders(player, this.carbonChat.translations().roleplayFormat());
|
||||
|
||||
if (!player.hasPermission("carbonchat.me.formatting")) {
|
||||
format = format.replace("<message>", "<pre><message></pre>");
|
||||
}
|
||||
|
||||
final Component component = this.carbonChat.adventureManager().processMessage(format, "br", "\n",
|
||||
final Component component = this.carbonChat.messageProcessor().processMessage(format, "br", "\n",
|
||||
"displayname", player.getDisplayName(), "message", message);
|
||||
|
||||
final ChatUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
@@ -62,7 +62,7 @@ public class MeCommand {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.carbonChat.adventureManager().audiences().player(onlinePlayer).sendMessage(component);
|
||||
this.carbonChat.messageProcessor().audiences().player(onlinePlayer.getUniqueId()).sendMessage(component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import dev.jorel.commandapi.arguments.GreedyStringArgument;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -17,9 +17,9 @@ import java.util.LinkedHashMap;
|
||||
public class MessageCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public MessageCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
public MessageCommand(@NonNull final CarbonChatBukkit carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
|
||||
@@ -7,13 +7,14 @@ import net.draycia.carbon.util.CommandUtils;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
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.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -21,9 +22,9 @@ import java.util.LinkedHashMap;
|
||||
public class MuteCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public MuteCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
public MuteCommand(@NonNull final CarbonChatBukkit carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -45,34 +46,41 @@ public class MuteCommand {
|
||||
|
||||
private void execute(@NonNull final CommandSender sender, @NonNull final Object @NonNull [] args) {
|
||||
final ChatUser user = (ChatUser) args[0];
|
||||
final Audience audience = this.carbonChat.adventureManager().audiences().audience(sender);
|
||||
|
||||
final Audience cmdSender;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
cmdSender = this.carbonChat.userService().wrap(((Player) sender).getUniqueId());
|
||||
} else {
|
||||
cmdSender = this.carbonChat.messageProcessor().audiences().console();
|
||||
}
|
||||
|
||||
final OfflinePlayer player = Bukkit.getOfflinePlayer(user.uuid());
|
||||
|
||||
if (user.shadowMuted()) {
|
||||
user.muted(false);
|
||||
final String format = this.carbonChat.language().getString("no-longer-muted");
|
||||
final String format = this.carbonChat.translations().noLongerMuted();
|
||||
|
||||
final Component message = this.carbonChat.adventureManager().processMessage(format, "br", "\n",
|
||||
final Component message = this.carbonChat.messageProcessor().processMessage(format, "br", "\n",
|
||||
"player", player.getName());
|
||||
|
||||
audience.sendMessage(message);
|
||||
cmdSender.sendMessage(message);
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.carbonChat, () -> {
|
||||
final Permission permission = this.carbonChat.permission();
|
||||
final String format;
|
||||
|
||||
if (permission.playerHas(null, player, "carbonchat.mute.exempt")) {
|
||||
format = this.carbonChat.language().getString("mute-exempt");
|
||||
format = this.carbonChat.translations().muteExempt();
|
||||
} else {
|
||||
user.muted(true);
|
||||
format = this.carbonChat.language().getString("is-now-muted");
|
||||
format = this.carbonChat.translations().nowMuted();
|
||||
}
|
||||
|
||||
final Component message = this.carbonChat.adventureManager().processMessage(format, "br", "\n",
|
||||
final Component message = this.carbonChat.messageProcessor().processMessage(format, "br", "\n",
|
||||
"player", player.getName());
|
||||
|
||||
audience.sendMessage(message);
|
||||
cmdSender.sendMessage(message);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import dev.jorel.commandapi.arguments.StringArgument;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -20,9 +20,9 @@ import java.util.LinkedHashMap;
|
||||
public class NicknameCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public NicknameCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
public NicknameCommand(@NonNull final CarbonChatBukkit carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -66,18 +66,25 @@ public class NicknameCommand {
|
||||
final String message;
|
||||
|
||||
if (nickname == null) {
|
||||
message = this.carbonChat.language().getString("nickname-reset");
|
||||
message = this.carbonChat.translations().nicknameReset();
|
||||
} else {
|
||||
message = this.carbonChat.language().getString("nickname-set");
|
||||
message = this.carbonChat.translations().nicknameSet();
|
||||
}
|
||||
|
||||
sender.sendMessage(this.carbonChat.adventureManager().processMessage(
|
||||
sender.sendMessage(this.carbonChat.messageProcessor().processMessage(
|
||||
message, "nickname", nickname == null ? "" : nickname,
|
||||
"user", Bukkit.getOfflinePlayer(sender.uuid()).getName()));
|
||||
}
|
||||
|
||||
private void executeOther(@NonNull final CommandSender sender, @NonNull final Object @NonNull [] args) {
|
||||
final Audience user = this.carbonChat.adventureManager().audiences().audience(sender);
|
||||
final Audience cmdSender;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
cmdSender = this.carbonChat.userService().wrap(((Player) sender).getUniqueId());
|
||||
} else {
|
||||
cmdSender = this.carbonChat.messageProcessor().audiences().console();
|
||||
}
|
||||
|
||||
final ChatUser target = (ChatUser) args[0];
|
||||
String nickname = (String) args[1];
|
||||
|
||||
@@ -91,12 +98,12 @@ public class NicknameCommand {
|
||||
final String message;
|
||||
|
||||
if (nickname == null) {
|
||||
message = this.carbonChat.language().getString("other-nickname-reset");
|
||||
message = this.carbonChat.translations().otherNicknameReset();
|
||||
} else {
|
||||
message = this.carbonChat.language().getString("other-nickname-set");
|
||||
message = this.carbonChat.translations().otherNicknameSet();
|
||||
}
|
||||
|
||||
user.sendMessage(this.carbonChat.adventureManager().processMessage(
|
||||
cmdSender.sendMessage(this.carbonChat.messageProcessor().processMessage(
|
||||
message, "nickname", nickname == null ? "" : nickname,
|
||||
"user", Bukkit.getOfflinePlayer(target.uuid()).getName()));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import dev.jorel.commandapi.arguments.GreedyStringArgument;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.commands.CommandSettings;
|
||||
import net.draycia.carbon.util.CommandUtils;
|
||||
@@ -17,9 +17,9 @@ import java.util.LinkedHashMap;
|
||||
public class ReplyCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public ReplyCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
public ReplyCommand(@NonNull final CarbonChatBukkit carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -45,8 +45,8 @@ public class ReplyCommand {
|
||||
final ChatUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
|
||||
if (input.isEmpty()) {
|
||||
final String message = this.carbonChat.language().getString("reply-message-blank");
|
||||
final Component component = this.carbonChat.adventureManager().processMessage(message, "br", "\n");
|
||||
final String message = this.carbonChat.translations().replyMessageBlank();
|
||||
final Component component = this.carbonChat.messageProcessor().processMessage(message, "br", "\n");
|
||||
|
||||
user.sendMessage(component);
|
||||
|
||||
@@ -54,8 +54,8 @@ public class ReplyCommand {
|
||||
}
|
||||
|
||||
if (user.replyTarget() == null) {
|
||||
final String message = this.carbonChat.language().getString("no-reply-target");
|
||||
final Component component = this.carbonChat.adventureManager().processMessage(message, "br", "\n");
|
||||
final String message = this.carbonChat.translations().noReplyTarget();
|
||||
final Component component = this.carbonChat.messageProcessor().processMessage(message, "br", "\n");
|
||||
|
||||
user.sendMessage(component);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import dev.jorel.commandapi.arguments.LiteralArgument;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.commands.CommandSettings;
|
||||
@@ -19,9 +19,9 @@ import java.util.LinkedHashMap;
|
||||
public class SetColorCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public SetColorCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
public SetColorCommand(@NonNull final CarbonChatBukkit carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -30,7 +30,7 @@ public class SetColorCommand {
|
||||
|
||||
CommandUtils.handleDuplicateCommands(commandSettings);
|
||||
|
||||
for (final ChatChannel channel : this.carbonChat.channelManager().registry()) {
|
||||
for (final ChatChannel channel : this.carbonChat.channelRegistry()) {
|
||||
final LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
|
||||
arguments.put("channel", new LiteralArgument(channel.key()));
|
||||
arguments.put("color", CarbonUtils.textColorArgument());
|
||||
@@ -44,8 +44,8 @@ public class SetColorCommand {
|
||||
final ChatUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
|
||||
if (!player.hasPermission("carbonchat.setcolor." + channel.key())) {
|
||||
user.sendMessage(carbonChat.adventureManager().processMessageWithPapi(player,
|
||||
this.carbonChat.language().getString("cannot-set-color"),
|
||||
user.sendMessage(carbonChat.messageProcessor().processMessage(
|
||||
this.carbonChat.translations().cannotSetColor(),
|
||||
"br", "\n", "input", color.asHexString(),
|
||||
"channel", channel.name()));
|
||||
|
||||
@@ -56,8 +56,8 @@ public class SetColorCommand {
|
||||
|
||||
settings.color(color);
|
||||
|
||||
user.sendMessage(carbonChat.adventureManager().processMessageWithPapi(player,
|
||||
this.carbonChat.language().getString("channel-color-set"),
|
||||
user.sendMessage(carbonChat.messageProcessor().processMessage(
|
||||
this.carbonChat.translations().channelColorSet(),
|
||||
"br", "\n", "color", "<color:" + color.asHexString() + ">", "channel",
|
||||
channel.name(), "hex", color.asHexString()));
|
||||
})
|
||||
|
||||
+19
-11
@@ -7,13 +7,14 @@ import net.draycia.carbon.util.CommandUtils;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
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.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -21,9 +22,9 @@ import java.util.LinkedHashMap;
|
||||
public class ShadowMuteCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public ShadowMuteCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
public ShadowMuteCommand(@NonNull final CarbonChatBukkit carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -44,35 +45,42 @@ public class ShadowMuteCommand {
|
||||
}
|
||||
|
||||
private void execute(@NonNull final CommandSender sender, @NonNull final Object @NonNull [] args) {
|
||||
final Audience cmdSender;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
cmdSender = this.carbonChat.userService().wrap(((Player) sender).getUniqueId());
|
||||
} else {
|
||||
cmdSender = this.carbonChat.messageProcessor().audiences().console();
|
||||
}
|
||||
|
||||
final ChatUser user = (ChatUser) args[0];
|
||||
final Audience audience = this.carbonChat.adventureManager().audiences().audience(sender);
|
||||
|
||||
final OfflinePlayer player = Bukkit.getOfflinePlayer(user.uuid());
|
||||
|
||||
if (user.shadowMuted()) {
|
||||
user.shadowMuted(false);
|
||||
final String format = this.carbonChat.language().getString("no-longer-shadow-muted");
|
||||
final String format = this.carbonChat.translations().noLongerShadowMuted();
|
||||
|
||||
final Component message = this.carbonChat.adventureManager().processMessage(format, "br", "\n",
|
||||
final Component message = this.carbonChat.messageProcessor().processMessage(format, "br", "\n",
|
||||
"player", player.getName());
|
||||
|
||||
audience.sendMessage(message);
|
||||
cmdSender.sendMessage(message);
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.carbonChat, () -> {
|
||||
final Permission permission = this.carbonChat.permission();
|
||||
final String format;
|
||||
|
||||
if (permission.playerHas(null, player, "carbonchat.shadowmute.exempt")) {
|
||||
format = this.carbonChat.language().getString("shadow-mute-exempt");
|
||||
format = this.carbonChat.translations().shadowMuteExempt();
|
||||
} else {
|
||||
user.shadowMuted(true);
|
||||
format = this.carbonChat.language().getString("is-now-shadow-muted");
|
||||
format = this.carbonChat.translations().nowShadowMuted();
|
||||
}
|
||||
|
||||
final Component message = this.carbonChat.adventureManager().processMessage(format, "br", "\n",
|
||||
final Component message = this.carbonChat.messageProcessor().processMessage(format, "br", "\n",
|
||||
"player", player.getName());
|
||||
|
||||
audience.sendMessage(message);
|
||||
cmdSender.sendMessage(message);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+14
-14
@@ -11,7 +11,7 @@ import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import dev.jorel.commandapi.arguments.BooleanArgument;
|
||||
import dev.jorel.commandapi.arguments.LiteralArgument;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
@@ -20,9 +20,9 @@ import java.util.LinkedHashMap;
|
||||
public class SpyChannelCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public SpyChannelCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
public SpyChannelCommand(@NonNull final CarbonChatBukkit carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -73,13 +73,13 @@ public class SpyChannelCommand {
|
||||
|
||||
if (settings.spying()) {
|
||||
settings.spying(false);
|
||||
message = this.carbonChat.language().getString("spy-toggled-off");
|
||||
message = this.carbonChat.translations().spyToggledOff();
|
||||
} else {
|
||||
settings.spying(true);
|
||||
message = this.carbonChat.language().getString("spy-toggled-on");
|
||||
message = this.carbonChat.translations().spyToggledOn();
|
||||
}
|
||||
|
||||
user.sendMessage(this.carbonChat.adventureManager().processMessageWithPapi(player, message, "br", "\n",
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(message, "br", "\n",
|
||||
"color", "<color:" + chatChannel.channelColor(user).toString() + ">", "channel", chatChannel.name()));
|
||||
}
|
||||
|
||||
@@ -90,13 +90,13 @@ public class SpyChannelCommand {
|
||||
|
||||
if (user.spyingwhispers()) {
|
||||
user.spyingWhispers(false);
|
||||
message = this.carbonChat.language().getString("spy-whispers-off");
|
||||
message = this.carbonChat.translations().spyWhispersOff();
|
||||
} else {
|
||||
user.spyingWhispers(true);
|
||||
message = this.carbonChat.language().getString("spy-whispers-on");
|
||||
message = this.carbonChat.translations().spyWhispersOn();
|
||||
}
|
||||
|
||||
user.sendMessage(this.carbonChat.adventureManager().processMessageWithPapi(player, message, "br", "\n"));
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(message, "br", "\n"));
|
||||
}
|
||||
|
||||
private void executeEverything(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
@@ -109,22 +109,22 @@ public class SpyChannelCommand {
|
||||
if (shouldSpy) {
|
||||
user.spyingWhispers(true);
|
||||
|
||||
for (final ChatChannel channel : this.carbonChat.channelManager().registry()) {
|
||||
for (final ChatChannel channel : this.carbonChat.channelRegistry()) {
|
||||
user.channelSettings(channel).spying(true);
|
||||
}
|
||||
|
||||
message = this.carbonChat.language().getString("spy-everything-off");
|
||||
message = this.carbonChat.translations().spyEverythingOff();
|
||||
} else {
|
||||
user.spyingWhispers(false);
|
||||
|
||||
for (final ChatChannel channel : this.carbonChat.channelManager().registry()) {
|
||||
for (final ChatChannel channel : this.carbonChat.channelRegistry()) {
|
||||
user.channelSettings(channel).spying(false);
|
||||
}
|
||||
|
||||
message = this.carbonChat.language().getString("spy-everything-on");
|
||||
message = this.carbonChat.translations().spyEverythingOn();
|
||||
}
|
||||
|
||||
user.sendMessage(this.carbonChat.adventureManager().processMessageWithPapi(player, message, "br", "\n"));
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(message, "br", "\n"));
|
||||
}
|
||||
|
||||
}
|
||||
+17
-7
@@ -6,13 +6,15 @@ import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import dev.jorel.commandapi.arguments.GreedyStringArgument;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.commands.CommandSettings;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -20,9 +22,9 @@ import java.util.LinkedHashMap;
|
||||
public class SudoChannelCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public SudoChannelCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
public SudoChannelCommand(@NonNull final CarbonChatBukkit carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -65,11 +67,19 @@ public class SudoChannelCommand {
|
||||
final String message = channel.switchMessage();
|
||||
final String otherMessage = channel.switchOtherMessage();
|
||||
|
||||
user.sendMessage(this.carbonChat.adventureManager().processMessage(message, "br", "\n",
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(message, "br", "\n",
|
||||
"color", "<color:" + channel.channelColor(user).toString() + ">", "channel", channel.name()));
|
||||
|
||||
this.carbonChat.adventureManager().audiences().audience(sender).sendMessage(
|
||||
this.carbonChat.adventureManager().processMessage(otherMessage, "br", "\n",
|
||||
final Audience cmdSender;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
cmdSender = this.carbonChat.userService().wrap(((Player) sender).getUniqueId());
|
||||
} else {
|
||||
cmdSender = this.carbonChat.messageProcessor().audiences().console();
|
||||
}
|
||||
|
||||
cmdSender.sendMessage(
|
||||
this.carbonChat.messageProcessor().processMessage(otherMessage, "br", "\n",
|
||||
"color", "<color:" + channel.channelColor(user).toString() + ">", "channel", channel.name(),
|
||||
"player", Bukkit.getOfflinePlayer(user.uuid()).getName()));
|
||||
}
|
||||
@@ -78,7 +88,7 @@ public class SudoChannelCommand {
|
||||
@NonNull final ChatChannel channel, @NonNull final String message) {
|
||||
final Component component = channel.sendMessage(user, message, false);
|
||||
|
||||
this.carbonChat.adventureManager().audiences().console().sendMessage(component);
|
||||
this.carbonChat.messageProcessor().audiences().console().sendMessage(component);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,8 @@ import net.draycia.carbon.util.CommandUtils;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -20,9 +21,9 @@ import java.util.LinkedHashMap;
|
||||
public class ToggleCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public ToggleCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
public ToggleCommand(@NonNull final CarbonChatBukkit carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -71,7 +72,7 @@ public class ToggleCommand {
|
||||
message = channel.toggleOnMessage();
|
||||
}
|
||||
|
||||
user.sendMessage(this.carbonChat.adventureManager().processMessageWithPapi(player, message, "br", "\n",
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(message, "br", "\n",
|
||||
"color", "<color:" + channel.channelColor(user).toString() + ">", "channel", channel.name()));
|
||||
}
|
||||
|
||||
@@ -94,11 +95,19 @@ public class ToggleCommand {
|
||||
otherMessage = channel.toggleOtherOnMessage();
|
||||
}
|
||||
|
||||
user.sendMessage(this.carbonChat.adventureManager().processMessage(message, "br", "\n",
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(message, "br", "\n",
|
||||
"color", "<color:" + channel.channelColor(user).toString() + ">", "channel", channel.name()));
|
||||
|
||||
this.carbonChat.adventureManager().audiences().audience(sender).sendMessage(
|
||||
this.carbonChat.adventureManager().processMessage(otherMessage,
|
||||
final Audience cmdSender;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
cmdSender = this.carbonChat.userService().wrap(((Player) sender).getUniqueId());
|
||||
} else {
|
||||
cmdSender = this.carbonChat.messageProcessor().audiences().console();
|
||||
}
|
||||
|
||||
cmdSender.sendMessage(
|
||||
this.carbonChat.messageProcessor().processMessage(otherMessage,
|
||||
"br", "\n", "color", "<color:" + channel.channelColor(user).toString() + ">",
|
||||
"channel", channel.name(), "player", Bukkit.getOfflinePlayer(user.uuid()).getName()));
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
package net.draycia.carbon.listeners.contexts;
|
||||
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.events.PreChatFormatEvent;
|
||||
import net.draycia.carbon.api.Context;
|
||||
@@ -11,12 +11,12 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class EconomyContext {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
@NonNull
|
||||
private final Economy economy;
|
||||
|
||||
public EconomyContext(@NonNull final CarbonChat carbonChat) {
|
||||
public EconomyContext(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.economy = this.carbonChat.getServer().getServicesManager().getRegistration(Economy.class).getProvider();
|
||||
|
||||
@@ -44,7 +44,7 @@ public class EconomyContext {
|
||||
if (!this.economy.has(player, requiredBal)) {
|
||||
event.cancelled(true);
|
||||
|
||||
event.user().sendMessage(this.carbonChat.adventureManager()
|
||||
event.user().sendMessage(this.carbonChat.messageProcessor()
|
||||
.processMessage(event.channel().cannotUseMessage()));
|
||||
}
|
||||
});
|
||||
@@ -73,7 +73,7 @@ public class EconomyContext {
|
||||
if (!this.economy.has(player, cost)) {
|
||||
event.cancelled(true);
|
||||
|
||||
event.user().sendMessage(this.carbonChat.adventureManager()
|
||||
event.user().sendMessage(this.carbonChat.messageProcessor()
|
||||
.processMessage(event.channel().cannotUseMessage()));
|
||||
|
||||
return;
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package net.draycia.carbon.listeners.contexts;
|
||||
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.events.PreChatFormatEvent;
|
||||
import net.draycia.carbon.api.Context;
|
||||
@@ -20,7 +20,7 @@ import java.util.regex.Pattern;
|
||||
public class FilterContext {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
@NonNull
|
||||
private final Map<String, List<@NonNull Pattern>> patternReplacements = new HashMap<>();
|
||||
@@ -28,7 +28,7 @@ public class FilterContext {
|
||||
@NonNull
|
||||
private final List<@NonNull Pattern> blockedWords = new ArrayList<>();
|
||||
|
||||
public FilterContext(@NonNull final CarbonChat carbonChat) {
|
||||
public FilterContext(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.reloadFilters();
|
||||
|
||||
|
||||
+3
-3
@@ -4,7 +4,7 @@ import com.palmergames.bukkit.towny.TownyAPI;
|
||||
import com.palmergames.bukkit.towny.event.TownRemoveResidentEvent;
|
||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
||||
import com.palmergames.bukkit.towny.object.Resident;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.events.ChannelSwitchEvent;
|
||||
@@ -25,9 +25,9 @@ public final class TownyContext implements Listener {
|
||||
private static final String KEY = "towny-town";
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public TownyContext(@NonNull final CarbonChat carbonChat) {
|
||||
public TownyContext(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
CarbonEvents.register(ReceiverContextEvent.class, event -> {
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ package net.draycia.carbon.listeners.contexts;
|
||||
|
||||
import com.gmail.nossr50.api.PartyAPI;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.events.ChannelSwitchEvent;
|
||||
@@ -20,12 +20,12 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
public final class mcMMOContext implements Listener {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
@NonNull
|
||||
private static final String KEY = "mcmmo-party";
|
||||
|
||||
public mcMMOContext(@NonNull final CarbonChat carbonChat) {
|
||||
public mcMMOContext(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
CarbonEvents.register(ReceiverContextEvent.class, PostOrders.NORMAL, false, event -> {
|
||||
|
||||
+7
-7
@@ -2,7 +2,7 @@ package net.draycia.carbon.listeners.events;
|
||||
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
||||
@@ -20,9 +20,9 @@ import java.util.HashSet;
|
||||
public class BukkitChatListener implements Listener {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public BukkitChatListener(@NonNull final CarbonChat carbonChat) {
|
||||
public BukkitChatListener(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
}
|
||||
|
||||
@@ -33,18 +33,18 @@ public class BukkitChatListener implements Listener {
|
||||
ChatChannel channel = user.selectedChannel();
|
||||
|
||||
if (channel == null) {
|
||||
if (this.carbonChat.channelManager().defaultChannel() == null) {
|
||||
if (this.carbonChat.channelRegistry().defaultChannel() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
channel = this.carbonChat.channelManager().defaultChannel();
|
||||
channel = this.carbonChat.channelRegistry().defaultChannel();
|
||||
}
|
||||
|
||||
if (channel.shouldCancelChatEvent()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
for (final ChatChannel entry : this.carbonChat.channelManager().registry()) {
|
||||
for (final ChatChannel entry : this.carbonChat.channelRegistry()) {
|
||||
if (entry.messagePrefix() == null || entry.messagePrefix().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class BukkitChatListener implements Listener {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.carbonChat, () -> {
|
||||
final Component component = selectedChannel.sendMessage(user, recipients, event.getMessage(), false);
|
||||
|
||||
this.carbonChat.adventureManager().audiences().console().sendMessage(component);
|
||||
this.carbonChat.messageProcessor().audiences().console().sendMessage(component);
|
||||
|
||||
if (this.carbonChat.getConfig().getBoolean("show-tips")) {
|
||||
this.carbonChat.getLogger().info("Tip: Sync chat event! I cannot set the message format due to this. :(");
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package net.draycia.carbon.listeners.events;
|
||||
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.events.PreChatFormatEvent;
|
||||
import net.kyori.event.PostOrders;
|
||||
@@ -8,7 +8,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class CapsHandler {
|
||||
|
||||
public CapsHandler(@NonNull final CarbonChat carbonChat) {
|
||||
public CapsHandler(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
CarbonEvents.register(PreChatFormatEvent.class, PostOrders.FIRST, false, event -> {
|
||||
if (!carbonChat.moderationConfig().getBoolean("caps-protection.enabled")) {
|
||||
return;
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package net.draycia.carbon.listeners.events;
|
||||
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.events.PreChatFormatEvent;
|
||||
import net.kyori.event.PostOrders;
|
||||
@@ -9,7 +9,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class CustomPlaceholderHandler {
|
||||
|
||||
public CustomPlaceholderHandler(@NonNull final CarbonChat carbonChat) {
|
||||
public CustomPlaceholderHandler(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
CarbonEvents.register(PreChatFormatEvent.class, PostOrders.FIRST, false, event -> {
|
||||
final ConfigurationSection placeholders = carbonChat.getConfig().getConfigurationSection("placeholders");
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package net.draycia.carbon.listeners.events;
|
||||
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.events.ChatComponentEvent;
|
||||
import net.kyori.adventure.key.Key;
|
||||
@@ -11,7 +11,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class PingHandler {
|
||||
|
||||
public PingHandler(@NonNull final CarbonChat carbonChat) {
|
||||
public PingHandler(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
CarbonEvents.register(ChatComponentEvent.class, PostOrders.LAST, false, event -> {
|
||||
if (!carbonChat.getConfig().getBoolean("pings.enabled")) {
|
||||
return;
|
||||
|
||||
+5
-5
@@ -2,7 +2,7 @@ package net.draycia.carbon.listeners.events;
|
||||
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
@@ -12,9 +12,9 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
public class PlayerJoinListener implements Listener {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public PlayerJoinListener(@NonNull final CarbonChat carbonChat) {
|
||||
public PlayerJoinListener(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
}
|
||||
|
||||
@@ -35,11 +35,11 @@ public class PlayerJoinListener implements Listener {
|
||||
}
|
||||
|
||||
if (channel.equals("DEFAULT")) {
|
||||
user.selectedChannel(this.carbonChat.channelManager().defaultChannel());
|
||||
user.selectedChannel(this.carbonChat.channelRegistry().defaultChannel());
|
||||
return;
|
||||
}
|
||||
|
||||
final ChatChannel chatChannel = this.carbonChat.channelManager().registry().get(channel);
|
||||
final ChatChannel chatChannel = this.carbonChat.channelRegistry().get(channel);
|
||||
|
||||
if (chatChannel != null) {
|
||||
user.selectedChannel(chatChannel);
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package net.draycia.carbon.listeners.events;
|
||||
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.events.ChatComponentEvent;
|
||||
import net.draycia.carbon.api.events.ChatFormatEvent;
|
||||
@@ -9,7 +9,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class ShadowMuteHandler {
|
||||
|
||||
public ShadowMuteHandler(@NonNull final CarbonChat carbonChat) {
|
||||
public ShadowMuteHandler(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
CarbonEvents.register(ChatComponentEvent.class, PostOrders.FIRST, false, event -> {
|
||||
if (event.sender().shadowMuted() && event.sender().equals(event.target())) {
|
||||
event.cancelled(true);
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package net.draycia.carbon.listeners.events;
|
||||
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.events.PreChatFormatEvent;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
@@ -20,7 +20,7 @@ public class UserFormattingHandler {
|
||||
this.suppressFormatting(event);
|
||||
} else {
|
||||
// Swap the &-style codes for minimessage-compatible strings
|
||||
event.message(MiniMessage.get().serialize(CarbonChat.LEGACY.deserialize(event.message())));
|
||||
event.message(MiniMessage.get().serialize(CarbonChatBukkit.LEGACY.deserialize(event.message())));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package net.draycia.carbon.listeners.events;
|
||||
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.events.PrivateMessageEvent;
|
||||
import net.kyori.adventure.key.Key;
|
||||
@@ -11,7 +11,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class WhisperPingHandler {
|
||||
|
||||
public WhisperPingHandler(@NonNull final CarbonChat carbonChat) {
|
||||
public WhisperPingHandler(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
|
||||
CarbonEvents.register(PrivateMessageEvent.class, PostOrders.LAST, false, event -> {
|
||||
if (event.sender().uuid().equals(event.target().uuid())) {
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
package net.draycia.carbon.managers;
|
||||
|
||||
import de.themoep.minedown.adventure.MineDown;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class AdventureManager {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
@NonNull
|
||||
private final BukkitAudiences audiences;
|
||||
|
||||
public AdventureManager(@NonNull final CarbonChat carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.audiences = BukkitAudiences.create(carbonChat);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Component processMessageWithPapi(@NonNull final Player player, @Nullable final String input,
|
||||
@NonNull final String @NonNull ... placeholders) {
|
||||
if (input == null || input.trim().isEmpty()) {
|
||||
return TextComponent.empty();
|
||||
}
|
||||
|
||||
return this.processMessage(PlaceholderAPI.setPlaceholders(player, input), placeholders);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Component processMessage(@Nullable final String input, @NonNull final String @NonNull ... placeholders) {
|
||||
if (input == null || input.trim().isEmpty()) {
|
||||
return TextComponent.empty();
|
||||
}
|
||||
|
||||
switch (this.carbonChat.language().getString("formatting.type", "minimessage").toLowerCase()) {
|
||||
case "minedown":
|
||||
return MineDown.parse(input, placeholders);
|
||||
case "mojang":
|
||||
case "mojangson":
|
||||
case "json":
|
||||
return this.processMojang(input, placeholders);
|
||||
case "minimessage-markdown":
|
||||
return MiniMessage.markdown().parse(input, placeholders);
|
||||
case "minimessage":
|
||||
default:
|
||||
return MiniMessage.get().parse(input, placeholders);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private Component processMojang(@NonNull String input, @NonNull final String @NonNull ... placeholders) {
|
||||
for (int i = 0; i < placeholders.length; i += 2) {
|
||||
final String placeholder = placeholders[i];
|
||||
final String replacement = placeholders[i + 1];
|
||||
|
||||
input = input.replace("<" + placeholder + ">", replacement);
|
||||
}
|
||||
|
||||
return this.audiences().gsonSerializer().deserialize(input);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public BukkitAudiences audiences() {
|
||||
return this.audiences;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.draycia.carbon.managers;
|
||||
|
||||
import net.draycia.carbon.channels.CarbonChatChannel;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.channels.ChannelRegistry;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
@@ -17,7 +17,7 @@ import java.util.Collections;
|
||||
public class ChannelManager {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
@NonNull
|
||||
private final ChannelRegistry registry;
|
||||
@@ -26,7 +26,7 @@ public class ChannelManager {
|
||||
@MonotonicNonNull
|
||||
private String defaultChannelKey = null;
|
||||
|
||||
public ChannelManager(@NonNull final CarbonChat carbonChat) {
|
||||
public ChannelManager(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.registry = new ChannelRegistry();
|
||||
|
||||
|
||||
@@ -15,17 +15,16 @@ import net.draycia.carbon.commands.SpyChannelCommand;
|
||||
import net.draycia.carbon.commands.SudoChannelCommand;
|
||||
import net.draycia.carbon.commands.ToggleCommand;
|
||||
import net.draycia.carbon.api.commands.CommandSettings;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.commands.ShadowMuteCommand;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class CommandManager {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public CommandManager(@NonNull final CarbonChat carbonChat) {
|
||||
public CommandManager(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
this.reloadCommands();
|
||||
@@ -51,10 +50,7 @@ public class CommandManager {
|
||||
|
||||
@NonNull
|
||||
private CommandSettings commandSettings(@NonNull final String command) {
|
||||
final ConfigurationSection section = this.carbonChat.commandsConfig().getConfigurationSection(command);
|
||||
|
||||
return new CommandSettings(section.getBoolean("enabled"), section.getString("name"),
|
||||
section.getStringList("aliases"));
|
||||
return this.carbonChat.commandSettingsRegistry().get(command);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,171 +0,0 @@
|
||||
package net.draycia.carbon.messaging;
|
||||
|
||||
import net.draycia.carbon.api.messaging.MessageService;
|
||||
import net.draycia.carbon.messaging.impl.BungeeMessageService;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.messaging.impl.EmptyMessageService;
|
||||
import net.draycia.carbon.messaging.impl.RedisMessageService;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class MessageManager {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
@NonNull
|
||||
private final MessageService messageService;
|
||||
|
||||
@NonNull
|
||||
private final GsonComponentSerializer gsonSerializer;
|
||||
|
||||
public MessageManager(@NonNull final CarbonChat carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.gsonSerializer = this.carbonChat.adventureManager().audiences().gsonSerializer();
|
||||
|
||||
String messageSystem = this.carbonChat.getConfig().getString("message-system", "none");
|
||||
|
||||
if (messageSystem == null) {
|
||||
messageSystem = "none";
|
||||
}
|
||||
|
||||
switch (messageSystem.toLowerCase()) {
|
||||
case "bungee":
|
||||
this.carbonChat.getLogger().info("Using Bungee Plugin Messaging for message forwarding!");
|
||||
this.messageService = new BungeeMessageService(this.carbonChat);
|
||||
break;
|
||||
case "redis":
|
||||
this.carbonChat.getLogger().info("Using Redis for message forwarding!");
|
||||
this.messageService = new RedisMessageService(this.carbonChat);
|
||||
break;
|
||||
case "none":
|
||||
this.messageService = new EmptyMessageService();
|
||||
break;
|
||||
default:
|
||||
this.carbonChat.getLogger().info("Invalid message service selected! Disabling syncing until next restart!");
|
||||
this.messageService = new EmptyMessageService();
|
||||
break;
|
||||
}
|
||||
|
||||
this.registerDefaultListeners();
|
||||
}
|
||||
|
||||
private void registerDefaultListeners() {
|
||||
this.messageService().registerUserMessageListener("nickname", (user, byteArray) -> {
|
||||
final String nickname = byteArray.readUTF();
|
||||
|
||||
user.nickname(nickname, true);
|
||||
|
||||
final Player player = Bukkit.getPlayer(user.uuid());
|
||||
|
||||
if (player != null) {
|
||||
final String message = this.carbonChat.language().getString("nickname-set");
|
||||
|
||||
user.sendMessage(this.carbonChat.adventureManager().processMessageWithPapi(player,
|
||||
message, "nickname", nickname));
|
||||
}
|
||||
});
|
||||
|
||||
this.messageService().registerUserMessageListener("nickname-reset", (user, byteArray) -> {
|
||||
user.nickname(null, true);
|
||||
|
||||
final Player player = Bukkit.getPlayer(user.uuid());
|
||||
|
||||
if (player != null) {
|
||||
final String message = this.carbonChat.language().getString("nickname-reset");
|
||||
|
||||
user.sendMessage(this.carbonChat.adventureManager().processMessageWithPapi(player, message));
|
||||
}
|
||||
});
|
||||
|
||||
this.messageService().registerUserMessageListener("selected-channel", (user, byteArray) -> {
|
||||
user.selectedChannel(this.carbonChat.channelManager().registry().get(byteArray.readUTF()), true);
|
||||
});
|
||||
|
||||
this.messageService().registerUserMessageListener("spying-whispers", (user, byteArray) -> {
|
||||
user.spyingWhispers(byteArray.readBoolean(), true);
|
||||
});
|
||||
|
||||
this.messageService().registerUserMessageListener("muted", (user, byteArray) -> {
|
||||
user.muted(byteArray.readBoolean(), true);
|
||||
});
|
||||
|
||||
this.messageService().registerUserMessageListener("shadow-muted", (user, byteArray) -> {
|
||||
user.shadowMuted(byteArray.readBoolean(), true);
|
||||
});
|
||||
|
||||
this.messageService().registerUserMessageListener("reply-target", (user, byteArray) -> {
|
||||
user.replyTarget(new UUID(byteArray.readLong(), byteArray.readLong()), true);
|
||||
});
|
||||
|
||||
this.messageService().registerUserMessageListener("ignoring-user", (user, byteArray) -> {
|
||||
user.ignoringUser(new UUID(byteArray.readLong(), byteArray.readLong()), byteArray.readBoolean(), true);
|
||||
});
|
||||
|
||||
this.messageService().registerUserMessageListener("ignoring-channel", (user, byteArray) -> {
|
||||
user.channelSettings(this.carbonChat.channelManager().registry().get(byteArray.readUTF()))
|
||||
.ignoring(byteArray.readBoolean(), true);
|
||||
});
|
||||
|
||||
this.messageService().registerUserMessageListener("spying-channel", (user, byteArray) -> {
|
||||
user.channelSettings(this.carbonChat.channelManager().registry().get(byteArray.readUTF()))
|
||||
.spying(byteArray.readBoolean(), true);
|
||||
});
|
||||
|
||||
this.messageService().registerUserMessageListener("channel-color", (user, byteArray) -> {
|
||||
user.channelSettings(this.carbonChat.channelManager().registry().get(byteArray.readUTF()))
|
||||
.color(TextColor.fromHexString(byteArray.readUTF()), true);
|
||||
});
|
||||
|
||||
this.messageService().registerUserMessageListener("channel-color-reset", (user, byteArray) -> {
|
||||
user.channelSettings(this.carbonChat.channelManager().registry().get(byteArray.readUTF()))
|
||||
.color(null, true);
|
||||
});
|
||||
|
||||
this.messageService().registerUUIDMessageListener("channel-component", (uuid, byteArray) -> {
|
||||
final ChatChannel channel = this.carbonChat.channelManager().registry().get(byteArray.readUTF());
|
||||
final ChatUser user = this.carbonChat.userService().wrap(uuid);
|
||||
|
||||
if (channel != null) {
|
||||
final Component component = this.gsonSerializer.deserialize(byteArray.readUTF());
|
||||
|
||||
channel.sendComponent(user, component);
|
||||
|
||||
this.carbonChat.adventureManager().audiences().console().sendMessage(component);
|
||||
}
|
||||
});
|
||||
|
||||
this.messageService().registerUUIDMessageListener("whisper-component", (uuid, byteArray) -> {
|
||||
final UUID recipient = new UUID(byteArray.readLong(), byteArray.readLong());
|
||||
|
||||
final ChatUser target = this.carbonChat.userService().wrap(recipient);
|
||||
final String message = byteArray.readUTF();
|
||||
|
||||
if (!target.ignoringUser(uuid)) {
|
||||
target.replyTarget(uuid);
|
||||
target.sendMessage(this.gsonSerializer.deserialize(message));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MessageService messageService() {
|
||||
return this.messageService;
|
||||
}
|
||||
|
||||
public void sendMessage(@NonNull final String key, @NonNull final UUID uuid,
|
||||
@NonNull final Consumer<@NonNull ByteArrayDataOutput> consumer) {
|
||||
this.messageService().sendMessage(key, uuid, consumer);
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -4,7 +4,7 @@ import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import io.github.leonardosnt.bungeechannelapi.BungeeChannelApi;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.messaging.MessageService;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -19,7 +19,7 @@ import java.util.function.Consumer;
|
||||
public class BungeeMessageService implements MessageService {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
@NonNull
|
||||
private final BungeeChannelApi api;
|
||||
@@ -33,7 +33,7 @@ public class BungeeMessageService implements MessageService {
|
||||
@NonNull
|
||||
private final UUID serverUUID = UUID.randomUUID();
|
||||
|
||||
public BungeeMessageService(@NonNull final CarbonChat carbonChat) {
|
||||
public BungeeMessageService(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
this.carbonChat.getServer().getMessenger().registerOutgoingPluginChannel(carbonChat, "BungeeCord");
|
||||
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
package net.draycia.carbon.messaging.impl;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import net.draycia.carbon.api.messaging.MessageService;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class EmptyMessageService implements MessageService {
|
||||
|
||||
@Override
|
||||
public void registerUserMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull ChatUser, @NonNull ByteArrayDataInput> listener) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerUUIDMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput> listener) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterMessageListener(@NonNull final String key) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NonNull final String key, @NonNull final UUID uuid, @NonNull final Consumer<@NonNull ByteArrayDataOutput> consumer) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
}
|
||||
-133
@@ -1,133 +0,0 @@
|
||||
package net.draycia.carbon.messaging.impl;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import io.lettuce.core.RedisClient;
|
||||
import io.lettuce.core.RedisURI;
|
||||
import io.lettuce.core.pubsub.StatefulRedisPubSubConnection;
|
||||
import io.lettuce.core.pubsub.api.sync.RedisPubSubCommands;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.api.messaging.MessageService;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.util.RedisListener;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class RedisMessageService implements MessageService {
|
||||
|
||||
@NonNull
|
||||
private final Map<@NonNull String, @NonNull BiConsumer<@NonNull ChatUser, @NonNull ByteArrayDataInput>> userLoadedListeners = new HashMap<>();
|
||||
|
||||
@NonNull
|
||||
private final Map<@NonNull String, @NonNull BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput>> userNotLoadedListeners = new HashMap<>();
|
||||
|
||||
@NonNull
|
||||
private final RedisPubSubCommands<@NonNull String, @NonNull String> subscribeSync;
|
||||
|
||||
@NonNull
|
||||
private final RedisPubSubCommands<@NonNull String, @NonNull String> publishSync;
|
||||
|
||||
@NonNull
|
||||
private final UUID serverUUID = UUID.randomUUID();
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public RedisMessageService(@NonNull final CarbonChat carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
final String host = this.carbonChat.getConfig().getString("redis.host");
|
||||
final String password = this.carbonChat.getConfig().getString("redis.password");
|
||||
final int port = this.carbonChat.getConfig().getInt("redis.port");
|
||||
final int database = this.carbonChat.getConfig().getInt("redis.database");
|
||||
|
||||
final RedisURI.Builder builder = RedisURI.Builder.redis(host, port)
|
||||
.withDatabase(database);
|
||||
|
||||
if (password != null) {
|
||||
builder.withPassword(password.toCharArray());
|
||||
}
|
||||
|
||||
final RedisClient client = RedisClient.create(builder.build());
|
||||
|
||||
final StatefulRedisPubSubConnection<String, String> subscribeConnection = client.connectPubSub();
|
||||
this.subscribeSync = subscribeConnection.sync();
|
||||
|
||||
final StatefulRedisPubSubConnection<String, String> publishConnection = client.connectPubSub();
|
||||
this.publishSync = publishConnection.sync();
|
||||
|
||||
subscribeConnection.addListener((RedisListener) (channel, message) -> {
|
||||
final ByteArrayDataInput input = ByteStreams.newDataInput(Base64.getDecoder().decode(message));
|
||||
|
||||
final UUID messageUUID = new UUID(input.readLong(), input.readLong());
|
||||
|
||||
if (messageUUID.equals(this.serverUUID)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final UUID uuid = new UUID(input.readLong(), input.readLong());
|
||||
|
||||
this.receiveMessage(uuid, channel, input);
|
||||
});
|
||||
}
|
||||
|
||||
private void receiveMessage(@NonNull final UUID uuid, @NonNull final String key, @NonNull final ByteArrayDataInput value) {
|
||||
final ChatUser user = this.carbonChat.userService().wrapIfLoaded(uuid);
|
||||
|
||||
if (user != null) {
|
||||
for (final Map.Entry<String, BiConsumer<ChatUser, ByteArrayDataInput>> listener : this.userLoadedListeners.entrySet()) {
|
||||
if (key.equals(listener.getKey())) {
|
||||
listener.getValue().accept(user, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (final Map.Entry<String, BiConsumer<UUID, ByteArrayDataInput>> listener : this.userNotLoadedListeners.entrySet()) {
|
||||
if (key.equals(listener.getKey())) {
|
||||
listener.getValue().accept(uuid, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerUserMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull ChatUser, @NonNull ByteArrayDataInput> listener) {
|
||||
this.userLoadedListeners.put(key, listener);
|
||||
this.subscribeSync.subscribe(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerUUIDMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput> listener) {
|
||||
this.userNotLoadedListeners.put(key, listener);
|
||||
this.subscribeSync.subscribe(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterMessageListener(@NonNull final String key) {
|
||||
this.userLoadedListeners.remove(key);
|
||||
this.userNotLoadedListeners.remove(key);
|
||||
|
||||
this.subscribeSync.unsubscribe(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NonNull final String key, @NonNull final UUID uuid, @NonNull final Consumer<@NonNull ByteArrayDataOutput> consumer) {
|
||||
final ByteArrayDataOutput msg = ByteStreams.newDataOutput();
|
||||
|
||||
msg.writeLong(this.serverUUID.getMostSignificantBits());
|
||||
msg.writeLong(this.serverUUID.getLeastSignificantBits());
|
||||
msg.writeLong(uuid.getMostSignificantBits());
|
||||
msg.writeLong(uuid.getLeastSignificantBits());
|
||||
|
||||
consumer.accept(msg);
|
||||
|
||||
this.publishSync.publish(key, Base64.getEncoder().encodeToString(msg.toByteArray()));
|
||||
}
|
||||
|
||||
}
|
||||
+20
-20
@@ -5,7 +5,7 @@ import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.UserChannelSettings;
|
||||
import net.draycia.carbon.util.FunctionalityConstants;
|
||||
import io.github.leonardosnt.bungeechannelapi.BungeeChannelApi;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.events.ChannelSwitchEvent;
|
||||
import net.draycia.carbon.api.events.PrivateMessageEvent;
|
||||
@@ -31,7 +31,7 @@ import java.util.UUID;
|
||||
public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
|
||||
@NonNull
|
||||
private final transient CarbonChat carbonChat;
|
||||
private final transient CarbonChatBukkit carbonChat;
|
||||
@NonNull
|
||||
private final Map<@NonNull String, @NonNull SimpleUserChannelSettings> channelSettings = new HashMap<>();
|
||||
@NonNull
|
||||
@@ -51,7 +51,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
private transient UUID replyTarget = null;
|
||||
|
||||
public CarbonChatUser() {
|
||||
this.carbonChat = (CarbonChat) Bukkit.getPluginManager().getPlugin("CarbonChat");
|
||||
this.carbonChat = (CarbonChatBukkit) Bukkit.getPluginManager().getPlugin("CarbonChat");
|
||||
}
|
||||
|
||||
public CarbonChatUser(@NonNull final UUID uuid) {
|
||||
@@ -62,7 +62,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
@Override
|
||||
@NonNull
|
||||
public Iterable<@NonNull ? extends Audience> audiences() {
|
||||
return Collections.singleton(this.carbonChat.adventureManager().audiences().player(this.uuid));
|
||||
return Collections.singleton(this.carbonChat.messageProcessor().audiences().player(this.uuid));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -95,8 +95,8 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
|
||||
if (player.isOnline()) {
|
||||
if (newNickname != null) {
|
||||
final Component component = this.carbonChat.adventureManager().processMessage(this.nickname);
|
||||
newNickname = CarbonChat.LEGACY.serialize(component);
|
||||
final Component component = this.carbonChat.messageProcessor().processMessage(this.nickname);
|
||||
newNickname = CarbonChatBukkit.LEGACY.serialize(component);
|
||||
}
|
||||
|
||||
final Player onlinePlayer = player.getPlayer();
|
||||
@@ -127,7 +127,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.carbonChat.channelManager().channelOrDefault(this.selectedChannel);
|
||||
return this.carbonChat.channelRegistry().channelOrDefault(this.selectedChannel);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,7 +139,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
CarbonEvents.post(event);
|
||||
|
||||
if (event.cancelled()) {
|
||||
this.sendMessage(this.carbonChat.adventureManager().processMessage(event.failureMessage(),
|
||||
this.sendMessage(this.carbonChat.messageProcessor().processMessage(event.failureMessage(),
|
||||
"channel", chatChannel.name()));
|
||||
|
||||
return;
|
||||
@@ -156,7 +156,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
final OfflinePlayer player = Bukkit.getOfflinePlayer(this.uuid());
|
||||
|
||||
if (player.isOnline()) {
|
||||
this.sendMessage(this.carbonChat.adventureManager().processMessageWithPapi(player.getPlayer(), chatChannel.switchMessage(),
|
||||
this.sendMessage(this.carbonChat.messageProcessor().processMessage(chatChannel.switchMessage(),
|
||||
"br", "\n",
|
||||
"color", "<" + chatChannel.channelColor(this).toString() + ">",
|
||||
"channel", chatChannel.name()));
|
||||
@@ -165,7 +165,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
|
||||
@Override
|
||||
public void clearSelectedChannel() {
|
||||
this.selectedChannel(this.carbonChat.channelManager().defaultChannel());
|
||||
this.selectedChannel(this.carbonChat.channelRegistry().defaultChannel());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -280,8 +280,8 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
return;
|
||||
}
|
||||
|
||||
final String toPlayerFormat = this.carbonChat.language().getString("message-to-other");
|
||||
final String fromPlayerFormat = this.carbonChat.language().getString("message-from-other");
|
||||
final String toPlayerFormat = this.carbonChat.translations().messageToOther();
|
||||
final String fromPlayerFormat = this.carbonChat.translations().messageFromOther();
|
||||
|
||||
final OfflinePlayer offlineSender = Bukkit.getOfflinePlayer(sender.uuid());
|
||||
String senderName = offlineSender.getName();
|
||||
@@ -299,12 +299,12 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
targetName = offlineTarget.getPlayer().getDisplayName();
|
||||
}
|
||||
|
||||
final Component toPlayerComponent = this.carbonChat.adventureManager().processMessage(toPlayerFormat, "br", "\n",
|
||||
final Component toPlayerComponent = this.carbonChat.messageProcessor().processMessage(toPlayerFormat, "br", "\n",
|
||||
"message", message,
|
||||
"targetname", targetOfflineName, "sendername", senderOfflineName,
|
||||
"target", targetName, "sender", senderName);
|
||||
|
||||
final Component fromPlayerComponent = this.carbonChat.adventureManager().processMessage(fromPlayerFormat, "br", "\n",
|
||||
final Component fromPlayerComponent = this.carbonChat.messageProcessor().processMessage(fromPlayerFormat, "br", "\n",
|
||||
"message", message,
|
||||
"targetname", targetOfflineName, "sendername", senderOfflineName,
|
||||
"target", targetName, "sender", senderName);
|
||||
@@ -344,9 +344,9 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
final String senderNameFinal = senderName;
|
||||
|
||||
if (!FunctionalityConstants.HAS_PROXY) {
|
||||
final String playerOfflineFormat = this.carbonChat.language().getString("other-player-offline");
|
||||
final String playerOfflineFormat = this.carbonChat.translations().otherPlayerOffline();
|
||||
|
||||
final Component playerOfflineComponent = this.carbonChat.adventureManager().processMessage(playerOfflineFormat,
|
||||
final Component playerOfflineComponent = this.carbonChat.messageProcessor().processMessage(playerOfflineFormat,
|
||||
"br", "\n",
|
||||
"message", message,
|
||||
"targetname", targetOfflineName, "sendername", senderOfflineName,
|
||||
@@ -361,9 +361,9 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
final OfflinePlayer player = Bukkit.getOfflinePlayer(this.uuid());
|
||||
|
||||
if (!list.contains(player.getName())) {
|
||||
final String playerOfflineFormat = this.carbonChat.language().getString("other-player-offline");
|
||||
final String playerOfflineFormat = this.carbonChat.translations().otherPlayerOffline();
|
||||
|
||||
final Component playerOfflineComponent = this.carbonChat.adventureManager().processMessage(playerOfflineFormat,
|
||||
final Component playerOfflineComponent = this.carbonChat.messageProcessor().processMessage(playerOfflineFormat,
|
||||
"br", "\n",
|
||||
"message", message,
|
||||
"targetname", targetOfflineName, "sendername", senderOfflineName,
|
||||
@@ -379,7 +379,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
this.carbonChat.messageManager().sendMessage("whisper-component", sender.uuid(), byteArray -> {
|
||||
byteArray.writeLong(this.uuid().getMostSignificantBits());
|
||||
byteArray.writeLong(this.uuid().getLeastSignificantBits());
|
||||
byteArray.writeUTF(this.carbonChat.adventureManager().audiences().gsonSerializer().serialize(fromPlayerComponent));
|
||||
byteArray.writeUTF(this.carbonChat.messageProcessor().audiences().gsonSerializer().serialize(fromPlayerComponent));
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -395,7 +395,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
continue;
|
||||
}
|
||||
|
||||
user.sendMessage(this.carbonChat.adventureManager().processMessage(this.carbonChat.language().getString("spy-whispers"),
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(this.carbonChat.translations().spyWhispers(),
|
||||
"br", "\n", "message", message,
|
||||
"targetname", targetOfflineName, "sendername", senderOfflineName,
|
||||
"target", targetName, "sender", senderName));
|
||||
|
||||
+3
-3
@@ -9,7 +9,7 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.UserService;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -27,7 +27,7 @@ import java.util.concurrent.ExecutionException;
|
||||
public class JSONUserService implements UserService {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
@NonNull
|
||||
private final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
@NonNull
|
||||
@@ -37,7 +37,7 @@ public class JSONUserService implements UserService {
|
||||
.removalListener(this::saveUser)
|
||||
.build(CacheLoader.from(this::loadUser));
|
||||
|
||||
public JSONUserService(@NonNull final CarbonChat carbonChat) {
|
||||
public JSONUserService(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(carbonChat, this.userCache::cleanUp, 0L, 20 * 60 * 10);
|
||||
|
||||
+5
-5
@@ -12,7 +12,7 @@ import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.cache.RemovalNotification;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.UserService;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
@@ -30,7 +30,7 @@ import java.util.concurrent.ExecutionException;
|
||||
public class MySQLUserService implements UserService {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
@NonNull
|
||||
private final Database database;
|
||||
@NonNull
|
||||
@@ -38,7 +38,7 @@ public class MySQLUserService implements UserService {
|
||||
.removalListener(this::saveUser)
|
||||
.build(CacheLoader.from(this::loadUser));
|
||||
|
||||
public MySQLUserService(@NonNull final CarbonChat carbonChat) {
|
||||
public MySQLUserService(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
final ConfigurationSection section = this.carbonChat.getConfig().getConfigurationSection("storage");
|
||||
@@ -134,7 +134,7 @@ public class MySQLUserService implements UserService {
|
||||
final List<DbRow> channelSettings = this.database.getResults("SELECT * from sc_channel_settings WHERE uuid = ?;", uuid.toString());
|
||||
final List<DbRow> ignoredUsers = this.database.getResults("SELECT * from sc_ignored_users WHERE uuid = ?;", uuid.toString());
|
||||
|
||||
final ChatChannel channel = this.carbonChat.channelManager().channelOrDefault(users.getString("channel"));
|
||||
final ChatChannel channel = this.carbonChat.channelRegistry().channelOrDefault(users.getString("channel"));
|
||||
|
||||
if (channel != null) {
|
||||
user.selectedChannel(channel, true);
|
||||
@@ -151,7 +151,7 @@ public class MySQLUserService implements UserService {
|
||||
user.spyingWhispers(users.<Boolean>get("spyingwhispers"), true);
|
||||
|
||||
for (final DbRow channelSetting : channelSettings) {
|
||||
final ChatChannel chatChannel = this.carbonChat.channelManager().registry().get(channelSetting.getString("channel"));
|
||||
final ChatChannel chatChannel = this.carbonChat.channelRegistry().get(channelSetting.getString("channel"));
|
||||
|
||||
if (chatChannel != null) {
|
||||
final UserChannelSettings settings = user.channelSettings(chatChannel);
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
package net.draycia.carbon.storage.impl;
|
||||
|
||||
import net.draycia.carbon.api.users.UserChannelSettings;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
@@ -13,7 +13,7 @@ import java.util.UUID;
|
||||
public class SimpleUserChannelSettings implements UserChannelSettings {
|
||||
|
||||
@NonNull
|
||||
private final transient CarbonChat carbonChat;
|
||||
private final transient CarbonChatBukkit carbonChat;
|
||||
private boolean spying;
|
||||
private boolean ignored;
|
||||
@Nullable
|
||||
@@ -24,14 +24,14 @@ public class SimpleUserChannelSettings implements UserChannelSettings {
|
||||
private String channel;
|
||||
|
||||
private SimpleUserChannelSettings() {
|
||||
this.carbonChat = (CarbonChat) Bukkit.getPluginManager().getPlugin("CarbonChat");
|
||||
this.carbonChat = (CarbonChatBukkit) Bukkit.getPluginManager().getPlugin("CarbonChat");
|
||||
}
|
||||
|
||||
public SimpleUserChannelSettings(@NonNull final UUID uuid, @NonNull final String channel) {
|
||||
this.uuid = uuid;
|
||||
this.channel = channel;
|
||||
|
||||
this.carbonChat = (CarbonChat) Bukkit.getPluginManager().getPlugin("CarbonChat");
|
||||
this.carbonChat = (CarbonChatBukkit) Bukkit.getPluginManager().getPlugin("CarbonChat");
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.draycia.carbon.util;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@@ -11,9 +11,9 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
public class CarbonPlaceholders extends PlaceholderExpansion {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public CarbonPlaceholders(@NonNull final CarbonChat carbonChat) {
|
||||
public CarbonPlaceholders(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class CarbonPlaceholders extends PlaceholderExpansion {
|
||||
if (key.startsWith("can_use_")) {
|
||||
final String value = key.replace("can_use_", "");
|
||||
|
||||
final ChatChannel channel = this.carbonChat.channelManager().registry().get(value);
|
||||
final ChatChannel channel = this.carbonChat.channelRegistry().get(value);
|
||||
|
||||
if (channel == null) {
|
||||
return "false";
|
||||
@@ -60,7 +60,7 @@ public class CarbonPlaceholders extends PlaceholderExpansion {
|
||||
} else if (key.startsWith("can_see_")) {
|
||||
final String value = key.replace("can_see_", "");
|
||||
|
||||
final ChatChannel channel = this.carbonChat.channelManager().registry().get(value);
|
||||
final ChatChannel channel = this.carbonChat.channelRegistry().get(value);
|
||||
|
||||
if (channel == null) {
|
||||
return "false";
|
||||
@@ -72,7 +72,7 @@ public class CarbonPlaceholders extends PlaceholderExpansion {
|
||||
} else if (key.startsWith("ignoring_channel_")) {
|
||||
final String value = key.replace("ignoring_channel_", "");
|
||||
|
||||
final ChatChannel channel = this.carbonChat.channelManager().registry().get(value);
|
||||
final ChatChannel channel = this.carbonChat.channelRegistry().get(value);
|
||||
|
||||
if (channel == null) {
|
||||
return "false";
|
||||
@@ -84,7 +84,7 @@ public class CarbonPlaceholders extends PlaceholderExpansion {
|
||||
} else if (key.startsWith("selected_channel")) {
|
||||
final ChatChannel channel = this.carbonChat.userService().wrap(player.getUniqueId()).selectedChannel();
|
||||
|
||||
return channel == null ? this.carbonChat.channelManager().defaultChannel().name() : channel.name();
|
||||
return channel == null ? this.carbonChat.channelRegistry().defaultChannel().name() : channel.name();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -23,7 +23,7 @@ package net.draycia.carbon.util;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import dev.jorel.commandapi.arguments.CustomArgument;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -136,7 +136,7 @@ public final class CarbonUtils {
|
||||
@NonNull
|
||||
public static Argument onlineChatUserArgument() {
|
||||
return new CustomArgument<>(input -> {
|
||||
final CarbonChat carbonChat = (CarbonChat) Bukkit.getPluginManager().getPlugin("CarbonChat");
|
||||
final CarbonChatBukkit carbonChat = (CarbonChatBukkit) Bukkit.getPluginManager().getPlugin("CarbonChat");
|
||||
|
||||
final Player player = Bukkit.getPlayer(input);
|
||||
|
||||
@@ -159,7 +159,7 @@ public final class CarbonUtils {
|
||||
@NonNull
|
||||
public static Argument chatUserArgument() {
|
||||
return new CustomArgument<>(input -> {
|
||||
final CarbonChat carbonChat = (CarbonChat) Bukkit.getPluginManager().getPlugin("CarbonChat");
|
||||
final CarbonChatBukkit carbonChat = (CarbonChatBukkit) Bukkit.getPluginManager().getPlugin("CarbonChat");
|
||||
|
||||
return carbonChat.userService().wrap(Bukkit.getOfflinePlayer(input).getUniqueId());
|
||||
// }).overrideSuggestions((sender, args) -> {
|
||||
@@ -189,9 +189,9 @@ public final class CarbonUtils {
|
||||
@NonNull
|
||||
public static Argument channelArgument() {
|
||||
return new CustomArgument<>(input -> {
|
||||
final CarbonChat carbonChat = (CarbonChat) Bukkit.getPluginManager().getPlugin("CarbonChat");
|
||||
final CarbonChatBukkit carbonChat = (CarbonChatBukkit) Bukkit.getPluginManager().getPlugin("CarbonChat");
|
||||
|
||||
final ChatChannel channel = carbonChat.channelManager().registry().get(input);
|
||||
final ChatChannel channel = carbonChat.channelRegistry().get(input);
|
||||
|
||||
if (channel == null) {
|
||||
throw new CustomArgument.CustomArgumentException("Invalid channel for input (" + input + ")");
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package net.draycia.carbon.util;
|
||||
|
||||
import io.lettuce.core.pubsub.RedisPubSubListener;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface RedisListener extends RedisPubSubListener<String, String> {
|
||||
|
||||
@Override
|
||||
void message(@NonNull String channel, @NonNull String message);
|
||||
|
||||
@Override
|
||||
default void message(@NonNull final String pattern, @NonNull final String channel, @NonNull final String message) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void subscribed(@NonNull final String channel, final long count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void psubscribed(@NonNull final String pattern, final long count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void unsubscribed(@NonNull final String channel, final long count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void punsubscribed(@NonNull final String pattern, final long count) {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user